网络请求封装
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { hdHttp, HdResponse,BasicConstant,ExpertData, authStore, ChangeUtil } from '@itcast/basic'
|
||||
import { hdHttp, HdResponse,BasicConstant,ExpertData, authStore, ChangeUtil,hdHttps } from '@itcast/basic'
|
||||
import HashMap from '@ohos.util.HashMap'
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { promptAction, router } from '@kit.ArkUI'
|
||||
@@ -43,6 +43,8 @@ interface UploadAvatarResponse {
|
||||
|
||||
@Component
|
||||
export struct EditUserDataComp {
|
||||
@Prop @Watch('pageShow') refreshStatus:boolean = false;
|
||||
|
||||
@State photoPath:string = BasicConstant.urlImage+authStore.getUser().photo;
|
||||
@State name:string = authStore.getUser().realName;
|
||||
@State sex:string = authStore.getUser().sex == 0 ? '男' : '女';
|
||||
@@ -75,10 +77,16 @@ export struct EditUserDataComp {
|
||||
this.initPositionPickerDialog();
|
||||
this.initCerficatePhotoDialog();
|
||||
this.initDiseaseSheetDIalog();
|
||||
this.uploadUserDataAction();
|
||||
// this.uploadUserDataAction();
|
||||
console.log('用户资料:'+authStore.getUser().specialy);
|
||||
}
|
||||
|
||||
pageShow() {
|
||||
if (this.refreshStatus) {
|
||||
this.uploadUserDataAction();
|
||||
}
|
||||
}
|
||||
|
||||
// 添加public修饰符暴露方法
|
||||
public refreshData() {
|
||||
this.uploadUserDataAction();
|
||||
@@ -93,13 +101,25 @@ export struct EditUserDataComp {
|
||||
if(json.code == 1 && json.expert && typeof json.expert === 'object') {
|
||||
authStore.updateUser(json.expert)
|
||||
this.arrToStringSpecialy(json.specialy);
|
||||
console.log('用户信息成功:', authStore.getUser().intro);
|
||||
this.photoPath = authStore.getUser().photo;
|
||||
this.name = authStore.getUser().realName;
|
||||
this.sex = authStore.getUser().sex == 0 ? '男' : '女';
|
||||
this.birthday = authStore.getUser().birthDate;
|
||||
this.phone = authStore.getUser().mobile;
|
||||
this.email = authStore.getUser().email;
|
||||
this.hospatilName = authStore.getUser().hospitalName;
|
||||
this.officeName = authStore.getUser().officeName;
|
||||
this.officePhone = authStore.getUser().officePhone;
|
||||
this.positionName = authStore.getUser().positionName;
|
||||
this.certificate = authStore.getUser().certificate;
|
||||
this.certificatePhoto = BasicConstant.urlImage+authStore.getUser().certificateImg;
|
||||
this.intro = authStore.getUser().intro;
|
||||
} else {
|
||||
console.error('用户信息失败:'+json.message)
|
||||
promptAction.showToast({ message: json.message, duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.info(`Response login fail222222222222222: ${err}`);
|
||||
console.info(`Response fails: ${err}`);
|
||||
})
|
||||
}
|
||||
|
||||
@@ -162,25 +182,34 @@ export struct EditUserDataComp {
|
||||
controller:this.officePickerDialog,
|
||||
officeSelected: (name:string , uuid:string) => {
|
||||
this.officeName = name;
|
||||
hdHttp.post<string>(this.updateDataUrl, {
|
||||
uuid: authStore.getUser().uuid,
|
||||
userName: authStore.getUser().userName,
|
||||
officeName: name,
|
||||
officeUuid:uuid,
|
||||
type:'2'
|
||||
} as updateExtraData).then(async (res: HdResponse<string>) => {
|
||||
let json:callBackData = JSON.parse(res+'') as callBackData;
|
||||
if(json.code == 1 && json.data && typeof json.data === 'object') {
|
||||
authStore.updateUser(json.data)
|
||||
this.arrToStringSpecialy(json.special);
|
||||
console.log('更新用户信息科室成功:', authStore.getUser().intro);
|
||||
} else {
|
||||
console.error('更新用户信息科室失败:'+json.message)
|
||||
promptAction.showToast({ message: json.message, duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.info(`更新用户信息职称科室失败: ${err}`);
|
||||
})
|
||||
hdHttps.post<null>(this.updateDataUrl, {
|
||||
officeName: name,
|
||||
officeUuid:uuid,
|
||||
type:'2',
|
||||
userName: authStore.getUser().userName,
|
||||
uuid: authStore.getUser().uuid,
|
||||
} as updateExtraData).then(res => {
|
||||
let json:callBackData = JSON.parse(res+'') as callBackData;
|
||||
})
|
||||
// hdHttp.post<string>(this.updateDataUrl, {
|
||||
// uuid: authStore.getUser().uuid,
|
||||
// userName: authStore.getUser().userName,
|
||||
// officeName: name,
|
||||
// officeUuid:uuid,
|
||||
// type:'2'
|
||||
// } as updateExtraData).then(async (res: HdResponse<string>) => {
|
||||
// let json:callBackData = JSON.parse(res+'') as callBackData;
|
||||
// if(json.code == 1 && json.data && typeof json.data === 'object') {
|
||||
// authStore.updateUser(json.data)
|
||||
// this.arrToStringSpecialy(json.special);
|
||||
// console.log('更新用户信息科室成功:', authStore.getUser().intro);
|
||||
// } else {
|
||||
// console.error('更新用户信息科室失败:'+json.message)
|
||||
// promptAction.showToast({ message: json.message, duration: 1000 })
|
||||
// }
|
||||
// }).catch((err: BusinessError) => {
|
||||
// console.info(`更新用户信息职称科室失败: ${err}`);
|
||||
// })
|
||||
}
|
||||
}),
|
||||
alignment: DialogAlignment.Bottom,
|
||||
|
||||
Reference in New Issue
Block a user