Ver Fonte

蓝牙设备添加重新发送验证码

xiaohaizhao há 8 meses atrás
pai
commit
a8f71c2fb3

+ 1 - 1
control/components/prodnum-FW01/modules/basics.vue

@@ -1,5 +1,5 @@
 <template>
-  <view class="reset">
+  <view class="reset" v-if="ctrlModel.funcname">
     <view class="update-line">
       <view class="label">
         {{ ctrlModel.funcname }}

+ 1 - 1
control/components/prodnum-FW01/prodnum-FW01.vue

@@ -57,7 +57,7 @@ export default {
               ["开度提醒复位"],
               newVal
             )[0];
-            console.log(this.$refs.basics.ctrlModel);
+            console.log("ctrlModel",this.$refs.basics.ctrlModel);
           }
           function getBoole(name, expect = 1) {
             try {

+ 37 - 22
control/components/prodnum-FW01B/prodnum-FW01B.vue

@@ -72,22 +72,29 @@ export default {
           安装位置: "radio",
           第二域名: "string",
         });
-        console.log(this.list);
-        try {
-          const E013 = this.list.find((v) => v.paramName == "E013");
-          if (E013) {
-            this.$refs.refCD.send(
-              { password: E013.params.options[0].value },
-              E013
-            );
-          }
-        } catch (error) {}
-
+        setTimeout(() => {
+          this.authentication();
+        }, 100);
         this.$refs.refCD.init();
       }
     },
   },
   methods: {
+    authentication() {
+      try {
+        uni.showLoading({
+          title: "身份验证中...",
+          mask: true,
+        });
+        const E013 = this.list.find((v) => v.paramName == "E013");
+        if (E013) {
+          this.$refs.refCD.send(
+            { password: E013.params.options[0].value },
+            E013
+          );
+        }
+      } catch (error) {}
+    },
     onClick(item) {
       this.$refs.MyInput.openInput(item);
     },
@@ -121,34 +128,42 @@ export default {
     },
     onFeedback(res) {
       console.log("onFeedback", res);
-
       const index = res.node
         ? this.list.findIndex((v) => res.node == v.paramName)
         : this.list.findIndex((v) => v.msgid == res.msgid);
-
+      uni.hideLoading();
+      let that = this;
       if (index != -1) {
         let item = this.list[index];
         let MyInput = this.$refs.MyInput;
         MyInput.loading = false;
         if (res.status == 1) {
           if (res.node) {
-             item.params.lastvalue = res.v;
+            item.params.lastvalue = res.v;
           } else if (res.msgid) {
-            item.params.lastvalue = item.msg.d[item.params.param];
+            try {
+              item.params.lastvalue = item.msg.d[item.params.param];
+            } catch (error) {}
           }
           MyInput.show = false;
           MyInput.stepIsCalculate = null;
         } else if (res.status == 0) {
           if (item.paramName == "E013") {
             uni.showModal({
-              title: "失败",
-              content: `身份验证失败,将断开连接`,
-              showCancel: false,
-            });
-            uni.closeBLEConnection({
-              deviceId: that.connected
+              content: `身份验证失败`,
+              confirmText: "重新验证",
+              cancelText: "断开连接",
+              complete: ({ confirm }) => {
+                if (confirm) {
+                  that.authentication();
+                } else {
+                  uni.closeBLEConnection({
+                    deviceId: that.connected,
+                  });
+                  uni.closeBluetoothAdapter();
+                }
+              },
             });
-            uni.closeBluetoothAdapter();
           } else {
             uni.showModal({
               title: "失败",

+ 2 - 1
control/modules/connectingDevice.vue

@@ -58,7 +58,7 @@ export default {
         uni.getBLEDeviceRSSI({
           deviceId: that.Bluetooth.device.deviceId,
           success: (success) => {
-            console.log("监听信号强度", success);
+            // console.log("监听信号强度", success);
             if (success.errCode == 0) that.Bluetooth.device.RSSI = success.RSSI;
           },
         });
@@ -87,6 +87,7 @@ export default {
 
       item.msgid = content.msgid;
       item.msg = content;
+      
       console.log("发送通信内容", item.msg);
 
       let msg = JSON.stringify({

+ 2 - 2
main.js

@@ -28,9 +28,9 @@ Vue.component('My_Files', My_Files);
 import connectingDevice from './control/modules/connectingDevice';
 Vue.component('connectingDevice', connectingDevice);
 
-console.log("process.env.NODE_ENV",process.env.NODE_ENV)
+console.log("process.env.NODE_ENV", process.env.NODE_ENV)
 //挂载接口 'production'
-let isDev = ['development'].includes(process.env.NODE_ENV);
+let isDev = false; // ['development'].includes(process.env.NODE_ENV);
 console.log('运行环境', isDev ? '开发' : '生产');
 
 const http = {};

+ 8 - 8
pages/facility/detail.vue

@@ -55,12 +55,7 @@
       <view class="ceiling" :style="{ top: tovw(CustomBar + tabsTop) }">
         <tabs :tabs="tabs" @changeTab="changeTab" />
       </view>
-      <control
-        ref="设备控制"
-        :detail="detail"
-        :mode="mode"
-        @onUpdate="getDetail"
-      />
+      <control ref="设备控制" :detail="detail" @onUpdate="getDetail" />
       <daily-record
         ref="设备日志"
         :isfeedback="detail.isfeedback"
@@ -119,7 +114,9 @@ export default {
     };
   },
   watch: {
-    mode: function () {
+    mode: function (newv) {
+      this.$refs.设备控制.mode = newv;
+      this.$refs.设备控制.uninitialized = true;
       this.$refs.设备控制.getControl(true);
     },
   },
@@ -131,7 +128,8 @@ export default {
     this.$refs.List.setHeight();
   },
   onShow() {
-    this.getDetail(true);
+    // if (["development"].includes(process.env.NODE_ENV)) this.getDetail(true);
+    if (this.mode == 0) this.getDetail(true);
     try {
       this.$Http.openNetwork = this.$refs.轮播图.openNetwork;
       this.$Http.slideshowSetData = this.$refs.轮播图.setData;
@@ -260,11 +258,13 @@ export default {
                         "Bluetooth/index/index"
                       )
                         uni.navigateBack();
+
                       this.$Http.setDetailMode = function (mode1) {
                         this.mode = mode1;
                         delete this.$Http.setDetailMode;
                         uni.closeBluetoothAdapter();
                       }.bind(this);
+
                       this.$Http.Bluetooth = Bluetooth;
                       delete this.$Http.setBluetooth;
                     }.bind(this);

+ 4 - 4
pages/facility/modules/control.vue

@@ -37,16 +37,14 @@ export default {
   props: {
     detail: Object,
     onUpdate: Function,
-    mode: {
-      type: Number,
-      default: 0,
-    },
   },
   data() {
     return {
       show: false,
       uninitialized: true,
       control: {},
+      isBluetooth: false,
+      mode: 0,
     };
   },
   methods: {
@@ -55,6 +53,7 @@ export default {
     },
     getControl(init) {
       if (init) this.control = null;
+      if (!this.uninitialized && this.isBluetooth) return;
       this.$Http
         .basic({
           id: "20230628084901",
@@ -67,6 +66,7 @@ export default {
           console.log("设备控制", res);
           if (this.cutoff(res.msg)) return;
           this.uninitialized = false;
+          this.isBluetooth = this.mode == 1;
           this.control = res.data;
           this.$Http.setControlItem = this.setControlItem.bind(this);
           this.setMonitoring();