sds
This commit is contained in:
parent
b6fb882a7e
commit
240e99a962
@ -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`,
|
||||
|
||||
@ -43,9 +43,7 @@ Page({
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
if(options.scrm_userid){
|
||||
this.scrmBindTag(options.scrm_userid)
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
handelClick(e) {
|
||||
@ -136,14 +134,7 @@ Page({
|
||||
},
|
||||
|
||||
|
||||
// 通过分享页面设置手术时间标签
|
||||
|
||||
scrmBindTag(user_id){
|
||||
request('patient/bind_tag', 'post', {
|
||||
wx_user_id: user_id,
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
})
|
||||
@ -364,37 +384,37 @@ Page({
|
||||
|
||||
//上传文件方法
|
||||
async uploadFileToOSS(file, callback) {
|
||||
|
||||
|
||||
|
||||
const policyData = await request('admin/policy_token', 'post')
|
||||
const res = JSON.parse(policyData.token)
|
||||
|
||||
|
||||
const fileName = file.split('/').pop(); // hello.png
|
||||
// const fileName = fileNameWithExt.split('.').slice(0, -1).join('.'); // hello
|
||||
|
||||
const formData = {
|
||||
key: 'upload_file/' + fileName, //上传文件名称
|
||||
policy: res.policy, //表单域
|
||||
'x-oss-signature-version': res.x_oss_signature_version, //指定签名的版本和算法
|
||||
'x-oss-credential': res.x_oss_credential, //指明派生密钥的参数集
|
||||
'x-oss-date': res.x_oss_date, //请求的时间
|
||||
'x-oss-signature': res.signature, //签名认证描述信息
|
||||
'x-oss-security-token': res.security_token, //安全令牌
|
||||
success_action_status: "200" //上传成功后响应状态码
|
||||
key: 'upload_file/' + fileName, //上传文件名称
|
||||
policy: res.policy, //表单域
|
||||
'x-oss-signature-version': res.x_oss_signature_version, //指定签名的版本和算法
|
||||
'x-oss-credential': res.x_oss_credential, //指明派生密钥的参数集
|
||||
'x-oss-date': res.x_oss_date, //请求的时间
|
||||
'x-oss-signature': res.signature, //签名认证描述信息
|
||||
'x-oss-security-token': res.security_token, //安全令牌
|
||||
success_action_status: "200" //上传成功后响应状态码
|
||||
};
|
||||
// console.log(filePath)
|
||||
// return
|
||||
// 发送请求上传文件
|
||||
wx.uploadFile({
|
||||
url: 'https://image-fudan.oss-cn-beijing.aliyuncs.com/',
|
||||
url: 'https://image-fudan.oss-cn-beijing.aliyuncs.com/',
|
||||
method: 'put',
|
||||
filePath: file,
|
||||
name: 'file', //固定值为file
|
||||
name: 'file', //固定值为file
|
||||
formData: formData,
|
||||
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,13 +423,16 @@ Page({
|
||||
},
|
||||
fail(err) {
|
||||
console.error('上传失败:', err); // 输出错误信息
|
||||
wx.showToast({ title: '上传失败,请重试!', icon: 'none' });
|
||||
wx.showToast({
|
||||
title: '上传失败,请重试!',
|
||||
icon: 'none'
|
||||
});
|
||||
callback(err); // 调用回调处理错误
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
async onSaveInfo() {
|
||||
let obj = this.data.personInfo;
|
||||
@ -428,26 +451,28 @@ 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'){
|
||||
errorStatus.prenatal_check_remark = !obj.prenatal_check_remark;
|
||||
if (obj.delivery_type == '1') {
|
||||
errorStatus.prenatal_check_remark = !obj.prenatal_check_remark;
|
||||
}
|
||||
if (obj.prenatal_check_type == 2) {
|
||||
obj.prenatal_check_remark = '无';
|
||||
errorStatus.prenatal_check_remark = false;
|
||||
}
|
||||
console.log(errorStatus);
|
||||
this.setData({ errorStatus });
|
||||
this.setData({
|
||||
errorStatus
|
||||
});
|
||||
if (Object.values(errorStatus).some(v => v)) {
|
||||
return;
|
||||
}
|
||||
obj.birth_weight = Number(obj.birth_weight);
|
||||
obj.gestational_week = Number(obj.gestational_week);
|
||||
|
||||
|
||||
await request('patient/set_personal_information', 'post', obj);
|
||||
wx.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
duration: 2000,
|
||||
complete: () => {
|
||||
wx.switchTab({
|
||||
url: '/pages/my/index'
|
||||
@ -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);
|
||||
},
|
||||
@ -500,11 +535,11 @@ Page({
|
||||
list
|
||||
} = e.currentTarget.dataset;
|
||||
modeText = mode
|
||||
|
||||
|
||||
// 所有设备都使用相同的处理逻辑,避免层级问题
|
||||
// 先让所有输入框失焦
|
||||
wx.hideKeyboard();
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
this.setData({
|
||||
selectVisible: true,
|
||||
@ -529,7 +564,7 @@ Page({
|
||||
['personInfo.prenatal_check_remark']: e.detail.value,
|
||||
['errorStatus.prenatal_check_remark']: false
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
onPickerCancel() {
|
||||
this.setData({
|
||||
@ -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() {
|
||||
|
||||
},
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user