From 9d2feb09bb634c4ee31d1ec5c83e84f34a5826c5 Mon Sep 17 00:00:00 2001 From: weiwei Date: Tue, 8 Apr 2025 10:35:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AF=97=E7=94=BB=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 29 +++++++++++++++-------------- src/pages/tabbar/my.vue | 2 ++ src/sheep/utils/request.ts | 2 ++ 3 files changed, 19 insertions(+), 14 deletions(-) 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) {