From 64d3ac8f8a3326203888d9ab02736adc0e3804b6 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Tue, 16 Jun 2026 11:25:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=BB=9F=E4=B8=80=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E5=BA=95=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F=E9=97=B4?= =?UTF-8?q?=E8=B7=9D=E9=80=BB=E8=BE=91=E4=B8=8E=E6=98=BE=E7=A4=BA=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增全局计算属性统一处理底部导航栏显示判断与间距样式 2. 替换多个页面的手写底部间距逻辑为通用样式 3. 新增路由匹配工具函数,支持灵活配置导航栏显示范围 4. 优化底部导航组件的显示条件判断 --- common/js/golbalConfig.js | 51 ++++++++++++++++++++ common/js/util.js | 63 +++++++++++++++++++++++++ components-diy/diy-bottom-nav.vue | 4 +- components-diy/diy-merch-list.vue | 16 ++++--- pages_order/list.vue | 9 +--- pages_promotion/fenxiao/goods_list.vue | 11 +---- pages_promotion/fenxiao/index.vue | 2 +- pages_promotion/fenxiao/order.vue | 9 +--- pages_promotion/merch/merchcategory.vue | 3 +- pages_promotion/point/goods_list.vue | 9 +--- pages_promotion/point/list.vue | 9 +--- pages_tool/article/list.vue | 9 +--- pages_tool/cases/index.vue | 9 +--- pages_tool/files/list.vue | 9 +--- pages_tool/goods/brand.vue | 9 +--- pages_tool/goods/coupon.vue | 9 +--- pages_tool/goods/search.vue | 9 +--- pages_tool/notice/list.vue | 9 +--- 18 files changed, 141 insertions(+), 108 deletions(-) diff --git a/common/js/golbalConfig.js b/common/js/golbalConfig.js index ea3de41..d93018c 100644 --- a/common/js/golbalConfig.js +++ b/common/js/golbalConfig.js @@ -22,6 +22,57 @@ export default { tabBarList() { return this.$store.state.tabBarList; }, + shouldShowTabBar() { + const tabBarList = this.$store.state.tabBarList; + if (!tabBarList || !tabBarList.list) { + return false; + } + const mode = tabBarList.page_visibility_mode; + const routeList = tabBarList.page_routes || []; + if (!mode || mode === 'all') { + return true; + } + if (mode === 'none') { + return false; + } + const pages = getCurrentPages(); + if (pages.length === 0) { + return true; + } + const currentPage = pages[pages.length - 1]; + let currentRoute = ''; + if (currentPage.route) { + currentRoute = currentPage.route; + } else if (currentPage.$page && currentPage.$page.path) { + currentRoute = currentPage.$page.path; + } + if (!currentRoute) { + return true; + } + if (!currentRoute.startsWith('/')) { + currentRoute = '/' + currentRoute; + } + const inList = this.$util && this.$util.isPageInRouteList + ? this.$util.isPageInRouteList(currentRoute, routeList) + : false; + if (mode === 'whitelist') { + return inList; + } + if (mode === 'blacklist') { + return !inList; + } + return true; + }, + tabBarPagePaddingStyle() { + return this.$util.objToStyle({ + paddingBottom: this.shouldShowTabBar ? '112rpx' : '0' + }); + }, + tabBarPaddingStyleValue() { + return { + paddingBottom: this.shouldShowTabBar ? '112rpx' : '0' + }; + }, siteInfo() { return this.$store.state.siteInfo; }, diff --git a/common/js/util.js b/common/js/util.js index 9d47240..0caf744 100644 --- a/common/js/util.js +++ b/common/js/util.js @@ -152,6 +152,66 @@ export const resolvePageUrl = (page_key, params = {}) => { return url; }; +/** + * 判断当前路由是否命中 page_routes 列表 + * 支持 3 种写法,可混合使用: + * 1) PAGE_KEY_MAP 的 key → 如 "PAGE_INDEX" + * 2) 实际页面路径 → 如 "/pages/index/index" + * 3) 通配符路径 → 如 "/pages_tool/*" 或 "PAGE_ORDER_*" + * @param {string} currentRoute 当前页面路径(会自动补 / 前缀) + * @param {string[]} routeList 后台配置的 page_routes 数组 + * @returns {boolean} 是否命中 + */ +export const isPageInRouteList = (currentRoute, routeList) => { + if (!currentRoute || !routeList || !Array.isArray(routeList) || routeList.length === 0) { + return false; + } + const route = currentRoute.startsWith('/') ? currentRoute : '/' + currentRoute; + + for (const item of routeList) { + if (!item || typeof item !== 'string') continue; + const entry = item.trim(); + if (!entry) continue; + + if (entry.endsWith('/*')) { + const prefix = entry.slice(0, -1); + if (route.startsWith(prefix)) return true; + continue; + } + + if (entry.endsWith('_*') && PAGE_KEY_MAP) { + const keyPrefix = entry.slice(0, -1); + const matchedPaths = []; + for (const k of Object.keys(PAGE_KEY_MAP)) { + if (k.startsWith(keyPrefix) && PAGE_KEY_MAP[k]) { + matchedPaths.push(PAGE_KEY_MAP[k]); + } + } + for (const p of matchedPaths) { + const pn = p.startsWith('/') ? p : '/' + p; + const dirPrefix = pn.substring(0, pn.lastIndexOf('/') + 1); + if (route.startsWith(dirPrefix)) return true; + if (route === pn) return true; + } + continue; + } + + if (PAGE_KEY_MAP && PAGE_KEY_MAP[entry]) { + let mapped = PAGE_KEY_MAP[entry]; + mapped = mapped.startsWith('/') ? mapped : '/' + mapped; + if (route === mapped) return true; + continue; + } + + if (entry.startsWith('/')) { + if (route === entry) return true; + continue; + } + } + + return false; +}; + /** * 解析 link 对象得到最终可跳转的 URL * 优先级: page_key → wap_url → null @@ -343,6 +403,9 @@ export default { /** 根据 page_key + params 解析实际URL */ resolvePageUrl, + /** 判断当前路由是否命中 page_routes 列表(支持 PAGE_KEY / 实际路径 / 通配符) */ + isPageInRouteList, + /** 解析 link 对象得到最终可跳转的 URL(优先级: page_key → wap_url) */ resolveLinkUrl, diff --git a/components-diy/diy-bottom-nav.vue b/components-diy/diy-bottom-nav.vue index 76e2ac5..1d2089d 100644 --- a/components-diy/diy-bottom-nav.vue +++ b/components-diy/diy-bottom-nav.vue @@ -1,5 +1,5 @@