wangliang_wd

feat:优化个人资料逻辑

import HashMap from '@ohos.util.HashMap'
import { ConfigConstants } from 'wdConstant'
import { DateTimeUtils, Logger, SPHelper } from 'wdKit'
import { ConfigConstants, SpConstants } from 'wdConstant'
import { DateTimeUtils, Logger, SPHelper, StringUtils } from 'wdKit'
/**
* 网络请求业务侧工具类
... ... @@ -58,10 +58,15 @@ export class HttpUrlUtils {
*/
static readonly APPOINTMENT_LIST_DATA_PATH: string = "/api/live-center-message/zh/c/live/subscribe";
/**
* 资料编辑 获取用户信息
* 资料编辑 特殊用户信息
*/
static readonly APPOINTMENT_AccountOwner_PATH: string = "/api/rmrb-contact/contact/zh/c/my/detail";
/**
* 资料编辑 普通用户信息
*/
static readonly APPOINTMENT_QueryUserDetail_PATH: string = "/api/rmrb-user-center/user/zh/c/queryUserDetail";
/**
/**
* 个人中心 关注列表详情
*/
static readonly FOLLOW_LIST_DETAIL_DATA_PATH: string = "/api/rmrb-creator-user/c/creatorDirectory/getContactMasterDetaiPage";
... ... @@ -258,10 +263,14 @@ export class HttpUrlUtils {
private static getUserId() {
// TODO 对接登录
return HttpUrlUtils.userId;
// let userid = await SPHelper.default.get(SpConstants.USER_ID,"")
// if(StringUtils.isNotEmpty(userid)) {
// return userid as string;
// }
return HttpUrlUtils.userId;
}
private static getUserType() {
private static getUserType() {
return HttpUrlUtils.userType;
}
... ...
... ... @@ -19,7 +19,7 @@ struct BrowsingHistoryPage {
@State private browSingModel: PageModel = new PageModel()
aboutToAppear(){
// this.getData()
this.getData()
}
build() {
... ...
import router from '@ohos.router';
import { CustomTitleUI } from '../reusable/CustomTitleUI';
import { EditInfoModel, EditListInfo } from '../../model/EditInfoModel';
import { EditInfoModel, EditListInfo, editModel } from '../../model/EditInfoModel';
import EditInfoViewModel from '../../viewmodel/EditInfoViewModel';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
... ... @@ -9,10 +9,10 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter';
@Component
struct EditUserInfoPage {
private listData: EditListInfo[] = []
editInfo: EditInfoModel = new EditInfoModel('','待完善','待完善','待完善','待完善','待完善','待完善')
editM: editModel = new editModel
aboutToAppear() {
this.listData = EditInfoViewModel.getEditListInfo(this.editInfo)
this.listData = EditInfoViewModel.getEditListInfo(this.editM)
this.getAccountOwnerInfo()
}
... ... @@ -20,7 +20,7 @@ struct EditUserInfoPage {
Row() {
Column() {
CustomTitleUI({titleName:'资料编辑'})
Image(this.editInfo.headPhotoUrl?this.editInfo.headPhotoUrl:'')
Image(this.editM.userExtend.headPhotoUrl?this.editM.userExtend.headPhotoUrl:'')
.backgroundColor(Color.Gray)
.width(100)
.height(100)
... ... @@ -110,8 +110,8 @@ struct EditUserInfoPage {
}
getAccountOwnerInfo(){
EditInfoViewModel.queryAccountOwnerInfo(1).then((result) => {
this.editInfo = result
EditInfoViewModel.queryAccountOwnerInfo(1,getContext(this)).then((result) => {
this.editM = result
});
}
... ...
... ... @@ -19,7 +19,7 @@ struct MyCollectionListPage {
isloading : boolean = false
aboutToAppear(){
// this.getData()
this.getData()
}
build() {
... ...
... ... @@ -11,11 +11,9 @@ export class EditListInfo{
}
}
export class EditInfoModel{
export class EditInfoModel{
//头像
headPhotoUrl:string = ''
//昵称
userName:string = ''
//简介
introduction:string = ''
//城市
... ... @@ -26,15 +24,16 @@ export class EditInfoModel{
birthday:string = ''
//性别
sex:string = ''
}
constructor(headPhotoUrl:string , userName:string , introduction:string , city:string , county:string, birthday:string , sex:string) {
this.headPhotoUrl = headPhotoUrl;
this.userName = userName;
this.introduction = introduction;
this.city = city;
this.county = county;
this.birthday = birthday;
this.sex = sex;
}
export class editModel{
userName:string = ''
userNameStatus:string = ''
phone:string = ''
headPhotoStatus:string = ''
userExtend:EditInfoModel
}
\ No newline at end of file
... ...
import { EditInfoModel, EditListInfo } from '../model/EditInfoModel';
import { EditInfoModel, EditListInfo, editModel } from '../model/EditInfoModel';
import HashMap from '@ohos.util.HashMap';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { Logger, ResourcesUtils } from 'wdKit';
const TAG = "EditInfoViewModel"
class EditInfoViewModel {
private static instance: EditInfoViewModel;
... ... @@ -20,30 +22,48 @@ class EditInfoViewModel {
BaseGetRequest(requestUrl:string){
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders()
requestUrl = HttpUrlUtils.HOST_SIT + requestUrl
return WDHttp.get<ResponseDTO>(requestUrl,headers)
}
getEditListInfo(item:EditInfoModel):EditListInfo[]{
getEditListInfo(item:editModel):EditListInfo[]{
this.editListData = [
new EditListInfo('昵称',item&&item.userName?item.userName:'待完善'),
new EditListInfo('简介',item&&item.introduction?item.introduction:'待完善'),
new EditListInfo('地区',item&&item.city?item.city:'待完善'),
new EditListInfo('生日',item&&item.birthday?item.birthday:'待完善'),
new EditListInfo('性别',item&&item.sex?item.sex:'待完善'),]
new EditListInfo('简介',item&&item.userExtend.introduction?item.userExtend.introduction:'待完善'),
new EditListInfo('地区',item&&item.userExtend.city?item.userExtend.city:'待完善'),
new EditListInfo('生日',item&&item.userExtend.birthday?item.userExtend.birthday:'待完善'),
new EditListInfo('性别',item&&item.userExtend.sex?item.userExtend.sex:'待完善'),]
return this.editListData
}
queryAccountOwnerInfo(userType:number):PromiseLike<EditInfoModel>{
///1普通用户
queryAccountOwnerInfo(userType:number, context: Context):PromiseLike<editModel>{
return new Promise(((success, error) => {
this.BaseGetRequest(HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then(navResDTO =>{
this.BaseGetRequest(userType == 1?HttpUrlUtils.APPOINTMENT_QueryUserDetail_PATH:HttpUrlUtils.APPOINTMENT_AccountOwner_PATH).then((navResDTO:ResponseDTO) =>{
if (navResDTO.code == 200) {
// success(JSON.parse(navResDTO.data))
// let editM = navResDTO.data as EditInfoModel
// success(JSON.parse(navResDTO.data)
}
}).catch()
}).catch((error: Error) => {
Logger.info('EditInfoViewModel','EditInfoViewModel','EditInfoViewModel')
return this.GetqueryAccountOwnerLocal(context)
})
}))
}
async GetqueryAccountOwnerLocal(context: Context): Promise<editModel> {
Logger.info(TAG, `getBottomNavDataMock start`);
let compRes: ResponseDTO<editModel> | null = await ResourcesUtils.getResourcesJson<ResponseDTO<editModel>>(context,'userInfo.json');
if (!compRes || !compRes.data) {
Logger.info(TAG, `getAppointmentListDataLocal compRes is empty`);
return {} as editModel
}
Logger.info(TAG, `getAppointmentListDataLocal getResourcesJsonSync compRes : ${JSON.stringify(compRes)}`);
return compRes.data
}
updateUserInfo(){
}
... ...
{
"code": "0",
"data": {
"createTime": "2023-12-15 17:19:47",
"headPhotoStatus": 1,
"id": 490264487281413,
"modifyNumber": 0,
"phone": "153****3615",
"status": 1,
"tenancy": 3,
"userExtend": {
"airec": 1,
"birthday": "1991-08-13",
"deviceId": "20065BDF-0E7C-4891-9F4A-85DA50A61F00",
"headBucketName": "",
"headPhotoUrl": "https://uatjdcdnphoto.aikan.pdnews.cn//zhbj/img/user/2024032614/900B80F379D94269AFF29AE815D25422.jpg",
"introduction": "唱、跳、rap",
"lastLoginTime": "2024-03-26 11:05:03",
"city": "安徽省 合肥市",
"sex": 1
},
"userName": "芒果",
"userNameStatus": 1,
"userType": 1
},
"message": "Success",
"success": true,
"timestamp": 1711434743663
}
\ No newline at end of file
... ...