From b687c50e3db940b2b29d0fbd90182a2fef96e755 Mon Sep 17 00:00:00 2001 From: wm <2747639460@qq.com> Date: Thu, 23 Jul 2026 19:54:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(category):=20=E5=88=86=E7=B1=BB=E6=A8=AA?= =?UTF-8?q?=E5=88=97=E5=90=B8=E9=A1=B6=E5=9B=BA=E5=AE=9A=20+=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E9=AB=98=E4=BA=AE=E3=80=8C=E5=85=A8=E9=83=A8=E3=80=8D?= =?UTF-8?q?+=20=E5=8A=A0=E8=BD=BD=E6=80=81=E5=B8=B8=E9=A9=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1) 滚动时顶部分类横列不被隐藏 - filterbar 改 position:sticky,top 用 calc(statusBarHeight px + 88rpx) 精确贴在 navbar 下方, 不同机型状态栏高度差异下不串位;加背景色(var(--bg-grad))避免滚动时内容透出 2) 修复「加载有问题」的感知问题 - 进入分类页(如首页分类 tab)时 activeValue 为空且 values 无空值项,导致所有 chip 都不高亮; 现头部插入「全部」项(value:'')并默认选中,进入即明确当前为全部动作 - filterbar 原 wx:if values.length 在加载期间整块消失;现加载/空态常驻占位(显示『加载分类中…』/『暂无分类』) --- miniprogram/pages/category/category.js | 8 ++++++-- miniprogram/pages/category/category.wxml | 3 ++- miniprogram/pages/category/category.wxss | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/miniprogram/pages/category/category.js b/miniprogram/pages/category/category.js index 0a046d8..124ffb4 100644 --- a/miniprogram/pages/category/category.js +++ b/miniprogram/pages/category/category.js @@ -51,9 +51,13 @@ Page({ this.setData({ loading: true }); const key = DIM_MAP[this.data.dimension] || 'body-parts'; svc.getCategories(key).then((items) => { + const list = (items || []).slice(); + // 头部插入「全部」项:无 value 入参时默认选中,明确当前为「全部」 + list.unshift({ value: '', label: '全部' }); + const activeValue = this.data.value || ''; this.setData({ - values: items || [], - activeValue: this.data.value, + values: list, + activeValue: activeValue, loading: false }); this.loadExercises(); diff --git a/miniprogram/pages/category/category.wxml b/miniprogram/pages/category/category.wxml index 17e8a70..10143c3 100644 --- a/miniprogram/pages/category/category.wxml +++ b/miniprogram/pages/category/category.wxml @@ -2,7 +2,7 @@ - + + {{ loading ? '加载分类中…' : '暂无分类' }} 共 {{total}} 个动作 diff --git a/miniprogram/pages/category/category.wxss b/miniprogram/pages/category/category.wxss index ae8a8dc..11fde5c 100644 --- a/miniprogram/pages/category/category.wxss +++ b/miniprogram/pages/category/category.wxss @@ -1,7 +1,20 @@ .page { min-height: 100vh; background: var(--bg-grad); } -.filterbar { white-space: nowrap; padding: 8rpx 0 4rpx; } +/* 分类横列吸顶:top = 状态栏高度 + 导航栏 88rpx,精确贴在 navbar 下方,不同机型不串位 */ +.filterbar { + position: sticky; + z-index: 40; + white-space: nowrap; + padding: 8rpx 0 4rpx; + background: var(--bg-grad); +} .filterbar chip { display: inline-block; margin-right: 16rpx; } .filterbar__spacer { display: inline-block; width: 4rpx; } +/* 加载 / 空态占位:横列区域常驻,避免加载期间整块消失 */ +.filterbar__loading { + font-size: 24rpx; + padding: 22rpx 4rpx 14rpx; + background: var(--bg-grad); +} .count { font-size: 24rpx; margin: 20rpx 0 8rpx; } .grid { display: flex; flex-wrap: wrap; gap: 18rpx; margin-top: 12rpx; } .grid__item { width: calc((100% - 18rpx) / 2); }