wangliang_wd

feat:优化个人信息更新

@@ -104,6 +104,10 @@ export class HttpUrlUtils { @@ -104,6 +104,10 @@ export class HttpUrlUtils {
104 */ 104 */
105 static readonly APPOINTMENT_editUserDetail1_PATH: string = "/api/rmrb-user-center/user/zh/c/completeUserInfo"; 105 static readonly APPOINTMENT_editUserDetail1_PATH: string = "/api/rmrb-user-center/user/zh/c/completeUserInfo";
106 /** 106 /**
  107 + * 资料编辑 地区拉取
  108 + */
  109 + static readonly APPOINTMENT_userArea_PATH: string = "/api/rmrb-content-center/c/service/sys-area/treeselect";
  110 + /**
107 /** 111 /**
108 * 个人中心 关注列表详情 112 * 个人中心 关注列表详情
109 */ 113 */
@@ -17,8 +17,11 @@ struct EditUserInfoPage { @@ -17,8 +17,11 @@ struct EditUserInfoPage {
17 17
18 dialogController: CustomDialogController = new CustomDialogController({ 18 dialogController: CustomDialogController = new CustomDialogController({
19 builder: AreaPickerDialog({dataSource:this.dataSource, 19 builder: AreaPickerDialog({dataSource:this.dataSource,
20 - confirmCallback:(area:string)=>{  
21 - this.currentUserInfo.userExtend.city = area; 20 + confirmCallback:(province:string,city:string,county:string,address:string)=>{
  21 + this.currentUserInfo.userExtend.province = province;
  22 + this.currentUserInfo.userExtend.city = city;
  23 + this.currentUserInfo.userExtend.county = county;
  24 + this.currentUserInfo.userExtend.address = address;
22 this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_region 25 this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_region
23 this.updateEditModel() 26 this.updateEditModel()
24 } 27 }
@@ -100,6 +103,8 @@ struct EditUserInfoPage { @@ -100,6 +103,8 @@ struct EditUserInfoPage {
100 .width('100%') 103 .width('100%')
101 .onClick(()=>{ 104 .onClick(()=>{
102 if (i === 1){ 105 if (i === 1){
  106 +
  107 +
103 let params: editModelParams = { 108 let params: editModelParams = {
104 editContent: this.currentUserInfo.userName 109 editContent: this.currentUserInfo.userName
105 } 110 }
@@ -163,7 +168,7 @@ struct EditUserInfoPage { @@ -163,7 +168,7 @@ struct EditUserInfoPage {
163 updateEditModel(){ 168 updateEditModel(){
164 this.listData = [] 169 this.listData = []
165 this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo)) 170 this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo))
166 - this.updateUserInfo(this.currentUserInfo) 171 + EditInfoViewModel.updateUserInfo(this.currentUserInfo)
167 } 172 }
168 getAccountOwnerInfo(){ 173 getAccountOwnerInfo(){
169 EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((editModel) => { 174 EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((editModel) => {
@@ -178,25 +183,4 @@ struct EditUserInfoPage { @@ -178,25 +183,4 @@ struct EditUserInfoPage {
178 this.dataSource.push(...value) 183 this.dataSource.push(...value)
179 }) 184 })
180 } 185 }
181 -  
182 - updateUserInfo(item?:editModel){  
183 - // if (item.editDataType == WDEditDataModelType.WDEditDataModelType_head) {  
184 - // } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_nickname) {  
185 - // let params: editModelParams = { userName: item.userName }  
186 - // EditInfoViewModel.updateUserInfo(params)  
187 - // }  
188 - // else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_intro) {  
189 - // let params: editModelParams = { introduction: item.userExtend.introduction }  
190 - // EditInfoViewModel.updateUserInfo(params)  
191 - // } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_sex) {  
192 - // let params: editModelParams = { sex: item.userExtend.sex.toString() }  
193 - // EditInfoViewModel.updateUserInfo(params)  
194 - // } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_birthday) {  
195 - // let params: editModelParams = { birthday: item.userExtend.birthday }  
196 - // EditInfoViewModel.updateUserInfo(params)  
197 - // } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_region) {  
198 - // let params: editModelParams = { county: item.userExtend.county }  
199 - // EditInfoViewModel.updateUserInfo(params)  
200 - // }  
201 - }  
202 } 186 }
@@ -13,7 +13,7 @@ export struct AreaPickerDialog { @@ -13,7 +13,7 @@ export struct AreaPickerDialog {
13 title: string = '地区选择' 13 title: string = '地区选择'
14 @Provide dataSource: AreaListModel[] = [] 14 @Provide dataSource: AreaListModel[] = []
15 result: JSON[] = []; 15 result: JSON[] = [];
16 - confirmCallback: (area:string) => void = () => { 16 + confirmCallback: (province:string,city:string,county:string,address:string) => void = () => {
17 } 17 }
18 18
19 build() { 19 build() {
@@ -37,7 +37,7 @@ export struct AreaPickerDialog { @@ -37,7 +37,7 @@ export struct AreaPickerDialog {
37 Button('确定',{type:ButtonType.Normal}) 37 Button('确定',{type:ButtonType.Normal})
38 .onClick(()=> { 38 .onClick(()=> {
39 this.controller.close() 39 this.controller.close()
40 - this.confirmCallback(this.currentFirst.label+this.currentSecondBean.label+this.currentThirdBean.label); 40 + this.confirmCallback(this.currentFirst.label,this.currentSecondBean.label,this.currentThirdBean.label,this.currentFirst.label+this.currentSecondBean.label+this.currentThirdBean.label);
41 }) 41 })
42 .backgroundColor(0xffffff) 42 .backgroundColor(0xffffff)
43 .fontColor(Color.Blue) 43 .fontColor(Color.Blue)
@@ -29,10 +29,14 @@ export class EditInfoModel{ @@ -29,10 +29,14 @@ export class EditInfoModel{
29 headPhotoUrl:string = '' 29 headPhotoUrl:string = ''
30 //简介 30 //简介
31 introduction:string = '' 31 introduction:string = ''
32 - //城市 32 + //
33 city:string = '' 33 city:string = ''
34 - //地区 34 + //市
  35 + province:string = ''
  36 + //区
35 county:string = '' 37 county:string = ''
  38 + //地址
  39 + address:string = ''
36 //生日 40 //生日
37 birthday:string = '' 41 birthday:string = ''
38 //性别 42 //性别
@@ -55,9 +59,9 @@ export class editModel{ @@ -55,9 +59,9 @@ export class editModel{
55 59
56 userExtend:EditInfoModel = new EditInfoModel() 60 userExtend:EditInfoModel = new EditInfoModel()
57 61
58 - editDataType:WDEditDataModelType = WDEditDataModelType.WDEditDataModelType_default 62 + editDataType:number = WDEditDataModelType.WDEditDataModelType_default
59 63
60 - constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel,editDataType?:WDEditDataModelType) { 64 + constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel,editDataType?:number) {
61 } 65 }
62 } 66 }
63 67
@@ -72,6 +76,7 @@ export interface editModelParams { @@ -72,6 +76,7 @@ export interface editModelParams {
72 city?:string; 76 city?:string;
73 county?:string; 77 county?:string;
74 province?:string; 78 province?:string;
  79 + address?:string;
75 80
76 //生日 81 //生日
77 birthday?:string; 82 birthday?:string;
1 1
2 import { 2 import {
3 editItem, 3 editItem,
4 - EditListInfo, editModel } from '../model/EditInfoModel'; 4 + EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../model/EditInfoModel';
5 import HashMap from '@ohos.util.HashMap'; 5 import HashMap from '@ohos.util.HashMap';
6 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 6 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
7 import { Logger, ResourcesUtils } from 'wdKit'; 7 import { Logger, ResourcesUtils } from 'wdKit';
8 import { AreaListManageModel, AreaListModel } from '../model/AreaListModel'; 8 import { AreaListManageModel, AreaListModel } from '../model/AreaListModel';
  9 +import promptAction from '@ohos.promptAction';
9 10
10 const TAG = "EditInfoViewModel" 11 const TAG = "EditInfoViewModel"
11 12
12 class EditInfoViewModel { 13 class EditInfoViewModel {
13 private static instance: EditInfoViewModel; 14 private static instance: EditInfoViewModel;
14 - editListData:EditListInfo[] = [] 15 + editListData:EditListInfo[] = []
  16 + params: editModelParams = {}
15 /** 17 /**
16 * 单例模式 18 * 单例模式
17 * @returns 19 * @returns
@@ -40,7 +42,7 @@ class EditInfoViewModel { @@ -40,7 +42,7 @@ class EditInfoViewModel {
40 this.editListData = [ 42 this.editListData = [
41 new EditListInfo('昵称',item&&item.userName.length > 0?item.userName:'待完善'), 43 new EditListInfo('昵称',item&&item.userName.length > 0?item.userName:'待完善'),
42 new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'), 44 new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'),
43 - new EditListInfo('地区',item&&item.userExtend.city?item.userExtend.city:'待完善'), 45 + new EditListInfo('地区',item&&item.userExtend.address?item.userExtend.address:'待完善'),
44 new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'), 46 new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'),
45 new EditListInfo('性别',item?(item.userExtend.sex === 1?'男':'女'):'待完善'),] 47 new EditListInfo('性别',item?(item.userExtend.sex === 1?'男':'女'):'待完善'),]
46 return this.editListData 48 return this.editListData
@@ -76,15 +78,14 @@ class EditInfoViewModel { @@ -76,15 +78,14 @@ class EditInfoViewModel {
76 getAreaList(context: Context):PromiseLike<AreaListModel[]>{ 78 getAreaList(context: Context):PromiseLike<AreaListModel[]>{
77 return new Promise((success, error) => { 79 return new Promise((success, error) => {
78 success(this.getAreaListLocal(context)) 80 success(this.getAreaListLocal(context))
79 - // this.BaseGetRequest(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{ 81 + // HttpRequest.post(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{
80 // if (navResDTO.code == 200) { 82 // if (navResDTO.code == 200) {
81 // // let editM = navResDTO.data as EditInfoModel 83 // // let editM = navResDTO.data as EditInfoModel
82 // // success(JSON.parse(navResDTO.data) 84 // // success(JSON.parse(navResDTO.data)
83 // } 85 // }
84 - //  
85 // }).catch((error: Error) => { 86 // }).catch((error: Error) => {
86 - // Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel')  
87 - // success(this.GetqueryAccountOwnerLocal(context)) 87 + // Logger.info(TAG,'getAreaList','EditInfoViewModel')
  88 + // success(this.getAreaListLocal(context))
88 // 89 //
89 // }) 90 // })
90 }) 91 })
@@ -105,11 +106,28 @@ class EditInfoViewModel { @@ -105,11 +106,28 @@ class EditInfoViewModel {
105 return new AreaListManageModel(item.code,item.id,item.label,item.children) 106 return new AreaListManageModel(item.code,item.id,item.label,item.children)
106 } 107 }
107 108
108 - updateUserInfo(params:object):Promise<ResponseDTO> { 109 + updateUserInfo(item:editModel):Promise<ResponseDTO> {
  110 + if (item.editDataType == WDEditDataModelType.WDEditDataModelType_head) {
  111 + } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_nickname) {
  112 + this.params = { userName: item.userName }
  113 + }
  114 + else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_intro) {
  115 + this.params = { introduction: item.userExtend.introduction }
  116 +
  117 + } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_sex) {
  118 + this.params = { sex: item.userExtend.sex.toString() }
  119 +
  120 + } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_birthday) {
  121 + this.params = { birthday: item.userExtend.birthday }
  122 +
  123 + } else if (item.editDataType == WDEditDataModelType.WDEditDataModelType_region) {
  124 + this.params = {province:item.userExtend.province,city:item.userExtend.city, county: item.userExtend.county ,address:item.userExtend.address}
  125 + }
109 return new Promise((success, error) => { 126 return new Promise((success, error) => {
110 - this.BasePostRequest(HttpUrlUtils.APPOINTMENT_editUserDetail_PATH,params) 127 + this.BasePostRequest(HttpUrlUtils.APPOINTMENT_editUserDetail_PATH,this.params)
111 .then((navResDTO: ResponseDTO) => { 128 .then((navResDTO: ResponseDTO) => {
112 - if (navResDTO.code == 200) { 129 + if (navResDTO.code == 0) {
  130 + promptAction.showToast({ message: '修改成功' })
113 } 131 }
114 }) 132 })
115 .catch((error: Error) => { 133 .catch((error: Error) => {