Browse Source

feature: 解决后台数据丢失连接的问题

Damon 7 tháng trước cách đây
mục cha
commit
d0573682d2
1 tập tin đã thay đổi với 6 bổ sung7 xóa
  1. 6 7
      app.js

+ 6 - 7
app.js

@@ -58,18 +58,17 @@ App({
     ///显示界面
     wx.onAppShow(() => {
       if (that.globalData.userInfo !== null) {
-        if (that.globalData.client) {
-          that.globalData.client.end(true);
+        if (!(that.globalData.client && that.globalData.client.connected)) {
+          that.connect();
         }
-        that.connect();
-      };
+      }
     });
 
     ///界面后台化
     wx.onAppHide(() => {
-      if (that.globalData.client && that.globalData.client.connected) {
-        that.globalData.client.end(true);
-      };
+      // if (that.globalData.client && that.globalData.client.connected) {
+      //   that.globalData.client.end(true);
+      // };
     });
 
     // that.getBluetoothStatus();