diff --git a/src/manifest.json b/src/manifest.json index a4d92a2..7a7c3df 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { "name": "", - "appid": "", + "appid": "wx11771c7bf2913cb2", "description": "", "versionName": "1.0.0", "versionCode": "100", @@ -50,7 +50,7 @@ "quickapp": {}, /* 小程序特有相关 */ "mp-weixin": { - "appid": "", + "appid": "wx11771c7bf2913cb2", "setting": { "urlCheck": false }, diff --git a/src/pages/integrated/notice/index.vue b/src/pages/integrated/notice/index.vue index e6b2753..5ed9ed3 100644 --- a/src/pages/integrated/notice/index.vue +++ b/src/pages/integrated/notice/index.vue @@ -1,5 +1,6 @@ + + diff --git a/src/pages/third-app/happyMall.vue b/src/pages/third-app/happyMall.vue index 5bf377d..1104de9 100644 --- a/src/pages/third-app/happyMall.vue +++ b/src/pages/third-app/happyMall.vue @@ -33,8 +33,18 @@ function normalizeMallUrl(rawUrl: string) { const [, origin, rawPathname = "/", search = "", hash = ""] = matched const queryItems = search.slice(1).split("&").filter(Boolean) - const queryKeys = queryItems.map((item) => decodeURIComponent(item.split("=")[0] || "")) - const hasToken = queryItems.some((item) => /^token=.+/i.test(item)) + const decodeQueryPart = (value: string) => { + try { + return decodeURIComponent(value) + } catch { + return value + } + } + const queryKeys = queryItems.map((item) => decodeQueryPart(item.split("=")[0] || "")) + const hasToken = queryItems.some((item) => { + const [key, ...valueParts] = item.split("=") + return decodeQueryPart(key || "").toLowerCase() === "token" && valueParts.join("=") + }) let pathname = rawPathname // 宁波银行正常登录页是 /h5/thirdApp;部分环境会错误返回带 token 的根路径。 @@ -51,7 +61,22 @@ function normalizeMallUrl(rawUrl: string) { if (pathname === "/" || !hasToken) { throw new Error("商城登录地址异常,请联系管理员") } - return `${origin}${pathname}${search}${hash}` + + // 宁波银行 H5 通过 platform 判断是否运行在微信小程序中。设置为 XR 后, + // H5 左上角返回按钮会调用 wx.miniProgram.navigateBack(),直接返回小程序上一页, + // 不会先消耗宁波银行 H5 自己的 history。覆盖旧值,避免后端返回其他平台参数。 + const queryWithoutPlatform = queryItems.filter((item) => { + const key = decodeQueryPart(item.split("=")[0] || "").toLowerCase() + return key !== "platform" + }) + queryWithoutPlatform.push("platform=XR") + const normalizedSearch = `?${queryWithoutPlatform.join("&")}` + console.log("[happyMall] 跳转平台:", { + platform: "XR", + queryKeys: queryWithoutPlatform.map((item) => decodeQueryPart(item.split("=")[0] || "")), + }) + + return `${origin}${pathname}${normalizedSearch}${hash}` } onLoad(async () => { diff --git a/src/sheep/components/crud/crud-layout/crud-layout.vue b/src/sheep/components/crud/crud-layout/crud-layout.vue index d756303..6538ba6 100644 --- a/src/sheep/components/crud/crud-layout/crud-layout.vue +++ b/src/sheep/components/crud/crud-layout/crud-layout.vue @@ -93,6 +93,10 @@ function initBackStyle() { function tabbarChange(index: number) { const target = tabbarStore.tabbarList[index] if (!target) return + if (target.pagePath === "/pages/root/dashboard") { + // 从业务导航返回工作台时,让首页根 Tabbar 同步选中“首页”。 + tabbarStore.setRootActiveIndex(0) + } jump(target.pagePath, {}, 3) } diff --git a/src/sheep/stores/tabbar.ts b/src/sheep/stores/tabbar.ts index dae372b..a6c2e87 100644 --- a/src/sheep/stores/tabbar.ts +++ b/src/sheep/stores/tabbar.ts @@ -118,16 +118,62 @@ const TABBAR_CONSTANT: Array = [ launchParam: ["integrated"], auth: ["user"], }, + { + pagePath: "/pages/integrated/notice/index", + text: "通知公告", + iconPath: "/static/tabbar/notice.png", + selectedIconPath: "/static/tabbar/notice-select.png", + launchParam: ["notice"], + auth: ["user"], + }, + { + pagePath: "/pages/integrated/feedback/index", + text: "意见反馈", + iconPath: "/static/tabbar/feedback.png", + selectedIconPath: "/static/tabbar/feedback-select.png", + launchParam: ["feedback"], + auth: ["user"], + }, { pagePath: "/pages/tabbar/my", text: "我的", iconPath: "/static/tabbar/my.png", selectedIconPath: "/static/tabbar/my-select.png", - launchParam: ["canteen", "selfMerchant", "onlineShop", "coopMerchant", "integrated", "prosperityShop", "prosperityShopMchList"], + launchParam: [ + "canteen", + "selfMerchant", + "onlineShop", + "coopMerchant", + "integrated", + "prosperityShop", + "prosperityShopMchList", + "notice", + "feedback", + ], auth: ["user", "merchant", "doorAdmin"], }, ] +const WORKBENCH_TABBAR_ITEM: TabbarItem = { + pagePath: "/pages/root/dashboard", + text: "工作台", + iconPath: "/static/tabbar/home.png", + selectedIconPath: "/static/tabbar/home-select.png", + launchParam: [], + auth: [], +} + +function getTabbarLaunchParam(url?: string) { + const launchParam = getLaunchParam(url) + if (launchParam) return launchParam + if (!url) return "" + + // 常用功能也可能直接配置 Tabbar 页面路径,需要由页面反推出所属业务场景。 + const pagePath = url.split("?")[0] + const tabbarItem = TABBAR_CONSTANT.find((item) => item.pagePath === pagePath) + return tabbarItem?.launchParam[0] || "" +} + const defaultRootTabbarList: Array = [ { pagePath: "/pages/root/dashboard", @@ -166,13 +212,17 @@ export const useTabbarStore = defineStore("tabbarStore", { }), getters: { isDashboardPage(state) { - return `/${state.currentRoute}` === "/pages/root/dashboard" || `/${state.currentRoute}` === "/pages/tabbar/my" + const currentRoute = state.currentRoute.startsWith("/") ? state.currentRoute : `/${state.currentRoute}` + return currentRoute === "/pages/root/dashboard" || currentRoute === "/pages/tabbar/my" }, isTabbar(state) { - return state.tabbarList.some((item) => item.pagePath === `/${state.currentRoute}`) + const currentRoute = state.currentRoute.startsWith("/") ? state.currentRoute : `/${state.currentRoute}` + // 工作台只作为业务 Tabbar 的返回入口,进入页面后仍展示首页自己的根 Tabbar。 + return currentRoute !== WORKBENCH_TABBAR_ITEM.pagePath && state.tabbarList.some((item) => item.pagePath === currentRoute) }, activeIndex(state) { - return state.tabbarList.findIndex((item) => item.pagePath === `/${state.currentRoute}`) + const currentRoute = state.currentRoute.startsWith("/") ? state.currentRoute : `/${state.currentRoute}` + return state.tabbarList.findIndex((item) => item.pagePath === currentRoute) }, pageTabbarList(state) { return state.tabbarList.map((item) => { @@ -196,22 +246,25 @@ export const useTabbarStore = defineStore("tabbarStore", { }, actions: { async componetTabbarList(launchParam?: string) { - let _launchParam = "" - if (launchParam) { - _launchParam = getLaunchParam(launchParam) - } else { - _launchParam = getLaunchParam() - } - if (this.launchParam === _launchParam) return + const _launchParam = getTabbarLaunchParam(launchParam) + const hasMyTabbar = this.tabbarList.some((item) => item.pagePath === "/pages/tabbar/my") + const hasWorkbenchTabbar = this.tabbarList.some((item) => item.pagePath === WORKBENCH_TABBAR_ITEM.pagePath) + // 热更新或旧状态中可能已有相同场景但尚未加入工作台,此时仍需重新组装。 + if (this.launchParam === _launchParam && (!hasMyTabbar || hasWorkbenchTabbar)) return const appInfo = await getAppInfo() if (!_launchParam || !appInfo) return const tabbarList: Array = [] - TABBAR_CONSTANT.forEach((item, index) => { + TABBAR_CONSTANT.forEach((item) => { const visible = item.launchParam.includes(_launchParam) if (visible) { tabbarList.push(item) } }) + const myTabbarIndex = tabbarList.findIndex((item) => item.pagePath === "/pages/tabbar/my") + if (myTabbarIndex !== -1) { + // 仅对带“我的”的业务导航生效,并保证“工作台”紧邻其左侧。 + tabbarList.splice(myTabbarIndex, 0, WORKBENCH_TABBAR_ITEM) + } this.tabbarList = tabbarList this.launchParam = _launchParam }, diff --git a/src/static/tabbar/feedback-select.png b/src/static/tabbar/feedback-select.png new file mode 100644 index 0000000..087a44e Binary files /dev/null and b/src/static/tabbar/feedback-select.png differ diff --git a/src/static/tabbar/feedback.png b/src/static/tabbar/feedback.png new file mode 100644 index 0000000..6605b5b Binary files /dev/null and b/src/static/tabbar/feedback.png differ diff --git a/src/static/tabbar/notice-select.png b/src/static/tabbar/notice-select.png new file mode 100644 index 0000000..90f55d6 Binary files /dev/null and b/src/static/tabbar/notice-select.png differ diff --git a/src/static/tabbar/notice.png b/src/static/tabbar/notice.png new file mode 100644 index 0000000..3f9ef60 Binary files /dev/null and b/src/static/tabbar/notice.png differ