You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

107 lines
2.4 KiB

<!--扫描组件-->
<template>
<view>
<view class="conbox">
<textarea v-model="scanMsg" :focus="boxfocus" trim="all" @keydown.enter="handelScanMsg" @focus="getfocus"
maxlength="1000" :placeholder="placeholder" @blur="blurfocus"></textarea>
</view>
<view class="uni-flex">
<button class="clean_scan_btn" @click="cancelClick()">清空</button>
<button class="scan_btn" @click="scanClick()">扫描</button>
</view>
</view>
<!-- <view class="conbox">
<uni-easyinput ref='scanInput' :inputBorder="false" :focus="boxfocus" v-model="scanMsg"
:class="`myinput ${boxfocus == true ?'inputfocus':''}`" @focus="getfocus" @blur="blurfocus" maxlength='512'
@iconClick="iconclick" @confirm="handelScanMsg" :placeholder="placeholder" placeholderStyle="font-size:16px"
style='font-size: 18px;'>
</uni-easyinput>
<comMessage ref="comMessage"></comMessage>
</view> -->
</template>
<script>
import {
analyseTJMesQRCode
} from '@/common/scan.js';
import comMessage from '@/mycomponents/common/comMessage.vue'
export default {
name: "scantjmes",
components: {
comMessage
},
props: {
placeholder: {
type: String,
default: '请扫描标签'
},
clearResult: {
type: Boolean,
default: true
},
boxFocus: {
type: Boolean,
default: true
}
},
data() {
return {
scanMsg: "",
items: null,
boxfocus: this.boxFocus,
}
},
created() {
},
methods: {
handelScanMsg() {
let that = this;
if (that.scanMsg == "")
return;
setTimeout(() => {
let content = that.scanMsg.replace(/[\r\n]/g, "");
let scanResult = analyseTJMesQRCode(content);
if (scanResult.sucess) {
if (that.clearResult) {
that.clear();
}
that.boxfocus = true;
that.$emit("getScanResult", scanResult);
} else {
this.showMessage(scanResult.message);
}
}, 100)
},
scanClick() {
this.handelScanMsg();
},
cancelClick() {
this.scanMsg = ""
},
getfocus() {
this.boxfocus = true;
this.$nextTick(r => {
this.boxfocus = true;
});
},
blurfocus() {
this.boxfocus = false;
},
clear() {
let that = this;
that.scanMsg = ''
that.boxfocus = true;
},
iconClick(type) {
this.$emit("clearResult", this.scanMsgk);
},
showMessage(message) {
this.$refs.comMessage.showMessage(message);
},
}
}
</script>
<style scoped lang="scss">
</style>