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); await wx.setStorageSync('access_token', res.token);
if (res.is_personal_information_complete) { if (res.is_personal_information_complete) {
wx.switchTab({ wx.navigateBack({
url: `/pages/my/index`, delta: 2
}); });
// wx.switchTab({
// url: `/pages/my/index`,
// });
} else { } else {
wx.navigateTo({ wx.navigateTo({
url: `/pages/my/info-edit/index`, url: `/pages/my/info-edit/index`,

View File

@ -43,9 +43,7 @@ Page({
}, },
onLoad(options) { onLoad(options) {
if(options.scrm_userid){
this.scrmBindTag(options.scrm_userid)
}
}, },
handelClick(e) { 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: '选择日期', timePickerTitle: '选择日期',
}, },
onLoad() { async onLoad(options) {
// this.initAreaData(); // this.getPersonalInfo()
this.getPersonalInfo()
this.setData({ this.setData({
isIOS: wx.getSystemInfoSync().platform === 'ios' isIOS: wx.getSystemInfoSync().platform === 'ios'
}) })
if (options.scrm_userid) {
await wx.setStorageSync('scrm_userid', options.scrm_userid);
}
},
onShow() {
this.getPersonalInfo()
}, },
async getPersonalInfo() { async getPersonalInfo() {
const info = await request('patient/basic/0') 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', 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] timePicker: this.data.personInfo.birthday ? this.data.personInfo.birthday : new Date().toISOString().split('T')[0]
}); });
} else { } else {
if(this.data.personInfo.operative_date){ if (this.data.personInfo.operative_date) {
return; return;
} }
this.setData({ this.setData({
@ -294,16 +302,22 @@ Page({
const value = e.detail.value; const value = e.detail.value;
// Validate name length (2-20) // Validate name length (2-20)
if (value.length < 2 || value.length > 20) { if (value.length < 2 || value.length > 20) {
this.setData({ 'errorStatus.name': true }); this.setData({
'errorStatus.name': true
});
} else if (this.data.errorStatus.name) { } else if (this.data.errorStatus.name) {
this.setData({ 'errorStatus.name': false }); this.setData({
'errorStatus.name': false
});
} }
}, },
onGenderChange(e) { onGenderChange(e) {
this.personInfoFieldChange('sex', e); this.personInfoFieldChange('sex', e);
if (this.data.errorStatus.gender) { if (this.data.errorStatus.gender) {
this.setData({ 'errorStatus.gender': false }); this.setData({
'errorStatus.gender': false
});
} }
}, },
// onYearChange(e) { // onYearChange(e) {
@ -344,15 +358,21 @@ Page({
// }); // });
}, },
userInfoHandler(e){ userInfoHandler(e) {
console.log(e.detail) console.log(e.detail)
this.uploadFileToOSS(e.detail.avatarUrl, (error, data) => { this.uploadFileToOSS(e.detail.avatarUrl, (error, data) => {
if (error) { if (error) {
wx.showToast({ title: '上传失败!', icon: 'none' }); wx.showToast({
title: '上传失败!',
icon: 'none'
});
console.error('上传失败:', error); // 输出具体的错误信息 console.error('上传失败:', error); // 输出具体的错误信息
} else { } else {
wx.showToast({ title: '上传成功!', icon: 'success' }); wx.showToast({
title: '上传成功!',
icon: 'success'
});
this.setData({ this.setData({
'personInfo.avatar': data 'personInfo.avatar': data
}) })
@ -373,14 +393,14 @@ Page({
// const fileName = fileNameWithExt.split('.').slice(0, -1).join('.'); // hello // const fileName = fileNameWithExt.split('.').slice(0, -1).join('.'); // hello
const formData = { const formData = {
key: 'upload_file/' + fileName, //上传文件名称 key: 'upload_file/' + fileName, //上传文件名称
policy: res.policy, //表单域 policy: res.policy, //表单域
'x-oss-signature-version': res.x_oss_signature_version, //指定签名的版本和算法 'x-oss-signature-version': res.x_oss_signature_version, //指定签名的版本和算法
'x-oss-credential': res.x_oss_credential, //指明派生密钥的参数集 'x-oss-credential': res.x_oss_credential, //指明派生密钥的参数集
'x-oss-date': res.x_oss_date, //请求的时间 'x-oss-date': res.x_oss_date, //请求的时间
'x-oss-signature': res.signature, //签名认证描述信息 'x-oss-signature': res.signature, //签名认证描述信息
'x-oss-security-token': res.security_token, //安全令牌 'x-oss-security-token': res.security_token, //安全令牌
success_action_status: "200" //上传成功后响应状态码 success_action_status: "200" //上传成功后响应状态码
}; };
// console.log(filePath) // console.log(filePath)
// return // return
@ -389,12 +409,12 @@ Page({
url: 'https://image-fudan.oss-cn-beijing.aliyuncs.com/', url: 'https://image-fudan.oss-cn-beijing.aliyuncs.com/',
method: 'put', method: 'put',
filePath: file, filePath: file,
name: 'file', //固定值为file name: 'file', //固定值为file
formData: formData, formData: formData,
success(res) { success(res) {
console.log('上传响应:', res); console.log('上传响应:', res);
if (res.statusCode === 200) { 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 { } else {
console.error('上传失败,状态码:', res.statusCode); console.error('上传失败,状态码:', res.statusCode);
console.error('失败响应:', res); console.error('失败响应:', res);
@ -403,7 +423,10 @@ Page({
}, },
fail(err) { fail(err) {
console.error('上传失败:', err); // 输出错误信息 console.error('上传失败:', err); // 输出错误信息
wx.showToast({ title: '上传失败,请重试!', icon: 'none' }); wx.showToast({
title: '上传失败,请重试!',
icon: 'none'
});
callback(err); // 调用回调处理错误 callback(err); // 调用回调处理错误
} }
}); });
@ -428,15 +451,17 @@ Page({
errorStatus.gestational_week = !/^\d+(\.\d+)?$/.test(obj.gestational_week) || Number(obj.gestational_week) <= 0; errorStatus.gestational_week = !/^\d+(\.\d+)?$/.test(obj.gestational_week) || Number(obj.gestational_week) <= 0;
errorStatus.prenatal_check_type = !obj.prenatal_check_type; errorStatus.prenatal_check_type = !obj.prenatal_check_type;
errorStatus.delivery_type = !obj.delivery_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; errorStatus.prenatal_check_remark = !obj.prenatal_check_remark;
} }
if (obj.prenatal_check_type == 2) { if (obj.prenatal_check_type == 2) {
obj.prenatal_check_remark = '无'; obj.prenatal_check_remark = '无';
errorStatus.prenatal_check_remark = false; errorStatus.prenatal_check_remark = false;
} }
console.log(errorStatus); console.log(errorStatus);
this.setData({ errorStatus }); this.setData({
errorStatus
});
if (Object.values(errorStatus).some(v => v)) { if (Object.values(errorStatus).some(v => v)) {
return; return;
} }
@ -460,7 +485,9 @@ Page({
const value = e.detail.value; 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]$/; 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) { if (this.data.errorStatus.id) {
this.setData({ 'errorStatus.id': false }); this.setData({
'errorStatus.id': false
});
} }
this.personInfoFieldChange('id_number', e); this.personInfoFieldChange('id_number', e);
// 如果输入合法身份证号,自动提取出生日期 // 如果输入合法身份证号,自动提取出生日期
@ -478,19 +505,27 @@ Page({
// if (this.data.errorStatus.birth_weight) { // if (this.data.errorStatus.birth_weight) {
// this.setData({ 'errorStatus.birth_weight': false }); // this.setData({ 'errorStatus.birth_weight': false });
// } // }
if(!e.detail.value || e.detail.value == 0){ if (!e.detail.value || e.detail.value == 0) {
this.setData({ 'errorStatus.birth_weight': true }); this.setData({
'errorStatus.birth_weight': true
});
} else { } else {
this.setData({ 'errorStatus.birth_weight': false }); this.setData({
'errorStatus.birth_weight': false
});
} }
this.personInfoFieldChange('birth_weight', e); this.personInfoFieldChange('birth_weight', e);
}, },
onWeekInput(e) { onWeekInput(e) {
console.log(e.detail.value == true) console.log(e.detail.value == true)
if(!e.detail.value || e.detail.value == 0){ if (!e.detail.value || e.detail.value == 0) {
this.setData({ 'errorStatus.gestational_week': true }); this.setData({
'errorStatus.gestational_week': true
});
} else { } else {
this.setData({ 'errorStatus.gestational_week': false }); this.setData({
'errorStatus.gestational_week': false
});
} }
this.personInfoFieldChange('gestational_week', e); this.personInfoFieldChange('gestational_week', e);
}, },
@ -540,4 +575,19 @@ Page({
wx.hideKeyboard(); wx.hideKeyboard();
}, 50) }, 50)
}, },
// 通过分享页面设置手术时间标签
async scrmBindTag(user_id) {
const res = await request('patient/bind_tag', 'post', {
wx_user_id: user_id,
})
await wx.removeStorageSync('scrm_userid');
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
}); });