wangliang_wd

feat:优化编辑资料

@@ -129,7 +129,7 @@ struct EditUserInfoPage { @@ -129,7 +129,7 @@ struct EditUserInfoPage {
129 range:['女','男'], 129 range:['女','男'],
130 selected:0, 130 selected:0,
131 onAccept:(value:TextPickerResult) => { 131 onAccept:(value:TextPickerResult) => {
132 - this.currentUserInfo.userExtend.sex = value.index.toString(); 132 + this.currentUserInfo.userExtend.sex = value.index as number;
133 this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_sex 133 this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_sex
134 this.updateEditModel() 134 this.updateEditModel()
135 } 135 }
@@ -163,11 +163,12 @@ struct EditUserInfoPage { @@ -163,11 +163,12 @@ struct EditUserInfoPage {
163 updateEditModel(){ 163 updateEditModel(){
164 this.listData = [] 164 this.listData = []
165 this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo)) 165 this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo))
  166 + this.updateUserInfo(this.currentUserInfo)
166 } 167 }
167 getAccountOwnerInfo(){ 168 getAccountOwnerInfo(){
168 EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((editModel) => { 169 EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((editModel) => {
169 this.headerImg = editModel.userExtend.headPhotoUrl 170 this.headerImg = editModel.userExtend.headPhotoUrl
170 - this.currentUserInfo = editModel; 171 + this.currentUserInfo = editModel as editModel;
171 this.listData.push(...EditInfoViewModel.getEditListInfo(editModel)) 172 this.listData.push(...EditInfoViewModel.getEditListInfo(editModel))
172 }); 173 });
173 } 174 }
@@ -177,4 +178,25 @@ struct EditUserInfoPage { @@ -177,4 +178,25 @@ struct EditUserInfoPage {
177 this.dataSource.push(...value) 178 this.dataSource.push(...value)
178 }) 179 })
179 } 180 }
  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 + }
