cuiqian2004
4 天以前 07925905f1a596e20e980de6d42db217abb753b0
App.vue
@@ -5,6 +5,7 @@
      showError
   } from "@/js/Page.js"
   const rfidModule = uni.requireNativePlugin('RFIDModule');
   // const honrfidModule = uni.requireNativePlugin('HonRFIDModule');
   var main;
   export default {
      globalData: {
@@ -39,11 +40,20 @@
         this.init();
      },
      onUnload() {
         if (this.deviceInfo?.brand.includes('alps')) { // 汉德霍尔设备特征
            // 汉德霍尔 PDA rfid扫码页面卸载时释放资源
            if (rfidModule) {
               rfidModule.closeModule();
         if (this.deviceInfo) {
            if (this.deviceInfo?.brand.includes('alps')) { // 汉德霍尔设备特征
               // 汉德霍尔 PDA rfid扫码页面卸载时释放资源
               if (rfidModule) {
                  rfidModule.closeModule();
               }
            } else if (this.deviceInfo?.brand.includes('honeywell') || this.deviceInfo?.deviceBrand.includes(
                  'honeywell')) {
               // 霍尼韦尔 PDA rfid扫码页面卸载时释放资源
               if (rfidModule) {
                  rfidModule.closeModule();
               }
            } else {
               main.unregisterReceiver(receiver); // 停止监听广播
            }
         } else {
            main.unregisterReceiver(receiver); // 停止监听广播
@@ -65,24 +75,42 @@
         init() {
            let that = this;
            console.log(this.deviceInfo);
            if (this.deviceInfo) {
               if (this.deviceInfo.brand.includes('alps')) { // 汉德霍尔设备特征
            if (this.deviceInfo?.brand.includes('alps')) { // 汉德霍尔设备特征
                  rfidModule.initModule((res) => {
                     console.log("alps rfid initModule", res)
                     if (res.code < 0) {
                        showInfo(res.msg);
                     }
               rfidModule.initModule((res) => {
                  console.log("rfid initModule", res)
                  if (res.code < 0) {
                     showInfo(res.msg);
                  }
                  })
               } else if (this.deviceInfo.brand.includes('honeywell') || this.deviceInfo.deviceBrand.includes(
                     'honeywell')) { // 霍尼韦尔
                  console.log("honeywell rfid initModule")
                  rfidModule.initModule("honeywell",(res) => {
                     console.log("rfid initModule", res)
                     if (res.code < 0) {
                        showInfo(res.msg);
                     }
                  })
               })
            } else if (this.deviceInfo?.brand.includes('mobiwire') || this.deviceInfo?.deviceBrand.includes(
                  'mobiwire')) { // 霍尼韦尔
               } else if (this.deviceInfo.brand.includes('mobiwire') || this.deviceInfo.deviceBrand.includes(
                     'mobiwire')) { // 霍尼韦尔
               this.initMobiwireScan()
                  this.initMobiwireScan()
               } else {
                  console.log(this.initScan);
                  this.initScan()
               }
            } else {
               this.initScan()
            }
         },
         initMobiwireScan() {
            main = plus.android.runtimeMainActivity(); // 获取主 activity
@@ -127,32 +155,39 @@
            main.registerReceiver(receiver, filter); //注册监听   
         },
         onScan(callback) {
            if (this.deviceInfo?.brand.includes('alps')) { // 汉德霍尔设备特征
               if (!rfidModule)
                  return
               rfidModule.startScan((ret) => {
                  console.log("startScan", ret)
                  let text = ""
                  if (ret.code < 0) {
                     showInfo(ret.msg);
                  } else {
                     const data = ret.data || []
                     if (Array.isArray(data)) {
                        if (data.length > 0)
                           text = data[0].epc
            if (this.deviceInfo) {
               if (this.deviceInfo?.brand.includes('alps') ||(this.deviceInfo?.brand.includes('honeywell') || this.deviceInfo?.deviceBrand.includes(
                     'honeywell'))) { // 汉德霍尔设备特征
                  if (!rfidModule)
                     return
                  rfidModule.startScan((ret) => {
                     console.log("startScan", ret)
                     let text = ""
                     if (ret.code < 0) {
                        showInfo(ret.msg);
                     } else {
                        text = data.epc || ""
                        const data = ret.data || []
                        if (Array.isArray(data)) {
                           if (data.length > 0)
                              text = data[0].epc
                        } else {
                           text = data.epc || ""
                        }
                        callback(text);
                     }
                     callback(text);
                  }
               })
                  })
               } else {
                  uni.$off("scanresult");
                  uni.$on("scanresult", (result) => {
                     callback(result);
                  });
               }
            } else {
               uni.$off("scanresult");
               uni.$on("scanresult", (result) => {
                  callback(result);
               });
            }
         },
      }