refactor(fe): Phase A —— tab 换成「我的」,计划降级,设置拆出来

## tab 结构
首页 / 记录 / 报告 / 社区 / 我的。计划从 tab 移出变二级页(导航栏补了
返回键),从「我的 → 养护计划」进。

## 消灭 5 处硬编码
tabBar 高亮原来靠每个 tab 页在 onShow 里写死 selected: 0/1/2/3/4,
调一次顺序就得同时改五个文件,漏一个就高亮错位——这次把计划换成我的
正好会踩到。改成 tabBar 组件在 pageLifetimes.show 里按当前 route 自己
匹配,五处硬编码全删。

## profile 拆成两页
原来的 profile 混了两类东西:「我是谁」和「怎么设置」。拆开:

pages/mine(tab)  个人名片(头像/昵称/签名/关注粉丝记录三个数)
                   + 我的毛孩子列表 + 常用入口 + 齿轮进设置
pages/settings     提醒设置、会员权益、数据导出、意见反馈、关于我们

「我的」上放了个「看看别人眼里的我」,点进去就是 pages/user 那个公开
主页——自己看和别人看必须是同一个页面同一套渲染,否则两边会慢慢长歪。
这也是 Phase D 装扮功能的落点。

首页齿轮从「进 profile」改成「进设置」(个人页已经在 tab 上了)。
旧的 pages/profile 整个删掉,没留兼容层。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-29 17:33:32 +08:00
parent 3ad1516aa4
commit 60baff8a2b
18 changed files with 242 additions and 78 deletions
+32 -15
View File
@@ -1,20 +1,37 @@
const LIST = [
{ pagePath: '/pages/home/home', text: '首页', icon: 'home' },
{ pagePath: '/pages/record/record', text: '记录', icon: 'record' },
{ pagePath: '/pages/report/report', text: '报告', icon: 'report' },
{ pagePath: '/pages/community/community', text: '社区', icon: 'community' },
{ pagePath: '/pages/mine/mine', text: '我的', icon: 'user' },
];
Component({
data: {
selected: 0,
hidden: false,
list: [
{ pagePath: '/pages/home/home', text: '首页', icon: 'home' },
{ pagePath: '/pages/plan/plan', text: '计划', icon: 'plan' },
{ pagePath: '/pages/record/record', text: '记录', icon: 'record' },
{ pagePath: '/pages/report/report', text: '报告', icon: 'report' },
{ pagePath: '/pages/community/community', text: '社区', icon: 'community' }
]
data: { selected: 0, hidden: false, list: LIST },
// 高亮由当前页面路径自己算出来。
// 原来每个 tab 页在 onShow 里硬写 selected: 0/1/2/3/4,调一次顺序就要同时改
// 五个文件,漏一个就高亮错位——这次把计划换成我的正好会踩到。
pageLifetimes: {
show() {
this.syncSelected();
},
},
lifetimes: {
attached() {
this.syncSelected();
},
},
methods: {
syncSelected() {
const pages = getCurrentPages();
const cur = pages[pages.length - 1];
if (!cur) return;
const path = '/' + cur.route;
const i = LIST.findIndex((t) => t.pagePath === path);
if (i >= 0 && i !== this.data.selected) this.setData({ selected: i });
},
switchTab(e) {
const idx = e.currentTarget.dataset.index;
const path = this.data.list[idx].pagePath;
wx.switchTab({ url: path });
}
}
wx.switchTab({ url: LIST[e.currentTarget.dataset.index].pagePath });
},
},
});