diff --git a/src/App.vue b/src/App.vue index 9b72032..38fb491 100644 --- a/src/App.vue +++ b/src/App.vue @@ -70,7 +70,10 @@ export default { async onLaunch() { if (isDevEnv()) return + uni.setNavigationBarTitle({ title: "" }) + console.log("环境判断") + // 诗画浦江获取用户信息进行环境判断 const res = await (window as any).CP2.getAppInfo() if (res.code == 0) { diff --git a/src/pages/tabbar/my.vue b/src/pages/tabbar/my.vue index 16d63b5..a8ff039 100644 --- a/src/pages/tabbar/my.vue +++ b/src/pages/tabbar/my.vue @@ -37,6 +37,11 @@ 退出登录 + + + 切换角色 + + @@ -45,6 +50,7 @@ import { reactive } from "vue" import { onLoad, onShow } from "@dcloudio/uni-app" import { isEmpty } from "radash" import { filePath } from "@@/utils/file" +import { getAppInfo } from "@@/utils/getAppInfo" import { hooks, router, constant } from "@@/index" import { userApi } from "@@/api" import isDevEnv from "@/sheep/utils/isDevEnv" @@ -57,7 +63,7 @@ interface MenuItem { router: string } -const state = reactive<{ wallet: any; userInfo: any; menuList: MenuItem[] }>({ +const state = reactive<{ wallet: any; userInfo: any; menuList: MenuItem[]; appInfo: string }>({ wallet: [], userInfo: {}, menuList: [ @@ -67,6 +73,7 @@ const state = reactive<{ wallet: any; userInfo: any; menuList: MenuItem[] }>({ // { text: "跨单位就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/stride-list" }, { text: "人脸管理", icon: "/static/icon/service_5.png", router: "/pages/human-face/list" }, ], + appInfo: "", }) const onTabLogin = () => (isDevEnv() ? router.jump("/pages/test/login") : checkAppInfo()) @@ -190,6 +197,12 @@ const doLogout = async () => { uni.showToast({ title: "退出登录成功", icon: "none" }) } +// 切换角色 +const doChangeRole = () => { + uni.removeStorageSync("userRole") + router.jump("/pages/user/userRole") +} + // 扫一扫 const doScanCode = async () => { usePayStore().setPayData({}) @@ -279,7 +292,7 @@ const getStorageUserInfo = () => { } } -onLoad(() => { +onLoad(async () => { const app = getApp() app._initTabbar() @@ -301,6 +314,8 @@ onLoad(() => { router: "", }) : "" + + state.appInfo = await getAppInfo() }) onShow(() => { getStorageUserInfo() diff --git a/src/pages/user/userRole.vue b/src/pages/user/userRole.vue index 5e096cc..8d0b880 100644 --- a/src/pages/user/userRole.vue +++ b/src/pages/user/userRole.vue @@ -48,7 +48,7 @@ const selectRole = (role: "user" | "merchant") => (userRole.value = role) // 确认选择 const confirmRole = () => { uni.setStorageSync("userRole", userRole.value) - if (userRole.value === "user") uni.switchTab({ url: "/pages/tabbar/coopMerchant" }) - if (userRole.value === "merchant") uni.switchTab({ url: "/pages/tabbar/individualOrder" }) + if (userRole.value === "user") uni.reLaunch({ url: "/pages/tabbar/coopMerchant" }) + if (userRole.value === "merchant") uni.reLaunch({ url: "/pages/tabbar/individualOrder" }) } diff --git a/src/sheep/utils/getAppInfo.ts b/src/sheep/utils/getAppInfo.ts new file mode 100644 index 0000000..5201054 --- /dev/null +++ b/src/sheep/utils/getAppInfo.ts @@ -0,0 +1,15 @@ +// 检测app信息判断运行环境 +export const getAppInfo = async (): Promise => { + try { + const res = await (window as any).CP2.getAppInfo() + // 浙政钉环境 + if (res.code === 0) { + return "dd" + } else { + // 诗画环境 + return "sh" + } + } catch (error) { + return "unknown" + } +} diff --git a/src/uni_modules/tm-ui/components/tm-between-time/tm-between-time.vue b/src/uni_modules/tm-ui/components/tm-between-time/tm-between-time.vue index a067b51..05feffd 100644 --- a/src/uni_modules/tm-ui/components/tm-between-time/tm-between-time.vue +++ b/src/uni_modules/tm-ui/components/tm-between-time/tm-between-time.vue @@ -1,8 +1,8 @@ \ No newline at end of file +