提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
USB连接扫码枪进行扫码,亲测有效
一、代码
代码如下(示例):
<template>
<view class="">
<view>
<input type="text" :focus="isFocus" v-model="inputValue" @input="inputChange" confirm-type="done" @confirm="inputChangeconfirm()" placeholder="请扫描录入" >
</view>
<view @click="empty" v-if="inputValue!=''">
扫
</view>
</view>
</template>
<script>
export default {
data() {
return {
inputValue:'',
}
},
onLoad(options) {
this.title=options.title
plus.key.addEventListener('keydown',this.getkeyCodes())
},
onHide() {
},
methods: {
getkeyCodes(event) {
this.keyCodes = event.keyCode;
},
// 扫描录入的变化
async inputChange(event) {
if (this.keyCodes == 302 || this.keyCodes == 303) {
let inputData = event.target.value;
console.log(inputData == null, inputData == undefined, inputData == '')
if (inputData == null || inputData == undefined || inputData == '') {
return;
}
this.inputValue = inputData;
this.checkWorkCardNo(this.inputValue);
}
},
inputChangeconfirm() {
if (this.inputValue == null || this.inputValue == undefined || this.inputValue == '') {
return;
}
this.checkWorkCardNo(this.inputValue);
},
loading() {
uni.showLoading({
title: '加载中...'
})
},
// 清空后自动聚焦
empty() {
this.inputValue = '';
this.isFocus = false
this.$nextTick(() => {
this.isFocus = true
})
},
checkWorkCardNo(inputValue) {
console.log(inputValue, 'inputValue')
this.loading();
this.$http.binscan.checkWorkCardNo({
work_card_no: inputValue,
receipt_type: 2,
position_house_id: this.userInfo.position_house_id,
position_house_name: this.userInfo.select
}).then(res => {
this.keyCodes = null;
uni.hideLoading();
if (res.code == 200) {
if (res.data.list <= 0) {
return;
}
correct();
this.disableds = false;
this.workOrderData = res.data.list;
this.goodsName = res.data.goods_name;
this.qu = res.data.qu;
this.work_card_no = this.inputValue;
} else {
this.isMask = true;
this.content = res.msg;
warning();
}
}).catch(err => {
uni.hideLoading();
this.keyCodes = null;
this.isMask = true;
this.content = err.msg;
warning()
})
}
},
}
</script>
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。
该博客分享了如何在uni-app中使用USB连接扫码枪进行扫码操作,提供了有效的代码示例。
6871

被折叠的 条评论
为什么被折叠?



