Showing
7 changed files
with
92 additions
and
35 deletions
| 1 | import HashMap from '@ohos.util.HashMap' | 1 | import HashMap from '@ohos.util.HashMap' |
| 2 | -import { ConfigConstants } from 'wdConstant' | ||
| 3 | -import { DateTimeUtils, Logger, SPHelper } from 'wdKit' | 2 | +import { ConfigConstants, SpConstants } from 'wdConstant' |
| 3 | +import { DateTimeUtils, Logger, SPHelper, StringUtils } from 'wdKit' | ||
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | * 网络请求业务侧工具类 | 6 | * 网络请求业务侧工具类 |
| @@ -58,10 +58,15 @@ export class HttpUrlUtils { | @@ -58,10 +58,15 @@ export class HttpUrlUtils { | ||
| 58 | */ | 58 | */ |
| 59 | static readonly APPOINTMENT_LIST_DATA_PATH: string = "/api/live-center-message/zh/c/live/subscribe"; | 59 | static readonly APPOINTMENT_LIST_DATA_PATH: string = "/api/live-center-message/zh/c/live/subscribe"; |
| 60 | /** | 60 | /** |
| 61 | - * 资料编辑 获取用户信息 | 61 | + * 资料编辑 特殊用户信息 |
| 62 | */ | 62 | */ |
| 63 | static readonly APPOINTMENT_AccountOwner_PATH: string = "/api/rmrb-contact/contact/zh/c/my/detail"; | 63 | static readonly APPOINTMENT_AccountOwner_PATH: string = "/api/rmrb-contact/contact/zh/c/my/detail"; |
| 64 | /** | 64 | /** |
| 65 | + * 资料编辑 普通用户信息 | ||
| 66 | + */ | ||
| 67 | + static readonly APPOINTMENT_QueryUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/queryUserDetail"; | ||
| 68 | + /** | ||
| 69 | + /** | ||
| 65 | * 个人中心 关注列表详情 | 70 | * 个人中心 关注列表详情 |
| 66 | */ | 71 | */ |
| 67 | static readonly FOLLOW_LIST_DETAIL_DATA_PATH: string = "/api/rmrb-creator-user/c/creatorDirectory/getContactMasterDetaiPage"; | 72 | static readonly FOLLOW_LIST_DETAIL_DATA_PATH: string = "/api/rmrb-creator-user/c/creatorDirectory/getContactMasterDetaiPage"; |
| @@ -258,10 +263,14 @@ export class HttpUrlUtils { | @@ -258,10 +263,14 @@ export class HttpUrlUtils { | ||
| 258 | 263 | ||
| 259 | private static getUserId() { | 264 | private static getUserId() { |
| 260 | // TODO 对接登录 | 265 | // TODO 对接登录 |
| 261 | - return HttpUrlUtils.userId; | 266 | + // let userid = await SPHelper.default.get(SpConstants.USER_ID,"") |
| 267 | + // if(StringUtils.isNotEmpty(userid)) { | ||
| 268 | + // return userid as string; | ||
| 269 | + // } | ||
| 270 | + return HttpUrlUtils.userId; | ||
| 262 | } | 271 | } |
| 263 | 272 | ||
| 264 | - private static getUserType() { | 273 | + private static getUserType() { |
| 265 | return HttpUrlUtils.userType; | 274 | return HttpUrlUtils.userType; |
| 266 | } | 275 | } |
| 267 | 276 |
| @@ -19,7 +19,7 @@ struct BrowsingHistoryPage { | @@ -19,7 +19,7 @@ struct BrowsingHistoryPage { | ||
| 19 | @State private browSingModel: PageModel = new PageModel() | 19 | @State private browSingModel: PageModel = new PageModel() |
| 20 | 20 | ||
| 21 | aboutToAppear(){ | 21 | aboutToAppear(){ |
| 22 | - // this.getData() | 22 | + this.getData() |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | build() { | 25 | build() { |
| 1 | import router from '@ohos.router'; | 1 | import router from '@ohos.router'; |
| 2 | import { CustomTitleUI } from '../reusable/CustomTitleUI'; | 2 | import { CustomTitleUI } from '../reusable/CustomTitleUI'; |
| 3 | -import { EditInfoModel, EditListInfo } from '../../model/EditInfoModel'; | 3 | +import { EditInfoModel, EditListInfo, editModel } 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 | 6 | ||
| @@ -9,10 +9,10 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter'; | @@ -9,10 +9,10 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter'; | ||
| 9 | @Component | 9 | @Component |
| 10 | struct EditUserInfoPage { | 10 | struct EditUserInfoPage { |
| 11 | private listData: EditListInfo[] = [] | 11 | private listData: EditListInfo[] = [] |
| 12 | - editInfo: EditInfoModel = new EditInfoModel('','待完善','待完善','待完善','待完善','待完善','待完善') | 12 | + editM: editModel = new editModel |
| 13 | 13 | ||
| 14 | aboutToAppear() { | 14 | aboutToAppear() { |
| 15 | - this.listData = EditInfoViewModel.getEditListInfo(this.editInfo) | 15 | + this.listData = EditInfoViewModel.getEditListInfo(this.editM) |
| 16 | this.getAccountOwnerInfo() | 16 | this.getAccountOwnerInfo() |
| 17 | } | 17 | } |
| 18 | 18 | ||
| @@ -20,7 +20,7 @@ struct EditUserInfoPage { | @@ -20,7 +20,7 @@ struct EditUserInfoPage { | ||
| 20 | Row() { | 20 | Row() { |
| 21 | Column() { | 21 | Column() { |
| 22 | CustomTitleUI({titleName:'资料编辑'}) | 22 | CustomTitleUI({titleName:'资料编辑'}) |
| 23 | - Image(this.editInfo.headPhotoUrl?this.editInfo.headPhotoUrl:'') | 23 | + Image(this.editM.userExtend.headPhotoUrl?this.editM.userExtend.headPhotoUrl:'') |
| 24 | .backgroundColor(Color.Gray) | 24 | .backgroundColor(Color.Gray) |
| 25 | .width(100) | 25 | .width(100) |
| 26 | .height(100) | 26 | .height(100) |
| @@ -110,8 +110,8 @@ struct EditUserInfoPage { | @@ -110,8 +110,8 @@ struct EditUserInfoPage { | ||
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | getAccountOwnerInfo(){ | 112 | getAccountOwnerInfo(){ |
| 113 | - EditInfoViewModel.queryAccountOwnerInfo(1).then((result) => { | ||
| 114 | - this.editInfo = result | 113 | + EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((result) => { |
| 114 | + this.editM = result | ||
| 115 | }); | 115 | }); |
| 116 | } | 116 | } |
| 117 | 117 |
| @@ -11,11 +11,9 @@ export class EditListInfo{ | @@ -11,11 +11,9 @@ export class EditListInfo{ | ||
| 11 | } | 11 | } |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | -export class EditInfoModel{ | 14 | +export class EditInfoModel{ |
| 15 | //头像 | 15 | //头像 |
| 16 | headPhotoUrl:string = '' | 16 | headPhotoUrl:string = '' |
| 17 | - //昵称 | ||
| 18 | - userName:string = '' | ||
| 19 | //简介 | 17 | //简介 |
| 20 | introduction:string = '' | 18 | introduction:string = '' |
| 21 | //城市 | 19 | //城市 |
| @@ -26,15 +24,16 @@ export class EditInfoModel{ | @@ -26,15 +24,16 @@ export class EditInfoModel{ | ||
| 26 | birthday:string = '' | 24 | birthday:string = '' |
| 27 | //性别 | 25 | //性别 |
| 28 | sex:string = '' | 26 | sex:string = '' |
| 27 | +} | ||
| 29 | 28 | ||
| 30 | - constructor(headPhotoUrl:string , userName:string , introduction:string , city:string , county:string, birthday:string , sex:string) { | ||
| 31 | - this.headPhotoUrl = headPhotoUrl; | ||
| 32 | - this.userName = userName; | ||
| 33 | - this.introduction = introduction; | ||
| 34 | - this.city = city; | ||
| 35 | - this.county = county; | ||
| 36 | - this.birthday = birthday; | ||
| 37 | - this.sex = sex; | ||
| 38 | - } | 29 | +export class editModel{ |
| 30 | + userName:string = '' | ||
| 31 | + | ||
| 32 | + userNameStatus:string = '' | ||
| 33 | + | ||
| 34 | + phone:string = '' | ||
| 35 | + | ||
| 36 | + headPhotoStatus:string = '' | ||
| 39 | 37 | ||
| 38 | + userExtend:EditInfoModel | ||
| 40 | } | 39 | } |
| 1 | 1 | ||
| 2 | -import { EditInfoModel, EditListInfo } from '../model/EditInfoModel'; | 2 | +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 | 6 | ||
| 7 | +const TAG = "EditInfoViewModel" | ||
| 6 | 8 | ||
| 7 | class EditInfoViewModel { | 9 | class EditInfoViewModel { |
| 8 | private static instance: EditInfoViewModel; | 10 | private static instance: EditInfoViewModel; |
| @@ -20,30 +22,48 @@ class EditInfoViewModel { | @@ -20,30 +22,48 @@ class EditInfoViewModel { | ||
| 20 | 22 | ||
| 21 | BaseGetRequest(requestUrl:string){ | 23 | BaseGetRequest(requestUrl:string){ |
| 22 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders() | 24 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders() |
| 25 | + requestUrl = HttpUrlUtils.HOST_SIT + requestUrl | ||
| 23 | return WDHttp.get<ResponseDTO>(requestUrl,headers) | 26 | return WDHttp.get<ResponseDTO>(requestUrl,headers) |
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | 29 | ||
| 27 | - getEditListInfo(item:EditInfoModel):EditListInfo[]{ | 30 | + getEditListInfo(item:editModel):EditListInfo[]{ |
| 28 | this.editListData = [ | 31 | this.editListData = [ |
| 29 | new EditListInfo('昵称',item&&item.userName?item.userName:'待完善'), | 32 | new EditListInfo('昵称',item&&item.userName?item.userName:'待完善'), |
| 30 | - new EditListInfo('简介',item&&item.introduction?item.introduction:'待完善'), | ||
| 31 | - new EditListInfo('地区',item&&item.city?item.city:'待完善'), | ||
| 32 | - new EditListInfo('生日',item&&item.birthday?item.birthday:'待完善'), | ||
| 33 | - new EditListInfo('性别',item&&item.sex?item.sex:'待完善'),] | 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:'待完善'),] | ||
| 34 | return this.editListData | 37 | return this.editListData |
| 35 | } | 38 | } |
| 36 | 39 | ||
| 37 | - queryAccountOwnerInfo(userType:number):PromiseLike<EditInfoModel>{ | 40 | + ///1普通用户 |
| 41 | + queryAccountOwnerInfo(userType:number, context: Context):PromiseLike<editModel>{ | ||
| 38 | return new Promise(((success, error) => { | 42 | return new Promise(((success, error) => { |
| 39 | - this.BaseGetRequest(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then(navResDTO =>{ | 43 | + this.BaseGetRequest(userType == 1?HttpUrlUtils.APPOINTMENT_QueryUserDetail_PATH:HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{ |
| 40 | if (navResDTO.code == 200) { | 44 | if (navResDTO.code == 200) { |
| 41 | - // success(JSON.parse(navResDTO.data)) | 45 | + // let editM = navResDTO.data as EditInfoModel |
| 46 | + // success(JSON.parse(navResDTO.data) | ||
| 42 | } | 47 | } |
| 43 | - }).catch() | 48 | + }).catch((error: Error) => { |
| 49 | + Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel') | ||
| 50 | + return this.GetqueryAccountOwnerLocal(context) | ||
| 51 | + | ||
| 52 | + }) | ||
| 44 | })) | 53 | })) |
| 45 | } | 54 | } |
| 46 | 55 | ||
| 56 | + async GetqueryAccountOwnerLocal(context: Context): Promise<editModel> { | ||
| 57 | + Logger.info(TAG, `getBottomNavDataMock start`); | ||
| 58 | + let compRes: ResponseDTO<editModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<editModel>>(context,'userInfo.json'); | ||
| 59 | + if (!compRes || !compRes.data) { | ||
| 60 | + Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`); | ||
| 61 | + return {} as editModel | ||
| 62 | + } | ||
| 63 | + Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`); | ||
| 64 | + return compRes.data | ||
| 65 | + } | ||
| 66 | + | ||
| 47 | updateUserInfo(){ | 67 | updateUserInfo(){ |
| 48 | 68 | ||
| 49 | } | 69 | } |
| 1 | +{ | ||
| 2 | + "code": "0", | ||
| 3 | + "data": { | ||
| 4 | + "createTime": "2023-12-15 17:19:47", | ||
| 5 | + "headPhotoStatus": 1, | ||
| 6 | + "id": 490264487281413, | ||
| 7 | + "modifyNumber": 0, | ||
| 8 | + "phone": "153****3615", | ||
| 9 | + "status": 1, | ||
| 10 | + "tenancy": 3, | ||
| 11 | + "userExtend": { | ||
| 12 | + "airec": 1, | ||
| 13 | + "birthday": "1991-08-13", | ||
| 14 | + "deviceId": "20065BDF-0E7C-4891-9F4A-85DA50A61F00", | ||
| 15 | + "headBucketName": "", | ||
| 16 | + "headPhotoUrl": "https://uatjdcdnphoto.aikan.pdnews.cn//zhbj/img/user/2024032614/900B80F379D94269AFF29AE815D25422.jpg", | ||
| 17 | + "introduction": "唱、跳、rap", | ||
| 18 | + "lastLoginTime": "2024-03-26 11:05:03", | ||
| 19 | + "city": "安徽省 合肥市", | ||
| 20 | + "sex": 1 | ||
| 21 | + }, | ||
| 22 | + "userName": "芒果", | ||
| 23 | + "userNameStatus": 1, | ||
| 24 | + "userType": 1 | ||
| 25 | + }, | ||
| 26 | + "message": "Success", | ||
| 27 | + "success": true, | ||
| 28 | + "timestamp": 1711434743663 | ||
| 29 | +} |
-
Please register or login to post a comment