1、Scan类创建
/**
* @description 封装扫码对象
* @param {Object} {onchange: function(code) {}} 回调函数
*/
class Scan {
constructor({
onchange = null }) {
this.code = '';
this.lastTime = '';
this.nextTime = '';
this.lastCode = '';
this.nextCode = '';
this.onchange = onchange;
}
start() {
// 开始监听扫码
this.change();
}
change() {
// 设置扫码对象监听
window.document.