sds
This commit is contained in:
parent
e8a8bec51e
commit
8cd91d92cf
105
api/upload.js
Normal file
105
api/upload.js
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import request from './request'
|
||||||
|
|
||||||
|
const uploadFile = async (file, callback) => {
|
||||||
|
|
||||||
|
|
||||||
|
const policyData = await request('admin/policy_token', 'post')
|
||||||
|
const res = JSON.parse(policyData.token)
|
||||||
|
|
||||||
|
const fileName = file.tempFilePath.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" //上传成功后响应状态码
|
||||||
|
};
|
||||||
|
// console.log(filePath)
|
||||||
|
// return
|
||||||
|
// 发送请求上传文件
|
||||||
|
wx.uploadFile({
|
||||||
|
url: 'https://image-fudan.oss-cn-beijing.aliyuncs.com/',
|
||||||
|
method: 'put',
|
||||||
|
filePath: file.tempFilePath,
|
||||||
|
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); // 上传成功
|
||||||
|
} else {
|
||||||
|
console.error('上传失败,状态码:', res.statusCode);
|
||||||
|
console.error('失败响应:', res);
|
||||||
|
callback(res); // 上传失败,返回响应
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail(err) {
|
||||||
|
console.error('上传失败:', err); // 输出错误信息
|
||||||
|
wx.showToast({
|
||||||
|
title: '上传失败,请重试!',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
callback(err); // 调用回调处理错误
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const uploadFileToOSS = () => {
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
|
wx.chooseMedia({
|
||||||
|
count: 1, // 选择一个文件
|
||||||
|
mediaType: ['image'],
|
||||||
|
sourceType: ['album', 'camera'],
|
||||||
|
// type: 'all', // 支持所有类型的文件
|
||||||
|
success: (res) => {
|
||||||
|
wx.showToast({
|
||||||
|
title: '文件上传中,请稍等!',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
console.log('选择的文件:', res.tempFiles); // 输出选择的文件信息
|
||||||
|
if (res.tempFiles.length > 0) {
|
||||||
|
const tempFilePath = res.tempFiles[0];
|
||||||
|
console.log('选择的文件路径:', tempFilePath); // 输出文件路径
|
||||||
|
uploadFile(tempFilePath, (error, data) => {
|
||||||
|
if (error) {
|
||||||
|
wx.showToast({
|
||||||
|
title: '上传失败!',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
console.error('上传失败:', error); // 输出具体的错误信息
|
||||||
|
reject(error)
|
||||||
|
} else {
|
||||||
|
resolve(data)
|
||||||
|
console.log('上传成功:', data); // 输出上传成功后的数据
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
wx.showToast({
|
||||||
|
title: '未选择文件!',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
reject('未选择文件!')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
wx.showToast({
|
||||||
|
title: '选择文件失败!',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
console.error('选择文件失败:', err); // 输出选择文件的错误信息
|
||||||
|
reject('选择文件失败!')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default uploadFileToOSS;
|
||||||
@ -1,4 +1,5 @@
|
|||||||
import request from '~/api/request';
|
import request from '~/api/request';
|
||||||
|
import uploadFileToOSS from '~/api/upload';
|
||||||
import {
|
import {
|
||||||
getOcr
|
getOcr
|
||||||
} from '~/api/drugOcr';
|
} from '~/api/drugOcr';
|
||||||
@ -319,105 +320,19 @@ Page({
|
|||||||
reminder: JSON.parse(obj.reminder),
|
reminder: JSON.parse(obj.reminder),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
//上传文件方法
|
|
||||||
async uploadFileToOSS(file, callback) {
|
|
||||||
|
|
||||||
|
|
||||||
const policyData = await request('admin/policy_token', 'post')
|
|
||||||
const res = JSON.parse(policyData.token)
|
|
||||||
const fileName = file.tempFilePath.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" //上传成功后响应状态码
|
|
||||||
};
|
|
||||||
// console.log(filePath)
|
|
||||||
// return
|
|
||||||
// 发送请求上传文件
|
|
||||||
wx.uploadFile({
|
|
||||||
url: 'https://image-fudan.oss-cn-beijing.aliyuncs.com/',
|
|
||||||
method: 'put',
|
|
||||||
filePath: file.tempFilePath,
|
|
||||||
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); // 上传成功
|
|
||||||
} else {
|
|
||||||
console.error('上传失败,状态码:', res.statusCode);
|
|
||||||
console.error('失败响应:', res);
|
|
||||||
callback(res); // 上传失败,返回响应
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail(err) {
|
|
||||||
console.error('上传失败:', err); // 输出错误信息
|
|
||||||
wx.showToast({
|
|
||||||
title: '上传失败,请重试!',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
callback(err); // 调用回调处理错误
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
handleUpload(e) {
|
handleUpload(e) {
|
||||||
wx.chooseMedia({
|
uploadFileToOSS().then((imageUrls) => {
|
||||||
count: 1, // 选择一个文件
|
wx.showToast({ title: '上传成功,正在识别内容!', icon: 'none' });
|
||||||
mediaType: ['image'],
|
this.setData({
|
||||||
sourceType: ['album', 'camera'],
|
imageFile: imageUrls
|
||||||
success: (res) => {
|
})
|
||||||
wx.showToast({
|
getOcr(imageUrls).then(res => {
|
||||||
title: '文件上传中,请稍等!',
|
wx.showToast({ title: '识别完成!', icon: 'none' })
|
||||||
icon: 'none'
|
this.ocrAdditem(res)
|
||||||
});
|
})
|
||||||
console.log('选择的文件:', res.tempFiles); // 输出选择的文件信息
|
})
|
||||||
if (res.tempFiles.length > 0) {
|
|
||||||
const tempFilePath = res.tempFiles[0];
|
|
||||||
console.log('选择的文件路径:', tempFilePath); // 输出文件路径
|
|
||||||
this.uploadFileToOSS(tempFilePath, (error, data) => {
|
|
||||||
if (error) {
|
|
||||||
wx.showToast({
|
|
||||||
title: '上传失败!',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
console.error('上传失败:', error); // 输出具体的错误信息
|
|
||||||
} else {
|
|
||||||
wx.showToast({ title: '上传成功,正在识别内容!', icon: 'none' });
|
|
||||||
|
|
||||||
this.setData({
|
|
||||||
imageFile: data
|
|
||||||
})
|
|
||||||
getOcr(data).then(res => {
|
|
||||||
wx.showToast({ title: '识别完成!', icon: 'none' })
|
|
||||||
this.ocrAdditem(res)
|
|
||||||
})
|
|
||||||
console.log('上传成功:', data); // 输出上传成功后的数据
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
wx.showToast({
|
|
||||||
title: '未选择文件!',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
wx.showToast({
|
|
||||||
title: '选择文件失败!',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
console.error('选择文件失败:', err); // 输出选择文件的错误信息
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
ocrAdditem(data) {
|
ocrAdditem(data) {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import request from '~/api/request';
|
import request from '~/api/request';
|
||||||
|
import uploadFileToOSS from '~/api/upload';
|
||||||
|
|
||||||
import { getOcr } from '~/api/ocr';
|
import { getOcr } from '~/api/ocr';
|
||||||
import { getBOcr } from '~/api/BOcr';
|
import { getBOcr } from '~/api/BOcr';
|
||||||
@ -247,111 +248,39 @@ Page({
|
|||||||
[`form.${mode}`]: e.detail.value
|
[`form.${mode}`]: e.detail.value
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
//上传文件方法
|
|
||||||
async uploadFileToOSS(file, callback) {
|
|
||||||
|
|
||||||
|
|
||||||
const policyData = await request('admin/policy_token', 'post')
|
|
||||||
const res = JSON.parse(policyData.token)
|
|
||||||
|
|
||||||
const fileName = file.tempFilePath.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" //上传成功后响应状态码
|
|
||||||
};
|
|
||||||
// console.log(filePath)
|
|
||||||
// return
|
|
||||||
// 发送请求上传文件
|
|
||||||
wx.uploadFile({
|
|
||||||
url: 'https://image-fudan.oss-cn-beijing.aliyuncs.com/',
|
|
||||||
method: 'put',
|
|
||||||
filePath: file.tempFilePath,
|
|
||||||
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); // 上传成功
|
|
||||||
} else {
|
|
||||||
console.error('上传失败,状态码:', res.statusCode);
|
|
||||||
console.error('失败响应:', res);
|
|
||||||
callback(res); // 上传失败,返回响应
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail(err) {
|
|
||||||
console.error('上传失败:', err); // 输出错误信息
|
|
||||||
wx.showToast({ title: '上传失败,请重试!', icon: 'none' });
|
|
||||||
callback(err); // 调用回调处理错误
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
handleUpload(e) {
|
handleUpload(e) {
|
||||||
const { mode } = e.currentTarget.dataset;
|
const { mode } = e.currentTarget.dataset;
|
||||||
if (this.data.form[mode].length >= 9) {
|
if (this.data.form[mode].length >= 9) {
|
||||||
wx.showToast({ title: '最多上传9张图片!', icon: 'none' });
|
wx.showToast({ title: '最多上传9张图片!', icon: 'none' });
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
wx.chooseMedia({
|
uploadFileToOSS().then((imageUrl) => {
|
||||||
count: 1, // 选择一个文件
|
const { mode } = e.currentTarget.dataset;
|
||||||
mediaType: ['image'],
|
let arr = this.data.form[mode]
|
||||||
sourceType: ['album', 'camera'],
|
arr.unshift(imageUrl)
|
||||||
// type: 'all', // 支持所有类型的文件
|
this.setData({
|
||||||
success: (res) => {
|
[`form.${mode}`]: arr
|
||||||
wx.showToast({ title: '文件上传中,请稍等!', icon: 'none' });
|
})
|
||||||
console.log('选择的文件:', res.tempFiles); // 输出选择的文件信息
|
if(mode == 'mdt_image'){
|
||||||
if (res.tempFiles.length > 0) {
|
wx.showToast({ title: '上传成功!', icon: 'none' });
|
||||||
const tempFilePath = res.tempFiles[0];
|
} else if(mode == 'b_mode_image'){
|
||||||
console.log('选择的文件路径:', tempFilePath); // 输出文件路径
|
wx.showToast({ title: '上传成功,正在识别内容!', icon: 'none' });
|
||||||
this.uploadFileToOSS(tempFilePath, (error, data) => {
|
getBOcr(imageUrl).then(ocrRes => {
|
||||||
if (error) {
|
console.log(ocrRes)
|
||||||
wx.showToast({ title: '上传失败!', icon: 'none' });
|
wx.showToast({ title: '识别完成!', icon: 'none' })
|
||||||
console.error('上传失败:', error); // 输出具体的错误信息
|
this.setFormData(ocrRes, mode)
|
||||||
} else {
|
})
|
||||||
const { mode } = e.currentTarget.dataset;
|
} else{
|
||||||
let arr = this.data.form[mode]
|
wx.showToast({ title: '上传成功,正在识别内容!', icon: 'none' });
|
||||||
arr.unshift(data)
|
getOcr(imageUrl).then(ocrRes => {
|
||||||
this.setData({
|
console.log(ocrRes)
|
||||||
[`form.${mode}`]: arr
|
wx.showToast({ title: '识别完成!', icon: 'none' })
|
||||||
})
|
this.setFormData(ocrRes, mode)
|
||||||
if(mode == 'mdt_image'){
|
})
|
||||||
wx.showToast({ title: '上传成功!', icon: 'none' });
|
|
||||||
} else if(mode == 'b_mode_image'){
|
|
||||||
wx.showToast({ title: '上传成功,正在识别内容!', icon: 'none' });
|
|
||||||
getBOcr(data).then(ocrRes => {
|
|
||||||
console.log(ocrRes)
|
|
||||||
wx.showToast({ title: '识别完成!', icon: 'none' })
|
|
||||||
this.setFormData(ocrRes, mode)
|
|
||||||
})
|
|
||||||
} else{
|
|
||||||
wx.showToast({ title: '上传成功,正在识别内容!', icon: 'none' });
|
|
||||||
getOcr(data).then(ocrRes => {
|
|
||||||
console.log(ocrRes)
|
|
||||||
wx.showToast({ title: '识别完成!', icon: 'none' })
|
|
||||||
this.setFormData(ocrRes, mode)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('上传成功:', data); // 输出上传成功后的数据
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
wx.showToast({ title: '未选择文件!', icon: 'none' });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
wx.showToast({ title: '选择文件失败!', icon: 'none' });
|
|
||||||
console.error('选择文件失败:', err); // 输出选择文件的错误信息
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
imageKey: '',
|
imageKey: '',
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import request from '~/api/request'
|
import request from '~/api/request'
|
||||||
|
import uploadFileToOSS from '~/api/upload';
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6,7 +7,7 @@ Page({
|
|||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
form: {
|
form: {
|
||||||
username:'',
|
username: '',
|
||||||
mmp_7: '',
|
mmp_7: '',
|
||||||
day: '',
|
day: '',
|
||||||
mobile: '',
|
mobile: '',
|
||||||
@ -28,177 +29,120 @@ Page({
|
|||||||
msg: ''
|
msg: ''
|
||||||
},
|
},
|
||||||
formKey: '',
|
formKey: '',
|
||||||
|
|
||||||
|
|
||||||
getUserinfo(e) {
|
getUserinfo(e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
},
|
},
|
||||||
|
|
||||||
//上传文件方法
|
handleUpload(e) {
|
||||||
async uploadFileToOSS(file, callback) {
|
const {
|
||||||
|
mode
|
||||||
|
} = e.currentTarget.dataset;
|
||||||
|
uploadFileToOSS().then((imageUrl) => {
|
||||||
|
wx.showToast({
|
||||||
|
title: '上传成功!',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
this.setData({
|
||||||
|
[`form.${mode}`]: imageUrl
|
||||||
|
}, () => {
|
||||||
|
this.validateForm(mode);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
const policyData = await request('admin/policy_token', 'post')
|
|
||||||
const res = JSON.parse(policyData.token)
|
|
||||||
const fileName = file.tempFilePath.split('/').pop(); // hello.png
|
|
||||||
// const fileName = fileNameWithExt.split('.').slice(0, -1).join('.'); // hello
|
|
||||||
|
|
||||||
const formData = {
|
},
|
||||||
key: 'upload_file/' + fileName, //上传文件名称
|
|
||||||
policy: res.policy, //表单域
|
handleDelete(e) {
|
||||||
'x-oss-signature-version': res.x_oss_signature_version, //指定签名的版本和算法
|
const {
|
||||||
'x-oss-credential': res.x_oss_credential, //指明派生密钥的参数集
|
mode
|
||||||
'x-oss-date': res.x_oss_date, //请求的时间
|
} = e.currentTarget.dataset;
|
||||||
'x-oss-signature': res.signature, //签名认证描述信息
|
this.setData({
|
||||||
'x-oss-security-token': res.security_token, //安全令牌
|
[`form.${mode}`]: ''
|
||||||
success_action_status: "200" //上传成功后响应状态码
|
})
|
||||||
};
|
},
|
||||||
// console.log(filePath)
|
handleImagePreview(e) {
|
||||||
// return
|
const {
|
||||||
// 发送请求上传文件
|
mode
|
||||||
wx.uploadFile({
|
} = e.currentTarget.dataset;
|
||||||
url: 'https://image-fudan.oss-cn-beijing.aliyuncs.com/',
|
this.setData({
|
||||||
method: 'put',
|
imageList: [this.data.form[mode]],
|
||||||
filePath: file.tempFilePath,
|
imageIndex: 1,
|
||||||
name: 'file', //固定值为file
|
imageVisible: true
|
||||||
formData: formData,
|
})
|
||||||
success(res) {
|
},
|
||||||
console.log('上传响应:', res);
|
|
||||||
if (res.statusCode === 200) {
|
onInput(e) {
|
||||||
callback(null, 'https://image-fudan.oss-cn-beijing.aliyuncs.com/upload_file/'+ fileName); // 上传成功
|
const {
|
||||||
} else {
|
mode
|
||||||
console.error('上传失败,状态码:', res.statusCode);
|
} = e.currentTarget.dataset;
|
||||||
console.error('失败响应:', res);
|
this.setData({
|
||||||
callback(res); // 上传失败,返回响应
|
[`form.${mode}`]: e.detail.value
|
||||||
}
|
}, () => {
|
||||||
},
|
this.validateForm(mode);
|
||||||
fail(err) {
|
});
|
||||||
console.error('上传失败:', err); // 输出错误信息
|
},
|
||||||
wx.showToast({ title: '上传失败,请重试!', icon: 'none' });
|
|
||||||
callback(err); // 调用回调处理错误
|
validateForm(mode) {
|
||||||
|
let update = {};
|
||||||
|
let form = this.data.form;
|
||||||
|
if (!mode || mode === 'username') {
|
||||||
|
update.isName = !!form.username.trim();
|
||||||
}
|
}
|
||||||
});
|
if (!mode || mode === 'mmp_7') {
|
||||||
|
update.isMmp = !!form.mmp_7.trim();
|
||||||
},
|
|
||||||
handleUpload(e) {
|
|
||||||
const { mode } = e.currentTarget.dataset;
|
|
||||||
|
|
||||||
|
|
||||||
wx.chooseMedia({
|
|
||||||
count: 1, // 选择一个文件
|
|
||||||
mediaType: ['image'],
|
|
||||||
sourceType: ['album', 'camera'],
|
|
||||||
success: (res) => {
|
|
||||||
wx.showToast({ title: '文件上传中,请稍等!', icon: 'none' });
|
|
||||||
if (res.tempFiles.length > 0) {
|
|
||||||
const tempFilePath = res.tempFiles[0];
|
|
||||||
this.uploadFileToOSS(tempFilePath, (error, data) => {
|
|
||||||
if (error) {
|
|
||||||
wx.showToast({ title: '上传失败!', icon: 'none' });
|
|
||||||
console.error('上传失败:', error); // 输出具体的错误信息
|
|
||||||
} else {
|
|
||||||
wx.showToast({ title: '上传成功!', icon: 'success' });
|
|
||||||
|
|
||||||
this.setData({
|
|
||||||
[`form.${mode}`]: data
|
|
||||||
}, () => {
|
|
||||||
this.validateForm(mode);
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log('上传成功:', data); // 输出上传成功后的数据
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
wx.showToast({ title: '未选择文件!', icon: 'none' });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
wx.showToast({ title: '选择文件失败!', icon: 'none' });
|
|
||||||
console.error('选择文件失败:', err); // 输出选择文件的错误信息
|
|
||||||
}
|
}
|
||||||
});
|
if (!mode || mode === 'day') {
|
||||||
},
|
update.isDay = !!form.day.trim();
|
||||||
|
}
|
||||||
|
if (!mode || mode === 'mobile') {
|
||||||
|
update.isMobile = /^1[3-9]\d{9}$/.test(form.mobile.trim());
|
||||||
|
}
|
||||||
|
if (!mode || mode === 'gallbladder_image') {
|
||||||
|
update.isGallbladder = !!form.gallbladder_image.trim();
|
||||||
|
}
|
||||||
|
if (!mode || mode === 'portal_vein_branch_image') {
|
||||||
|
update.isPortalVeinBranch = !!form.portal_vein_branch_image.trim();
|
||||||
|
}
|
||||||
|
if (!mode || mode === 'portal_vein_cross_image') {
|
||||||
|
update.isPortalVeinCross = !!form.portal_vein_cross_image.trim();
|
||||||
|
}
|
||||||
|
this.setData(update);
|
||||||
|
// 全量校验时返回整体结果
|
||||||
|
if (!mode) {
|
||||||
|
return update.isName && update.isMmp && update.isDay && update.isMobile && update.isGallbladder && update.isPortalVeinBranch && update.isPortalVeinCross;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
handleDelete(e){
|
async toQuestionnaire() {
|
||||||
const { mode } = e.currentTarget.dataset;
|
if (!this.validateForm()) {
|
||||||
this.setData({
|
wx.showToast({
|
||||||
[`form.${mode}`]: ''
|
title: '请完善表单信息',
|
||||||
})
|
icon: 'none'
|
||||||
},
|
});
|
||||||
handleImagePreview(e){
|
return;
|
||||||
const { mode } = e.currentTarget.dataset;
|
}
|
||||||
this.setData({
|
const body = {
|
||||||
imageList: [this.data.form[mode]],
|
username: this.data.form.username,
|
||||||
imageIndex: 1,
|
mmp_7: this.data.form.mmp_7,
|
||||||
imageVisible: true
|
day: Number(this.data.form.day),
|
||||||
})
|
mobile: this.data.form.mobile,
|
||||||
},
|
gallbladder_image: this.data.form.gallbladder_image,
|
||||||
|
portal_vein_branch_image: this.data.form.portal_vein_branch_image,
|
||||||
onInput(e){
|
portal_vein_cross_image: this.data.form.portal_vein_cross_image
|
||||||
const { mode } = e.currentTarget.dataset;
|
}
|
||||||
this.setData({
|
const res = await request('patient/diagnostic', 'post', body)
|
||||||
[`form.${mode}`]: e.detail.value
|
this.setData({
|
||||||
}, () => {
|
msg: res.message,
|
||||||
this.validateForm(mode);
|
visible: true
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
confirm() {
|
||||||
validateForm(mode) {
|
this.setData({
|
||||||
let update = {};
|
visible: false
|
||||||
let form = this.data.form;
|
})
|
||||||
if (!mode || mode === 'username') {
|
},
|
||||||
update.isName = !!form.username.trim();
|
|
||||||
}
|
|
||||||
if (!mode || mode === 'mmp_7') {
|
|
||||||
update.isMmp = !!form.mmp_7.trim();
|
|
||||||
}
|
|
||||||
if (!mode || mode === 'day') {
|
|
||||||
update.isDay = !!form.day.trim();
|
|
||||||
}
|
|
||||||
if (!mode || mode === 'mobile') {
|
|
||||||
update.isMobile = /^1[3-9]\d{9}$/.test(form.mobile.trim());
|
|
||||||
}
|
|
||||||
if (!mode || mode === 'gallbladder_image') {
|
|
||||||
update.isGallbladder = !!form.gallbladder_image.trim();
|
|
||||||
}
|
|
||||||
if (!mode || mode === 'portal_vein_branch_image') {
|
|
||||||
update.isPortalVeinBranch = !!form.portal_vein_branch_image.trim();
|
|
||||||
}
|
|
||||||
if (!mode || mode === 'portal_vein_cross_image') {
|
|
||||||
update.isPortalVeinCross = !!form.portal_vein_cross_image.trim();
|
|
||||||
}
|
|
||||||
this.setData(update);
|
|
||||||
// 全量校验时返回整体结果
|
|
||||||
if (!mode) {
|
|
||||||
return update.isName && update.isMmp && update.isDay && update.isMobile && update.isGallbladder && update.isPortalVeinBranch && update.isPortalVeinCross;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async toQuestionnaire(){
|
|
||||||
if (!this.validateForm()) {
|
|
||||||
wx.showToast({ title: '请完善表单信息', icon: 'none' });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const body = {
|
|
||||||
username: this.data.form.username,
|
|
||||||
mmp_7: this.data.form.mmp_7,
|
|
||||||
day: Number(this.data.form.day),
|
|
||||||
mobile: this.data.form.mobile,
|
|
||||||
gallbladder_image: this.data.form.gallbladder_image,
|
|
||||||
portal_vein_branch_image: this.data.form.portal_vein_branch_image,
|
|
||||||
portal_vein_cross_image: this.data.form.portal_vein_cross_image
|
|
||||||
}
|
|
||||||
const res = await request('patient/diagnostic', 'post', body)
|
|
||||||
this.setData({
|
|
||||||
msg: res.message,
|
|
||||||
visible: true
|
|
||||||
})
|
|
||||||
},
|
|
||||||
confirm(){
|
|
||||||
this.setData({
|
|
||||||
visible: false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user