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); }