This commit is contained in:
左哥 2025-06-23 23:54:25 +08:00
parent 2d962dc386
commit e3dde62565
5 changed files with 233 additions and 55 deletions

View File

@ -9,12 +9,17 @@ Page({
data: {
style: 'border: 2rpx solid #efefef;border-radius: 12rpx;',
dataItem:[
{
title: '随访信息',
child: []
}
],
form: {
},
key: 'filename.txt', //待上传的文件名称您也可以指定其存储在某个目录下。例如将filename.txt文件上传到youfolder文件夹下此时需填写/youfolder/filename.txt。
policy: '',
xOssSecurityToken: '',
xOssSignatureVersion: '',
xOssCredential: '',
xOssDate: '',
xOssSignature: '',
@ -25,7 +30,7 @@ Page({
address: [],
introduction: '',
yearType: 0,
// photos: [],
},
mode: '',
@ -113,20 +118,25 @@ Page({
},
onInput(e) {
const { key } = e.currentTarget.dataset;
this.setData({
[key]: e.detail.value,
});
// this.setData({
// ['form.key']: e.detail.value,
// });
},
showPicker(e) {
const { mode } = e.currentTarget.dataset;
this.setData({
[`${mode}Visible`]: true,
});
},
},
onPickerChange(e) {
console.log(e)
this.setData({
['form.follow_date']: e.detail.value
})
},
handleSuccess(e) {
console.log(e.detail)
const { files } = e.detail;
@ -146,12 +156,154 @@ Page({
handleClick(e) {
console.log(e.detail.file);
},
toQuestionnaire(){
request('/patient/follow_questionnaire', 'post', {
toQuestionnaire() {
request('patient/follow_questionnaire', 'post', {
})
},
handleChangeGroup(e) {
console.log(e)
const { mode } = e.currentTarget.dataset
this.setData({
[`form.${mode}`]: e.detail.value
})
},
//上传文件方法
async uploadFileToOSS(filePath, callback) {
const {
key,
policy,
xOssSecurityToken,
xOssSignatureVersion,
xOssCredential,
xOssDate,
xOssSignature
} = this.data;
const policyData = await request('admin/policy_token', 'post')
const res = JSON.parse(policyData.token)
console.log(res)
const formData = {
key, //上传文件名称
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" //上传成功后响应状态码
};
// 发送请求上传文件
wx.uploadFile({
url: 'https://image-fudan.oss-cn-beijing.aliyuncs.com/', // 此域名仅作示例实际Bucket域名请替换为您的目标Bucket域名。
filePath: filePath,
name: 'file', //固定值为file
formData: formData,
success(res) {
console.log('上传响应:', res);
if (res.statusCode === 200) {
callback(null, res.data); // 上传成功
} else {
console.error('上传失败,状态码:', res.statusCode);
console.error('失败响应:', res);
callback(res); // 上传失败,返回响应
}
},
fail(err) {
console.error('上传失败:', err); // 输出错误信息
wx.showToast({ title: '上传失败,请重试!', icon: 'none' });
callback(err); // 调用回调处理错误
}
});
return
const apiUrl = 'http://<ECS实例公网IP地址>:<port>/generate_signature' //请将IP地址和端口号替换为实际服务器公网IP地址及端口号
// 发送请求获取签名信息
wx.request({
url: apiUrl,
success: (res) => {
this.data.xOssSignatureVersion = res.x_oss_signature_version;
this.data.xOssCredential = res.x_oss_credential;
this.data.xOssDate = res.x_oss_date;
this.data.xOssSignature = res.signature;
this.data.xOssSecurityToken = res.security_token;
this.data.policy = res.policy;
//此示例上传参数只列举必填字段,如有其他需求可参考:
//PostObject文档https://help.aliyun.com/zh/oss/developer-reference/postobject
//签名版本4文档https://help.aliyun.com/zh/oss/developer-reference/signature-version-4-recommend
const formData = {
key, //上传文件名称
policy: this.data.policy, //表单域
'x-oss-signature-version': this.data.xOssSignatureVersion, //指定签名的版本和算法
'x-oss-credential': this.data.xOssCredential, //指明派生密钥的参数集
'x-oss-date': this.data.xOssDate, //请求的时间
'x-oss-signature': this.data.xOssSignature, //签名认证描述信息
'x-oss-security-token': this.data.xOssSecurityToken, //安全令牌
success_action_status: "200" //上传成功后响应状态码
};
// 发送请求上传文件
wx.uploadFile({
url: 'https://examplebucket.oss-cn-hangzhou.aliyuncs.com', // 此域名仅作示例实际Bucket域名请替换为您的目标Bucket域名。
filePath: filePath,
name: 'file', //固定值为file
formData: formData,
success(res) {
console.log('上传响应:', res);
if (res.statusCode === 200) {
callback(null, res.data); // 上传成功
} else {
console.error('上传失败,状态码:', res.statusCode);
console.error('失败响应:', res);
callback(res); // 上传失败,返回响应
}
},
fail(err) {
console.error('上传失败:', err); // 输出错误信息
wx.showToast({ title: '上传失败,请重试!', icon: 'none' });
callback(err); // 调用回调处理错误
}
});
},
fail: (err) => {
console.error('请求接口失败:', err);
wx.showToast({ title: '获取上传参数失败,请重试!', icon: 'none' });
}
});
},
handleUpload() {
wx.chooseMessageFile({
count: 1, // 选择一个文件
type: 'all', // 支持所有类型的文件
success: (res) => {
console.log('选择的文件:', res.tempFiles); // 输出选择的文件信息
if (res.tempFiles.length > 0) {
const tempFilePath = res.tempFiles[0].path; // 获取选择的文件路径
console.log('选择的文件路径:', tempFilePath); // 输出文件路径
this.uploadFileToOSS(tempFilePath, (error, data) => {
if (error) {
wx.showToast({ title: '上传失败!', icon: 'none' });
console.error('上传失败:', error); // 输出具体的错误信息
} else {
wx.showToast({ title: '上传成功!', icon: 'success' });
console.log('上传成功:', data); // 输出上传成功后的数据
}
});
} else {
wx.showToast({ title: '未选择文件!', icon: 'none' });
}
},
fail: (err) => {
wx.showToast({ title: '选择文件失败!', icon: 'none' });
console.error('选择文件失败:', err); // 输出选择文件的错误信息
}
});
},
/**
* 生命周期函数--监听页面加载

View File

@ -39,4 +39,23 @@
flex-wrap: wrap;
padding-right: 60rpx;
}
.improt-file{
width: 140rpx;
height: 140rpx;
background: rgba(0,91,162,0.05);
border-radius: 16rpx;
border: 2rpx dotted rgba(0,91,162,0.2);
display: flex;
justify-content: center;
align-items: center;
.upload-flow{
text-align: center;
font-size: 26rpx;
.iconfont{
font-size: 36rpx;
color: var(--td-brand-color);
}
}
}
}

View File

@ -4,16 +4,16 @@
<view>随访信息</view>
<view class="input-example">
<view class="input-example__label"> 随访名称</view>
<t-input placeholder="请输入" size="small" bind:tap="onInput" data-key="follow_name" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" size="small" bind:tap="onInput" value="{{form.follow_name}}" data-key="follow_name" borderless="{{true}}" style="{{style}}" />
</view>
<view class="input-example">
<view class="input-example__label"> 随访日期</view>
<t-input placeholder="请输入" bindtap="showPicker" size="small" borderless="{{true}}" style="{{style}}" data-mode="birth" suffixIcon="{{ { name: 'calendar-1', ariaLabel: '通讯录' } }}" />
<t-input placeholder="请输入" bindtap="showPicker" size="small" borderless="{{true}}" style="{{style}}" data-mode="birth" suffixIcon="{{ { name: 'calendar-1'} }}" note="'请选择'" value="{{form.follow_date}}" />
</view>
<view class="input-example">
<view class="input-example__label"> 随访医院</view>
<t-input placeholder="请输入" size="small" bind:tap="onInput" data-key="follow_hospital" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" size="small" bind:tap="onInput" value="{{form.follow_hospital}}" data-key="follow_hospital" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -25,7 +25,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 身高cm </view>
<t-input placeholder="请输入" size="small" bind:tap="onInput" data-key="height" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" size="small" bind:tap="onInput" value="{{form.height}}" data-key="height" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -34,7 +34,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 体重kg </view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="weight" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.weight}}" data-key="weight" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -42,7 +42,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 头围cm </view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="head_circumference" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.head_circumference}}" data-key="head_circumference" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -51,7 +51,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 上臀围cm </view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="high_hip" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.high_hip}}" data-key="high_hip" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -64,7 +64,13 @@
<view class="input-example">
<view class="input-example__label"> 上传肝功能检查报告支持OCR识别</view>
</view>
<t-upload media-type="{{['image']}}" files="{{originFiles}}" gridConfig="{{gridConfig}}" removeBtn="{{false}}" bind:success="handleSuccess" bind:remove="handleRemove" bind:click="handleClick" bind:sort-end="handleSortEnd" />
<view class="improt-file" bind:tap="handleUpload">
<view class="upload-flow">
<text class="iconfont icon-xiangji"></text>
<view>拍照导入</view>
</view>
</view>
<!-- <t-upload media-type="{{['image']}}" files="{{originFiles}}" gridConfig="{{gridConfig}}" removeBtn="{{false}}" bind:success="handleSuccess" bind:remove="handleRemove" bind:click="handleClick" bind:sort-end="handleSortEnd" /> -->
</view>
<t-row gutter="12">
@ -72,7 +78,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 总胆红素µmol/L) </view>
<t-input placeholder="请输入" size="small" bind:tap="onInput" data-key="total_bilirubin" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" size="small" bind:tap="onInput" value="{{form.total_bilirubin}}" data-key="total_bilirubin" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -81,7 +87,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label">直接胆红素(µmol/L)</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="direct_bilirubin" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.direct_bilirubin}}" data-key="direct_bilirubin" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -89,7 +95,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 总胆汁酸g/L </view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="total_bile_acid" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.total_bile_acid}}" data-key="total_bile_acid" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -98,7 +104,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 白蛋白g/L </view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="albumin" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.albumin}}" data-key="albumin" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -106,7 +112,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 谷草U/L</view>
<t-input placeholder="请输入" size="small" bind:tap="onInput" data-key="grain_grass" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" size="small" bind:tap="onInput" value="{{form.grain_grass}}" data-key="grain_grass" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -115,7 +121,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 谷丙U/L</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="gu_bing" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.gu_bing}}" data-key="gu_bing" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -123,7 +129,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> GGTU/L</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="ggt" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.ggt}}" data-key="ggt" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -132,7 +138,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> ALPU/L</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="alp" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.alp}}" data-key="alp" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -154,7 +160,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 凝血酶原时间s</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="follow_name" size="small" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.follow_date}}" data-key="follow_name" size="small" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -163,7 +169,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 国际标准化比</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="follow_name" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.follow_date}}" data-key="follow_name" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -171,7 +177,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 活化的部分凝血酶时间s</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="follow_name" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.follow_date}}" data-key="follow_name" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -195,7 +201,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 血小板10^9/L </view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="platelets" size="small" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.platelets}}" data-key="platelets" size="small" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -204,7 +210,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 血红蛋白g/L</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="hemoglobin" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.hemoglobin}}" data-key="hemoglobin" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -212,7 +218,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 白细胞10^9/L</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="white_blood_cells" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.white_blood_cells}}" data-key="white_blood_cells" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -236,7 +242,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 25OHD3 (ng/ml) </view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="oh_d3" size="small" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.oh_d3}}" data-key="oh_d3" size="small" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -245,7 +251,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 维生素A (ng/ml)</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="vitamin_a" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.vitamin_a}}" data-key="vitamin_a" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -253,7 +259,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 维生素K (ng/ml)</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="vitamin_k" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.vitamin_k}}" data-key="vitamin_k" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -262,7 +268,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 维生素E (ng/ml)</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="vitamin_e" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.vitamin_e}}" data-key="vitamin_e" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -285,7 +291,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 肝肋下(mm)</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="under_the_liver_rib" size="small" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.under_the_liver_rib}}" data-key="under_the_liver_rib" size="small" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -294,7 +300,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 肝剑突下(mm)</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="under_the_xiphoid_liver" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.under_the_xiphoid_liver}}" data-key="under_the_xiphoid_liver" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -302,7 +308,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 脾肋下(mm)</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="spleen_rib_area" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.spleen_rib_area}}" data-key="spleen_rib_area" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -311,7 +317,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 门静脉主干(mm)</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="main_portal_vein" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.main_portal_vein}}" data-key="main_portal_vein" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -320,7 +326,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 门静脉流速</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="pvv" size="small" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.pvv}}" data-key="pvv" size="small" borderless="{{true}}" style="{{style}}" />
</view>
</view>
@ -329,7 +335,7 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 肝弹性值</view>
<t-input placeholder="请输入" bind:tap="onInput" data-key="liver_elasticity_value" borderless="{{true}}" style="{{style}}" />
<t-input placeholder="请输入" bind:tap="onInput" value="{{form.liver_elasticity_value}}" data-key="liver_elasticity_value" borderless="{{true}}" style="{{style}}" />
</view>
</view>
</t-col>
@ -337,9 +343,9 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 有无肝囊肿</view>
<t-radio-group default-value="0" borderless t-class="box">
<t-radio block="{{false}}" label="有" value="0" />
<t-radio block="{{false}}" label="无" value="1" />
<t-radio-group default-value="{{form.is_have_cyst}}" borderless t-class="box" data-mode="is_have_cyst" bind:change="handleChangeGroup">
<t-radio block="{{false}}" label="有" value="1" />
<t-radio block="{{false}}" label="无" value="2" />
</t-radio-group>
</view>
@ -349,9 +355,9 @@
<view class="dark">
<view class="input-example">
<view class="input-example__label"> 有无腹水</view>
<t-radio-group default-value="0" borderless t-class="box">
<t-radio block="{{false}}" label="有" value="0" />
<t-radio block="{{false}}" label="无" value="1" />
<t-radio-group default-value="{{form.is_have_ascites}}" borderless t-class="box" data-mode="is_have_ascites" bind:change="handleChangeGroup">
<t-radio block="{{false}}" label="有" value="1" />
<t-radio block="{{false}}" label="无" value="2" />
</t-radio-group>
</view>

View File

@ -39,6 +39,7 @@
height: 160rpx;
align-self: center;
margin-top: 196rpx;
border-radius: 160px;
}
.box_1 {
display: flex;

View File

@ -126,7 +126,7 @@
]
}
},
"libVersion": "3.8.8",
"libVersion": "3.8.9",
"setting": {
"urlCheck": false,
"compileHotReLoad": false