This commit is contained in:
@zuopngfei 2025-08-01 14:19:38 +08:00
parent b6fb882a7e
commit 240e99a962
3 changed files with 99 additions and 55 deletions

View File

@ -118,9 +118,12 @@ Page({
});
await wx.setStorageSync('access_token', res.token);
if (res.is_personal_information_complete) {
wx.switchTab({
url: `/pages/my/index`,
wx.navigateBack({
delta: 2
});
// wx.switchTab({
// url: `/pages/my/index`,
// });
} else {
wx.navigateTo({
url: `/pages/my/info-edit/index`,

View File

@ -43,9 +43,7 @@ Page({
},
onLoad(options) {
if(options.scrm_userid){
this.scrmBindTag(options.scrm_userid)
}
},
handelClick(e) {
@ -136,13 +134,6 @@ Page({
},
// 通过分享页面设置手术时间标签
scrmBindTag(user_id){
request('patient/bind_tag', 'post', {
wx_user_id: user_id,
})
},

View File

@ -125,12 +125,17 @@ Page({
timePickerTitle: '选择日期',
},
onLoad() {
// this.initAreaData();
this.getPersonalInfo()
async onLoad(options) {
// this.getPersonalInfo()
this.setData({
isIOS: wx.getSystemInfoSync().platform === 'ios'
})
if (options.scrm_userid) {
await wx.setStorageSync('scrm_userid', options.scrm_userid);
}
},
onShow() {
this.getPersonalInfo()
},
async getPersonalInfo() {
const info = await request('patient/basic/0')
@ -153,6 +158,9 @@ Page({
avatar: info.avatar ? info.avatar : 'https://image-fudan.oss-cn-beijing.aliyuncs.com/mini_images/my/baby.png',
}
})
if (wx.getStorageSync('scrm_userid')) {
this.scrmBindTag(wx.getStorageSync('scrm_userid'))
}
},
@ -206,7 +214,7 @@ Page({
timePicker: this.data.personInfo.birthday ? this.data.personInfo.birthday : new Date().toISOString().split('T')[0]
});
} else {
if(this.data.personInfo.operative_date){
if (this.data.personInfo.operative_date) {
return;
}
this.setData({
@ -294,16 +302,22 @@ Page({
const value = e.detail.value;
// Validate name length (2-20)
if (value.length < 2 || value.length > 20) {
this.setData({ 'errorStatus.name': true });
this.setData({
'errorStatus.name': true
});
} else if (this.data.errorStatus.name) {
this.setData({ 'errorStatus.name': false });
this.setData({
'errorStatus.name': false
});
}
},
onGenderChange(e) {
this.personInfoFieldChange('sex', e);
if (this.data.errorStatus.gender) {
this.setData({ 'errorStatus.gender': false });
this.setData({
'errorStatus.gender': false
});
}
},
// onYearChange(e) {
@ -344,15 +358,21 @@ Page({
// });
},
userInfoHandler(e){
userInfoHandler(e) {
console.log(e.detail)
this.uploadFileToOSS(e.detail.avatarUrl, (error, data) => {
if (error) {
wx.showToast({ title: '上传失败!', icon: 'none' });
wx.showToast({
title: '上传失败!',
icon: 'none'
});
console.error('上传失败:', error); // 输出具体的错误信息
} else {
wx.showToast({ title: '上传成功!', icon: 'success' });
wx.showToast({
title: '上传成功!',
icon: 'success'
});
this.setData({
'personInfo.avatar': data
})
@ -394,7 +414,7 @@ Page({
success(res) {
console.log('上传响应:', res);
if (res.statusCode === 200) {
callback(null, 'https://image-fudan.oss-cn-beijing.aliyuncs.com/upload_file/'+ fileName); // 上传成功
callback(null, 'https://image-fudan.oss-cn-beijing.aliyuncs.com/upload_file/' + fileName); // 上传成功
} else {
console.error('上传失败,状态码:', res.statusCode);
console.error('失败响应:', res);
@ -403,7 +423,10 @@ Page({
},
fail(err) {
console.error('上传失败:', err); // 输出错误信息
wx.showToast({ title: '上传失败,请重试!', icon: 'none' });
wx.showToast({
title: '上传失败,请重试!',
icon: 'none'
});
callback(err); // 调用回调处理错误
}
});
@ -428,7 +451,7 @@ Page({
errorStatus.gestational_week = !/^\d+(\.\d+)?$/.test(obj.gestational_week) || Number(obj.gestational_week) <= 0;
errorStatus.prenatal_check_type = !obj.prenatal_check_type;
errorStatus.delivery_type = !obj.delivery_type;
if(obj.delivery_type == '1'){
if (obj.delivery_type == '1') {
errorStatus.prenatal_check_remark = !obj.prenatal_check_remark;
}
if (obj.prenatal_check_type == 2) {
@ -436,7 +459,9 @@ Page({
errorStatus.prenatal_check_remark = false;
}
console.log(errorStatus);
this.setData({ errorStatus });
this.setData({
errorStatus
});
if (Object.values(errorStatus).some(v => v)) {
return;
}
@ -460,7 +485,9 @@ Page({
const value = e.detail.value;
const reg18 = /^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/;
if (this.data.errorStatus.id) {
this.setData({ 'errorStatus.id': false });
this.setData({
'errorStatus.id': false
});
}
this.personInfoFieldChange('id_number', e);
// 如果输入合法身份证号,自动提取出生日期
@ -478,19 +505,27 @@ Page({
// if (this.data.errorStatus.birth_weight) {
// this.setData({ 'errorStatus.birth_weight': false });
// }
if(!e.detail.value || e.detail.value == 0){
this.setData({ 'errorStatus.birth_weight': true });
if (!e.detail.value || e.detail.value == 0) {
this.setData({
'errorStatus.birth_weight': true
});
} else {
this.setData({ 'errorStatus.birth_weight': false });
this.setData({
'errorStatus.birth_weight': false
});
}
this.personInfoFieldChange('birth_weight', e);
},
onWeekInput(e) {
console.log(e.detail.value == true)
if(!e.detail.value || e.detail.value == 0){
this.setData({ 'errorStatus.gestational_week': true });
if (!e.detail.value || e.detail.value == 0) {
this.setData({
'errorStatus.gestational_week': true
});
} else {
this.setData({ 'errorStatus.gestational_week': false });
this.setData({
'errorStatus.gestational_week': false
});
}
this.personInfoFieldChange('gestational_week', e);
},
@ -540,4 +575,19 @@ Page({
wx.hideKeyboard();
}, 50)
},
// 通过分享页面设置手术时间标签
async scrmBindTag(user_id) {
const res = await request('patient/bind_tag', 'post', {
wx_user_id: user_id,
})
await wx.removeStorageSync('scrm_userid');
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
});