|
@@ -196,6 +196,21 @@ import { clearLogin } from "@/api/admin";
|
|
|
import { APP_VERSION } from "@/config";
|
|
import { APP_VERSION } from "@/config";
|
|
|
import { iconSrc } from "@/utils/iconSrc";
|
|
import { iconSrc } from "@/utils/iconSrc";
|
|
|
|
|
|
|
|
|
|
+function isValidLoginSession (loginInfo) {
|
|
|
|
|
+ const token = uni.getStorageSync("token");
|
|
|
|
|
+ if (!token) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ const info = loginInfo || {};
|
|
|
|
|
+ const shopId = Number(
|
|
|
|
|
+ uni.getStorageSync("shopId") ||
|
|
|
|
|
+ (info.admin && info.admin.currentShopId) ||
|
|
|
|
|
+ info.currentShopId ||
|
|
|
|
|
+ 0
|
|
|
|
|
+ );
|
|
|
|
|
+ return shopId > 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
name: "me",
|
|
name: "me",
|
|
|
components: {
|
|
components: {
|
|
@@ -204,20 +219,7 @@ export default {
|
|
|
computed: {
|
|
computed: {
|
|
|
...mapGetters(["getLoginInfo"]),
|
|
...mapGetters(["getLoginInfo"]),
|
|
|
isLoggedIn () {
|
|
isLoggedIn () {
|
|
|
- if (uni.getStorageSync("manualLogout") === "1") {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- const token = uni.getStorageSync("token");
|
|
|
|
|
- if (this.$util.isEmpty(token)) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- const loginInfo = this.getLoginInfo || {};
|
|
|
|
|
- const currentShopId = Number(
|
|
|
|
|
- (loginInfo.admin && loginInfo.admin.currentShopId) ||
|
|
|
|
|
- loginInfo.currentShopId ||
|
|
|
|
|
- 0
|
|
|
|
|
- );
|
|
|
|
|
- return currentShopId > 0;
|
|
|
|
|
|
|
+ return isValidLoginSession(this.getLoginInfo);
|
|
|
},
|
|
},
|
|
|
shopTitle () {
|
|
shopTitle () {
|
|
|
const sjName = this.myInfo.sjName || "";
|
|
const sjName = this.myInfo.sjName || "";
|
|
@@ -280,17 +282,25 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onShow () {
|
|
onShow () {
|
|
|
- if (uni.getStorageSync("manualLogout") === "1") {
|
|
|
|
|
- this.$store.commit("setLoginInfo", {});
|
|
|
|
|
- this.$store.commit("setMyShopInfo", {});
|
|
|
|
|
- this.resetGuestState();
|
|
|
|
|
|
|
+ if (isValidLoginSession(this.getLoginInfo)) {
|
|
|
|
|
+ uni.removeStorageSync("manualLogout");
|
|
|
|
|
+ this.getMyInfo();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (!this.isLoggedIn) {
|
|
|
|
|
- this.resetGuestState();
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ this.resetGuestState();
|
|
|
|
|
+ },
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ getLoginInfo: {
|
|
|
|
|
+ handler (val) {
|
|
|
|
|
+ if (isValidLoginSession(val)) {
|
|
|
|
|
+ uni.removeStorageSync("manualLogout");
|
|
|
|
|
+ this.getMyInfo();
|
|
|
|
|
+ } else if (uni.getStorageSync("manualLogout") === "1") {
|
|
|
|
|
+ this.resetGuestState();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ deep: true
|
|
|
}
|
|
}
|
|
|
- this.getMyInfo();
|
|
|
|
|
},
|
|
},
|
|
|
onLoad () {
|
|
onLoad () {
|
|
|
this.setStatusBarHeight();
|
|
this.setStatusBarHeight();
|
|
@@ -441,7 +451,7 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
getMyInfo () {
|
|
getMyInfo () {
|
|
|
- if (!this.isLoggedIn) {
|
|
|
|
|
|
|
+ if (!isValidLoginSession(this.getLoginInfo)) {
|
|
|
this.resetGuestState();
|
|
this.resetGuestState();
|
|
|
uni.stopPullDownRefresh();
|
|
uni.stopPullDownRefresh();
|
|
|
return Promise.resolve();
|
|
return Promise.resolve();
|