问题修改

This commit is contained in:
hayu 2025-08-05 21:07:15 +08:00
parent a021fbbc0f
commit 030aa30b97
1 changed files with 110 additions and 108 deletions

View File

@ -119,6 +119,7 @@
<script>
import ImageUtils from "../../services/utils/imageUtils";
import {decryptWithSM4} from "../../utils/sm";
import {getDeviceListAPI} from "../../services/picking/outbound";
export default {
data() {
@ -525,7 +526,6 @@ export default {
console.log("resData.data.result",resData.data.result)
if (resData.code===0){
console.log(111111)
if (resData.data.result) {
this.queryCodeParams.maCode = resData.data.result
await this.closeCamera();
@ -554,55 +554,6 @@ export default {
})
},
})
// const response = await new Promise((resolve, reject)=>
// {
// uni.request({
// url: '/material/app/ocr/getOcrCode',
// method: 'POST',
// data: {
// image: cleanBase64,
// jiju_type: '',
// auth_lic: 'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4='
// },
// header: {
// "Content-Type": "application/json;charset=UTF-8"
// },
// timeout: 30000,
// success: resolve,
// fail: reject
// });
// }
// );
// console.log("response",response);
// console.log("response.data",response.data);
//
// //
// if (response.data?.code === 0) {
// const ocrData = response.data.data;
// if (ocrData?.result) {
// this.queryCodeParams.maCode = ocrData.result;
// await this.closeCamera();
// this.getCode();
// uni.showToast({
// title: '',
// icon: 'success'
// });
// } else {
// uni.showToast({
// title: '',
// icon: 'none'
// });
// }
// } else {
// // HTTP
// const errorMsg = response.data?.msg || 'OCR';
// uni.showToast({
// title: errorMsg,
// icon: 'none'
// });
// }
} catch (error) {
console.error('图片处理或OCR识别失败:', error);
uni.showToast({
@ -682,39 +633,62 @@ export default {
// quality: 50,
// outputFormat: 'base64'
// });
console.log('相册图片处理完成开始OCR识别...');
const response = await new Promise((resolve, reject)=>
{
uni.request({
url: '/material/app/ocr/getOcrCode',
method: 'POST',
data: {
image: processedBase64,
jiju_type: '',
auth_lic: 'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4='
},
timeout: 30000,
success: resolve,
fail: reject
});
}
);
console.log("response",response.data);
if (response.data?.data?.result) {
this.queryCodeParams.maCode = response.data.data.result;
await this.closeCamera();
this.getCode();
uni.showToast({
title: '识别成功',
icon: 'success'
});
} else {
uni.showToast({
title: '未识别到有效编码',
icon: 'none'
});
}
uni.request({
url: '/material/app/ocr/getOcrCode',
method: 'POST',
data: {
image: processedBase64,
jiju_type: '',
auth_lic: 'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4='
},
header: {
"Content-Type": "application/json;charset=UTF-8"
},
success: async (res) => {
if (!res.data.code){
res=JSON.parse(decryptWithSM4(res.data))
} else {
res =res.data
}
console.log("res", res);
console.log("res.data",res.data)
const {data: resData} = res
console.log("resData",resData)
console.log("resData.data",resData.data)
console.log("resData.code",resData.code)
console.log("resData.data.result",resData.data.result)
if (resData.code===0){
if (resData.data.result) {
this.queryCodeParams.maCode = resData.data.result
await this.closeCamera();
await this.getCode();
await uni.showToast({
title: '识别成功',
icon: 'success'
});
} else {
uni.showToast({
title: '识别失败!' + resData.data.msg,
icon: 'none',
})
}
} else {
uni.showToast({
title: '识别失败!',
icon: 'none',
})
}
},
fail: (err) => {
uni.showToast({
title: '请求失败:' + err.errMsg,
icon: 'none',
})
},
});
} catch (error) {
console.error('相册图片处理或OCR识别失败:', error);
uni.showToast({
@ -736,33 +710,61 @@ export default {
return;
}
try {
const response = await new Promise((resolve, reject)=>
{
uni.request({
url: '/material/ma_machine/getHisByCode',
method: 'GET',
data: {maCode: this.queryCodeParams.maCode},
success: resolve,
fail: reject
});
}
)
;
if (response.data?.data && response.data.data.length > 0) {
this.optionList = response.data.data.map(option => ({
value: option.maId,
text: option.maCode
}));
if (response.data.data.length === 1) {
this.codeData = response.data.data[0];
getDeviceListAPI({'maCode': this.queryCodeParams.maCode}).then(response => {
console.log("xxxxxxxxxxx",response)
if (response.data && response.data.length !== 0) {
this.optionList = response.data.data.map(option => ({
value: option.maId,
text: option.maCode
}));
if (response.data.data.length === 1) {
this.codeData = response.data.data[0];
}
}else{
uni.showToast({
title: '未查询到该编号信息',
icon: 'none',
duration: 2000
})
}
} else {
uni.showToast({
title: '未查询到该编号信息',
icon: 'none'
});
}
}).catch(error => {
console.error("获取设备信息失败", error)
uni.hideLoading()
})
// const response = await new Promise((resolve, reject)=>
// {
// uni.request({
// url: '/material/ma_machine/getHisByCode',
// method: 'GET',
// data: {maCode: this.queryCodeParams.maCode},
// success: resolve,
// fail: reject
// });
// }
// )
// ;
// let res;
// if (!response.data.code) {
// res=JSON.parse(decryptWithSM4(res.data))
// } else {
// res =res.data
// }
// console.log("res", res);
// if (response.data?.data && response.data.data.length > 0) {
// this.optionList = response.data.data.map(option => ({
// value: option.maId,
// text: option.maCode
// }));
// if (response.data.data.length === 1) {
// this.codeData = response.data.data[0];
// }
// } else {
// uni.showToast({
// title: '',
// icon: 'none'
// });
// }
} catch (error) {
console.error('查询失败:', error);
uni.showToast({