|
|
|
|
@ -26,8 +26,8 @@ |
|
|
|
|
<uni-easyinput |
|
|
|
|
ref="inputRef" |
|
|
|
|
:inputBorder="false" |
|
|
|
|
:focus="isAutoFocus" |
|
|
|
|
@focus="handleFocus" |
|
|
|
|
:focus="true" |
|
|
|
|
@confirm="qucikScan" |
|
|
|
|
readonly |
|
|
|
|
v-model="quickScanData" |
|
|
|
|
class="uni-input" |
|
|
|
|
@ -81,16 +81,15 @@ export default { |
|
|
|
|
checkedNum: null, |
|
|
|
|
ticketNum: null, |
|
|
|
|
quickScanData: null, |
|
|
|
|
isAutoFocus: false |
|
|
|
|
isAutoFocus: true |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
watch:{ |
|
|
|
|
watch: { |
|
|
|
|
quickScanData:{ |
|
|
|
|
handler(val){ |
|
|
|
|
if(val.includes('_')&&val.split('_').length>0&&val.split('_')[0].length==23){ |
|
|
|
|
this.qucikScan() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.isAutoFocus = true |
|
|
|
|
}, |
|
|
|
|
immediate:true |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
@ -98,17 +97,13 @@ export default { |
|
|
|
|
return uni.getSystemInfoSync().windowHeight; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 当前页面的 onShow 生命周期 |
|
|
|
|
onShow() { |
|
|
|
|
// 需要配合 nextTick 或 setTimeout 保证 DOM 更新完成 |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.quickScanData = null; |
|
|
|
|
this.$refs.inputRef.focus(); // 通过 ref 获取 input 组件 |
|
|
|
|
}); |
|
|
|
|
// 或使用定时器 |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.isAutoFocus = true; // 触发 :focus 属性 |
|
|
|
|
}, 100); |
|
|
|
|
setTimeout(()=>{ |
|
|
|
|
this.isAutoFocus = true |
|
|
|
|
},100) |
|
|
|
|
}, |
|
|
|
|
onLoad: function () { |
|
|
|
|
if (uni.getStorageSync('menu') && uni.getStorageSync('menu') != null) { |
|
|
|
|
@ -120,21 +115,10 @@ export default { |
|
|
|
|
this.getIndexData(); |
|
|
|
|
|
|
|
|
|
// #ifdef APP-PLUS |
|
|
|
|
this.timer = setInterval(() => { |
|
|
|
|
uni.hideKeyboard(); |
|
|
|
|
}, 50); |
|
|
|
|
// this.timer = setInterval(() => { |
|
|
|
|
// uni.hideKeyboard(); |
|
|
|
|
// }, 50); |
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
// // #ifdef APP-PLUS |
|
|
|
|
// globalEvent.addEventListener('myScanEvent', function (e) { |
|
|
|
|
// console.log(e); |
|
|
|
|
// if (e.requestCode == 1 && e.data && e.data.VALUE) { |
|
|
|
|
// //识别成功 |
|
|
|
|
// // self.initSample(e.data.VALUE); |
|
|
|
|
// } |
|
|
|
|
// }); |
|
|
|
|
// DCSunmiScanModule.registerReceiver(); |
|
|
|
|
// // #endif |
|
|
|
|
}, |
|
|
|
|
onUnload() { |
|
|
|
|
// // #ifdef APP-PLUS |
|
|
|
|
@ -152,14 +136,23 @@ export default { |
|
|
|
|
console.log(this.quickScanData, 'qucikScan'); |
|
|
|
|
if (!this.quickScanData) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
icon:'none', |
|
|
|
|
icon: 'none', |
|
|
|
|
title: '请先扫描或输入票号', |
|
|
|
|
duration: 2000 |
|
|
|
|
}); |
|
|
|
|
return |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
uni.redirectTo({ |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/checkResult/checkResult?result=' + this.quickScanData + '&quick=1', |
|
|
|
|
events: { |
|
|
|
|
updateInvoice: (result) => { |
|
|
|
|
console.log('返回传输的数据', result); |
|
|
|
|
this.quickScanData = null; |
|
|
|
|
this.$nextTick(()=>{ |
|
|
|
|
this.$set(this,'isAutoFocus',true) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
success() { |
|
|
|
|
this.quickScanData = null; |
|
|
|
|
} |
|
|
|
|
@ -191,15 +184,6 @@ export default { |
|
|
|
|
console.log(err); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
goNFC() { |
|
|
|
|
const getSN = uni.requireNativePlugin('Mi-GetSN'); |
|
|
|
|
getSN.getSN((snCode) => { |
|
|
|
|
console.log(snCode); |
|
|
|
|
}); |
|
|
|
|
// uni.navigateTo({ |
|
|
|
|
// url:'/pages/NFC/NFC' |
|
|
|
|
// }) |
|
|
|
|
}, |
|
|
|
|
goList() { |
|
|
|
|
uni.removeStorageSync('ALL_TICKET'); |
|
|
|
|
uni.removeStorageSync('EVENT'); |
|
|
|
|
@ -212,85 +196,6 @@ export default { |
|
|
|
|
url: '/pages/shoppingTrolley/shoppingTrolley' |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
print(val) { |
|
|
|
|
console.log(val, '1'); |
|
|
|
|
const sunmi_print = uni.requireNativePlugin('Sunmi-Print-Inner'); |
|
|
|
|
console.log(sunmi_print); |
|
|
|
|
//使用前连接打印机 |
|
|
|
|
sunmi_print.connect((res) => { |
|
|
|
|
if (res.connect == 'hello') { |
|
|
|
|
console.log('打印机成功连接'); |
|
|
|
|
//空白行分割之前打印内容(类似走空白) |
|
|
|
|
sunmi_print.printDividingline({ |
|
|
|
|
style: '4', |
|
|
|
|
height: '50' |
|
|
|
|
}); |
|
|
|
|
//虚线分割线 |
|
|
|
|
sunmi_print.printDividingline({ |
|
|
|
|
style: '3', |
|
|
|
|
height: '3' |
|
|
|
|
}); |
|
|
|
|
//空白行分割之后的打印内容(类似走空白) |
|
|
|
|
sunmi_print.printDividingline({ |
|
|
|
|
style: '4', |
|
|
|
|
height: '30' |
|
|
|
|
}); |
|
|
|
|
sunmi_print.printText({ |
|
|
|
|
text: '这是打印的头部', |
|
|
|
|
align: 1, |
|
|
|
|
size: 30, |
|
|
|
|
bold: true, |
|
|
|
|
underline: false, |
|
|
|
|
compact: true, |
|
|
|
|
skip: true |
|
|
|
|
}); |
|
|
|
|
sunmi_print.printQrCode({ |
|
|
|
|
text: 'SC202408081557067846785_0', |
|
|
|
|
size: 15, |
|
|
|
|
errorlevel: 0, |
|
|
|
|
align: 1 |
|
|
|
|
}); |
|
|
|
|
sunmi_print.printText({ |
|
|
|
|
text: '这是打印的底部', |
|
|
|
|
align: 1, |
|
|
|
|
size: 30, |
|
|
|
|
bold: true, |
|
|
|
|
underline: false, |
|
|
|
|
compact: true, |
|
|
|
|
skip: true |
|
|
|
|
}); |
|
|
|
|
//空白行分割之前打印内容(类似走空白) |
|
|
|
|
sunmi_print.printDividingline({ |
|
|
|
|
style: '4', |
|
|
|
|
height: '30' |
|
|
|
|
}); |
|
|
|
|
//虚线分割线 |
|
|
|
|
sunmi_print.printDividingline({ |
|
|
|
|
style: '3', |
|
|
|
|
height: '3' |
|
|
|
|
}); |
|
|
|
|
//空白行分割之后的打印内容(类似走空白) |
|
|
|
|
sunmi_print.printDividingline({ |
|
|
|
|
style: '4', |
|
|
|
|
height: '50' |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
console.log(val, '2'); |
|
|
|
|
}, |
|
|
|
|
getInfo() { |
|
|
|
|
uni.getSystemInfo({ |
|
|
|
|
success: function (res) { |
|
|
|
|
console.log(res); |
|
|
|
|
}, |
|
|
|
|
fail: function (err) { |
|
|
|
|
console.log(err); |
|
|
|
|
}, |
|
|
|
|
complete: function (res) { |
|
|
|
|
console.log(res); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
scanCode() { |
|
|
|
|
uni.removeStorageSync('ALL_TICKET'); |
|
|
|
|
uni.removeStorageSync('EVENT'); |
|
|
|
|
@ -302,8 +207,17 @@ export default { |
|
|
|
|
success: function (res) { |
|
|
|
|
console.log('条码类型:' + res.scanType); |
|
|
|
|
console.log('条码内容:' + res.result); |
|
|
|
|
uni.redirectTo({ |
|
|
|
|
url: '/pages/checkResult/checkResult?result=' + res.result + '&quick=0' |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/checkResult/checkResult?result=' + res.result + '&quick=0', |
|
|
|
|
events: { |
|
|
|
|
updateInvoice: (result) => { |
|
|
|
|
console.log('返回传输的数据', result); |
|
|
|
|
this.quickScanData = null; |
|
|
|
|
this.$nextTick(()=>{ |
|
|
|
|
this.$set(this,'isAutoFocus',true) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|