材料站领料出库orc识别

This commit is contained in:
hongchao 2025-06-29 10:53:46 +08:00
parent aa8e3f7dfa
commit b7bbf03e27
1 changed files with 123 additions and 45 deletions

View File

@ -1,11 +1,11 @@
<template> <template>
<view class="page-container"> <view class="page-container">
<view> <!-- <view>
<live-pusher v-once id="livePusher" ref="livePusher" class="livePusher" mode="FHD" beauty="0" whiteness="0" <live-pusher v-once id="livePusher" ref="livePusher" class="livePusher" mode="FHD" beauty="0" whiteness="0"
device-position="back" :auto-focus="false" :muted="true" :enable-camera="true" :enable-mic="true" device-position="back" :auto-focus="false" :muted="true" :enable-camera="true" :enable-mic="true"
:zoom="true" :style="[{height: '450rpx' ,width:'750rpx'}]"> :zoom="true" :style="[{height: '450rpx' ,width:'750rpx'}]">
</live-pusher> </live-pusher>
</view> </view> -->
<view class="table-list-item"> <view class="table-list-item">
<view class="scan-btn" @click="handleInstruct('shutter')"> <view class="scan-btn" @click="handleInstruct('shutter')">
<text style="color: #FFF;">开始识别</text> <text style="color: #FFF;">开始识别</text>
@ -114,51 +114,129 @@
} }
}); });
}, },
//截屏
handleInstruct(instruct) {
if (this.ready) {
this.ready = false
this.livePusher.snapshot({
success: async (res) => {
console.log('拍照成功', res)
this.ready = true
let base64 = await this.imgToBase64(res.message.tempImagePath)
// console.log('base64', base64)
let params = {
image: base64,
jiju_type: '',
auth_lic:
'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4=',
}
uni.request({
url: '/material/app/ocr/getOcrCode',
method: 'post',
data: params,
header: {
'Content-Type': 'application/json', // 根据后端要求设置请求头,常见的 POST 请求数据格式为 JSON
},
success: (res) => {
console.log('88888888', res)
if (res.data.code == 200 && res.data.data.data.result) {
this.queryCodeParams.maCode = res.data.data.data.result
this.getCode()
} else {
uni.showToast({ title: '扫描失败!', icon: 'none' })
}
},
fail: (err) => {
uni.showToast({
title: err,
icon: 'none',
})
},
})
//this.$emit('getImage', res.message.tempImagePath) handleInstruct() {
}, uni.showActionSheet({
}) itemList: ['拍照', '从相册选择'],
} success: (res) => {
if (res.tapIndex === 0) {
this.getCamera()
} else if (res.tapIndex === 1) {
// 从相册选择
this.getPhoto()
}
},
fail: (err) => {
console.error('操作菜单选择失败:', err)
},
})
},
getCamera() {
console.log(1)
navigator.camera.getPicture(this.onCameraSuccess, this.onCameraError, {
quality: 50,
destinationType: window.Camera.DestinationType.DATA_URL,
sourceType: window.Camera.PictureSourceType.CAMERA,
})
}, },
getPhoto() {
console.log(2)
navigator.camera.getPicture(this.onCameraSuccess, this.onCameraError, {
quality: 50,
destinationType: window.Camera.DestinationType.DATA_URL,
sourceType: window.Camera.PictureSourceType.SAVEDPHOTOALBUM,
})
},
onCameraError(message) {
console.log(message)
},
onCameraSuccess(file) {
// const file1 = "data:image/jpeg;base64," + file;
const file1 = file
let params = {
image: file1,
jiju_type: '',
auth_lic:
'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4=',
}
uni.request({
url: '/material/app/ocr/getOcrCode',
method: 'post',
data: params,
header: {
'Content-Type': 'application/json', // 根据后端要求设置请求头,常见的 POST 请求数据格式为 JSON
},
success: (res) => {
const { data: resData } = res
if (resData.data.data.result) {
this.queryCodeParams.maCode = res.data.data.data.result
this.getCode()
} else {
uni.showToast({
title: '扫描失败!' ,
icon: 'none',
})
}
},
fail: (err) => {
uni.showToast({
title: '请求失败:' + err.errMsg,
icon: 'none',
})
},
})
},
//截屏
// handleInstruct(instruct) {
// if (this.ready) {
// this.ready = false
// this.livePusher.snapshot({
// success: async (res) => {
// console.log('拍照成功', res)
// this.ready = true
// let base64 = await this.imgToBase64(res.message.tempImagePath)
// // console.log('base64', base64)
// let params = {
// image: base64,
// jiju_type: '',
// auth_lic:
// 'xIWDlaDVdijcBB4mjhGCPYk5Kvk8tHZJbUn+vW+ih15+MYx98e/PXyBmKL5gFcWMPznLgDA15QuSAnZQSLddwdy9HkZgtuQDEEZZ351Eyb1eiDUccUnyoSGIrNimbx5TooBNNPYqU4qJeFrPJXAqjBHzRrxoBxuR2CEGKQPgHC4=',
// }
// uni.request({
// url: '/material/app/ocr/getOcrCode',
// method: 'post',
// data: params,
// header: {
// 'Content-Type': 'application/json', // 根据后端要求设置请求头,常见的 POST 请求数据格式为 JSON
// },
// success: (res) => {
// console.log('88888888', res)
// if (res.data.code == 200 && res.data.data.data.result) {
// this.queryCodeParams.maCode = res.data.data.data.result
// this.getCode()
// } else {
// uni.showToast({ title: '扫描失败!', icon: 'none' })
// }
// },
// fail: (err) => {
// uni.showToast({
// title: err,
// icon: 'none',
// })
// },
// })
// //this.$emit('getImage', res.message.tempImagePath)
// },
// })
// }
// },
imgToBase64(filePath) { imgToBase64(filePath) {
// return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {