diff --git a/src/App.vue b/src/App.vue index ab4bab0..de94b6d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -73,7 +73,7 @@ export default { console.log("环境判断") // 诗画浦江获取用户信息进行环境判断 const res = await (window as any).CP2.getAppInfo() - if (res.code == 0) { + if (res.code !== 0) { // 不是诗画环境 const launchParam = new URL(window.location.href).searchParams.get("launchParam") console.log("app launch 启动路径参数", launchParam) @@ -90,20 +90,21 @@ export default { } else { // 是诗画环境 const userRole = uni.getStorageSync("userRole") - if (userRole && userRole == "user") uni.switchTab({ url: "/pages/tabbar/coopMerchant" }) - if (userRole && userRole == "merchant") uni.switchTab({ url: "/pages/tabbar/individualOrder" }) + if (!userRole) return uni.redirectTo({ url: "/pages/user/userRole" }) + if (userRole && userRole == "user") return uni.switchTab({ url: "/pages/tabbar/coopMerchant" }) + if (userRole && userRole == "merchant") return uni.switchTab({ url: "/pages/tabbar/individualOrder" }) - const res = await user.isMerchant() - if (res.code == 0) { - if (res.data) { - return uni.redirectTo({ url: "/pages/user/userRole" }) - } else { - uni.setStorageSync("userRole", "user") - uni.switchTab({ url: "/pages/tabbar/coopMerchant" }) - } - } else { - uni.showToast({ title: "角色身份判断失败", icon: "none" }) - } + // const res = await user.isMerchant() + // if (res.code == 0) { + // if (res.data) { + // return uni.redirectTo({ url: "/pages/user/userRole" }) + // } else { + // uni.setStorageSync("userRole", "user") + // uni.switchTab({ url: "/pages/tabbar/coopMerchant" }) + // } + // } else { + // uni.showToast({ title: "角色身份判断失败", icon: "none" }) + // } } }, onShow() {}, diff --git a/src/pages/tabbar/my.vue b/src/pages/tabbar/my.vue index bca2f5b..16d63b5 100644 --- a/src/pages/tabbar/my.vue +++ b/src/pages/tabbar/my.vue @@ -135,6 +135,8 @@ const doLogin = async (loginType: number, token: string, accountId: string, sess getStorageUserInfo() } else { uni.hideLoading() + uni.removeStorageSync(tokenKey) + uni.removeStorageSync(userInfoKey) uni.showToast({ title: "登录失败", icon: "none" }) } break diff --git a/src/sheep/utils/request.ts b/src/sheep/utils/request.ts index b397bca..d071c9a 100644 --- a/src/sheep/utils/request.ts +++ b/src/sheep/utils/request.ts @@ -95,6 +95,8 @@ async function handleShLogin(): Promise { return true } else { uni.showToast({ title: "获取用户信息失败", icon: "none" }) + uni.removeStorageSync(TOKEN_KEY) + uni.removeStorageSync(USER_INFO_KEY) return false } } catch (error) {