This commit is contained in:
@zuopngfei 2025-07-21 18:14:53 +08:00
parent 1f115d390e
commit 49c0136bff
8 changed files with 93 additions and 29 deletions

65
api/ocr.js Normal file
View File

@ -0,0 +1,65 @@
export const getOcr = (url) => {
return new Promise((resolve, reject) => {
wx.request({
url: 'https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions',
method: 'POST',
dataType: 'json', // 微信官方文档中介绍会对数据进行一次JSON.parse
header: {
'Authorization': 'Bearer sk-52414b887aee47e4883caf16cbf801bd',
'Content-Type': 'application/json'
},
data: {
"model": "qwen-vl-ocr-latest",
"messages": [{
"role": "user",
"content": [{
"type": "image_url",
"image_url": {
"url": url
},
"min_pixels": 3136,
"max_pixels": 6422528
},
{
"type": "text",
"text": "要求准确无误的提取上述关键信息、不要遗漏和捏造虚假信息,模糊或者强光遮挡的单个文字可以用英文问号?代替。返回数据格式以MD方式输出"
}
]
}]
},
success(res) {
const data = parseMarkdownTable(res.data.choices[0].message.content)
resolve(data);
},
fail(err) {
console.log(err)
// 断网、服务器挂了都会fail回调直接reject即可
reject(err);
},
});
})
}
function parseMarkdownTable(md) {
// 拆分行,去掉空行
const lines = md.split('\n').filter(line => line.trim().length > 0);
// 找到表头和数据行
const headerLine = lines[0];
const header = headerLine.split('|').map(h => h.trim()).filter(Boolean);
// 数据行从第三行开始(第二行为分隔符)
const dataLines = lines.slice(2);
// 解析每一行
const result = dataLines.map(line => {
const cells = line.split('|').map(cell => cell.trim()).filter(Boolean);
const obj = {};
header.forEach((key, idx) => {
obj[key] = cells[idx];
});
return obj;
});
return result;
}

View File

@ -11,7 +11,7 @@ export function resetTokenInvalid() {
function request(url, method = 'GET', data = {}) {
// 如果 token 已失效,直接中断请求
if (isTokenInvalid) {
if (isTokenInvalid && wx.getStorageSync('access_token')) {
return Promise.reject({ code: 10103, message: '登录已失效,请重新登录' });
}
const header = {

View File

@ -1,4 +1,6 @@
import request from '~/api/request';
import { getOcr } from '~/api/ocr';
Page({
/**
@ -313,6 +315,7 @@ Page({
wx.showToast({ title: '上传失败!', icon: 'none' });
console.error('上传失败:', error); // 输出具体的错误信息
} else {
// getOcr(data)
wx.showToast({ title: '上传成功!', icon: 'success' });
const { mode } = e.currentTarget.dataset;
let arr = this.data.form[mode]
@ -320,7 +323,7 @@ Page({
this.setData({
[`form.${mode}`]: arr
})
getOcr(data)
console.log('上传成功:', data); // 输出上传成功后的数据
}
});

View File

@ -1,8 +1,6 @@
.page {
background-color: rgba(255,255,255,1.000000);
position: relative;
width: 750rpx;
height: 1624rpx;
overflow: hidden;
display: flex;
flex-direction: column;
@ -83,7 +81,7 @@
font-size: 40rpx;
margin-right: 8rpx;
width: 50rpx;
transform: translateY(4rpx);
// transform: translateY(4rpx);
}
.text-group_2 {
overflow-wrap: break-word;
@ -133,7 +131,7 @@
height: 32rpx;
display: flex;
flex-direction: column;
margin: 2rpx 0 0 0;
margin: 6rpx 0 0 0;
}
.text_3 {
overflow-wrap: break-word;
@ -145,6 +143,7 @@
white-space: nowrap;
line-height: 32rpx;
margin: 2rpx 0 0 34rpx;
transform: translateY(4rpx);
}
.text-wrapper_1 {
background-color: rgba(0,91,162,1.000000);

View File

@ -1,9 +1,6 @@
<view class="page">
<view class="box_1">
<image src="https://lanhu-oss-2537-2.lanhuapp.com/SketchPngc7eafd88f05e3acc51a4c7ba25ac5d8858a9aaac00d7c68d603489d8e173d890" class="image_1"></image>
<view class="image-wrapper_1">
<image src="https://lanhu-oss-2537-2.lanhuapp.com/SketchPngf1d54de0848dc82606ca0a16f317ad38594ba02bce6208c871534a0b25940b90" class="image_2"></image>
<image src="https://lanhu-oss-2537-2.lanhuapp.com/SketchPng2e60a3b7b2cf506a5f57e1f715583164f2b1c3ebfdb48ed093bfea66a8490f11" class="image_3"></image>
</view>
</view>
<view class="box_2">

View File

@ -108,10 +108,10 @@ Page({
})
},
goQuestionnaire(e) {
const data = this.data.dataList
const target = data.find(item => item.questionnaire_id === 0 && item.status === 2);
// const data = this.data.dataList
// const target = data.find(item => item.questionnaire_id == 0 && item.status == 2);
wx.navigateTo({
url: `/pages/followUp/index?planId=${target.id}&name=&time=&questionnaire_id=0` ,
url: `/pages/followUp/index?planId=0&name=&time=&questionnaire_id=0` ,
})
},
toRegister() {

View File

@ -220,15 +220,18 @@
// margin: -76rpx 170rpx 0 88rpx;
}
.group_1 {
width: 270rpx;
margin-top: 22rpx;
// width: 270rpx;
// background-color: rgba(208,15,22,0.100000);
border-radius: 28rpx;
border: 1px solid rgba(255,255,255,1);
padding-left: 20rpx;
flex-direction: row;
display: flex;
// flex-direction: row;
width: 300rpx;
display: inline-flex;
// width: auto;
justify-content: space-between;
margin: 22rpx 82rpx 0 0;
// margin: 22rpx 82rpx 0 0;
}
.success{
background-color: rgba(43, 164, 113, 0.1);
@ -268,32 +271,29 @@
}
.image-text_4 {
width: 188rpx;
flex-direction: row;
display: flex;
justify-content: space-between;
margin: 14rpx 0 14rpx 0;
// width: 188rpx;
margin: 8rpx 0 8rpx 0;
}
.thumbnail_1 {
color: rgba(212,48,48,1);
transform: translateY(-2rpx);
margin-right: 8rpx;
}
.text-group_5 {
overflow-wrap: break-word;
color: rgba(212,48,48,1);
font-size: 24rpx;
font-family: Alibaba-PuHuiTi-R;
font-weight: normal;
text-align: left;
white-space: nowrap;
line-height: 24rpx;
line-height: 26rpx;
}
.text-wrapper_2 {
border-radius: 28rpx;
border: 1px solid rgba(255,255,255,1);
display: flex;
flex-direction: column;
padding: 12rpx 22rpx 12rpx 22rpx;
width: 80rpx;
// height: 60rpx;
align-items: center;
justify-content: center;
margin-left: 12rpx;
}
.text_6 {

View File

@ -38,7 +38,7 @@
<view class="text-wrapper_2" wx:if="{{personalInfo.risk_type == 2}}">
<text lines="1" class="text_6">中危</text>
</view>
<view class="text-wrapper_2" wx:if="{{personalInfo.risk_type == 3}}">
<view class="text-wrapper_2" >
<text lines="1" class="text_6">高危</text>
</view>