标准箱识别
This commit is contained in:
parent
0694c4c573
commit
b5ba331df0
|
|
@ -0,0 +1,64 @@
|
||||||
|
<template>
|
||||||
|
<!-- 该组件无实际 DOM 结构 -->
|
||||||
|
<div style="display: none;"></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { onMounted } from 'vue'
|
||||||
|
// 定义自定义事件
|
||||||
|
const emit = defineEmits(['scanSuccessBox', 'scanErrorBox'])
|
||||||
|
|
||||||
|
// 扫描二维码方法
|
||||||
|
const scanQrCode = () => {
|
||||||
|
console.log("扫一扫");
|
||||||
|
console.log("window对象", window);
|
||||||
|
|
||||||
|
document.addEventListener("deviceready", onDeviceReady.bind(this), false);
|
||||||
|
|
||||||
|
function onDeviceReady() {
|
||||||
|
// Cordova is now initialized. Have fun!
|
||||||
|
console.log(
|
||||||
|
"Running cordova-" +
|
||||||
|
window.cordova.platformId +
|
||||||
|
"@" +
|
||||||
|
window.cordova.version
|
||||||
|
);
|
||||||
|
window.cordova.plugins.barcodeScanner.scan(
|
||||||
|
function (result) {
|
||||||
|
emit('scanSuccessBox', result)
|
||||||
|
console.log("success");
|
||||||
|
console.log(result);
|
||||||
|
}.bind(this),
|
||||||
|
function (error) {
|
||||||
|
emit('scanErrorBox', new Error(`扫描失败: ${error}`))
|
||||||
|
console.log("error");
|
||||||
|
console.log(error);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
preferFrontCamera: false, // 是否默认使用前置摄像头(同时支持 iOS 和 Android)
|
||||||
|
showFlipCameraButton: true, // 是否显示前后摄像头切换按钮(同时支持 iOS 和 Android)
|
||||||
|
showTorchButton: true, // 是否显示打开关闭闪光灯按钮(同时支持 iOS 和 Android)
|
||||||
|
torchOn: false, // 是否默认打开闪关灯(仅支持 Android)
|
||||||
|
saveHistory: true, // 是否记录扫码历史(仅支持 Android)
|
||||||
|
prompt: "请扫描二维码", // 扫码界面下方提示语(仅支持 Android)
|
||||||
|
resultDisplayDuration: 500, // 扫码文本在扫码界面上显示多少毫秒。0完全禁用。默认1500(仅Android)
|
||||||
|
formats: "QR_CODE,PDF_417", // 支持的格式,默认为除PDF_417和RSS_EXPANDED之外的所有格式
|
||||||
|
orientation: "portrait", // 设置为横向或纵向(portrait|landscape),默认跟随手机旋转(仅Android)
|
||||||
|
disableAnimations: true, // 禁用动画(仅支持 iOS)
|
||||||
|
disableSuccessBeep: false, // 禁用成功蜂鸣声(同时支持 iOS 和 Android)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 暴露扫描方法
|
||||||
|
defineExpose({
|
||||||
|
scanQrCode
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (!window.cordova) {
|
||||||
|
console.warn('Cordova 未加载,二维码扫描功能可能不可用')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
@ -48,6 +48,11 @@
|
||||||
@scanSuccess="handleScanSuccess"
|
@scanSuccess="handleScanSuccess"
|
||||||
@scanError="handleScanError"
|
@scanError="handleScanError"
|
||||||
/>
|
/>
|
||||||
|
<ScanQrCodeBox
|
||||||
|
ref="scanQrCodeRefBox"
|
||||||
|
@scanSuccess="handleScanSuccessBox"
|
||||||
|
@scanError="handleScanErrorBox"
|
||||||
|
/>
|
||||||
<view class="table-list-item">
|
<view class="table-list-item">
|
||||||
<uni-row :gutter="24" style="display: flex; align-items: center">
|
<uni-row :gutter="24" style="display: flex; align-items: center">
|
||||||
<uni-col :span="6">
|
<uni-col :span="6">
|
||||||
|
|
@ -139,9 +144,11 @@ import {
|
||||||
import { getBoxBindByCode } from '@/services/standard.js'
|
import { getBoxBindByCode } from '@/services/standard.js'
|
||||||
import { debounce } from 'lodash-es'
|
import { debounce } from 'lodash-es'
|
||||||
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
|
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
|
||||||
|
import ScanQrCodeBox from '@/pages/devicesSearch/ScanQrCodeBox.vue'
|
||||||
// const query = defineProps() // 获取上级页面传递的路由参数
|
// const query = defineProps() // 获取上级页面传递的路由参数
|
||||||
// const queryParams = JSON.parse(query.queryParams)
|
// const queryParams = JSON.parse(query.queryParams)
|
||||||
const scanQrCodeRef = ref(null)
|
const scanQrCodeRef = ref(null)
|
||||||
|
const scanQrCodeRefBox = ref(null)
|
||||||
const queryParams = ref({})
|
const queryParams = ref({})
|
||||||
const formData = ref({})
|
const formData = ref({})
|
||||||
const codeDeviceList = ref([])
|
const codeDeviceList = ref([])
|
||||||
|
|
@ -295,39 +302,59 @@ const boxScan = async () => {
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
boxCode.value = ''
|
boxCode.value = ''
|
||||||
var mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
|
// var mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
|
||||||
mpaasScanModule.mpaasScan(
|
// mpaasScanModule.mpaasScan(
|
||||||
{
|
// {
|
||||||
// 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
|
// // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
|
||||||
scanType: ['qrCode', 'barCode'],
|
// scanType: ['qrCode', 'barCode'],
|
||||||
// 是否隐藏相册,默认false不隐藏
|
// // 是否隐藏相册,默认false不隐藏
|
||||||
hideAlbum: false,
|
// hideAlbum: false,
|
||||||
//ios需要设置这个参数,只支持中英文 zh-Hans、en,默认中文
|
// //ios需要设置这个参数,只支持中英文 zh-Hans、en,默认中文
|
||||||
language: 'en',
|
// language: 'en',
|
||||||
//相册选择照片识别错误提示(ios)
|
// //相册选择照片识别错误提示(ios)
|
||||||
failedMsg: '未识别到二维码,请重试',
|
// failedMsg: '未识别到二维码,请重试',
|
||||||
//Android支持全屏需要设置此参数
|
// //Android支持全屏需要设置此参数
|
||||||
screenType: 'full',
|
// screenType: 'full',
|
||||||
},
|
// },
|
||||||
(ret) => {
|
// (ret) => {
|
||||||
if (ret.resp_code == 10) {
|
// if (ret.resp_code == 10) {
|
||||||
uni.showToast({ title: '用户取消', icon: 'none' })
|
// uni.showToast({ title: '用户取消', icon: 'none' })
|
||||||
}
|
// }
|
||||||
if (ret.resp_code == 11) {
|
// if (ret.resp_code == 11) {
|
||||||
uni.showToast({ title: '扫码失败', icon: 'none' })
|
// uni.showToast({ title: '扫码失败', icon: 'none' })
|
||||||
}
|
// }
|
||||||
if (ret.resp_code == 1000) {
|
// if (ret.resp_code == 1000) {
|
||||||
boxCode.value = ret.resp_result
|
// boxCode.value = ret.resp_result
|
||||||
if (boxCode.value == '') {
|
// if (boxCode.value == '') {
|
||||||
uni.showToast({ title: '扫码识别失败', icon: 'none' })
|
// uni.showToast({ title: '扫码识别失败', icon: 'none' })
|
||||||
} else {
|
// } else {
|
||||||
boxOut()
|
// boxOut()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
)
|
// )
|
||||||
|
if (scanQrCodeRefBox.value) {
|
||||||
|
scanQrCodeRefBox.value.scanQrCode()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理扫描成功事件
|
||||||
|
const handleScanSuccessBox = (result) => {
|
||||||
|
boxCode.value = result?.text || ''
|
||||||
|
if (boxCode.value === '') {
|
||||||
|
uni.showToast({ title: '扫码识别失败', icon: 'none' })
|
||||||
|
} else {
|
||||||
|
boxOut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理扫描失败事件
|
||||||
|
const handleScanErrorBox = (error) => {
|
||||||
|
console.error('扫描出错:', error.message)
|
||||||
|
uni.showToast({ title: error.message, icon: 'none' })
|
||||||
|
}
|
||||||
|
|
||||||
// 标准箱出库确认
|
// 标准箱出库确认
|
||||||
const boxOut = async () => {
|
const boxOut = async () => {
|
||||||
console.log(queryParams)
|
console.log(queryParams)
|
||||||
|
|
@ -477,6 +504,9 @@ const handleScanError = (error) => {
|
||||||
console.error('扫描出错:', error.message)
|
console.error('扫描出错:', error.message)
|
||||||
uni.showToast({ title: error.message, icon: 'none' })
|
uni.showToast({ title: error.message, icon: 'none' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//查看是否是该规格型号
|
//查看是否是该规格型号
|
||||||
const getMaInfoScan = async () => {
|
const getMaInfoScan = async () => {
|
||||||
let param = {
|
let param = {
|
||||||
|
|
|
||||||
|
|
@ -128,14 +128,15 @@ const onClick=(e,item)=> {
|
||||||
content: '是否确认接收?',
|
content: '是否确认接收?',
|
||||||
confirmText: '确定',
|
confirmText: '确定',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
success: async (res) => {
|
success: async (modalRes) => {
|
||||||
if (res.confirm) {
|
if (modalRes.confirm) {
|
||||||
let param = {
|
let param = {
|
||||||
boxId:item.boxId
|
boxId:item.boxId
|
||||||
}
|
}
|
||||||
// console.log(param)
|
|
||||||
const res = await appReceiveApi(param)
|
const res = await appReceiveApi(param)
|
||||||
if (res.code === 200) {
|
console.log("yyyyyyyyyyy",res)
|
||||||
|
if (res.code == 200) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '接收成功',
|
title: '接收成功',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
|
|
@ -144,6 +145,7 @@ const onClick=(e,item)=> {
|
||||||
getTableList(true)
|
getTableList(true)
|
||||||
}, 500)
|
}, 500)
|
||||||
}else{
|
}else{
|
||||||
|
console.log("xxxxxxxxxxxxxxxxxxxxxxxxx")
|
||||||
uni.showToast({ title: '接收失败', icon: 'none' })
|
uni.showToast({ title: '接收失败', icon: 'none' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +304,7 @@ const finish = computed(() => {
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.page-container {
|
.page-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 100%;
|
height: 100vh;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background-color: #f7f8fa;
|
background-color: #f7f8fa;
|
||||||
padding: 24rpx;
|
padding: 24rpx;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,11 @@
|
||||||
</uni-forms>
|
</uni-forms>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ScanQrCode
|
||||||
|
ref="scanQrCodeRef"
|
||||||
|
@scanSuccess="handleScanSuccess"
|
||||||
|
@scanError="handleScanError"
|
||||||
|
/>
|
||||||
<div class="btn">
|
<div class="btn">
|
||||||
<button class="btn-cont" @click="backPage">取消</button>
|
<button class="btn-cont" @click="backPage">取消</button>
|
||||||
<button class="btn-cont" @click="pass">创建</button>
|
<button class="btn-cont" @click="pass">创建</button>
|
||||||
|
|
@ -34,27 +39,46 @@ import { onLoad,onShow } from '@dcloudio/uni-app'
|
||||||
import { innerVerify } from '../../services/purchase.js';
|
import { innerVerify } from '../../services/purchase.js';
|
||||||
import { appCreateBoxApi } from '../../services/standard.js';
|
import { appCreateBoxApi } from '../../services/standard.js';
|
||||||
import { baseURL } from '@/utils/http'
|
import { baseURL } from '@/utils/http'
|
||||||
|
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
|
||||||
const formData = ref({})
|
const formData = ref({})
|
||||||
|
const scanQrCodeRef = ref(null)
|
||||||
// 编码识别按钮
|
// 编码识别按钮
|
||||||
const scanStart = () => {
|
const scanStart = () => {
|
||||||
console.log('编码识别--')
|
console.log('编码识别--')
|
||||||
// 只允许通过相机扫码
|
// // 只允许通过相机扫码
|
||||||
uni.scanCode({
|
// uni.scanCode({
|
||||||
onlyFromCamera: true,
|
// onlyFromCamera: true,
|
||||||
scanType: ['qrCode', 'pdf417'],
|
// scanType: ['qrCode', 'pdf417'],
|
||||||
success: (res) => {
|
// success: (res) => {
|
||||||
console.log('扫码结果:' + res.result)
|
// console.log('扫码结果:' + res.result)
|
||||||
formData.value.boxCode = res.result
|
// formData.value.boxCode = res.result
|
||||||
},
|
// },
|
||||||
fail: (err) => {
|
// fail: (err) => {
|
||||||
// uni.showToast({
|
// // uni.showToast({
|
||||||
// title: '取消',
|
// // title: '取消',
|
||||||
// icon: 'none'
|
// // icon: 'none'
|
||||||
// });
|
// // });
|
||||||
},
|
// },
|
||||||
})
|
// })
|
||||||
|
if (scanQrCodeRef.value) {
|
||||||
|
scanQrCodeRef.value.scanQrCode()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理扫描成功事件
|
||||||
|
const handleScanSuccess = (result) => {
|
||||||
|
formData.value.boxCode = result?.text || ''
|
||||||
|
if (formData.value.boxCode === '') {
|
||||||
|
uni.showToast({ title: '扫码识别失败', icon: 'none' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理扫描失败事件
|
||||||
|
const handleScanError = (error) => {
|
||||||
|
console.error('扫描出错:', error.message)
|
||||||
|
uni.showToast({ title: error.message, icon: 'none' })
|
||||||
|
}
|
||||||
|
|
||||||
//确认
|
//确认
|
||||||
const pass = () => {
|
const pass = () => {
|
||||||
if(formData.value.boxName==""){
|
if(formData.value.boxName==""){
|
||||||
|
|
@ -94,11 +118,11 @@ onLoad((options)=>{
|
||||||
// formData.value = JSON.parse(options.item)
|
// formData.value = JSON.parse(options.item)
|
||||||
})
|
})
|
||||||
// 页面加载完毕
|
// 页面加载完毕
|
||||||
onShow(() => {
|
// onShow(() => {
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
scanStart()
|
// scanStart()
|
||||||
}, 500)
|
// }, 500)
|
||||||
})
|
// })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,11 @@
|
||||||
<button class="btn-cont" style="width: 90%;" @click="transfer">移交</button>
|
<button class="btn-cont" style="width: 90%;" @click="transfer">移交</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ScanQrCode
|
||||||
|
ref="scanQrCodeRef"
|
||||||
|
@scanSuccess="handleScanSuccess"
|
||||||
|
@scanError="handleScanError"
|
||||||
|
/>
|
||||||
|
|
||||||
<uni-popup ref="keeperPopup" type="bottom" border-radius="10px 10px 0 0">
|
<uni-popup ref="keeperPopup" type="bottom" border-radius="10px 10px 0 0">
|
||||||
<view class="keeper-popup">
|
<view class="keeper-popup">
|
||||||
|
|
@ -102,6 +106,8 @@ import { onLoad,onShow } from '@dcloudio/uni-app'
|
||||||
import { getAppBoxDetailListApi,appBindMaCodeApi,appUnbindMaCodeApi,getTransferKeepsListApi,appTransferApi } from '../../services/standard.js';
|
import { getAppBoxDetailListApi,appBindMaCodeApi,appUnbindMaCodeApi,getTransferKeepsListApi,appTransferApi } from '../../services/standard.js';
|
||||||
import { getMaCodeByQrCodeApi } from '@/services/index.js';
|
import { getMaCodeByQrCodeApi } from '@/services/index.js';
|
||||||
import { baseURL } from '@/utils/http'
|
import { baseURL } from '@/utils/http'
|
||||||
|
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
|
||||||
|
const scanQrCodeRef = ref(null)
|
||||||
const keeperPopup = ref(null);
|
const keeperPopup = ref(null);
|
||||||
const searchValue = ref('')
|
const searchValue = ref('')
|
||||||
const boxInfo = ref({})
|
const boxInfo = ref({})
|
||||||
|
|
@ -136,33 +142,55 @@ const getCodeList = () => {
|
||||||
// 扫码识别按钮
|
// 扫码识别按钮
|
||||||
// 二维码扫码
|
// 二维码扫码
|
||||||
const scanStart = async () => {
|
const scanStart = async () => {
|
||||||
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
|
// var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
|
||||||
mpaasScanModule.mpaasScan({
|
// mpaasScanModule.mpaasScan({
|
||||||
// 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
|
// // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
|
||||||
'scanType': ['qrCode','barCode'],
|
// 'scanType': ['qrCode','barCode'],
|
||||||
// 是否隐藏相册,默认false不隐藏
|
// // 是否隐藏相册,默认false不隐藏
|
||||||
'hideAlbum': false,
|
// 'hideAlbum': false,
|
||||||
//ios需要设置这个参数,只支持中英文 zh-Hans、en,默认中文
|
// //ios需要设置这个参数,只支持中英文 zh-Hans、en,默认中文
|
||||||
'language' : 'en',
|
// 'language' : 'en',
|
||||||
//相册选择照片识别错误提示(ios)
|
// //相册选择照片识别错误提示(ios)
|
||||||
'failedMsg': '未识别到二维码,请重试',
|
// 'failedMsg': '未识别到二维码,请重试',
|
||||||
//Android支持全屏需要设置此参数
|
// //Android支持全屏需要设置此参数
|
||||||
'screenType': 'full'
|
// 'screenType': 'full'
|
||||||
},(ret) => {
|
// },(ret) => {
|
||||||
console.log(ret)
|
// console.log(ret)
|
||||||
if(ret.resp_code==10){
|
// if(ret.resp_code==10){
|
||||||
uni.showToast({ title: '用户取消', icon: 'none' })
|
// uni.showToast({ title: '用户取消', icon: 'none' })
|
||||||
}
|
// }
|
||||||
if(ret.resp_code==11){
|
// if(ret.resp_code==11){
|
||||||
uni.showToast({ title: '扫码失败', icon: 'none' })
|
// uni.showToast({ title: '扫码失败', icon: 'none' })
|
||||||
}
|
// }
|
||||||
if(ret.resp_code==1000){
|
// if(ret.resp_code==1000){
|
||||||
let qrCode = ret.resp_result.split("qrcode=")[1];
|
// let qrCode = ret.resp_result.split("qrcode=")[1];
|
||||||
bindMa(qrCode)
|
// bindMa(qrCode)
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
|
if (scanQrCodeRef.value) {
|
||||||
|
scanQrCodeRef.value.scanQrCode()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理扫描成功事件
|
||||||
|
const handleScanSuccess = (result) => {
|
||||||
|
const qrCode = result?.text || '';
|
||||||
|
if (qrCode === '') {
|
||||||
|
uni.showToast({ title: '扫码识别失败', icon: 'none' })
|
||||||
|
} else {
|
||||||
|
// 原代码中 split 处理逻辑
|
||||||
|
const actualQrCode = qrCode.split("qrcode=")[1] || qrCode;
|
||||||
|
bindMa(actualQrCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理扫描失败事件
|
||||||
|
const handleScanError = (error) => {
|
||||||
|
console.error('扫描出错:', error.message)
|
||||||
|
uni.showToast({ title: error.message, icon: 'none' })
|
||||||
|
}
|
||||||
|
|
||||||
//绑定接口
|
//绑定接口
|
||||||
const bindMa = (qrCode) => {
|
const bindMa = (qrCode) => {
|
||||||
console.log(qrCode)
|
console.log(qrCode)
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,7 @@ const confirmTransfer = () => {
|
||||||
|
|
||||||
let param = {
|
let param = {
|
||||||
"boxId":transferItem.value.boxId,
|
"boxId":transferItem.value.boxId,
|
||||||
"transferUser":transferUser.value,
|
"inputUser":transferUser.value,
|
||||||
}
|
}
|
||||||
console.log(param)
|
console.log(param)
|
||||||
appTransferApi(param).then(res => {
|
appTransferApi(param).then(res => {
|
||||||
|
|
@ -353,7 +353,7 @@ const finish = computed(() => {
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.page-container {
|
.page-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 100%;
|
height: 100vh;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background-color: #f7f8fa;
|
background-color: #f7f8fa;
|
||||||
padding: 24rpx;
|
padding: 24rpx;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue