From 013eef46fb7a7de0ea012965e43d98ef10db6b6c Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 10 Jul 2026 15:46:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(common,components):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=BA=95=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F=E6=98=BE?= =?UTF-8?q?=E9=9A=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增isCurrentPageTabBarRoot工具方法封装页面判断逻辑 2. 调整弹窗打开时的导航栏隐藏时机,仅在非TabBar根页面执行 3. 移除弹窗open回调中的导航栏显示逻辑,改为在关闭弹窗时显式处理 4. 补充注释说明回调不可靠的问题和根页面不隐藏导航的原因 --- common/js/util.js | 22 ++++++++++++++++++++++ components-diy/diy-member-info.vue | 11 +++++++---- components/ns-login/ns-login.vue | 12 ++++++++---- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/common/js/util.js b/common/js/util.js index 1600e20..41ec82f 100644 --- a/common/js/util.js +++ b/common/js/util.js @@ -584,6 +584,25 @@ export const isTabBarRootPage = (pagePath, tabBarList) => { }); }; +/** + * 判断**当前**页面是否是 TabBar 根页面 + * 封装了 getCurrentPages() + isTabBarRootPage 的组合,供业务组件在弹窗/操作前判断 + * 例: 登录弹窗在会员中心页打开时,应当跳过 hideTabBar 的调用 + * @returns {boolean} 当前页是 TabBar 项时返回 true,否则 false(getCurrentPages 不可用时也返回 false) + */ +export const isCurrentPageTabBarRoot = () => { + try { + const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : [] + if (!pages || !pages.length) return false + const currentRoute = '/' + String(pages[pages.length - 1].route || '').replace(/^\//, '') + if (!currentRoute) return false + const tabBarList = store && store.state ? store.state.tabBarList : null + return isTabBarRootPage(currentRoute, tabBarList) + } catch (e) { + return false + } +}; + /** * 检查tabBar是否激活 * @param {string} linkUrl 链接路径 /pages/goods/category @@ -671,6 +690,9 @@ export default { /** 判断给定路径是否是 TabBar 根页面(用于动态控制返回按钮显示) */ isTabBarRootPage, + /** 判断当前页面是否是 TabBar 根页面(供业务组件在弹窗前判断是否需要隐藏 TabBar) */ + isCurrentPageTabBarRoot, + /** * 页面跳转 * @param {string} to 跳转链接 /pages/idnex/index diff --git a/components-diy/diy-member-info.vue b/components-diy/diy-member-info.vue index be6313a..50985ff 100644 --- a/components-diy/diy-member-info.vue +++ b/components-diy/diy-member-info.vue @@ -634,10 +634,13 @@ export default { }); }, openCompleteInfoPop(callback) { - this.$refs.completeInfoPopup.open(() => { - this.$store.commit('setBottomNavHidden', false); //显示底部导航 - }); - this.$store.commit('setBottomNavHidden', true); // 隐藏底部导航 + this.$refs.completeInfoPopup.open(); + // 关闭时(setBottomNavHidden=false)由 saveCompleteInfo / cancelCompleteInfo 显式处理, + // 不在 open 回调里写 — 回调在"弹窗被销毁/页面被卸载"等异常路径下不保证触发,会卡住 TabBar 隐藏态 + // TabBar 根页面(如会员中心)不能藏 TabBar — 否则会被自己藏起来 + if (!this.$util.isCurrentPageTabBarRoot()) { + this.$store.commit('setBottomNavHidden', true); // 隐藏底部导航 + } this.completeInfoCallback = callback; }, saveCompleteInfo() { diff --git a/components/ns-login/ns-login.vue b/components/ns-login/ns-login.vue index 6b2b1d0..7ce6a3b 100644 --- a/components/ns-login/ns-login.vue +++ b/components/ns-login/ns-login.vue @@ -237,6 +237,7 @@ export default { // 关闭登录 closeLogin() { this.$refs.completeInfoPopup.close(); + this.$store.commit('setBottomNavHidden', false); // 显示底部导航 }, // 获取注册配置 @@ -346,10 +347,13 @@ export default { if (!this.storeToken) this.getCaptchaConfig(); // #endif - this.$refs.completeInfoPopup.open(() => { - this.$store.commit('setBottomNavHidden', false); //显示底部导航 - }); - this.$store.commit('setBottomNavHidden', true); //隐藏底部导航 + this.$refs.completeInfoPopup.open(); + // 关闭时(setBottomNavHidden=false)由 cancelCompleteInfo / forceBindMobile 显式处理, + // 不在 open 回调里写 — 回调在"弹窗被销毁/页面被卸载"等异常路径下不保证触发,会卡住 TabBar 隐藏态 + // TabBar 根页面(如会员中心)不能藏 TabBar — 否则会被自己藏起来 + if (!this.$util.isCurrentPageTabBarRoot()) { + this.$store.commit('setBottomNavHidden', true); //隐藏底部导航 + } }, // 获取前台登录验证码开关配置