浏览代码

feature: 退出登录或token过期登录,自动去除订阅

Damon 8 月之前
父节点
当前提交
d0d35c5256
共有 1 个文件被更改,包括 17 次插入0 次删除
  1. 17 0
      pages/index/index.js

+ 17 - 0
pages/index/index.js

@@ -475,6 +475,23 @@ Page({
   ///退出登录
   logOut() {
     var that = this;
+    ///有设备在线被选中,则让它不被选择
+    var deviceListIndex = that.data.deviceListIndex;
+    if (deviceListIndex != null) {
+      var list = that.data.deviceList;
+      if (list.length > deviceListIndex) {
+        if (list[deviceListIndex].connectType == 3) {
+          if (that.data.thisDeviceMac !== null) {
+            app.unsubscribe(`/${that.data.thisDeviceMac}/user/pub_response`);
+            that.setData({
+              actionIndex: null,
+              deviceListIndex: null,
+            });
+          };
+        }
+      }
+    }
+
     wx.removeStorageSync('userInfo');
     wx.removeStorageSync('token');
     var nickName = "未登录";