Commit 24d76fdc by zhuxiaomei

条码扫描

parent 68123ecd
...@@ -57,13 +57,17 @@ ...@@ -57,13 +57,17 @@
barcode = null; barcode = null;
let that = this; let that = this;
if (!barcode) { if (!barcode) {
barcode = new plus.barcode.Barcode('bcid', [plus.barcode.CODE128], { barcode = new plus.barcode.Barcode('bcid', [plus.barcode.EAN13], {
frameColor: '#00FF00', frameColor: '#00FF00',
scanbarColor: '#00FF00' scanbarColor: '#00FF00'
}); });
barcode.onmarked = function (type, result) { barcode.onmarked = function (type, result) {
if (type === plus.barcode.CODE128) { if (type === plus.barcode.EAN13) {
that._getSample(result) that._getSample(result)
}else{
that.$toast('扫描失败!')
barcode.close()
that._open()
} }
}; };
plus.webview.currentWebview().append(barcode); plus.webview.currentWebview().append(barcode);
...@@ -71,17 +75,14 @@ ...@@ -71,17 +75,14 @@
barcode.start(); barcode.start();
}) })
}, },
_getSample: async function (data) { _getSample: async function (qrcode) {
console.log(data,'data') let res = await samplingSample.scanSample({qrcode: qrcode})
let res = await samplingSample.scanSample({qrcode: '123456'})
if (res) { if (res) {
this.$emit('on-result-change', res) this.$emit('on-result-change', res)
barcode.close(); barcode.close();
this.showScan = false this.showScan = false
} else { } else {
this.$toast('扫描失败!') this.$emit('on-result-change', {qrcode:qrcode})
barcode.close()
this._open()
} }
}, },
_cancelScan() { _cancelScan() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment