| | |
| | | |
| | | testErrorSound() { |
| | | this.$playSound('error'); |
| | | }, |
| | | |
| | | |
| | | |
| | | startScan() { |
| | | const qrScanner = new Html5Qrcode("qr-reader"); |
| | | const config = { |
| | | fps: 10, |
| | | qrbox: 250 |
| | | }; |
| | | |
| | | qrScanner.start( |
| | | { facingMode: "environment" }, |
| | | config, |
| | | (decodedText) => { |
| | | // 扫码成功处理 |
| | | this.scanWorkstation = decodedText; |
| | | qrScanner.stop(); |
| | | document.getElementById('qr-reader').style.display = 'none'; |
| | | }, |
| | | (errorMessage) => { |
| | | // 错误处理 |
| | | console.error(errorMessage); |
| | | } |
| | | ).catch(err => { |
| | | alert('无法启动摄像头: ' + err); |
| | | }); |
| | | |
| | | // 显示扫码容器 |
| | | document.getElementById('qr-reader').style.display = 'block'; |
| | | } |
| | | } |
| | | }) |