Parcourir la source

feature: 回到主界面切换模式改变

Damon il y a 8 mois
Parent
commit
4f9652f268

+ 6 - 6
pages/deviceConnect0/deviceConnect0.js

@@ -35,9 +35,9 @@ Page({
           showCapsule: 1,
           title: '连接配网',
           callback: () => {
-            wx.switchTab({
-              url: "./../index/index"
-            })
+          wx.redirectTo({
+            url: '/pages/index/index'
+          });
           }
         },
       })
@@ -127,9 +127,9 @@ Page({
   },
   notRoter() {
     getCurrentPages()[0].onLoad();
-    wx.switchTab({
-      url: "./../index/index"
-    });
+          wx.redirectTo({
+            url: '/pages/index/index'
+          });
   },
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 3 - 3
pages/deviceConnect3/deviceConnect3.js

@@ -217,8 +217,8 @@ Page({
   goIndex(){
     //  BLUFI_7cdfa1fd3cfc
     app.globalData.newDeviceId = this.data.name;
-    wx.switchTab({
-      url: `./../index/index`
-    });
+          wx.redirectTo({
+            url: '/pages/index/index'
+          });
   }
 })

+ 29 - 4
pages/index/index.js

@@ -747,13 +747,38 @@ Page({
       title: '确定删除?',
       success: function (res) {
         if (res.confirm) {
-          if (element.ProdModel == "MW-2AX(WIFI-N)") {}
+          if (that.data.deviceList[e.currentTarget.dataset.index].ProdModel != "MW-2AX(WIFI-N)") {
+            const id = that.data.deviceList[e.currentTarget.dataset.index].deviceId;
+            const deviceList = that.data.deviceList.filter((item, i) => {
+              return id !== item.deviceId
+            });
+
+            wx.setStorage({
+              key: "devicelist",
+              data: JSON.stringify(deviceList),
+              success() {
+                that.setData({
+                  deviceList,
+                });
+
+                // 当前没有设备
+                if (deviceList.length === 0) {
+                  that.setData({
+                    deviceListIndex: null,
+                  });
+                }
+              }
+            });
+            return;
+          }
 
           const id = that.data.deviceList[e.currentTarget.dataset.index].deviceId;
           let name = that.data.deviceListIndex !== null ? that.data.deviceList[that.data.deviceListIndex].name : null;
-          const deviceList = that.data.deviceList.filter((v, i) => {
-            return id !== v.deviceId
+
+          const deviceList = that.data.deviceList.filter((item, i) => {
+            return id !== item.deviceId
           });
+
           // 取消订阅
           app.unsubscribe(`/AIrSMArT_${that.data.deviceList[e.currentTarget.dataset.index].name.split("BLUFI_")[1]}/user/pub_response`);
 
@@ -761,7 +786,6 @@ Page({
             key: "devicelist",
             data: JSON.stringify(deviceList),
             success() {
-
               that.setData({
                 deviceList,
                 thisDeviceMac: null
@@ -778,6 +802,7 @@ Page({
               if (that.data.deviceListIndex === null) {
                 return
               };
+
               if (e.currentTarget.dataset.index === that.data.deviceListIndex) {
                 let index_ = null;
                 deviceList.map((v, index) => {

+ 2 - 2
pages/meCopy/meCopy.js

@@ -55,8 +55,8 @@ Page({
             userName: "未登录",
             userPic: "./../../img/head_pic.png",
           });
-          wx.switchTab({
-            url: `./../index/index`
+          wx.redirectTo({
+            url: '/pages/index/index'
           });
         }
       });

+ 3 - 3
utils/route_util.js

@@ -8,9 +8,9 @@ async function goBack(pages) {
 
   if (currentPage.route.lastIndexOf("detail/detail")) {
     setTimeout(() => {
-      wx.switchTab({
-        url: '../pages/index/index'
-      });
+          wx.redirectTo({
+            url: '/pages/index/index'
+          });
     }, 300);
   } else {
     // 执行返回操作