商户角色判断

This commit is contained in:
weiwei committed 2025-04-01 20:13:36 +08:00
1 parent c64d88ee3a
commit 374717bc5c
3 files changed
+27 -5

No files matched your search

+18 -3
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import user from "./sheep/api/user"
import isDevEnv from "./sheep/utils/isDevEnv"
// import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"
@@ -69,8 +70,8 @@ export default {
onLaunch() {
console.log("环境判断")
// 诗画浦江获取用户信息进行环境判断
;(window as any).CP2.getAppInfo().then((res) => {
if (res.code == 0) {
;(window as any).CP2.getAppInfo().then(async (res) => {
if (res.code !== 0) {
// 不是诗画环境
const launchParam = new URL(window.location.href).searchParams.get("launchParam")
console.log("app launch 启动路径参数", launchParam)
@@ -86,7 +87,21 @@ export default {
}
} else {
// 是诗画环境
return uni.redirectTo({ url: "/pages/user/userRole" })
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" })
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" })
}
}
})
},
+9
View File
@@ -87,4 +87,13 @@ export default {
},
})
},
// 判断是否是商户角色
isMerchant: (): Promise<any> =>
request({
url: "/admin/role/isMchUser",
method: "GET",
custom: {
showLoading: false,
},
}),
}