From c2a09a505743e7d024db0c445ee3faff1132c71e Mon Sep 17 00:00:00 2001 From: future <1360317836@qq.com> Date: Thu, 11 Jun 2026 14:51:07 +0800 Subject: [PATCH] =?UTF-8?q?tabbar=E9=80=82=E9=85=8D=E5=AE=89=E5=8D=93?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gym-manage-uniapp/App.vue | 108 +++++++++--------- gym-manage-uniapp/components/TabBar.vue | 83 ++++++++++---- gym-manage-uniapp/manifest.json | 8 +- gym-manage-uniapp/pages.json | 2 +- gym-manage-uniapp/pages/course/index.vue | 107 ++++++++--------- gym-manage-uniapp/pages/discover/index.vue | 104 ++++++++--------- gym-manage-uniapp/pages/index/index.vue | 78 ++++--------- .../pages/memberInfo/memberInfo.vue | 18 ++- gym-manage-uniapp/pages/train/index.vue | 104 ++++++++--------- 9 files changed, 308 insertions(+), 304 deletions(-) diff --git a/gym-manage-uniapp/App.vue b/gym-manage-uniapp/App.vue index 6b319d8..b72acaf 100644 --- a/gym-manage-uniapp/App.vue +++ b/gym-manage-uniapp/App.vue @@ -3,75 +3,81 @@ + - - \ No newline at end of file + \ No newline at end of file diff --git a/gym-manage-uniapp/components/TabBar.vue b/gym-manage-uniapp/components/TabBar.vue index 174a95e..1ad9eb8 100644 --- a/gym-manage-uniapp/components/TabBar.vue +++ b/gym-manage-uniapp/components/TabBar.vue @@ -1,21 +1,23 @@ @@ -98,15 +100,22 @@ function checkShouldShow() { let routeWatcher = null let appRouteCallback = null +let isNavigating = false onMounted(() => { syncActiveState() checkShouldShow() - // #ifdef APP-PLUS + // #ifndef MP-WEIXIN + // H5和其他平台使用轮询监听路由变化 routeWatcher = setInterval(() => { - syncActiveState() + // 导航期间不更新状态,避免覆盖用户点击的索引 + if (isNavigating) return + const newIndex = getActiveIndexFromRoute() + if (newIndex !== currentActiveIndex.value) { + currentActiveIndex.value = newIndex + } checkShouldShow() - }, 300) + }, 200) // #endif // #ifdef MP-WEIXIN if (typeof uni.onAppRoute === 'function') { @@ -122,12 +131,17 @@ onMounted(() => { }) onBeforeUnmount(() => { - // #ifdef APP-PLUS - if (routeWatcher) { clearInterval(routeWatcher) } + // #ifndef MP-WEIXIN + // H5和其他平台清理定时器 + if (routeWatcher) { + clearInterval(routeWatcher) + routeWatcher = null + } // #endif // #ifdef MP-WEIXIN if (appRouteCallback && typeof uni.offAppRoute === 'function') { uni.offAppRoute(appRouteCallback) + appRouteCallback = null } // #endif }) @@ -184,9 +198,12 @@ function onTabTap(index) { const currentPath = TAB_ROUTES[currentActiveIndex.value] if (targetPath === currentPath) return console.log('Tab 点击:', index, targetPath) + // 立即更新状态 currentActiveIndex.value = index emit('update:active', index) emit('tab-change', index) + // 设置导航标志,阻止轮询覆盖状态 + isNavigating = true let timer = setTimeout(() => { uni.showLoading({ title: '加载中...', mask: true }) }, 50) @@ -203,7 +220,10 @@ function onTabTap(index) { uni.hideLoading() setTimeout(() => { isSwitching = false + isNavigating = false + // #ifdef MP-WEIXIN syncActiveState() + // #endif checkShouldShow() }, 100) } @@ -215,11 +235,21 @@ function onTabTap(index) { // 引入字体图标 CSS(定义 @font-face) @import '/common/style/tabbar_icon/tabbar.css'; -.tab-bar { +// 固定容器 - 确保TabBar始终在屏幕底部 +.tab-bar-wrapper { position: fixed; bottom: 0; left: 0; right: 0; + z-index: 9999; + pointer-events: none; +} + +.tab-bar-wrapper .tab-bar { + pointer-events: auto; +} + +.tab-bar { height: 120rpx; background: white; backdrop-filter: blur(24px); @@ -231,7 +261,14 @@ function onTabTap(index) { padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4rpx 24rpx var(--tabbar-shadow); border-radius: 32rpx 32rpx 0 0; - z-index: 999; + /* 防闪烁优化 */ + transform: translateZ(0); + -webkit-transform: translateZ(0); + will-change: transform; + backface-visibility: hidden; + -webkit-backface-visibility: hidden; + perspective: 1000; + -webkit-perspective: 1000; } .tab-item { diff --git a/gym-manage-uniapp/manifest.json b/gym-manage-uniapp/manifest.json index f6e57db..70f4370 100644 --- a/gym-manage-uniapp/manifest.json +++ b/gym-manage-uniapp/manifest.json @@ -1,6 +1,6 @@ { - "name" : "gym-manage-uniapp", - "appid" : "__UNI__1F1874C", + "name" : "活氧舱", + "appid" : "__UNI__52E2F0D", "description" : "", "versionName" : "1.0.0", "versionCode" : "100", @@ -41,7 +41,9 @@ ] }, /* ios打包配置 */ - "ios" : {}, + "ios" : { + "dSYMs" : false + }, /* SDK配置 */ "sdkConfigs" : {} } diff --git a/gym-manage-uniapp/pages.json b/gym-manage-uniapp/pages.json index 0a10e5e..45c07e7 100644 --- a/gym-manage-uniapp/pages.json +++ b/gym-manage-uniapp/pages.json @@ -284,7 +284,7 @@ }, "uniIdRouter": {}, "tabBar": { - "custom": true, // 启用自定义 tabBar + "custom": true, "list": [ { "pagePath": "pages/index/index", "text": "首页" }, { "pagePath": "pages/course/index", "text": "课程" }, diff --git a/gym-manage-uniapp/pages/course/index.vue b/gym-manage-uniapp/pages/course/index.vue index cb7ab10..8ae02bd 100644 --- a/gym-manage-uniapp/pages/course/index.vue +++ b/gym-manage-uniapp/pages/course/index.vue @@ -1,40 +1,43 @@ \ No newline at end of file diff --git a/gym-manage-uniapp/pages/discover/index.vue b/gym-manage-uniapp/pages/discover/index.vue index 58e3237..7e145a7 100644 --- a/gym-manage-uniapp/pages/discover/index.vue +++ b/gym-manage-uniapp/pages/discover/index.vue @@ -1,34 +1,37 @@ diff --git a/gym-manage-uniapp/pages/index/index.vue b/gym-manage-uniapp/pages/index/index.vue index c4665ce..f7f0585 100644 --- a/gym-manage-uniapp/pages/index/index.vue +++ b/gym-manage-uniapp/pages/index/index.vue @@ -1,9 +1,4 @@