开发环境菜单页面

This commit is contained in:
weiwei committed 2025-07-15 19:47:53 +08:00
1 parent 209f40ae9b
commit 9fa5be0de1
7 files changed
+225 -140

No files matched your search

+41 -96
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { isDevEnv, getLaunchParam } from "@/sheep/utils/app"
import { getLaunchParam } from "@/sheep/utils/app"
import { getAppInfo } from "@@/utils/app"
interface TabbarItem {
@@ -12,6 +12,14 @@ interface TabbarItem {
}
const tabbar: TabbarItem[] = [
{
pagePath: "pages/tabbar/index",
text: "导航",
iconPath: "",
selectedIconPath: "",
launchParam: [],
auth: [],
},
{
pagePath: "pages/tabbar/canteen",
text: "食堂",
@@ -122,7 +130,7 @@ const setTabbarItem = (index: number, item: TabbarItem, visible: boolean) => {
})
}
// 根据启动参数设置tabbar项目
// 根据启动参数和用户角色设置tabbar
const setTabbar = (launchParam?: string, auth?: string) => {
if (launchParam && !auth) {
tabbar.forEach((item, index) => {
@@ -146,107 +154,44 @@ const setTabbar = (launchParam?: string, auth?: string) => {
}
export default {
async onLaunch() {
if (isDevEnv()) return
// 环境判断
const appInfo = await getAppInfo()
if (appInfo == "zzd") {
// 浙政钉环境
switch (getLaunchParam()) {
case "canteen":
uni.switchTab({ url: "/pages/tabbar/canteen" })
break
case "selfMerchant":
uni.switchTab({ url: "/pages/tabbar/selfMerchant" })
break
case "onlineShop":
uni.switchTab({ url: "/pages/tabbar/onlineShop" })
break
case "coopMerchant":
uni.switchTab({ url: "/pages/tabbar/coopMerchant" })
break
default:
break
}
} else if (appInfo == "sh") {
// 诗画环境
const userRole = uni.getStorageSync("userRole")
const launchParam = getLaunchParam()
if (launchParam == "thirdApp") {
uni.reLaunch({ url: "/pages/thirdApp/thirdAppList" })
return
}
if (launchParam) {
switch (userRole) {
case "merchant":
return uni.switchTab({ url: "/pages/tabbar/individualOrder" })
case "user":
if (launchParam === "selfMerchant") return uni.switchTab({ url: "/pages/tabbar/selfMerchant" })
if (launchParam === "onlineShop") return uni.reLaunch({ url: "/pages/tabbar/onlineShop" })
if (launchParam === "coopMerchant") return uni.reLaunch({ url: "/pages/tabbar/coopMerchant" })
return
case "doorAdmin":
return uni.switchTab({ url: "/pages/tabbar/cabinet" })
default:
return uni.redirectTo({ url: "/pages/user/userRole" })
}
}
}
},
methods: {
async _initTabbar() {
if (isDevEnv()) {
tabbar.forEach((item, index) => {
setTabbarItem(index, item, true)
})
const launchParam = getLaunchParam()
const appInfo = await getAppInfo()
// 浙政钉环境
if (appInfo == "zzd") {
if (!launchParam) return uni.hideTabBar()
setTabbar(launchParam)
uni.showTabBar()
return
}
const launchParam = getLaunchParam()
// 诗画环境
if (appInfo == "sh") {
if (!launchParam) return uni.hideTabBar()
const appInfo = await getAppInfo()
if (appInfo == "zzd") {
// 浙政钉环境
if (launchParam) {
setTabbar(launchParam)
uni.showTabBar()
} else {
uni.hideTabBar()
// uni.showToast({ title: "启动参数不合法", icon: "none" })
}
} else if (appInfo == "sh") {
// 是诗画环境
const userRole = uni.getStorageSync("userRole")
if (launchParam == "thirdApp") {
uni.navigateTo({ url: "/pages/thirdApp/thirdApp" })
return
}
if (launchParam) {
switch (userRole) {
case "user":
setTabbar(launchParam, "user")
uni.showTabBar()
break
case "merchant":
setTabbar(undefined, "merchant")
uni.showTabBar()
break
case "doorAdmin":
setTabbar(undefined, "doorAdmin")
uni.showTabBar()
break
default:
uni.hideTabBar()
uni.removeStorageSync("userRole")
uni.showToast({ title: "用户身份未确认", icon: "none" })
uni.reLaunch({ url: "/pages/user/userRole" })
break
}
} else {
uni.hideTabBar()
// uni.showToast({ title: "启动参数不合法", icon: "none" })
switch (userRole) {
case "user":
setTabbar(launchParam, "user")
uni.showTabBar()
break
case "merchant":
setTabbar(undefined, "merchant")
uni.showTabBar()
break
case "doorAdmin":
setTabbar(undefined, "doorAdmin")
uni.showTabBar()
break
default:
uni.hideTabBar()
uni.removeStorageSync("userRole")
uni.showToast({ title: "用户身份未确认", icon: "none" })
uni.reLaunch({ url: "/pages/user/userRole" })
break
}
}
},
+17 -7
View File
@@ -9,6 +9,13 @@
}
},
"pages": [
{
"path": "pages/tabbar/index",
"style": {
"navigationBarTitleText": "导航",
"disableScroll": true
}
},
{
"path": "pages/tabbar/canteen",
"style": {
@@ -214,8 +221,8 @@
{
"path": "food",
"style": {
"navigationBarTitleText": "菜谱",
"navigationBarBackgroundColor": "#1777FF",
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "",
"disableScroll": true
}
},
@@ -464,7 +471,6 @@
{
"path": "feedback/index",
"style": {
"enablePullDownRefresh": true,
"navigationBarTitleText": "意见反馈"
}
},
@@ -477,7 +483,6 @@
{
"path": "repair/index",
"style": {
"enablePullDownRefresh": true,
"navigationBarTitleText": "维修上报"
}
},
@@ -532,7 +537,6 @@
{
"path": "todo/index",
"style": {
"enablePullDownRefresh": true,
"navigationBarTitleText": "工作待办"
}
}
@@ -548,6 +552,12 @@
},
"tabBar": {
"list": [
{
"pagePath": "pages/tabbar/index",
"text": "",
"iconPath": "",
"selectedIconPath": ""
},
{
"pagePath": "pages/tabbar/canteen",
"text": "",
@@ -609,13 +619,13 @@
"selectedIconPath": ""
},
{
"pagePath": "pages/tabbar/my",
"pagePath": "pages/integrated/index",
"text": "",
"iconPath": "",
"selectedIconPath": ""
},
{
"pagePath": "pages/integrated/index",
"pagePath": "pages/tabbar/my",
"text": "",
"iconPath": "",
"selectedIconPath": ""
+149
View File
@@ -0,0 +1,149 @@
<script setup lang="ts">
import { getAppInfo, getLaunchParam } from "@/sheep/utils/app"
import { onLoad, onShow } from "@dcloudio/uni-app"
const moduleList = [
{
pagePath: "/pages/tabbar/canteen",
text: "食堂",
iconPath: "/static/tabbar/canteen-select.png",
launchParam: "canteen",
},
{
pagePath: "/pages/tabbar/selfMerchant",
text: "自营商家",
iconPath: "/static/tabbar/selfMerchant-select.png",
launchParam: "selfMerchant",
},
{
pagePath: "/pages/tabbar/coopMerchant",
text: "合作商家",
iconPath: "/static/tabbar/coopMerchant-select.png",
launchParam: "coopMerchant",
},
{
pagePath: "/pages/tabbar/onlineShop",
text: "在线商城",
iconPath: "/static/tabbar/online-shop-select.png",
launchParam: "onlineShop",
},
{
pagePath: "/pages/tabbar/cabinet",
text: "智能柜",
iconPath: "/static/tabbar/cabinet-select.png",
launchParam: "cabinet",
},
{
pagePath: "/pages/tabbar/flowStatistics",
text: "流水统计",
iconPath: "/static/tabbar/order-select.png",
launchParam: "flowStatistics",
},
{
pagePath: "/pages/tabbar/visitor",
text: "访客",
iconPath: "/static/tabbar/visitor-select.png",
launchParam: "visitor",
},
{
pagePath: "/pages/tabbar/message",
text: "通知公告",
iconPath: "/static/tabbar/message-select.png",
launchParam: "message",
},
{
pagePath: "/pages/integrated/index",
text: "综合服务",
iconPath: "/static/tabbar/integrated-select.png",
launchParam: "integrated",
},
]
onLoad(() => {
uni.removeStorageSync("launchParam")
jumpByParam()
})
const jumpByParam = async () => {
const appInfo = await getAppInfo() // 环境判断
const launchParam = getLaunchParam() // 获取启动参数
// 浙政钉环境
if (appInfo == "zzd") {
switch (launchParam) {
case "canteen": // 食堂
uni.setStorageSync("launchParam", launchParam)
uni.switchTab({ url: "/pages/tabbar/canteen" })
break
case "selfMerchant": // 自营商家
uni.setStorageSync("launchParam", launchParam)
uni.switchTab({ url: "/pages/tabbar/selfMerchant" })
break
case "onlineShop": // 在线商城
uni.setStorageSync("launchParam", launchParam)
uni.switchTab({ url: "/pages/tabbar/onlineShop" })
break
case "coopMerchant": // 合作商家
uni.setStorageSync("launchParam", launchParam)
uni.switchTab({ url: "/pages/tabbar/coopMerchant" })
break
default:
uni.hideTabBar()
break
}
return
}
// 诗画环境
if (appInfo == "sh") {
const userRole = uni.getStorageSync("userRole") // 获取用户角色
if (!launchParam) return uni.hideTabBar()
if (launchParam == "thirdApp") return uni.reLaunch({ url: "/pages/thirdApp/thirdAppList" })
switch (userRole) {
case "merchant":
return uni.switchTab({ url: "/pages/tabbar/individualOrder" })
case "user":
if (launchParam === "selfMerchant") {
uni.setStorageSync("launchParam", launchParam)
return uni.switchTab({ url: "/pages/tabbar/selfMerchant" })
}
if (launchParam === "onlineShop") {
uni.setStorageSync("launchParam", launchParam)
return uni.reLaunch({ url: "/pages/tabbar/onlineShop" })
}
if (launchParam === "coopMerchant") {
uni.setStorageSync("launchParam", launchParam)
return uni.reLaunch({ url: "/pages/tabbar/coopMerchant" })
}
case "doorAdmin":
return uni.switchTab({ url: "/pages/tabbar/cabinet" })
default:
return uni.redirectTo({ url: "/pages/user/userRole" })
}
}
}
const doModuleJump = (item: any) => {
uni.setStorageSync("launchParam", item.launchParam)
uni.switchTab({ url: item.pagePath })
}
</script>
<template>
<crud-layout mainIsScroll bg="/static/page/blue-bg.png">
<view class="h-30rpx" />
<tm-sheet :margin="[0]">
<view class="flex-row items-center justify-center flex-wrap">
<view class="w-half flex justify-center py-2 rounded-1" v-for="(item, index) in moduleList" :key="index">
<view class="w-half text-center rounded-1 active:bg-#e8e8e8 duration-200" @tap="doModuleJump(item)">
<image class="w-80 h-80 px-2 pt-2" :src="item.iconPath" />
<tm-text font-size="32">{{ item.text }}</tm-text>
</view>
</view>
</view>
</tm-sheet>
<view class="h-30rpx" />
</crud-layout>
</template>
+12 -25
View File
@@ -84,7 +84,6 @@ const state = reactive<{
menuList: [
{ text: "扫一扫", icon: "/static/icon/scan.png", router: "" },
{ text: "钱包管理", icon: "/static/icon/service_3.png", router: "/pages/wallet/list" },
// { text: "包厢预定", icon: "/static/icon/service_4.png", router: "/pages/boxes/apply-list" },
{ text: "人脸管理", icon: "/static/icon/service_5.png", router: "/pages/human-face/list" },
{ text: "清除缓存", icon: "/static/icon/clear-storage.png", router: "" },
],
@@ -136,7 +135,6 @@ const storage = {
success: (res) => {
if (res.confirm) {
uni.clearStorageSync()
uni.removeStorageSync("userRole")
state.userInfo = {}
uni.reLaunch({ url: "/pages/tabbar/my" })
}
@@ -372,9 +370,10 @@ const scanCode = {
const onTabLogin = () => (isDevEnv() ? router.jump("/pages/user/login") : login.checkAppInfo())
const onTabMenu = async (item: any, index: number) => {
const onTabMenu = async (item: any) => {
const isLogin = await hooks.useCheckLogin()
if (isLogin) {
if (item.router == "/pages/tabbar/index") return uni.reLaunch({ url: item.router })
switch (item.text) {
case "扫一扫":
await scanCode.scan()
@@ -401,28 +400,16 @@ const doChangeRole = () => {
// 初始化配置菜单
const initMenuConfig = () => {
if (isDevEnv()) {
state.menuList.push({ text: "dev-外来人员就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/foreign-list" })
state.menuList.push({ text: "dev-跨单位就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/stride-list" })
state.menuList.push({
text: "测试-第三方应用",
icon: "/static/icon/login.png",
router: "/pages/thirdApp/thirdAppList",
})
state.menuList.push({
text: "测试-登录",
icon: "/static/icon/login.png",
router: "/pages/user/login",
})
state.menuList.push({
text: "测试-角色选择",
icon: "/static/icon/login.png",
router: "/pages/user/userRole",
})
state.menuList.push({
text: "测试-意见反馈",
icon: "/static/icon/service_5.png",
router: "/pages/integrated/feedback",
})
state.menuList.push(
{ text: "dev-✨导航✨", icon: "/static/icon/service_1.png", router: "/pages/tabbar/index" },
{ text: "dev-外来人员就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/foreign-list" },
{ text: "dev-跨单位就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/stride-list" },
{ text: "dev-包厢预定", icon: "/static/icon/service_4.png", router: "/pages/boxes/apply-list" },
{ text: "dev-第三方应用", icon: "/static/icon/login.png", router: "/pages/thirdApp/thirdAppList" },
{ text: "dev-登录", icon: "/static/icon/login.png", router: "/pages/user/login" },
{ text: "dev-角色选择", icon: "/static/icon/login.png", router: "/pages/user/userRole" },
{ text: "dev-意见反馈", icon: "/static/icon/service_5.png", router: "/pages/integrated/feedback/index" },
)
}
}
+1 -1
View File
@@ -123,7 +123,7 @@ const doRefund = (v: any) => {
</view>
<view class="flex-row items-center justify-between m-t-5rpx">
<view class="sub-text-24">
<text v-if="v.payType == '9'">{{ v.productDesc }}</text>
<text v-if="v.payType == '9'">{{ v.productDesc?.replaceAll(";", "\;\n") }}</text>
</view>
<view class="main-text-30 whitespace-nowrap color-red! text-right">¥ {{ hooks.useMoney(v.totalPrice) }}</view>
</view>
+2 -8
View File
@@ -62,7 +62,7 @@
<script setup lang="ts">
import { ref, reactive } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { onShow } from "@dcloudio/uni-app"
import { hooks } from "@@/index"
import { merchantApi } from "@@/api"
import { filePath } from "@@/utils/file"
@@ -75,14 +75,8 @@ const state = reactive({
show: false,
})
onLoad(() => {
const app = getApp()
app._initTabbar()
})
onShow(() => {
if (pageRef.value) {
pageRef.value.reload(false)
}
if (pageRef.value) pageRef.value.reload(false)
})
const pageRef = ref<any>(null)
+3 -3
View File
@@ -4,7 +4,7 @@ export const isDevEnv = (): boolean => process.env.NODE_ENV === "development"
// 获取启动参数
export const getLaunchParam = (): string => {
return new URL(window.location.href).searchParams.get("launchParam") || ""
return new URL(window.location.href).searchParams.get("launchParam") || uni.getStorageSync("launchParam") || ""
}
// 检测app信息判断运行环境
@@ -13,11 +13,11 @@ export const getAppInfo = async (): Promise<string> => {
const res = await (window as any).CP2.getAppInfo()
// 浙政钉环境
if (res.code === 0) {
console.log("环境:zzd")
console.log("环境:浙政钉-zzd")
return "zzd"
} else {
// 诗画环境
console.log("环境:sh")
console.log("环境:诗画浦江-sh")
return "sh"
}
} catch (error) {