wangliang_wd

feat:优化编辑资料

... ... @@ -96,6 +96,14 @@ export class HttpUrlUtils {
*/
static readonly APPOINTMENT_QueryUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/queryUserDetail";
/**
* 资料编辑 更新普通用户信息
*/
static readonly APPOINTMENT_editUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/editUserDetail";
/**
* 资料编辑 更新普通用户名
*/
static readonly APPOINTMENT_editUserDetail1_PATH: string = "/api/rmrb-user-center/user/zh/c/completeUserInfo";
/**
/**
* 个人中心 关注列表详情
*/
... ...
import { CustomTitleUI } from '../reusable/CustomTitleUI';
import { EditListInfo, editModel } from '../../model/EditInfoModel';
import { EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../../model/EditInfoModel';
import EditInfoViewModel from '../../viewmodel/EditInfoViewModel';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog'
import { AreaListModel } from '../../model/AreaListModel';
import router from '@ohos.router';
@Entry
@Component
... ... @@ -18,6 +19,7 @@ struct EditUserInfoPage {
builder: AreaPickerDialog({dataSource:this.dataSource,
confirmCallback:(area:string)=>{
this.currentUserInfo.userExtend.city = area;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_region
this.updateEditModel()
}
}),
... ... @@ -31,7 +33,7 @@ struct EditUserInfoPage {
}
onPageShow(){
this.updateUserNameAndIntroduction()
}
build() {
... ... @@ -98,13 +100,15 @@ struct EditUserInfoPage {
.width('100%')
.onClick(()=>{
if (i === 1){
WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage)
let params: editModelParams = {
editContent: this.currentUserInfo.userName
}
WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage,params)
}else if (i === 2){
WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage)
// router.pushUrl({
// url:'pages/EditUserInstoductionPage',
// params:{pageNum:i}
// })
let params: editModelParams = {
editContent: this.currentUserInfo.userExtend.introduction
}
WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage,params)
}else if (i === 3){
this.dialogController.open()
} else if (i === 4) {
... ... @@ -116,6 +120,7 @@ struct EditUserInfoPage {
onAccept:(value:DatePickerResult) => {
let mon = value.month as number + 1
this.currentUserInfo.userExtend.birthday = value.year+'-'+mon.toString()+'-'+value.day;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_birthday
this.updateEditModel()
}
})
... ... @@ -125,6 +130,7 @@ struct EditUserInfoPage {
selected:0,
onAccept:(value:TextPickerResult) => {
this.currentUserInfo.userExtend.sex = value.index.toString();
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_sex
this.updateEditModel()
}
})
... ... @@ -132,6 +138,28 @@ struct EditUserInfoPage {
})
}
updateUserNameAndIntroduction(){
let backParams:editModelParams = router.getParams() as editModelParams;
if (backParams) {
let userName = backParams.userName as string ///昵称
let introduction = backParams.introduction as string ///简介
if (userName) {
if (userName != this.currentUserInfo.userName) {
this.currentUserInfo.userName = userName;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_nickname
this.updateEditModel()
}
} else if (introduction){
if (introduction != this.currentUserInfo.userExtend.introduction ) {
this.currentUserInfo.userExtend.introduction = introduction;
this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_intro
this.updateEditModel()
}
}
}
}
updateEditModel(){
this.listData = []
this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo))
... ...
import { CustomTitleUI } from '../reusable/CustomTitleUI'
import router from '@ohos.router'
import { editModelParams } from '../../model/EditInfoModel'
@Entry
@Component
... ... @@ -7,13 +8,13 @@ struct EditUserIntroductionPage {
@State numCount: number = 0
@State textColor : string = '#222222'
@State introduction: string = ''
@State params:editModelParams = router.getParams() as editModelParams;
build() {
Column(){
CustomTitleUI({titleName:'修改简介'})
Row(){
TextInput({placeholder:'请输入简介'})
TextInput({placeholder:'请输入简介',text:this.params.editContent})
.maxLength(60)
.width('100%')
.height(80)
... ... @@ -50,9 +51,12 @@ struct EditUserIntroductionPage {
.borderRadius(5)
.margin(30)
.onClick(()=>{
let params: editModelParams = {
introduction: this.introduction
}
router.back({
url:'',
params:{nikeName:this.introduction}
params:params
})
})
}
... ...
import { CustomTitleUI } from '../reusable/CustomTitleUI'
import router from '@ohos.router'
import { editModelParams } from '../../model/EditInfoModel'
@Entry
@Component
... ... @@ -8,13 +9,13 @@ struct EditUserNikeNamePage {
@State numCount: number = 0
@State textColor : string = '#222222'
@State nikeName: string = ''
@State params:editModelParams = router.getParams() as editModelParams;
build() {
Column(){
CustomTitleUI({titleName:'修改昵称'})
Row(){
TextInput({placeholder:'请输入昵称'})
TextInput({placeholder:'请输入昵称',text:this.params.editContent})
.width('100%')
.maxLength(16)
.height(50)
... ... @@ -50,9 +51,12 @@ struct EditUserNikeNamePage {
.borderRadius(5)
.margin(30)
.onClick(()=>{
let params: editModelParams = {
userName: this.nikeName
}
router.back({
url:'',
params:{nikeName:this.nikeName}
params:params
})
})
}
... ...
/**
* WDEditDataModelType 更新资料类型
*/
export const enum WDEditDataModelType {
WDEditDataModelType_default, //默认不修改
WDEditDataModelType_head, //头像
WDEditDataModelType_nickname, //昵称
WDEditDataModelType_intro, //简介
WDEditDataModelType_sex, //性别
WDEditDataModelType_birthday, //生日
WDEditDataModelType_region, //地址
}
export class EditListInfo{
//标题
title:string
... ... @@ -42,6 +55,26 @@ export class editModel{
userExtend:EditInfoModel = new EditInfoModel()
constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel) {
editDataType:WDEditDataModelType = 0
constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel,editDataType?:WDEditDataModelType) {
}
}
export interface editModelParams {
editContent?: string;
userName?: string;
introduction?: string;
//地区
city?:string;
county?:string;
province?:string;
//生日
birthday?:string;
//性别
sex?:string;
}
\ No newline at end of file
... ...
import { EditInfoModel, EditListInfo, editModel } from '../model/EditInfoModel';
import { EditInfoModel, EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../model/EditInfoModel';
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger, ResourcesUtils } from 'wdKit';
... ... @@ -27,6 +27,12 @@ class EditInfoViewModel {
return WDHttp.get<ResponseDTO>(requestUrl,headers)
}
BasePOSTRequest(requestUrl:string){
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
requestUrl = HttpUrlUtils.HOST_SIT + requestUrl
return WDHttp.post<ResponseDTO>(requestUrl,headers)
}
getEditListInfo(item?:editModel):EditListInfo[]{
this.editListData = [
... ... @@ -34,8 +40,7 @@ class EditInfoViewModel {
new EditListInfo('简介',item&&item.userExtend.introduction.length > 0?item.userExtend.introduction:'待完善'),
new EditListInfo('地区',item&&item.userExtend.city.length > 0?item.userExtend.city:'待完善'),
new EditListInfo('生日',item&&item.userExtend.birthday.length > 0?item.userExtend.birthday:'待完善'),
new EditListInfo('性别',item&&item.userExtend.sex.length > 0?(item.userExtend.sex=== '1'?'男':'女'):'待完善'),
]
new EditListInfo('性别',item&&item.userExtend.sex.length > 0?(item.userExtend.sex=== '1'?'男':'女'):'待完善'),]
return this.editListData
}
... ... @@ -51,7 +56,6 @@ class EditInfoViewModel {
}).catch((error: Error) => {
Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel')
success(this.GetqueryAccountOwnerLocal(context))
})
}))
}
... ... @@ -68,7 +72,7 @@ class EditInfoViewModel {
}
getAreaList(context: Context):PromiseLike<AreaListModel[]>{
return new Promise(((success, error) => {
return new Promise((success, error) => {
success(this.getAreaListLocal(context))
// this.BaseGetRequest(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{
// if (navResDTO.code == 200) {
... ... @@ -81,7 +85,7 @@ class EditInfoViewModel {
// success(this.GetqueryAccountOwnerLocal(context))
//
// })
}))
})
}
async getAreaListLocal(context: Context): Promise<AreaListModel[]> {
... ... @@ -99,8 +103,32 @@ class EditInfoViewModel {
return new AreaListManageModel(item.code,item.id,item.label,item.children)
}
updateUserInfo(){
updateUserInfo(item?:editModel):Promise<ResponseDTO> {
let params: editModelParams = {};
if (item.editDataType === WDEditDataModelType.WDEditDataModelType_head) {
// params =
} else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_nickname) {
params = { userName: item.userName }
} else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_intro) {
params = { introduction: item.userExtend.introduction }
} else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_sex) {
params = { sex: item.userExtend.sex }
} else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_birthday) {
params = { birthday: item.userExtend.birthday }
} else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_region) {
params = { county: item.userExtend.county }
} else {
}
return new Promise((success, error) => {
this.BasePOSTRequest(HttpUrlUtils.APPOINTMENT_editUserDetail_PATH)
.then((navResDTO: ResponseDTO) => {
if (navResDTO.code == 200) {
}
})
.catch((error: Error) => {
})
})
}
}
... ...