This commit is contained in:
左哥 2025-07-10 22:11:05 +08:00
parent 428c0064f8
commit 67229cbd61
10 changed files with 112 additions and 41 deletions

View File

@ -36,6 +36,10 @@ function request(url, method = 'GET', data = {}) {
}
reject(res.data);
}
wx.showToast({
title: res.data.message,
icon: 'none'
});
reject(res.data);
} else {
resolve(res.data);

View File

@ -303,10 +303,11 @@ Page({
const policyData = await request('admin/policy_token', 'post')
const res = JSON.parse(policyData.token)
const fileNameWithExt = file.path.split('/').pop(); // hello.png
const fileName = fileNameWithExt.split('.').slice(0, -1).join('.'); // hello
const formData = {
key: 'upload_file/' + file.name, //上传文件名称
key: 'upload_file/' + fileName, //上传文件名称
policy: res.policy, //表单域
'x-oss-signature-version': res.x_oss_signature_version, //指定签名的版本和算法
'x-oss-credential': res.x_oss_credential, //指明派生密钥的参数集
@ -327,7 +328,7 @@ Page({
success(res) {
console.log('上传响应:', res);
if (res.statusCode === 200) {
callback(null, 'https://image-fudan.oss-cn-beijing.aliyuncs.com/upload_file/'+ file.name); // 上传成功
callback(null, 'https://image-fudan.oss-cn-beijing.aliyuncs.com/upload_file/'+ fileName); // 上传成功
} else {
console.error('上传失败,状态码:', res.statusCode);
console.error('失败响应:', res);
@ -376,7 +377,7 @@ Page({
}
});
},
handleDelete(){
handleDelete(e){
this.setData({
imageFile: ''
});

View File

@ -223,7 +223,7 @@ Page({
data.coagulation_function_image = data.coagulation_function_image.length > 0 ? data.coagulation_function_image.join(',') : '',
data.mdt_image = data.mdt_image.length > 0 ? data.mdt_image.join(',') : '',
data.nutritional_indicator_image = data.nutritional_indicator_image.length > 0 ? data.nutritional_indicator_image.join(',') : ''
await request('patient/follow_questionnaire', 'post',{planId: this.planId, ...data})
await request('patient/follow_questionnaire', 'post',{plan_id: Number(this.planId), ...data})
wx.showToast({
title: '提交成功',
icon: 'success',
@ -248,9 +248,11 @@ Page({
const policyData = await request('admin/policy_token', 'post')
const res = JSON.parse(policyData.token)
const fileNameWithExt = file.path.split('/').pop(); // hello.png
const fileName = fileNameWithExt.split('.').slice(0, -1).join('.'); // hello
const formData = {
key: 'upload_file/' + file.name, //上传文件名称
key: 'upload_file/' + fileName, //上传文件名称
policy: res.policy, //表单域
'x-oss-signature-version': res.x_oss_signature_version, //指定签名的版本和算法
'x-oss-credential': res.x_oss_credential, //指明派生密钥的参数集
@ -271,7 +273,7 @@ Page({
success(res) {
console.log('上传响应:', res);
if (res.statusCode === 200) {
callback(null, 'https://image-fudan.oss-cn-beijing.aliyuncs.com/upload_file/'+ file.name); // 上传成功
callback(null, 'https://image-fudan.oss-cn-beijing.aliyuncs.com/upload_file/'+ fileName); // 上传成功
} else {
console.error('上传失败,状态码:', res.statusCode);
console.error('失败响应:', res);
@ -287,6 +289,11 @@ Page({
},
handleUpload(e) {
const { mode } = e.currentTarget.dataset;
if(this.data.form[mode].length >= 9){
wx.showToast({ title: '最多上传9张图片!', icon: 'none' });
return
}
wx.chooseImage({
count: 1, // 选择一个文件
type: 'all', // 支持所有类型的文件
@ -339,7 +346,7 @@ Page({
imageVisible: false
})
},
handleDelete(){
handleDelete(e){
const { mode, index } = e.currentTarget.dataset;
let arr = this.data.form[mode]
arr.splice(index, 1)
@ -366,10 +373,28 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options)
this.planId = options.planId
this.setData({
['form.follow_name']: options.name,
['form.follow_date']: options.time
})
this.getDetail()
},
async getDetail(){
const res = await request('patient/questionnaire_info', 'post',{patient_id : 0, questionnaire_id: Number(this.planId)})
const data = res.data
data.liver_function_image = data.liver_function_image ? data.liver_function_image.split(',') : []
data.b_mode_image = data.b_mode_image ? data.b_mode_image.split(',') : []
data.blood_routine_image = data.blood_routine_image ? data.blood_routine_image.split(',') : []
data.coagulation_function_image = data.coagulation_function_image ? data.coagulation_function_image.split(',') : []
data.mdt_image = data.mdt_image ? data.mdt_image.split(',') : []
data.nutritional_indicator_image = data.nutritional_indicator_image ? data.nutritional_indicator_image.split(',') : []
this.setData({
form: data
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -46,7 +46,7 @@
</view>
<view class="input-example">
<view class="">头围cm</view>
<view class="input-example__label">头围cm</view>
<t-input placeholder="请输入" bind:change="onInput" value="{{form.head_circumference}}" data-key="head_circumference" borderless="{{true}}" style="{{style}}"
type="digit" />
</view>

View File

@ -23,7 +23,7 @@ Page({
async getCode(){
if (!this.data.phoneNumber) {
wx.showToast({
title: '请输入手机号',
title: '手机号码不能为空',
icon: 'none'
});
return;
@ -31,7 +31,7 @@ Page({
// 验证手机号格式
if (!/^1[3-9]\d{9}$/.test(this.data.phoneNumber)) {
wx.showToast({
title: '请输入正确的手机号',
title: '手机号码格式不正确',
icon: 'none'
});
return;
@ -79,7 +79,7 @@ Page({
// 验证手机号
if (!this.data.phoneNumber) {
wx.showToast({
title: '请输入手机号',
title: '手机号码不能为空',
icon: 'none'
});
return;
@ -87,7 +87,7 @@ Page({
// 验证手机号格式
if (!/^1[3-9]\d{9}$/.test(this.data.phoneNumber)) {
wx.showToast({
title: '请输入正确的手机号',
title: '手机号码格式不正确',
icon: 'none'
});
return;
@ -95,24 +95,28 @@ Page({
// 验证验证码
if (!this.data.code) {
wx.showToast({
title: '请输入验证码',
title: '验证码不能为空',
icon: 'none'
});
return;
}
// 验证验证码格式假设验证码为6位数字
if (!/^\d{6}$/.test(this.data.code)) {
wx.showToast({
title: '请输入6位数字验证码',
icon: 'none'
});
return;
}
// if (!/^\d{6}$/.test(this.data.code)) {
// wx.showToast({
// title: '请输入6位数字验证码',
// icon: 'none'
// });
// return;
// }
const res = await request('patient/code_login', 'post', {
code: this.data.code,
mobile: this.data.phoneNumber
});
wx.showToast({
title: '登录成功',
icon: 'success'
});
await wx.setStorageSync('access_token', res.token);
if (res.is_personal_information_complete) {
wx.switchTab({

View File

@ -101,9 +101,9 @@ Page({
},
toQuestionnaire(e) {
const id = e.currentTarget.dataset.id
const { id, time, name } = e.currentTarget.dataset
wx.navigateTo({
url: '/pages/followUp/index?planId='+id,
url: `/pages/followUp/index?planId=${id}&name=${name}&time=${time}` ,
})
},
toRegister() {

View File

@ -16,7 +16,7 @@
</view>
<view class="dose">{{item.plan_name}}</view>
<t-button theme="primary" block bindtap="toQuestionnaire" data-id="{{item.id}}" wx:if="{{item.status == 2}}">填写随访问卷</t-button>
<t-button theme="primary" block bindtap="toQuestionnaire" data-id="{{item.id}}" data-time="{{item.plan_date}}" data-name="{{item.plan_name}}" wx:if="{{item.status == 2}}">填写随访问卷</t-button>
<t-button bindtap="toRegister" theme="primary" block wx:if="{{item.status == 3}}">预约挂号</t-button>
</view>

View File

@ -38,10 +38,11 @@ async uploadFileToOSS(file, callback) {
const policyData = await request('admin/policy_token', 'post')
const res = JSON.parse(policyData.token)
const fileNameWithExt = file.path.split('/').pop(); // hello.png
const fileName = fileNameWithExt.split('.').slice(0, -1).join('.'); // hello
const formData = {
key: 'upload_file/' + file.name, //上传文件名称
key: 'upload_file/' + fileName, //上传文件名称
policy: res.policy, //表单域
'x-oss-signature-version': res.x_oss_signature_version, //指定签名的版本和算法
'x-oss-credential': res.x_oss_credential, //指明派生密钥的参数集
@ -62,7 +63,7 @@ async uploadFileToOSS(file, callback) {
success(res) {
console.log('上传响应:', res);
if (res.statusCode === 200) {
callback(null, 'https://image-fudan.oss-cn-beijing.aliyuncs.com/upload_file/'+ file.name); // 上传成功
callback(null, 'https://image-fudan.oss-cn-beijing.aliyuncs.com/upload_file/'+ fileName); // 上传成功
} else {
console.error('上传失败,状态码:', res.statusCode);
console.error('失败响应:', res);

View File

@ -237,6 +237,17 @@ Page({
years--;
months += 12;
}
if (years <= 0 && months <= 0) {
// 小于一个月,显示几周
const diffTime = today - birthDate;
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
if (diffDays < 7) {
return `${diffDays}`;
} else {
const weeks = Math.floor(diffDays / 7);
return `${weeks}`;
}
}
if (years <= 0) {
return `${months}个月`;
}
@ -251,11 +262,13 @@ Page({
if (mode == 'birth') {
this.setData({
['personInfo.birthday']: value,
['personInfo.age']: this.getAgeByBirthday(value)
['personInfo.age']: this.getAgeByBirthday(value),
['errorStatus.birthday']: false
})
} else {
this.setData({
['personInfo.operative_date']: value
['personInfo.operative_date']: value,
['errorStatus.operative_date']: false
})
}
@ -272,7 +285,11 @@ Page({
onNameChange(e) {
this.personInfoFieldChange('username', e);
if (this.data.errorStatus.name) {
const value = e.detail.value;
// Validate name length (2-20)
if (value.length < 2 || value.length > 20) {
this.setData({ 'errorStatus.name': true });
} else if (this.data.errorStatus.name) {
this.setData({ 'errorStatus.name': false });
}
},
@ -324,7 +341,8 @@ Page({
async onSaveInfo() {
let obj = this.data.personInfo;
let errorStatus = {};
errorStatus.name = !obj.username;
// Name must be 2-20 characters
errorStatus.name = !obj.username || obj.username.length < 2 || obj.username.length > 20;
errorStatus.gender = !obj.sex;
errorStatus.id = obj.id_number ? !/^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(obj.id_number) : false;
errorStatus.birthday = !obj.birthday;
@ -334,9 +352,10 @@ Page({
errorStatus.parity_number = !obj.parity_number;
errorStatus.birth_number = !obj.birth_number;
errorStatus.conception_type = !obj.conception_type;
errorStatus.gestational_week = !/^\d+(\.\d+)?$/.test(obj.gestational_week);
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;
errorStatus.prenatal_check_remark = !obj.prenatal_check_remark;
this.setData({ errorStatus });
if (Object.values(errorStatus).some(v => v)) {
return;
@ -377,15 +396,22 @@ Page({
}
},
onWeightInput(e) {
const isNumber = /^\d+(\.\d+)?$/.test(e.detail.value);
if (this.data.errorStatus.birth_weight) {
// const isNumber = /^\d+(\.\d+)?$/.test(e.detail.value);
// 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 });
} else {
this.setData({ 'errorStatus.birth_weight': false });
}
this.personInfoFieldChange('birth_weight', e);
},
onWeekInput(e) {
const isNumber = /^\d+(\.\d+)?$/.test(e.detail.value);
if (this.data.errorStatus.gestational_week) {
console.log(e.detail.value == true)
if(!e.detail.value || e.detail.value == 0){
this.setData({ 'errorStatus.gestational_week': true });
} else {
this.setData({ 'errorStatus.gestational_week': false });
}
this.personInfoFieldChange('gestational_week', e);
@ -408,7 +434,16 @@ Page({
label
} = e.detail;
this.setData({
[`personInfo.${modeText}`]: value[0]
[`personInfo.${modeText}`]: value[0],
[`errorStatus.${modeText}`]: false
})
},
onPrenatalCheckRemarkChange(e) {
this.setData({
['personInfo.prenatal_check_remark']: e.detail.value,
['errorStatus.prenatal_check_remark']: false
})
},
});

View File

@ -3,7 +3,7 @@
<t-cell class="info-edit__cell" required title="姓名" bordered="{{false}}">
<t-input bind:change="onNameChange" align="right" borderless placeholder="请输入患者姓名" slot="note" value="{{personInfo.username}}"/>
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.name}}">请输入患者姓名</view>
<view class="info-edit__tips" wx:if="{{errorStatus.name}}">姓名字数在2至20之间</view>
</view>
<view class="info-item">
<t-cell class="info-edit__cell" required title="性别" bordered="{{false}}">
@ -39,7 +39,7 @@
<t-cell required arrow bind:click="showPicker" data-mode="operative" title="胆道闭锁手术时间" bordered="{{false}}">
<t-input align="right" borderless placeholder="请选择" readonly slot="note" value="{{personInfo.operative_date}}" />
</t-cell>
<view class="info-edit__tips" wx:if="{{errorStatus.operative_date}}">请选择胆道闭锁手术时间</view>
<view class="info-edit__tips" wx:if="{{errorStatus.operative_date}}">请选择胆道闭锁手术时间</view>
</view>
<view class="info-item">
<t-cell title="胎次" required arrow bordered="{{false}}" bind:click="showSelect" data-mode="parity_number" data-list="{{parity_numberList}}" >
@ -69,8 +69,9 @@
<t-cell title="产检是否有异常(如有,请填写)" bordered="{{false}}" required arrow bind:click="showSelect" data-mode="prenatal_check_type" data-list="{{prenatal_checkList}}" >
<t-input align="right" borderless placeholder="请选择" readonly slot="note" value="{{prenatal_checkList[personInfo.prenatal_check_type - 1].label}}" />
</t-cell>
<t-textarea t-class="external-class" wx:if="{{personInfo.prenatal_check_type == 1}}" placeholder="请输入异常描述" disableDefaultPadding="{{true}}" value="{{personInfo.prenatal_check_remark}}" />
<t-textarea bind:change="onPrenatalCheckRemarkChange" t-class="external-class" wx:if="{{personInfo.prenatal_check_type == 1}}" placeholder="请输入异常描述" disableDefaultPadding="{{true}}" value="{{personInfo.prenatal_check_remark}}" />
<view class="info-edit__tips" wx:if="{{errorStatus.prenatal_check_type}}">请选择产检是否有异常</view>
<view class="info-edit__tips" wx:if="{{personInfo.prenatal_check_type == 1 && errorStatus.prenatal_check_remark}}">请输入异常描述</view>
</view>
<view class="info-item">
<t-cell title="分娩方式" required arrow bordered="{{false}}" bind:click="showSelect" data-mode="delivery_type" data-list="{{deliveryList}}" >