1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| <script> var scan = null; methods:{ handleStartScan(){ const that = this; if(!window.plus) return; scan = new plus.barcode.Barcode('bcid'); scan.start(); scan.onmarked = function(type,result){ const text = ''; switch(type){ case plus.barcode.QR: type = 'QR'; break; case plus.barcode.EAN13: type = "EAN13"; break; case plus.barcode.EAN8: type = "EAN8"; break; default: type = "其它" + type; break; } result = result.replace(/\n/g,""); const id = result.match(/\d+/)[0]; that.$router.push({ name:'ComponentName', params: { id:id } }); scan.close(); } }, handleCloseScan(){ if(!window.plus) return; scan.close(); this.$router.push('/'); } } } </script>
|