wangliang_wd

feat:优化编辑资料

@@ -96,6 +96,14 @@ export class HttpUrlUtils { @@ -96,6 +96,14 @@ export class HttpUrlUtils {
96 */ 96 */
97 static readonly APPOINTMENT_QueryUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/queryUserDetail"; 97 static readonly APPOINTMENT_QueryUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/queryUserDetail";
98 /** 98 /**
  99 + * 资料编辑 更新普通用户信息
  100 + */
  101 + static readonly APPOINTMENT_editUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/editUserDetail";
  102 + /**
  103 + * 资料编辑 更新普通用户名
  104 + */
  105 + static readonly APPOINTMENT_editUserDetail1_PATH: string = "/api/rmrb-user-center/user/zh/c/completeUserInfo";
  106 + /**
99 /** 107 /**
100 * 个人中心 关注列表详情 108 * 个人中心 关注列表详情
101 */ 109 */
1 1
2 import { CustomTitleUI } from '../reusable/CustomTitleUI'; 2 import { CustomTitleUI } from '../reusable/CustomTitleUI';
3 -import { EditListInfo, editModel } from '../../model/EditInfoModel'; 3 +import { EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../../model/EditInfoModel';
4 import EditInfoViewModel from '../../viewmodel/EditInfoViewModel'; 4 import EditInfoViewModel from '../../viewmodel/EditInfoViewModel';
5 import { WDRouterPage, WDRouterRule } from 'wdRouter'; 5 import { WDRouterPage, WDRouterRule } from 'wdRouter';
6 import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog' 6 import {AreaPickerDialog} from '../view/areaPickerDialog/AreaPickerDialog'
7 import { AreaListModel } from '../../model/AreaListModel'; 7 import { AreaListModel } from '../../model/AreaListModel';
  8 +import router from '@ohos.router';
8 9
9 @Entry 10 @Entry
10 @Component 11 @Component
@@ -18,6 +19,7 @@ struct EditUserInfoPage { @@ -18,6 +19,7 @@ struct EditUserInfoPage {
18 builder: AreaPickerDialog({dataSource:this.dataSource, 19 builder: AreaPickerDialog({dataSource:this.dataSource,
19 confirmCallback:(area:string)=>{ 20 confirmCallback:(area:string)=>{
20 this.currentUserInfo.userExtend.city = area; 21 this.currentUserInfo.userExtend.city = area;
  22 + this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_region
21 this.updateEditModel() 23 this.updateEditModel()
22 } 24 }
23 }), 25 }),
@@ -31,7 +33,7 @@ struct EditUserInfoPage { @@ -31,7 +33,7 @@ struct EditUserInfoPage {
31 } 33 }
32 34
33 onPageShow(){ 35 onPageShow(){
34 - 36 + this.updateUserNameAndIntroduction()
35 } 37 }
36 38
37 build() { 39 build() {
@@ -98,13 +100,15 @@ struct EditUserInfoPage { @@ -98,13 +100,15 @@ struct EditUserInfoPage {
98 .width('100%') 100 .width('100%')
99 .onClick(()=>{ 101 .onClick(()=>{
100 if (i === 1){ 102 if (i === 1){
101 - WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage) 103 + let params: editModelParams = {
  104 + editContent: this.currentUserInfo.userName
  105 + }
  106 + WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage,params)
102 }else if (i === 2){ 107 }else if (i === 2){
103 - WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage)  
104 - // router.pushUrl({  
105 - // url:'pages/EditUserInstoductionPage',  
106 - // params:{pageNum:i}  
107 - // }) 108 + let params: editModelParams = {
  109 + editContent: this.currentUserInfo.userExtend.introduction
  110 + }
  111 + WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage,params)
108 }else if (i === 3){ 112 }else if (i === 3){
109 this.dialogController.open() 113 this.dialogController.open()
110 } else if (i === 4) { 114 } else if (i === 4) {
@@ -116,6 +120,7 @@ struct EditUserInfoPage { @@ -116,6 +120,7 @@ struct EditUserInfoPage {
116 onAccept:(value:DatePickerResult) => { 120 onAccept:(value:DatePickerResult) => {
117 let mon = value.month as number + 1 121 let mon = value.month as number + 1
118 this.currentUserInfo.userExtend.birthday = value.year+'-'+mon.toString()+'-'+value.day; 122 this.currentUserInfo.userExtend.birthday = value.year+'-'+mon.toString()+'-'+value.day;
  123 + this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_birthday
119 this.updateEditModel() 124 this.updateEditModel()
120 } 125 }
121 }) 126 })
@@ -125,6 +130,7 @@ struct EditUserInfoPage { @@ -125,6 +130,7 @@ struct EditUserInfoPage {
125 selected:0, 130 selected:0,
126 onAccept:(value:TextPickerResult) => { 131 onAccept:(value:TextPickerResult) => {
127 this.currentUserInfo.userExtend.sex = value.index.toString(); 132 this.currentUserInfo.userExtend.sex = value.index.toString();
  133 + this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_sex
128 this.updateEditModel() 134 this.updateEditModel()
129 } 135 }
130 }) 136 })
@@ -132,6 +138,28 @@ struct EditUserInfoPage { @@ -132,6 +138,28 @@ struct EditUserInfoPage {
132 }) 138 })
133 } 139 }
134 140
  141 + updateUserNameAndIntroduction(){
  142 + let backParams:editModelParams = router.getParams() as editModelParams;
  143 + if (backParams) {
  144 + let userName = backParams.userName as string ///昵称
  145 + let introduction = backParams.introduction as string ///简介
  146 +
  147 + if (userName) {
  148 + if (userName != this.currentUserInfo.userName) {
  149 + this.currentUserInfo.userName = userName;
  150 + this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_nickname
  151 + this.updateEditModel()
  152 + }
  153 + } else if (introduction){
  154 + if (introduction != this.currentUserInfo.userExtend.introduction ) {
  155 + this.currentUserInfo.userExtend.introduction = introduction;
  156 + this.currentUserInfo.editDataType = WDEditDataModelType.WDEditDataModelType_intro
  157 + this.updateEditModel()
  158 + }
  159 + }
  160 + }
  161 + }
  162 +
135 updateEditModel(){ 163 updateEditModel(){
136 this.listData = [] 164 this.listData = []
137 this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo)) 165 this.listData.push(...EditInfoViewModel.getEditListInfo(this.currentUserInfo))
1 import { CustomTitleUI } from '../reusable/CustomTitleUI' 1 import { CustomTitleUI } from '../reusable/CustomTitleUI'
2 import router from '@ohos.router' 2 import router from '@ohos.router'
  3 +import { editModelParams } from '../../model/EditInfoModel'
3 4
4 @Entry 5 @Entry
5 @Component 6 @Component
@@ -7,13 +8,13 @@ struct EditUserIntroductionPage { @@ -7,13 +8,13 @@ struct EditUserIntroductionPage {
7 @State numCount: number = 0 8 @State numCount: number = 0
8 @State textColor : string = '#222222' 9 @State textColor : string = '#222222'
9 @State introduction: string = '' 10 @State introduction: string = ''
10 - 11 + @State params:editModelParams = router.getParams() as editModelParams;
11 build() { 12 build() {
12 Column(){ 13 Column(){
13 CustomTitleUI({titleName:'修改简介'}) 14 CustomTitleUI({titleName:'修改简介'})
14 15
15 Row(){ 16 Row(){
16 - TextInput({placeholder:'请输入简介'}) 17 + TextInput({placeholder:'请输入简介',text:this.params.editContent})
17 .maxLength(60) 18 .maxLength(60)
18 .width('100%') 19 .width('100%')
19 .height(80) 20 .height(80)
@@ -50,9 +51,12 @@ struct EditUserIntroductionPage { @@ -50,9 +51,12 @@ struct EditUserIntroductionPage {
50 .borderRadius(5) 51 .borderRadius(5)
51 .margin(30) 52 .margin(30)
52 .onClick(()=>{ 53 .onClick(()=>{
  54 + let params: editModelParams = {
  55 + introduction: this.introduction
  56 + }
53 router.back({ 57 router.back({
54 url:'', 58 url:'',
55 - params:{nikeName:this.introduction} 59 + params:params
56 }) 60 })
57 }) 61 })
58 } 62 }
1 import { CustomTitleUI } from '../reusable/CustomTitleUI' 1 import { CustomTitleUI } from '../reusable/CustomTitleUI'
2 import router from '@ohos.router' 2 import router from '@ohos.router'
  3 +import { editModelParams } from '../../model/EditInfoModel'
3 4
4 @Entry 5 @Entry
5 @Component 6 @Component
@@ -8,13 +9,13 @@ struct EditUserNikeNamePage { @@ -8,13 +9,13 @@ struct EditUserNikeNamePage {
8 @State numCount: number = 0 9 @State numCount: number = 0
9 @State textColor : string = '#222222' 10 @State textColor : string = '#222222'
10 @State nikeName: string = '' 11 @State nikeName: string = ''
11 - 12 + @State params:editModelParams = router.getParams() as editModelParams;
12 build() { 13 build() {
13 Column(){ 14 Column(){
14 CustomTitleUI({titleName:'修改昵称'}) 15 CustomTitleUI({titleName:'修改昵称'})
15 16
16 Row(){ 17 Row(){
17 - TextInput({placeholder:'请输入昵称'}) 18 + TextInput({placeholder:'请输入昵称',text:this.params.editContent})
18 .width('100%') 19 .width('100%')
19 .maxLength(16) 20 .maxLength(16)
20 .height(50) 21 .height(50)
@@ -50,9 +51,12 @@ struct EditUserNikeNamePage { @@ -50,9 +51,12 @@ struct EditUserNikeNamePage {
50 .borderRadius(5) 51 .borderRadius(5)
51 .margin(30) 52 .margin(30)
52 .onClick(()=>{ 53 .onClick(()=>{
  54 + let params: editModelParams = {
  55 + userName: this.nikeName
  56 + }
53 router.back({ 57 router.back({
54 url:'', 58 url:'',
55 - params:{nikeName:this.nikeName} 59 + params:params
56 }) 60 })
57 }) 61 })
58 } 62 }
1 1
  2 +/**
  3 + * WDEditDataModelType 更新资料类型
  4 + */
  5 +export const enum WDEditDataModelType {
  6 + WDEditDataModelType_default, //默认不修改
  7 + WDEditDataModelType_head, //头像
  8 + WDEditDataModelType_nickname, //昵称
  9 + WDEditDataModelType_intro, //简介
  10 + WDEditDataModelType_sex, //性别
  11 + WDEditDataModelType_birthday, //生日
  12 + WDEditDataModelType_region, //地址
  13 +}
  14 +
2 export class EditListInfo{ 15 export class EditListInfo{
3 //标题 16 //标题
4 title:string 17 title:string
@@ -42,6 +55,26 @@ export class editModel{ @@ -42,6 +55,26 @@ export class editModel{
42 55
43 userExtend:EditInfoModel = new EditInfoModel() 56 userExtend:EditInfoModel = new EditInfoModel()
44 57
45 - constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel) { 58 + editDataType:WDEditDataModelType = 0
  59 +
  60 + constructor(userName?:string , userNameStatus?:string,phone?:string , headPhotoStatus?:string,userExtend?:EditInfoModel,editDataType?:WDEditDataModelType) {
46 } 61 }
  62 +}
  63 +
  64 +export interface editModelParams {
  65 + editContent?: string;
  66 +
  67 + userName?: string;
  68 +
  69 + introduction?: string;
  70 +
  71 + //地区
  72 + city?:string;
  73 + county?:string;
  74 + province?:string;
  75 +
  76 + //生日
  77 + birthday?:string;
  78 + //性别
  79 + sex?:string;
47 } 80 }
1 1
2 -import { EditInfoModel, EditListInfo, editModel } from '../model/EditInfoModel'; 2 +import { EditInfoModel, EditListInfo, editModel, editModelParams, WDEditDataModelType } from '../model/EditInfoModel';
3 import HashMap from '@ohos.util.HashMap'; 3 import HashMap from '@ohos.util.HashMap';
4 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; 4 import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
5 import { Logger, ResourcesUtils } from 'wdKit'; 5 import { Logger, ResourcesUtils } from 'wdKit';
@@ -27,6 +27,12 @@ class EditInfoViewModel { @@ -27,6 +27,12 @@ class EditInfoViewModel {
27 return WDHttp.get<ResponseDTO>(requestUrl,headers) 27 return WDHttp.get<ResponseDTO>(requestUrl,headers)
28 } 28 }
29 29
  30 + BasePOSTRequest(requestUrl:string){
  31 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
  32 + requestUrl = HttpUrlUtils.HOST_SIT + requestUrl
  33 + return WDHttp.post<ResponseDTO>(requestUrl,headers)
  34 + }
  35 +
30 36
31 getEditListInfo(item?:editModel):EditListInfo[]{ 37 getEditListInfo(item?:editModel):EditListInfo[]{
32 this.editListData = [ 38 this.editListData = [
@@ -34,8 +40,7 @@ class EditInfoViewModel { @@ -34,8 +40,7 @@ class EditInfoViewModel {
34 new EditListInfo('简介',item&&item.userExtend.introduction.length > 0?item.userExtend.introduction:'待完善'), 40 new EditListInfo('简介',item&&item.userExtend.introduction.length > 0?item.userExtend.introduction:'待完善'),
35 new EditListInfo('地区',item&&item.userExtend.city.length > 0?item.userExtend.city:'待完善'), 41 new EditListInfo('地区',item&&item.userExtend.city.length > 0?item.userExtend.city:'待完善'),
36 new EditListInfo('生日',item&&item.userExtend.birthday.length > 0?item.userExtend.birthday:'待完善'), 42 new EditListInfo('生日',item&&item.userExtend.birthday.length > 0?item.userExtend.birthday:'待完善'),
37 - new EditListInfo('性别',item&&item.userExtend.sex.length > 0?(item.userExtend.sex=== '1'?'男':'女'):'待完善'),  
38 - ] 43 + new EditListInfo('性别',item&&item.userExtend.sex.length > 0?(item.userExtend.sex=== '1'?'男':'女'):'待完善'),]
39 return this.editListData 44 return this.editListData
40 } 45 }
41 46
@@ -51,7 +56,6 @@ class EditInfoViewModel { @@ -51,7 +56,6 @@ class EditInfoViewModel {
51 }).catch((error: Error) => { 56 }).catch((error: Error) => {
52 Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel') 57 Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel')
53 success(this.GetqueryAccountOwnerLocal(context)) 58 success(this.GetqueryAccountOwnerLocal(context))
54 -  
55 }) 59 })
56 })) 60 }))
57 } 61 }
@@ -68,7 +72,7 @@ class EditInfoViewModel { @@ -68,7 +72,7 @@ class EditInfoViewModel {
68 } 72 }
69 73
70 getAreaList(context: Context):PromiseLike<AreaListModel[]>{ 74 getAreaList(context: Context):PromiseLike<AreaListModel[]>{
71 - return new Promise(((success, error) => { 75 + return new Promise((success, error) => {
72 success(this.getAreaListLocal(context)) 76 success(this.getAreaListLocal(context))
73 // this.BaseGetRequest(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{ 77 // this.BaseGetRequest(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{
74 // if (navResDTO.code == 200) { 78 // if (navResDTO.code == 200) {
@@ -81,7 +85,7 @@ class EditInfoViewModel { @@ -81,7 +85,7 @@ class EditInfoViewModel {
81 // success(this.GetqueryAccountOwnerLocal(context)) 85 // success(this.GetqueryAccountOwnerLocal(context))
82 // 86 //
83 // }) 87 // })
84 - })) 88 + })
85 } 89 }
86 90
87 async getAreaListLocal(context: Context): Promise<AreaListModel[]> { 91 async getAreaListLocal(context: Context): Promise<AreaListModel[]> {
@@ -99,8 +103,32 @@ class EditInfoViewModel { @@ -99,8 +103,32 @@ class EditInfoViewModel {
99 return new AreaListManageModel(item.code,item.id,item.label,item.children) 103 return new AreaListManageModel(item.code,item.id,item.label,item.children)
100 } 104 }
101 105
102 - updateUserInfo(){  
103 - 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 + })
104 } 132 }
105 133
106 } 134 }