| | |
| | | let initResult = null; |
| | | const PLUGIN_DEBUG_ENABLED = true; |
| | | let debugModalQueue = Promise.resolve(); |
| | | let lastPrinterOutOfPaperNoticeAt = 0; |
| | | |
| | | const emitPrinterOutOfPaperNoticeOnce = () => { |
| | | const now = Date.now(); |
| | | // 打印机缺纸时,原生插件可能在短时间内连续回调很多次 code=2,这里做节流避免重复弹窗轰炸。 |
| | | if (now - lastPrinterOutOfPaperNoticeAt < 10000) { |
| | | return; |
| | | } |
| | | |
| | | lastPrinterOutOfPaperNoticeAt = now; |
| | | uni.$emit('Hardware-PrintOutOfPaper', { |
| | | code: 2, |
| | | message: '打印机缺纸,请联系管理员', |
| | | }); |
| | | }; |
| | | |
| | | const getPluginMethod = (methodNames = []) => { |
| | | if (!HardwarePlugin) { |
| | |
| | | if (methodName) { |
| | | HardwarePlugin[methodName]({ options: printList }, (res) => { |
| | | // showPluginDebugModal('打印凭证回调', res); |
| | | if (res && res.code === 2) { |
| | | emitPrinterOutOfPaperNoticeOnce(); |
| | | } |
| | | |
| | | if (res && res.code === 0) { |
| | | resolve(res); |
| | | } else { |