基于 2026-08-08-tabbar-redesign.md 设计文档 状态:pending · 待执行
将小程序底部 TabBar 从 5 个五维标签(行/心/身/智/富)重构为 4 个功能标签(首页/健康/成长/我的)+ 中间五维启动器按钮。
1.1 创建 utils/nav.js 统一导航工具
/**
* 统一导航工具
* TabBar 页面列表(4个新Tab)
*/
var TAB_BAR_PAGES = [
'/pages/index-home/index',
'/pages/health/index',
'/pages/growth/index',
'/pages/profile/profile'
]
/**
* 跳转到维度页面(五维页已移出 TabBar,统一用 navigateTo)
* 行 = index-home(仍是 TabBar 页,用 switchTab)
* 心/身/智/富 = 分包页,用 navigateTo
*/
function goDimension(dimCode) {
var dimMap = {
action: '/pages/index-home/index',
mind: '/pages/mind/index',
body: '/pages/body/index',
wisdom: '/pages/wisdom/index',
wealth: '/pages/wealth/index'
}
var url = dimMap[dimCode]
if (!url) return
if (TAB_BAR_PAGES.indexOf(url) !== -1) {
uni.switchTab({ url: url })
} else {
uni.navigateTo({ url: url })
}
}
function goPage(url) {
if (!url) return
if (TAB_BAR_PAGES.indexOf(url) !== -1) {
uni.switchTab({ url: url })
} else {
uni.navigateTo({ url: url })
}
}
module.exports = {
TAB_BAR_PAGES: TAB_BAR_PAGES,
goDimension: goDimension,
goPage: goPage
}
1.2 准备 TabBar 图标
static/tab-home.png / static/tab-home-active.pngstatic/tab-health.png / static/tab-health-active.pngstatic/tab-growth.png / static/tab-growth-active.png(已有)static/tab-profile.png / static/tab-profile-active.png(已有)2.1 修改主包 pages 数组(5 页 → 4 页)
{
"pages": [
{ "path": "pages/index-home/index", "style": { "navigationBarTitleText": "首页" } },
{ "path": "pages/health/index", "style": { "navigationBarTitleText": "健康" } },
{ "path": "pages/growth/index", "style": { "navigationBarTitleText": "成长档案" } },
{ "path": "pages/profile/profile", "style": { "navigationBarTitleText": "我的" } }
]
}
2.2 修改 tabBar.list
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#F97316",
"borderStyle": "black",
"backgroundColor": "#FFFFFF",
"list": [
{ "pagePath": "pages/index-home/index", "text": "首页", "iconPath": "static/tab-home.png", "selectedIconPath": "static/tab-home-active.png" },
{ "pagePath": "pages/health/index", "text": "健康", "iconPath": "static/tab-health.png", "selectedIconPath": "static/tab-health-active.png" },
{ "pagePath": "pages/growth/index", "text": "成长", "iconPath": "static/tab-growth.png", "selectedIconPath": "static/tab-growth-active.png" },
{ "pagePath": "pages/profile/profile", "text": "我的", "iconPath": "static/tab-profile.png", "selectedIconPath": "static/tab-profile-active.png" }
]
}
2.3 分包调整
| 操作 | 分包 | 说明 |
|---|---|---|
| 移除 | pages/growth |
删除 { "path": "index" } 条目 |
| 移除 | pages/profile |
删除 { "path": "profile" } 条目 |
| 新增 | pages/mind-detail |
添加 { "path": "index", "style": { "navigationBarTitleText": "心" } } |
| 新增 | pages/body-detail |
添加 { "path": "index", "style": { "navigationBarTitleText": "身" } } |
| 新增 | pages/wisdom-detail |
添加 { "path": "index", "style": { "navigationBarTitleText": "智" } } |
| 新建 | pages/wealth 分包 |
含 { "path": "index", "style": { "navigationBarTitleText": "富" } } |
3.1 index-home/index.vue — onFuncClick 中改用 nav.goPage()
3.2 wisdom/index.vue — onFuncClick 中改用 nav.goPage()
3.3 wisdom/self-quiz.vue — switchTab → navigateTo
3.4 wisdom-detail/self-quiz.vue — switchTab → navigateTo
3.5 全局 grep 兜底
grep -rn "switchTab.*/pages/\(mind\|body\|wisdom\|wealth\)" --include="*.vue" .
预期:无输出
4.1 重构 custom-tab-bar/index.vue
模板结构:
4.2 五维半屏浮层
5.1 创建 pages/health/index.vue
内容:
6.1 改造 pages/growth/index.vue
从"档案查看"扩展为"方案执行中心":
新增内容:
保留原有:
推荐分布原则:
7.1 首页 index-home/index.vue
7.2 成长页 growth/index.vue
7.3 健康页 pages/health/index.vue
8.1 profile/profile.vue
ProfileMenu 的 showServices prop 改为 true9.1 构建
cd cfc-frontend && npm run build:mp-weixin
9.2 路由完整性检查
grep -rn "switchTab.*/pages/\(mind\|body\|wisdom\|wealth\)" --include="*.vue" .
预期:无输出
9.3 主包体积确认
阶段1 → 阶段3(nav.js 是 switchTab 改造的前提)
↘ 阶段4(custom-tab-bar 需要 nav.js)
阶段2 → 阶段3(pages.json 改完后 switchTab 才失效)
阶段5、6、7 可并行
阶段8 独立
阶段9 最后
若构建失败:
pages.json 到 git HEADcustom-tab-bar/index.vue 到 git HEAD