二维码
This commit is contained in:
parent
f521356c3c
commit
c8f62074a3
|
|
@ -24,23 +24,20 @@
|
||||||
<uni-row :gutter="24">
|
<uni-row :gutter="24">
|
||||||
<uni-col :span="6">接收方式:</uni-col>
|
<uni-col :span="6">接收方式:</uni-col>
|
||||||
<uni-col :span="6">
|
<uni-col :span="6">
|
||||||
<view class="coding-btn">编码识别</view>
|
<view class="coding-btn" @tap="onCodeIdentify1">编码识别</view>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
<uni-col :span="6">
|
<uni-col :span="6">
|
||||||
<view class="coding-btn">编码识别</view>
|
<view class="coding-btn" @tap="onCodeIdentify2">二维码识别</view>
|
||||||
</uni-col>
|
|
||||||
<uni-col :span="6">
|
|
||||||
<view class="coding-btn">二维码识别</view>
|
|
||||||
</uni-col>
|
</uni-col>
|
||||||
</uni-row>
|
</uni-row>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="card" style="margin-top: 20px;">
|
<div class="card" style="margin-top: 20px;">
|
||||||
<div>扫码识别</div>
|
<!-- <div>扫码识别</div>
|
||||||
<div style="width: 94%;height: 120px;margin: 10px;border: 1px solid #ccc;">
|
<div style="width: 94%;height: 120px;margin: 10px;border: 1px solid #ccc;">
|
||||||
|
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
|
|
||||||
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
|
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 10px;">
|
||||||
|
|
@ -213,6 +210,67 @@ const uploadImg = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const toBase64 = (path) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
plus.io.resolveLocalFileSystemURL(path, (entry) => {
|
||||||
|
entry.file((file) => {
|
||||||
|
let fileReader = new plus.io.FileReader()
|
||||||
|
fileReader.readAsDataURL(file)
|
||||||
|
fileReader.onloadend = (evt) => {
|
||||||
|
let base64 = evt.target.result.split(",")[1]
|
||||||
|
resolve(base64)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 编码识别按钮
|
||||||
|
const onCodeIdentify1 = () => {
|
||||||
|
console.log('编码识别--')
|
||||||
|
|
||||||
|
// 只允许通过相机扫码
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 1, // 选择一张图片
|
||||||
|
sourceType: ['camera'], // 只允许从相机拍照
|
||||||
|
success: (res) => {
|
||||||
|
const tempFilePath = res.tempFilePaths[0];
|
||||||
|
toBase64(tempFilePath)
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error("选择图片失败", err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 引入百度 OCR API 需要的请求函数
|
||||||
|
const recognizeCode =((imagePath)=>{
|
||||||
|
// 将图片转换为 Base64 格式
|
||||||
|
toBase64(imagePath).then(res=>{
|
||||||
|
callBaiduOcrApi(res);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const onCodeIdentify2 = () => {
|
||||||
|
console.log('二维码识别--')
|
||||||
|
|
||||||
|
// 只允许通过相机扫码
|
||||||
|
uni.scanCode({
|
||||||
|
onlyFromCamera: true,
|
||||||
|
scanType: ['qrCode', 'pdf417'],
|
||||||
|
success: function (res) {
|
||||||
|
console.log('条码类型:' + res.scanType)
|
||||||
|
console.log('条码内容:' + res)
|
||||||
|
maCode.value = res.result;
|
||||||
|
getMaInfo();
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onLoad((options)=>{
|
onLoad((options)=>{
|
||||||
console.log(options)
|
console.log(options)
|
||||||
taskInfo.value = JSON.parse(options.taskInfo)
|
taskInfo.value = JSON.parse(options.taskInfo)
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,10 @@
|
||||||
<uni-row :gutter="24">
|
<uni-row :gutter="24">
|
||||||
<uni-col :span="6">出库方式:</uni-col>
|
<uni-col :span="6">出库方式:</uni-col>
|
||||||
<uni-col :span="6">
|
<uni-col :span="6">
|
||||||
<view class="coding-btn" @tap="onCodeIdentify">编码识别</view>
|
<view class="coding-btn" @tap="onCodeIdentify1">编码识别</view>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
<uni-col :span="6">
|
<uni-col :span="6">
|
||||||
<view class="coding-btn" @tap="onCodeIdentify">编码识别</view>
|
<view class="coding-btn" @tap="onCodeIdentify2">二维码识别</view>
|
||||||
</uni-col>
|
|
||||||
<uni-col :span="6">
|
|
||||||
<view class="coding-btn" @tap="onCodeIdentify">二维码识别</view>
|
|
||||||
</uni-col>
|
</uni-col>
|
||||||
</uni-row>
|
</uni-row>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -170,13 +167,27 @@ const getCodeDeviceListData = async () => {
|
||||||
getCodeDeviceListData()
|
getCodeDeviceListData()
|
||||||
|
|
||||||
// 编码识别按钮
|
// 编码识别按钮
|
||||||
const onCodeIdentify = () => {
|
const onCodeIdentify1 = () => {
|
||||||
console.log('编码识别--')
|
console.log('编码识别--')
|
||||||
|
|
||||||
// 只允许通过相机扫码
|
// 只允许通过相机扫码
|
||||||
uni.scanCode({
|
uni.scanCode({
|
||||||
onlyFromCamera: true,
|
onlyFromCamera: true,
|
||||||
scanType: ['qrCode', 'pdf417'],
|
scanType: ['qrCode'],
|
||||||
|
success: function (res) {
|
||||||
|
console.log('条码类型:' + res.scanType)
|
||||||
|
console.log('条码内容:' + res.result)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 二维码识别按钮
|
||||||
|
const onCodeIdentify2 = () => {
|
||||||
|
console.log('二维码识别--')
|
||||||
|
|
||||||
|
// 只允许通过相机扫码
|
||||||
|
uni.scanCode({
|
||||||
|
onlyFromCamera: true,
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
console.log('条码类型:' + res.scanType)
|
console.log('条码类型:' + res.scanType)
|
||||||
console.log('条码内容:' + res.result)
|
console.log('条码内容:' + res.result)
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,19 @@
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="new-purchase">
|
||||||
|
<view
|
||||||
|
class="purchase-item"
|
||||||
|
:key="index"
|
||||||
|
@tap="onNavigateTo(item.url)"
|
||||||
|
v-for="(item, index) in backList"
|
||||||
|
>
|
||||||
|
<image :src="item.iconSrc" mode="scaleToFill" />
|
||||||
|
<text>
|
||||||
|
{{ item.title }}
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -82,6 +95,15 @@ const repairList = ref([
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// 退料
|
||||||
|
const backList = ref([
|
||||||
|
{
|
||||||
|
title: '退料',
|
||||||
|
url: '/pages/back/index',
|
||||||
|
iconSrc: '../../static/workbench/fix.png',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
const onNavigateTo = (url) => {
|
const onNavigateTo = (url) => {
|
||||||
uni.navigateTo({ url })
|
uni.navigateTo({ url })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue