Showing
9 changed files
with
312 additions
and
17 deletions
| 1 | -import router from '@ohos.router'; | 1 | + |
| 2 | import { CustomTitleUI } from '../reusable/CustomTitleUI'; | 2 | import { CustomTitleUI } from '../reusable/CustomTitleUI'; |
| 3 | -import { EditInfoModel, EditListInfo, editModel } from '../../model/EditInfoModel'; | 3 | +import { EditListInfo } 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' | ||
| 7 | +import { AreaListModel } from '../../model/AreaListModel'; | ||
| 6 | 8 | ||
| 7 | 9 | ||
| 8 | @Entry | 10 | @Entry |
| 9 | @Component | 11 | @Component |
| 10 | struct EditUserInfoPage { | 12 | struct EditUserInfoPage { |
| 11 | - private listData: EditListInfo[] = [] | ||
| 12 | - // editM: editModel | 13 | + @State listData: EditListInfo[] = [] |
| 14 | + @State headerImg: string = '' | ||
| 15 | + @State dataSource: AreaListModel[] = [] | ||
| 16 | + | ||
| 17 | + dialogController: CustomDialogController = new CustomDialogController({ | ||
| 18 | + builder: AreaPickerDialog({dataSource:this.dataSource}), | ||
| 19 | + alignment: DialogAlignment.Bottom, | ||
| 20 | + offset:{dx:0,dy:-20} | ||
| 21 | + }) | ||
| 13 | 22 | ||
| 14 | aboutToAppear() { | 23 | aboutToAppear() { |
| 15 | - // this.listData = EditInfoViewModel.getEditListInfo(this.editM) | 24 | + // this.listData = EditInfoViewModel.getEditListInfo() |
| 16 | this.getAccountOwnerInfo() | 25 | this.getAccountOwnerInfo() |
| 26 | + this.getAreaList() | ||
| 17 | } | 27 | } |
| 18 | 28 | ||
| 19 | build() { | 29 | build() { |
| 20 | Row() { | 30 | Row() { |
| 21 | Column() { | 31 | Column() { |
| 22 | CustomTitleUI({titleName:'资料编辑'}) | 32 | CustomTitleUI({titleName:'资料编辑'}) |
| 23 | - Image('') | 33 | + Image(this.headerImg) |
| 34 | + .alt($r('app.media.default_head')) | ||
| 24 | .backgroundColor(Color.Gray) | 35 | .backgroundColor(Color.Gray) |
| 25 | .width(100) | 36 | .width(100) |
| 26 | .height(100) | 37 | .height(100) |
| @@ -87,6 +98,8 @@ struct EditUserInfoPage { | @@ -87,6 +98,8 @@ struct EditUserInfoPage { | ||
| 87 | // url:'pages/EditUserInstoductionPage', | 98 | // url:'pages/EditUserInstoductionPage', |
| 88 | // params:{pageNum:i} | 99 | // params:{pageNum:i} |
| 89 | // }) | 100 | // }) |
| 101 | + }else if (i === 3){ | ||
| 102 | + this.dialogController.open() | ||
| 90 | } else if (i === 4) { | 103 | } else if (i === 4) { |
| 91 | DatePickerDialog.show({ | 104 | DatePickerDialog.show({ |
| 92 | start:new Date('1900-1-1'), | 105 | start:new Date('1900-1-1'), |
| @@ -110,9 +123,15 @@ struct EditUserInfoPage { | @@ -110,9 +123,15 @@ struct EditUserInfoPage { | ||
| 110 | } | 123 | } |
| 111 | 124 | ||
| 112 | getAccountOwnerInfo(){ | 125 | getAccountOwnerInfo(){ |
| 113 | - EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((result) => { | ||
| 114 | - // this.editM = result | 126 | + EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((editModel) => { |
| 127 | + this.headerImg = editModel.userExtend.headPhotoUrl | ||
| 128 | + this.listData.push(...EditInfoViewModel.getEditListInfo(editModel)) | ||
| 115 | }); | 129 | }); |
| 116 | } | 130 | } |
| 117 | 131 | ||
| 132 | + getAreaList(){ | ||
| 133 | + EditInfoViewModel.getAreaList(getContext(this)).then((value) =>{ | ||
| 134 | + this.dataSource.push(...value) | ||
| 135 | + }) | ||
| 136 | + } | ||
| 118 | } | 137 | } |
| 1 | +import { AreaListManageModel, AreaListModel } from '../../../model/AreaListModel'; | ||
| 2 | +import EditInfoViewModel from '../../../viewmodel/EditInfoViewModel'; | ||
| 3 | +import { FirstLevelComponent } from './FirstLevelComponent'; | ||
| 4 | +import { SecondLevelComponent } from './SecondLevelComponent'; | ||
| 5 | +import { ThirdLevelComponent } from './ThirdLevelComponent'; | ||
| 6 | +@CustomDialog | ||
| 7 | +export struct AreaPickerDialog { | ||
| 8 | + @Provide currentFirst: AreaListManageModel = new AreaListManageModel('','','',[]) | ||
| 9 | + @Provide currentSecondBean: AreaListManageModel = new AreaListManageModel('','','',[]) | ||
| 10 | + @Provide currentThirdBean: AreaListManageModel = new AreaListManageModel('','','',[]) | ||
| 11 | + controller: CustomDialogController | ||
| 12 | + title: string = '地区选择' | ||
| 13 | + @Provide dataSource: AreaListModel[] = [] | ||
| 14 | + result: JSON[] = []; | ||
| 15 | + | ||
| 16 | + aboutToAppear(){ | ||
| 17 | + this.currentFirst = EditInfoViewModel.getAreaListManageModel(this.dataSource[0]) | ||
| 18 | + this.currentSecondBean = EditInfoViewModel.getAreaListManageModel(this.dataSource[0].children[0]) | ||
| 19 | + this.currentThirdBean = EditInfoViewModel.getAreaListManageModel(this.dataSource[0].children[0].children[0]) | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + build() { | ||
| 23 | + Column(){ | ||
| 24 | + Row(){ | ||
| 25 | + Button('取消',{type:ButtonType.Normal}) | ||
| 26 | + .onClick(()=> { | ||
| 27 | + this.controller.close() | ||
| 28 | + }) | ||
| 29 | + .backgroundColor(0xffffff) | ||
| 30 | + .fontColor(Color.Black) | ||
| 31 | + .layoutWeight(1) | ||
| 32 | + | ||
| 33 | + Blank() | ||
| 34 | + | ||
| 35 | + Text(this.title) | ||
| 36 | + .fontSize(18).textAlign(TextAlign.Center).margin({top:10,bottom:10}) | ||
| 37 | + | ||
| 38 | + Blank() | ||
| 39 | + | ||
| 40 | + Button('确定',{type:ButtonType.Normal}) | ||
| 41 | + .onClick(()=> { | ||
| 42 | + | ||
| 43 | + }) | ||
| 44 | + .backgroundColor(0xffffff) | ||
| 45 | + .fontColor(Color.Blue) | ||
| 46 | + .layoutWeight(1) | ||
| 47 | + } | ||
| 48 | + .margin({top:0,bottom:10}) | ||
| 49 | + | ||
| 50 | + Row(){ | ||
| 51 | + FirstLevelComponent().width('30%') | ||
| 52 | + SecondLevelComponent().width('30%') | ||
| 53 | + ThirdLevelComponent().width('30%') | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + .height('40%') | ||
| 57 | + | ||
| 58 | + } | ||
| 59 | +} |
| 1 | +import { AreaListManageModel, AreaListModel } from '../../../model/AreaListModel'; | ||
| 2 | +import EditInfoViewModel from '../../../viewmodel/EditInfoViewModel'; | ||
| 3 | +@Component | ||
| 4 | +export struct FirstLevelComponent { | ||
| 5 | + @State labelList :string[] = []; | ||
| 6 | + @State select: number = 0; | ||
| 7 | + @Consume currentFirst: AreaListManageModel | ||
| 8 | + @Consume dataSource: AreaListModel[] | ||
| 9 | + | ||
| 10 | + aboutToAppear(){ | ||
| 11 | + for (let index = 0; index < this.dataSource.length; index++) { | ||
| 12 | + const element = this.dataSource[index]; | ||
| 13 | + this.labelList.push(element.label) | ||
| 14 | + } | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + build() { | ||
| 18 | + Column(){ | ||
| 19 | + Column(){ | ||
| 20 | + if (this.labelList.length === 0){ | ||
| 21 | + Text('暂无数据').fontSize(20) | ||
| 22 | + }else { | ||
| 23 | + TextPicker({range:this.labelList,selected:this.select}) | ||
| 24 | + // .onChange((value:string,index:number) => { | ||
| 25 | + // this.select = index | ||
| 26 | + // this.currentFirst = EditInfoViewModel.getAreaListManageModel(this.dataSource[index]) | ||
| 27 | + // }) | ||
| 28 | + .backgroundColor(Color.White) | ||
| 29 | + .border({color:'#e2e2e2',width:{right:0.5}}) | ||
| 30 | + .width('100%') | ||
| 31 | + .layoutWeight(1) | ||
| 32 | + } | ||
| 33 | + } | ||
| 34 | + .justifyContent(FlexAlign.Center) | ||
| 35 | + } | ||
| 36 | + .height('100%') | ||
| 37 | + | ||
| 38 | + } | ||
| 39 | +} |
| 1 | +import { AreaListManageModel, AreaListModel } from '../../../model/AreaListModel'; | ||
| 2 | + | ||
| 3 | +@Component | ||
| 4 | +export struct SecondLevelComponent { | ||
| 5 | + @State mTip: string = '暂无数据' | ||
| 6 | + @State labelList: string[] = []; | ||
| 7 | + @State select: number = 0; | ||
| 8 | + @Consume @Watch('onFirstChange') currentFirst: AreaListManageModel; | ||
| 9 | + @Consume currentSecondBean: AreaListManageModel | ||
| 10 | + | ||
| 11 | + aboutToAppear(){ | ||
| 12 | + for (let index = 0; index < this.currentFirst.children.length; index++) { | ||
| 13 | + const element = this.currentFirst.children[index]; | ||
| 14 | + this.labelList.push(element.label) | ||
| 15 | + } | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + build() { | ||
| 19 | + Column(){ | ||
| 20 | + Column(){ | ||
| 21 | + if (this.labelList.length === 0){ | ||
| 22 | + Text(this.mTip).fontSize(20) | ||
| 23 | + }else { | ||
| 24 | + TextPicker({range:this.labelList,selected:this.select}) | ||
| 25 | + // .onChange((value:string,index:number) => { | ||
| 26 | + // this.select = index | ||
| 27 | + // this.currentSecondBean = this.currentFirst.children[index] | ||
| 28 | + // }) | ||
| 29 | + .backgroundColor(Color.White) | ||
| 30 | + .border({color:'#e2e2e2',width:{right:0.5}}) | ||
| 31 | + .width('100%') | ||
| 32 | + .layoutWeight(1) | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + .justifyContent(FlexAlign.Center) | ||
| 36 | + } | ||
| 37 | + .height('100%') | ||
| 38 | + | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + onFirstChange(){ | ||
| 42 | + if (!this.currentFirst) { | ||
| 43 | + this.mTip = '暂无数据'; | ||
| 44 | + } else { | ||
| 45 | + this.labelList = [] | ||
| 46 | + for (let index = 0; index < this.currentFirst.children.length; index++) { | ||
| 47 | + const element = this.currentFirst.children[index]; | ||
| 48 | + this.labelList.push(element.label) | ||
| 49 | + } | ||
| 50 | + // this.currentSecondBean = this.currentFirst.children[this.select] | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | +} |
| 1 | +import { AreaListManageModel, AreaListModel } from '../../../model/AreaListModel'; | ||
| 2 | + | ||
| 3 | +@Component | ||
| 4 | +export struct ThirdLevelComponent { | ||
| 5 | + @State mTip: string = '暂无数据' | ||
| 6 | + @State labelList: string[] = []; | ||
| 7 | + @State select: number = 0; | ||
| 8 | + @Consume @Watch('onFirstChange') currentFirst: AreaListManageModel; | ||
| 9 | + @Consume @Watch('onSecondChange') currentSecondBean: AreaListManageModel; | ||
| 10 | + @Consume currentThirdBean: AreaListManageModel | ||
| 11 | + | ||
| 12 | + aboutToAppear(){ | ||
| 13 | + for (let index = 0; index < this.currentSecondBean.children.length; index++) { | ||
| 14 | + const element = this.currentSecondBean.children[index]; | ||
| 15 | + this.labelList.push(element.label) | ||
| 16 | + } | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + build() { | ||
| 20 | + Column(){ | ||
| 21 | + Column(){ | ||
| 22 | + if (this.labelList.length === 0){ | ||
| 23 | + Text(this.mTip).fontSize(20) | ||
| 24 | + }else { | ||
| 25 | + TextPicker({range:this.labelList,selected:this.select}) | ||
| 26 | + // .onChange((value:string,index:number) => { | ||
| 27 | + // this.select = index | ||
| 28 | + // this.currentThirdBean = this.currentSecondBean.children[index] | ||
| 29 | + // }) | ||
| 30 | + .backgroundColor(Color.White) | ||
| 31 | + .border({color:'#e2e2e2',width:{right:0.5}}) | ||
| 32 | + .width('100%') | ||
| 33 | + .layoutWeight(1) | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + .justifyContent(FlexAlign.Center) | ||
| 37 | + } | ||
| 38 | + .height('100%') | ||
| 39 | + | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + onFirstChange(){ | ||
| 43 | + | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + onSecondChange(){ | ||
| 47 | + if (!this.currentSecondBean) { | ||
| 48 | + this.mTip = '暂无数据'; | ||
| 49 | + } else { | ||
| 50 | + this.labelList = [] | ||
| 51 | + for (let index = 0; index < this.currentSecondBean.children.length; index++) { | ||
| 52 | + const element = this.currentSecondBean.children[index]; | ||
| 53 | + this.labelList.push(element.label) | ||
| 54 | + } | ||
| 55 | + // this.currentThirdBean = this.currentSecondBean.children[this.select] | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | +} |
| 1 | + | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +export interface AreaListModel{ | ||
| 5 | + | ||
| 6 | + code: string | ||
| 7 | + | ||
| 8 | + id: string | ||
| 9 | + | ||
| 10 | + label: string | ||
| 11 | + | ||
| 12 | + children: AreaListModel[] | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +export class AreaListManageModel{ | ||
| 18 | + | ||
| 19 | + code: string = '' | ||
| 20 | + | ||
| 21 | + id: string = '' | ||
| 22 | + | ||
| 23 | + label: string = '' | ||
| 24 | + | ||
| 25 | + children: AreaListModel[] = [] | ||
| 26 | + | ||
| 27 | + constructor(code:string , id:string,label:string, children:AreaListModel[]) { | ||
| 28 | + this.code = code; | ||
| 29 | + this.id = id | ||
| 30 | + this.label = label; | ||
| 31 | + this.children = children | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | +} |
| @@ -3,6 +3,7 @@ import { EditInfoModel, EditListInfo, editModel } from '../model/EditInfoModel'; | @@ -3,6 +3,7 @@ import { EditInfoModel, EditListInfo, editModel } 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'; |
| 6 | +import { AreaListManageModel, AreaListModel } from '../model/AreaListModel'; | ||
| 6 | 7 | ||
| 7 | const TAG = "EditInfoViewModel" | 8 | const TAG = "EditInfoViewModel" |
| 8 | 9 | ||
| @@ -27,13 +28,13 @@ class EditInfoViewModel { | @@ -27,13 +28,13 @@ class EditInfoViewModel { | ||
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | 30 | ||
| 30 | - getEditListInfo(item:editModel):EditListInfo[]{ | 31 | + getEditListInfo(item?:editModel):EditListInfo[]{ |
| 31 | this.editListData = [ | 32 | this.editListData = [ |
| 32 | - // new EditListInfo('昵称',item&&item.userName?item.userName:'待完善'), | ||
| 33 | - // new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'), | ||
| 34 | - // new EditListInfo('地区',item&&item.userExtend.city?item.userExtend.city:'待完善'), | ||
| 35 | - // new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'), | ||
| 36 | - // new EditListInfo('性别',item&&item.userExtend.sex?item.userExtend.sex:'待完善'), | 33 | + new EditListInfo('昵称',item&&item.userName?item.userName:'待完善'), |
| 34 | + new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'), | ||
| 35 | + new EditListInfo('地区',item&&item.userExtend.city?item.userExtend.city:'待完善'), | ||
| 36 | + new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'), | ||
| 37 | + new EditListInfo('性别',item&&item.userExtend.sex?item.userExtend.sex===1?'男':'女':'待完善'), | ||
| 37 | ] | 38 | ] |
| 38 | return this.editListData | 39 | return this.editListData |
| 39 | } | 40 | } |
| @@ -46,10 +47,10 @@ class EditInfoViewModel { | @@ -46,10 +47,10 @@ class EditInfoViewModel { | ||
| 46 | // let editM = navResDTO.data as EditInfoModel | 47 | // let editM = navResDTO.data as EditInfoModel |
| 47 | // success(JSON.parse(navResDTO.data) | 48 | // success(JSON.parse(navResDTO.data) |
| 48 | } | 49 | } |
| 49 | - return this.GetqueryAccountOwnerLocal(context) | 50 | + success(this.GetqueryAccountOwnerLocal(context)) |
| 50 | }).catch((error: Error) => { | 51 | }).catch((error: Error) => { |
| 51 | Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel') | 52 | Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel') |
| 52 | - return this.GetqueryAccountOwnerLocal(context) | 53 | + success(this.GetqueryAccountOwnerLocal(context)) |
| 53 | 54 | ||
| 54 | }) | 55 | }) |
| 55 | })) | 56 | })) |
| @@ -66,6 +67,38 @@ class EditInfoViewModel { | @@ -66,6 +67,38 @@ class EditInfoViewModel { | ||
| 66 | return compRes.data | 67 | return compRes.data |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 70 | + getAreaList(context: Context):PromiseLike<AreaListModel[]>{ | ||
| 71 | + return new Promise(((success, error) => { | ||
| 72 | + success(this.getAreaListLocal(context)) | ||
| 73 | + // this.BaseGetRequest(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{ | ||
| 74 | + // if (navResDTO.code == 200) { | ||
| 75 | + // // let editM = navResDTO.data as EditInfoModel | ||
| 76 | + // // success(JSON.parse(navResDTO.data) | ||
| 77 | + // } | ||
| 78 | + // | ||
| 79 | + // }).catch((error: Error) => { | ||
| 80 | + // Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel') | ||
| 81 | + // success(this.GetqueryAccountOwnerLocal(context)) | ||
| 82 | + // | ||
| 83 | + // }) | ||
| 84 | + })) | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + async getAreaListLocal(context: Context): Promise<AreaListModel[]> { | ||
| 88 | + Logger.info(TAG, `getBottomNavDataMock start`); | ||
| 89 | + let compRes: ResponseDTO<AreaListModel[]> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<AreaListModel[]>>(context,'areaList_data.json'); | ||
| 90 | + if (!compRes || !compRes.data) { | ||
| 91 | + Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`); | ||
| 92 | + return [] as AreaListModel[] | ||
| 93 | + } | ||
| 94 | + Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`); | ||
| 95 | + return compRes.data | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + getAreaListManageModel(item:AreaListModel):AreaListManageModel{ | ||
| 99 | + return new AreaListManageModel(item.code,item.id,item.label,item.children) | ||
| 100 | + } | ||
| 101 | + | ||
| 69 | updateUserInfo(){ | 102 | updateUserInfo(){ |
| 70 | 103 | ||
| 71 | } | 104 | } |
This diff could not be displayed because it is too large.
-
Please register or login to post a comment