ソースを参照

token过期后保存页面数据,恢复登录跳转到该页面

xiaohaizhao 2 年 前
コミット
c6b38f4d8d
2 ファイル変更19 行追加2 行削除
  1. 18 1
      pages/tabbar/home/index.js
  2. 1 1
      utils/Http.js

+ 18 - 1
pages/tabbar/home/index.js

@@ -28,7 +28,24 @@ Page({
                 res.data.unshift(data)
             }
             wx.setStorageSync('templetList', res.data)
-        })
+        });
+        let history = getApp().globalData.LaunchOptions;
+        if (history) {
+            let url = `/${history.path}?`;
+            for (const key in history.query) {
+                url += `${key}=${history.query[key]}&`
+            }
+            wx.navigateTo({
+                url,
+                success(res) {
+                    wx.showToast({
+                        title: '已恢复页面',
+                        icon: "none"
+                    });
+                    getApp().globalData.LaunchOptions = null;
+                }
+            })
+        }
     },
     /* 更新站点信息 */
     refreshData() {

+ 1 - 1
utils/Http.js

@@ -38,12 +38,12 @@ class HTTP {
                         icon: "none"
                     })
                 } else if (res.data.msg == '登陆状态已过期,请重新登陆!') {
-                    clearTimeout(count);
                     wx.showToast({
                         title: '登陆状态已过期,请重新登陆!',
                         icon: "none",
                         mask: true
                     })
+                    getApp().globalData.LaunchOptions = wx.getLaunchOptionsSync();
                     count = setTimeout(() => {
                         wx.reLaunch({
                             url: '/pages/login/phone',