测试诗画登录
This commit is contained in:
1 parent
04164a1b28
commit
9d2feb09bb
3 files changed
+19
-14
No files matched your search
+15
-14
@@ -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() {},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -95,6 +95,8 @@ async function handleShLogin(): Promise<boolean> {
|
||||
return true
|
||||
} else {
|
||||
uni.showToast({ title: "获取用户信息失败", icon: "none" })
|
||||
uni.removeStorageSync(TOKEN_KEY)
|
||||
uni.removeStorageSync(USER_INFO_KEY)
|
||||
return false
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user