diff --git a/src/pages/devicesSearch/codeSearch.vue b/src/pages/devicesSearch/codeSearch.vue
index 0784427..017a9e7 100644
--- a/src/pages/devicesSearch/codeSearch.vue
+++ b/src/pages/devicesSearch/codeSearch.vue
@@ -19,13 +19,14 @@
>编码检索
-
+
@@ -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%;
diff --git a/src/pages/devicesSearch/ocrSearch.nvue b/src/pages/devicesSearch/ocrSearch.nvue
index 6bbfedb..8c4b80c 100644
--- a/src/pages/devicesSearch/ocrSearch.nvue
+++ b/src/pages/devicesSearch/ocrSearch.nvue
@@ -1,11 +1,11 @@
-
+
开始识别
@@ -28,6 +28,16 @@
+
+
+
@@ -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
+ })
+ }
}
}
}