180 } 202 }
@@ -3,13 +3,13 @@ @@ -3,13 +3,13 @@
3 * WDEditDataModelType 更新资料类型 3 * WDEditDataModelType 更新资料类型
4 */ 4 */
5 export const enum WDEditDataModelType { 5 export const enum WDEditDataModelType {
6 - WDEditDataModelType_default, //默认不修改 6 + WDEditDataModelType_default = 0, //默认不修改
7 WDEditDataModelType_head, //头像 7 WDEditDataModelType_head, //头像
8 WDEditDataModelType_nickname, //昵称 8 WDEditDataModelType_nickname, //昵称
9 WDEditDataModelType_intro, //简介 9 WDEditDataModelType_intro, //简介
10 WDEditDataModelType_sex, //性别 10 WDEditDataModelType_sex, //性别
11 WDEditDataModelType_birthday, //生日 11 WDEditDataModelType_birthday, //生日
12 - WDEditDataModelType_region, //地址 12 + WDEditDataModelType_region //地址
13 } 13 }
14 14
15 export class EditListInfo{ 15 export class EditListInfo{
@@ -36,11 +36,11 @@ export class EditInfoModel{ @@ -36,11 +36,11 @@ export class EditInfoModel{
36 //生日 36 //生日
37 birthday:string = '' 37 birthday:string = ''
38 //性别 38 //性别
39 - sex:string = '' 39 + sex:number = 0
40 40
41 airec:number = 0 41 airec:number = 0
42 42
43 - constructor(headPhotoUrl?:string , introduction?:string,city?:string , county?:string,birthday?:string , sex?:string,airec?:number) { 43 + constructor(headPhotoUrl?:string , introduction?:string,city?:string , county?:string,birthday?:string , sex?:number,airec?:number) {
44 } 44 }
45 } 45 }
46 46
@@ -55,7 +55,7 @@ export class editModel{ @@ -55,7 +55,7 @@ export class editModel{
55 55
56 userExtend:EditInfoModel = new EditInfoModel() 56 userExtend:EditInfoModel = new EditInfoModel()
57 57
58 - editDataType:WDEditDataModelType = 0 58 + editDataType:WDEditDataModelType = WDEditDataModelType.WDEditDataModelType_default
59 59
60 constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel,editDataType?:WDEditDataModelType) { 60 constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel,editDataType?:WDEditDataModelType) {
61 } 61 }
@@ -77,4 +77,18 @@ export interface editModelParams { @@ -77,4 +77,18 @@ export interface editModelParams {
77 birthday?:string; 77 birthday?:string;
78 //性别 78 //性别
79 sex?:string; 79 sex?:string;
  80 +}
  81 +
  82 +
  83 +export interface editItem{
  84 + code:number
  85 +
  86 + data:editModel
  87 +
  88 + message:string
  89 +
  90 + success:boolean
  91 +
  92 + timestamp:number
  93 +
80 } 94 }
1 1
2 -import { EditInfoModel, EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../model/EditInfoModel'; 2 +import {
  3 + editItem,
  4 + EditListInfo, editModel } from '../model/EditInfoModel';
3 import HashMap from '@ohos.util.HashMap'; 5 import HashMap from '@ohos.util.HashMap';
4 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 6 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
5 import { Logger, ResourcesUtils } from 'wdKit'; 7 import { Logger, ResourcesUtils } from 'wdKit';
@@ -23,38 +25,38 @@ class EditInfoViewModel { @@ -23,38 +25,38 @@ class EditInfoViewModel {
23 25
24 BaseGetRequest(requestUrl:string){ 26 BaseGetRequest(requestUrl:string){
25 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders() 27 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
26 - requestUrl = HttpUrlUtils.HOST_SIT + requestUrl  
27 - return WDHttp.get<ResponseDTO>(requestUrl,headers) 28 + requestUrl = HttpUrlUtils.getHost() + requestUrl
  29 + return WDHttp.get<editItem>(requestUrl,headers)
28 } 30 }
29 31
30 - BasePOSTRequest(requestUrl:string){ 32 + BasePostRequest(requestUrl:string,params: object){
31 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders() 33 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
32 - requestUrl = HttpUrlUtils.HOST_SIT + requestUrl  
33 - return WDHttp.post<ResponseDTO>(requestUrl,headers) 34 + requestUrl = HttpUrlUtils.getHost() + requestUrl
  35 + return WDHttp.post<ResponseDTO>(requestUrl,params,headers)
34 } 36 }
35 37
36 38
37 getEditListInfo(item?:editModel):EditListInfo[]{ 39 getEditListInfo(item?:editModel):EditListInfo[]{
38 this.editListData = [ 40 this.editListData = [
39 new EditListInfo('昵称',item&&item.userName.length > 0?item.userName:'待完善'), 41 new EditListInfo('昵称',item&&item.userName.length > 0?item.userName:'待完善'),
40 - new EditListInfo('简介',item&&item.userExtend.introduction.length > 0?item.userExtend.introduction:'待完善'),  
41 - new EditListInfo('地区',item&&item.userExtend.city.length > 0?item.userExtend.city:'待完善'),  
42 - new EditListInfo('生日',item&&item.userExtend.birthday.length > 0?item.userExtend.birthday:'待完善'),  
43 - new EditListInfo('性别',item&&item.userExtend.sex.length > 0?(item.userExtend.sex=== '1'?'男':'女'):'待完善'),] 42 + new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'),
  43 + new EditListInfo('地区',item&&item.userExtend.city?item.userExtend.city:'待完善'),
  44 + new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'),
  45 + new EditListInfo('性别',item?(item.userExtend.sex === 1?'男':'女'):'待完善'),]
44 return this.editListData 46 return this.editListData
45 } 47 }
46 48
47 ///1普通用户 49 ///1普通用户
48 queryAccountOwnerInfo(userType:number, context: Context):PromiseLike<editModel>{ 50 queryAccountOwnerInfo(userType:number, context: Context):PromiseLike<editModel>{
49 return new Promise(((success, error) => { 51 return new Promise(((success, error) => {
50 - this.BaseGetRequest(userType == 1?HttpUrlUtils.APPOINTMENT_QueryUserDetail_PATH:HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{  
51 - if (navResDTO.code == 200) {  
52 - // let editM = navResDTO.data as EditInfoModel  
53 - // success(JSON.parse(navResDTO.data) 52 + this.BaseGetRequest(userType == 1?HttpUrlUtils.APPOINTMENT_QueryUserDetail_PATH:HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((editDTO:editItem) =>{
  53 + if (editDTO.code == 0) {
  54 + success(editDTO.data)
  55 + }else {
  56 + success(this.GetqueryAccountOwnerLocal(context))
54 } 57 }
55 - success(this.GetqueryAccountOwnerLocal(context))  
56 }).catch((error: Error) => { 58 }).catch((error: Error) => {
57 - Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel') 59 + Logger.info(TAG,'queryAccountOwnerInfo','EditInfoViewModel')
58 success(this.GetqueryAccountOwnerLocal(context)) 60 success(this.GetqueryAccountOwnerLocal(context))
59 }) 61 })
60 })) 62 }))
@@ -103,34 +105,18 @@ class EditInfoViewModel { @@ -103,34 +105,18 @@ class EditInfoViewModel {
103 return new AreaListManageModel(item.code,item.id,item.label,item.children) 105 return new AreaListManageModel(item.code,item.id,item.label,item.children)
104 } 106 }
105 107
106 - // updateUserInfo(item?:editModel):Promise<ResponseDTO> {  
107 - // let params: editModelParams = {};  
108 - // if (item.editDataType === WDEditDataModelType.WDEditDataModelType_head) {  
109 - // // params =  
110 - // } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_nickname) {  
111 - // params = { userName: item.userName }  
112 - // } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_intro) {  
113 - // params = { introduction: item.userExtend.introduction }  
114 - // } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_sex) {  
115 - // params = { sex: item.userExtend.sex }  
116 - // } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_birthday) {  
117 - // params = { birthday: item.userExtend.birthday }  
118 - // } else if (item.editDataType === WDEditDataModelType.WDEditDataModelType_region) {  
119 - // params = { county: item.userExtend.county }  
120 - // } else {  
121 - // }  
122 - // return new Promise((success, error) => {  
123 - // this.BasePOSTRequest(HttpUrlUtils.APPOINTMENT_editUserDetail_PATH)  
124 - // .then((navResDTO: ResponseDTO) => {  
125 - // if (navResDTO.code == 200) {  
126 - // }  
127 - // })  
128 - // .catch((error: Error) => {  
129 - //  
130 - // })  
131 - // })  
132 - // }  
133 - 108 + updateUserInfo(params:object):Promise<ResponseDTO> {
  109 + return new Promise((success, error) => {
  110 + this.BasePostRequest(HttpUrlUtils.APPOINTMENT_editUserDetail_PATH,params)
  111 + .then((navResDTO: ResponseDTO) => {
  112 + if (navResDTO.code == 200) {
  113 + }
  114 + })
  115 + .catch((error: Error) => {
  116 + Logger.info(TAG,'updateUserInfo','EditInfoViewModel')
  117 + })
  118 + })
  119 + }
134 } 120 }
135 121
136 const editInfoViewModel = EditInfoViewModel.getInstance(); 122 const editInfoViewModel = EditInfoViewModel.getInstance();