zjk
2026-07-24 860560648a27010ab8d919eff55c3b4fdb682fab
utils/visitorDevice.js
@@ -14,6 +14,21 @@
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) {
@@ -540,6 +555,10 @@
      if (methodName) {
        HardwarePlugin[methodName]({ options: printList }, (res) => {
         // showPluginDebugModal('打印凭证回调', res);
          if (res && res.code === 2) {
            emitPrinterOutOfPaperNoticeOnce();
          }
          if (res && res.code === 0) {
            resolve(res);
          } else {