ocr查询
This commit is contained in:
parent
287745de4e
commit
22b9b9ab6a
|
|
@ -19,13 +19,14 @@
|
|||
>编码检索</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<div v-if="optionList.length > 1" class="select-container">
|
||||
<div v-if="optionList.length > 1" >
|
||||
<uni-data-select
|
||||
v-model="maId"
|
||||
:localdata="optionList"
|
||||
@change="changeTag"
|
||||
placeholder="请选择相关联编号"
|
||||
class="data-select"
|
||||
:searchable="false"
|
||||
filterable
|
||||
></uni-data-select>
|
||||
</div>
|
||||
</view>
|
||||
|
|
@ -203,6 +204,18 @@ const changeTag = async () => {
|
|||
padding: 0 0;
|
||||
border-top: 1px #eee solid;
|
||||
}
|
||||
|
||||
.select-container :deep(.uni-select__input-text) {
|
||||
white-space: nowrap;
|
||||
text-overflow: clip;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.select-container :deep(.uni-select) {
|
||||
width: auto;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.page-container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<template>
|
||||
<view class="page-container">
|
||||
<view>
|
||||
<!-- <view>
|
||||
<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"
|
||||
:zoom="true" :style="[{height: '350rpx' ,width:'750rpx'}]">
|
||||
</live-pusher>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="table-list-item">
|
||||
<view class="scan-btn" @click="handleInstruct('shutter')">
|
||||
<text style="color: #FFF;">开始识别</text>
|
||||
|
|
@ -28,6 +28,16 @@
|
|||
</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<div v-if="optionList.length > 1" class="select-container">
|
||||
<uni-data-select
|
||||
v-model="queryCodeParams.maId"
|
||||
:localdata="optionList"
|
||||
@change="changeTag"
|
||||
placeholder="请选择相关联编号"
|
||||
class="data-select"
|
||||
:searchable="false"
|
||||
></uni-data-select>
|
||||
</div>
|
||||
</view>
|
||||
<view class="table-list-item">
|
||||
<!-- <scroll-view class="scroll-view" scroll-y="true" style="height: 650rpx;"> -->
|
||||
|
|
@ -86,47 +96,49 @@
|
|||
coverImage: null,
|
||||
queryParams:{},
|
||||
queryCodeParams:{
|
||||
maCode:""
|
||||
maCode:"",
|
||||
maId:""
|
||||
},
|
||||
codeData:{}
|
||||
codeData:{},
|
||||
optionList:[],
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
// this.queryParams = JSON.parse(options.queryParams)
|
||||
// this.queryCodeParams.typeId = this.queryParams.typeId;
|
||||
},
|
||||
onReady() {
|
||||
this.cameraHeight = uni.getSystemInfoSync().screenHeight * 0.22
|
||||
console.log(this.cameraHeight)
|
||||
this.init()
|
||||
},
|
||||
// onReady() {
|
||||
// this.cameraHeight = uni.getSystemInfoSync().screenHeight * 0.22
|
||||
// console.log(this.cameraHeight)
|
||||
// this.init()
|
||||
// },
|
||||
methods: {
|
||||
//初始化相机
|
||||
init() {
|
||||
this.livePusher = uni.createLivePusherContext('livePusher', this);
|
||||
console.log(this.livePusher)
|
||||
setTimeout(() => {
|
||||
this.startPreview()
|
||||
}, 1000)
|
||||
},
|
||||
// init() {
|
||||
// this.livePusher = uni.createLivePusherContext('livePusher', this);
|
||||
// console.log(this.livePusher)
|
||||
// setTimeout(() => {
|
||||
// this.startPreview()
|
||||
// }, 1000)
|
||||
// },
|
||||
// 开始相机
|
||||
startPreview() {
|
||||
this.livePusher.startPreview({
|
||||
success: () => {
|
||||
console.log('相机初始化成功');
|
||||
switch (plus.os.name) {
|
||||
case 'Android':
|
||||
break;
|
||||
case 'iOS':
|
||||
this.livePusher.switchCamera()
|
||||
break
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log(err)
|
||||
}
|
||||
});
|
||||
},
|
||||
// startPreview() {
|
||||
// this.livePusher.startPreview({
|
||||
// success: () => {
|
||||
// console.log('相机初始化成功');
|
||||
// switch (plus.os.name) {
|
||||
// case 'Android':
|
||||
// break;
|
||||
// case 'iOS':
|
||||
// this.livePusher.switchCamera()
|
||||
// break
|
||||
// }
|
||||
// },
|
||||
// fail: (err) => {
|
||||
// console.log(err)
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
//截屏
|
||||
handleInstruct(instruct) {
|
||||
if (this.ready) {
|
||||
|
|
@ -140,27 +152,110 @@
|
|||
})
|
||||
}
|
||||
},
|
||||
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 = resData.data.data.result
|
||||
this.queryCodeParams.maCode = resData.data.data.result
|
||||
this.$nextTick(() => {
|
||||
this.getCode();
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '识别失败!' + resData.data.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showToast({
|
||||
title: '请求失败:' + err.errMsg,
|
||||
icon: 'none',
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
//编码检索
|
||||
async getCode(){
|
||||
let param = {
|
||||
maCode:this.queryCodeParams.maCode,
|
||||
typeId:this.queryCodeParams.typeId,
|
||||
maStatus:1
|
||||
}
|
||||
maCode: this.queryCodeParams.maCode,
|
||||
}
|
||||
uni.request({
|
||||
url: '/material/ma_machine/list',
|
||||
url: '/material/ma_machine/getHisByCode',
|
||||
method: 'get',
|
||||
data: param,
|
||||
success: res => {
|
||||
res = res.data;
|
||||
console.log(res)
|
||||
if(res.rows&&res.rows.length>0){
|
||||
this.codeData=res.rows[0];
|
||||
success: response => {
|
||||
response = response.data;
|
||||
if (response.data && response.data.length !== 0) {
|
||||
this.optionList = response.data.map(option => ({
|
||||
value: option.maId,
|
||||
text: option.maCode
|
||||
}))
|
||||
if(response.data.length === 1){
|
||||
this.codeData = response.data[0]
|
||||
}
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: '未检索到有效的设备编码!',
|
||||
icon: 'none',
|
||||
})
|
||||
title: '未查询到该编号信息',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
|
|
@ -168,12 +263,53 @@
|
|||
console.log(err)
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
changeTag(){
|
||||
if (!this.queryCodeParams.maId) return
|
||||
|
||||
try {
|
||||
let param = {
|
||||
maId: this.queryCodeParams.maId,
|
||||
}
|
||||
uni.request({
|
||||
url: '/material/ma_machine/getHisByCode',
|
||||
method: 'get',
|
||||
data: param,
|
||||
success: response => {
|
||||
response = response.data;
|
||||
if (response.data && response.data.length !== 0) {
|
||||
this.codeData = response.data[0]
|
||||
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: '获取编号信息失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
fail: err => {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("获取编号信息失败", error)
|
||||
uni.showToast({
|
||||
title: '获取信息失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.page-container {
|
||||
display: flex;
|
||||
height: auto;
|
||||
|
|
@ -181,15 +317,80 @@
|
|||
background-color: #f7f8fa;
|
||||
padding: 24rpx;
|
||||
}
|
||||
.table-list-item {
|
||||
|
||||
margin-top: 10rpx;
|
||||
background: #fff;
|
||||
padding: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.table-list-item {
|
||||
background: #fff;
|
||||
padding: 32rpx;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
|
||||
margin-bottom: 24rpx;
|
||||
|
||||
|
||||
:deep(.uni-forms) {
|
||||
.uni-forms-item {
|
||||
margin-bottom: 24rpx;
|
||||
padding: 0;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.uni-forms-item__label {
|
||||
color: #8c8c8c;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
padding: 0;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.uni-forms-item__content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: unset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
:deep(.uni-row) {
|
||||
/* margin-bottom: 20rpx; */
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.uni-col-6 {
|
||||
color: #8c8c8c;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.cont {
|
||||
color: #262626;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
line-height: 1.8;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.uni-easyinput__content) {
|
||||
background-color: #f7f8fa;
|
||||
border: 2rpx solid #e8e8e8;
|
||||
border-radius: 12rpx;
|
||||
height: 75rpx;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:focus-within {
|
||||
border-color: #3784fb;
|
||||
box-shadow: 0 0 0 2rpx rgba(55, 132, 251, 0.1);
|
||||
}
|
||||
|
||||
.uni-easyinput__content-input {
|
||||
font-size: 28rpx;
|
||||
color: #262626;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.scan-btn {
|
||||
/* width: 100%; */
|
||||
height: 88rpx;
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
</view>
|
||||
</view>
|
||||
|
||||
<view> 参数:{{ testParams }} </view>
|
||||
<view> 返回:{{ resData }} </view>
|
||||
<!-- <view> 参数:{{ testParams }} </view>
|
||||
<view> 返回:{{ resData }} </view> -->
|
||||
<view class="table-list-item">
|
||||
<uni-row :gutter="24" style="display: flex; align-items: center">
|
||||
<uni-col :span="5">
|
||||
|
|
|
|||
Loading…
Reference in New Issue