Prechádzať zdrojové kódy

feature: 处理连接失败重新连接的问题

Damon 7 mesiacov pred
rodič
commit
8bdd82ab4a

+ 0 - 2
app.js

@@ -59,7 +59,6 @@ App({
     wx.onAppShow(() => {
       if (that.globalData.userInfo !== null) {
         if (!(that.globalData.client && that.globalData.client.connected)) {
-          console.log("开始连接=00=")
           that.connect();
         }
       }
@@ -100,7 +99,6 @@ App({
 
     // 设备连接
     that.globalData.client.on('connect', () => {
-      console.log("connect的回调==")
       var pages = getCurrentPages();
       var length = pages.length;
       var currentPage = pages[length - 1];

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 24 - 5
pages/deviceConnect0/deviceConnect0.js


+ 11 - 11
pages/deviceConnect0/deviceConnect0.wxml

@@ -4,18 +4,18 @@
   </nav-bar>
   <view class="roterps">
     <view class="devicePic">
-      <image mode="widthFix" src="./../../img/c.png"></image>
+      <image mode="widthFix" src="{{imageUrl}}"></image>
     </view>
     <text>开启设备并将开关打至WiFi模式,指示灯亮
-起后,即可进入下一步</text>
-      <view wx:if="{{!scopeBluetooth && userFuzzyLocation}}" class="qx">
-        <text bindtap="setBluetooth">开启蓝牙权限</text>
-        <image mode="heightFix" src="./../../img/a.png"></image>
-      </view>
-      <view wx:if="{{!userFuzzyLocation}}" class="qx">
-        <text bindtap="setUserFuzzyLocation">开启定位权限</text>
-        <image mode="heightFix" src="./../../img/a.png"></image>
-      </view>
+      起后,即可进入下一步</text>
+    <view wx:if="{{!scopeBluetooth && userFuzzyLocation}}" class="qx">
+      <text bindtap="setBluetooth">开启蓝牙权限</text>
+      <image mode="heightFix" src="./../../img/a.png"></image>
+    </view>
+    <view wx:if="{{!userFuzzyLocation}}" class="qx">
+      <text bindtap="setUserFuzzyLocation">开启定位权限</text>
+      <image mode="heightFix" src="./../../img/a.png"></image>
+    </view>
   </view>
   <view class="subBtn">
     <view class="btn" style="opacity: {{scopeBluetooth && userFuzzyLocation ? '1' : '0.6'}};" bindtap="next">
@@ -26,4 +26,4 @@
       <image mode="heightFix" src="./../../img/b.png"></image>
     </view>
   </view>
-</view>
+</view>

+ 12 - 3
pages/deviceConnect1/deviceConnect1.js

@@ -1,4 +1,7 @@
 const app = getApp();
+import route_util from '../../utils/route_util.js';
+import route_constant from '../../utils/route_constant.js'
+
 Page({
   data: {
     nvabarData: {
@@ -11,6 +14,13 @@ Page({
     ssid: "",
     pwdData: "",
     pwdData1: "",
+    connectDevice: "",
+  },
+
+  onLoad(options) {
+    var that = this;
+    var param = options.param;
+    that.data.connectDevice = param;
   },
 
   onShow() {
@@ -113,9 +123,8 @@ Page({
 
     app.globalData.ssid = that.data.ssid;
     app.globalData.pwdData = that.data.pwdData;
-    wx.navigateTo({
-      url: './../deviceConnect2/deviceConnect2',
-    })
+    route_util.jumpParam(route_constant.deviceConnect2, that.data.connectDevice);
+
   },
 
   notRoter() {

+ 20 - 2
pages/deviceConnect2/deviceConnect2.js

@@ -22,10 +22,27 @@ Page({
     isSubmit: false,
     islanya: false,
     isOnBluetooth: false,
+    imageUrl: "./../../img/f.png",
+    connectDevice: {},
   },
 
-  onLoad() {
+  onLoad(options) {
     const that = this;
+    var param = options.param;
+    if (!strings.isEmpty(param)) {
+      param = JSON.parse(options.param);
+      that.data.connectDevice = param;
+      if (!strings.isEmpty(param.typeList)) {
+        var typeList = param.typeList;
+        typeList = typeList.filter((v) => v.connectType == 3);
+        if (!strings.isEmpty(typeList)) {
+          that.setData({
+            imageUrl: typeList[0].deviceLinkResp.icon2,
+          });
+        }
+      }
+    }
+
     const isOne = setTimeout(() => {
       clearTimeout(isOne);
       if (that.data.isOne) {
@@ -120,8 +137,9 @@ Page({
               devicesList: [],
               isOnBluetooth: false,
             });
+            var param = JSON.stringify(that.data.connectDevice);
             wx.navigateTo({
-              url: '../deviceConnect3/deviceConnect3?deviceId=' + options.data.deviceId + '&name=' + options.data.name,
+              url: '../deviceConnect3/deviceConnect3?deviceId=' + options.data.deviceId + '&name=' + options.data.name + "&param=" + param,
             });
           }, 200);
         } else {

+ 3 - 4
pages/deviceConnect2/deviceConnect2.wxml

@@ -5,15 +5,14 @@
   </nav-bar>
   <view class="roterps">
     <view class="devicePic">
-      <image mode="widthFix" src="./../../img/f.png"></image>
+      <image mode="widthFix" src="{{imageUrl}}"></image>
     </view>
     <text>短按设备背面“配对”键,
-    当听见语音提示“进入WiFi配对模式”时,即可进入下一步</text>
+      当听见语音提示“进入WiFi配对模式”时,即可进入下一步</text>
   </view>
   <view class="subBtn">
     <view class="btn" style="opacity: {{islanya ? '1' : '0.6'}};" bindtap="Connect">
       {{'下一步'}}
     </view>
   </view>
-</view>
-
+</view>

+ 13 - 2
pages/deviceConnect3/deviceConnect3.js

@@ -1,8 +1,9 @@
 // pages/deviceConnect3/deviceConnect3.ts
 const app = getApp();
 let xBlufi = require("../../utils/blufi/xBlufi.js");
-import route_constant from '../../utils/route_constant.js'
+import strings from '../../utils/strings.js';
 import route_util from '../../utils/route_util.js';
+import route_constant from '../../utils/route_constant.js'
 let percentIn = null;
 let errTi = null;
 
@@ -24,10 +25,19 @@ Page({
     customData: '',
     percent: 0,
     ruterStatus: 0, // 0 连接中 // 1 成功 // 2失败
+    imageUrl: "./../../img/g.png",
   },
 
   onLoad: function (options) {
     var that = this;
+    var param = options.param;
+    if (!strings.isEmpty(param)) {
+      param = JSON.parse(param);
+      that.setData({
+        imageUrl: param.img,
+      });
+    }
+
     that.setData({
       name: options.name,
       connectedDeviceId: options.deviceId,
@@ -101,7 +111,8 @@ Page({
               name: deviceId,
               deviceId: deviceId,
               mac: deviceId,
-              imageUrl: "./../../img/min.png",
+              imageUrl: that.data.imageUrl,
+              // imageUrl: "./../../img/min.png",
             }
             getCurrentPages()[0].addWifiDevice(device);
             // [{"deviceId":"BLUFI_7cdfa1fcbb24","name":"BLUFI_7cdfa1fcbb24","state":"online"}]

+ 5 - 6
pages/deviceConnect3/deviceConnect3.wxml

@@ -5,11 +5,11 @@
   </nav-bar>
   <view class="roterps">
     <view class="devicePic">
-      <image style="width: 320rpx; height: 240rpx;" mode="scaleToFill" src="./../../img/g.png"></image>
+      <image style="width: 320rpx; height: 240rpx;" mode="scaleToFill" src="{{imageUrl}}"></image>
     </view>
     <view class="lodRuter" wx:if="{{ruterStatus === 0}}">
       <text>正在连接中,请保持设备开机状态…</text>
-      <progress color="#6547A3" percent="{{percent}}" show-info stroke-width="3"/>
+      <progress color="#6547A3" percent="{{percent}}" show-info stroke-width="3" />
     </view>
     <view class="suRuter" wx:elif="{{ruterStatus === 1}}">
       <image mode="widthFix" src="./../../img/h.png"></image>
@@ -27,15 +27,14 @@
     </view>
   </view>
   <view class="subBtn">
-    <view wx:if="{{ruterStatus === 0}}" class="btn" style="opacity: 0.6" >
+    <view wx:if="{{ruterStatus === 0}}" class="btn" style="opacity: 0.6">
       连接中...
     </view>
     <view wx:elif="{{ruterStatus === 1}}" class="btn" bindtap="goIndex">
       完成
     </view>
-    <view wx:else style="background-color: #353535;"  class="btn"  bindtap="egen">
+    <view wx:else style="background-color: #353535;" class="btn" bindtap="egen">
       重新连接
     </view>
   </view>
-</view>
-
+</view>

+ 0 - 1
utils/lexin/message.js

@@ -68,7 +68,6 @@ function getDeviceInfo(payloads) {
               if (productItem.clientType == ProdModel) {
                 device.imageUrl = productItem.img;
                 device.offlineImg = productItem.offlineImg;
-                device.offlineImg = productItem.offlineImg;
                 break;
               }
             }

+ 6 - 1
utils/route_constant.js

@@ -3,11 +3,14 @@ const indexRoot = "pages/index/index";
 const loginRoot = "pages/login/login";
 const connectBleRoot = "pages/connectBle/connectBle";
 
-  ///跳转路径
+///跳转路径
 const index = "../index/index";
 const login = "../login/login";
 const about = "../about/about";
 const deviceConnect0 = "../deviceConnect0/deviceConnect0";
+const deviceConnect1 = "../deviceConnect1/deviceConnect1";
+const deviceConnect2 = "../deviceConnect2/deviceConnect2";
+
 /// 抽奖记录
 const deviceList = "../deviceList/deviceList";
 const connectMode = "../deviceConMode/index";
@@ -24,6 +27,8 @@ module.exports = {
   login: login,
   about: about,
   deviceConnect0: deviceConnect0,
+  deviceConnect1: deviceConnect1,
+  deviceConnect2: deviceConnect2,
   deviceList: deviceList,
   connectMode: connectMode,
   connectBle: connectBle,