ソースを参照

微信端每天退出问题修复

wangtao 7 ヶ月 前
コミット
f9c71f2b9f
1 ファイル変更6 行追加4 行削除
  1. 6 4
      src/store/modules/user.js

+ 6 - 4
src/store/modules/user.js

@@ -309,13 +309,14 @@ const useStores = defineStore("useStores", {
     GetWxOpenId(type, options) {
       let url = "https://manager.usky.cn/mobile/#/"
       if (type == 1 && common.isWechatMp()) {
-        if (localStorage.getItem("wxOpenId") && getToken()) {
+        if (localStorage.getItem("wxOpenId") && localStorage.getItem("App-Token")) {
           getPageAuthorization({ openId: localStorage.getItem("wxOpenId") }).then((res) => {
-            if (res.data?.openid) {
+            if (res.data?.openid && res.data?.acesToken) {
               window.location.href = `${url}pages/index`;
             } else {
               this.LogOut().then(() => {
                 localStorage.removeItem("wxOpenId")
+                localStorage.removeItem("App-Token")
                 window.location.href = config.baseUrl + "/service-iot/weChat/getFirst1";
               })
             }
@@ -328,11 +329,12 @@ const useStores = defineStore("useStores", {
           }
         }
       } else if (type == 2 && common.isWechatMp()) {
-        if (localStorage.getItem("wxOpenId") && getToken()) {
+        if (localStorage.getItem("wxOpenId") && localStorage.getItem("App-Token")) {
           getPageAuthorization({ openId: localStorage.getItem("wxOpenId") }).then((res) => {
-            if (!res.data?.openid) {
+            if (!res.data?.openid || !res.data?.acesToken) {
               this.LogOut().then(() => {
                 localStorage.removeItem("wxOpenId")
+                localStorage.removeItem("App-Token")
                 window.location.href = config.baseUrl + "/service-iot/weChat/getFirst1";
               })
             }