feat(fe): 首页改成品牌活泼版(本次设计语言的样板页)

- 门面换成完成度环 + 状态 chip:一眼能看到「今天还剩几件事」,
  原来的 hero 卡只是把宠物信息平铺,占了 340rpx 却没给出任何判断
- 快速记录 8 宫格从 emoji 换成图标 + 4 色分类(体重/疫苗=橙、
  便便/饮食=绿、异常/用药=蓝、消费/照片=紫),靠颜色分组而不是靠认 emoji
- AI 建议卡底部加深色 CTA,全页唯一的深色块,指明主操作
- 顶部 🔔⚙ 换成图标;日期条、任务卡、空态全部走 token
- 任务列表落地时顺手算未完成数,门面文案由它驱动

后 8 页按这套语言套用,不再重新发明。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-29 10:40:09 +08:00
parent 15ff59e6db
commit c076968b2c
4 changed files with 112 additions and 71 deletions
+44 -4
View File
@@ -19,11 +19,39 @@ function mapTask(t) {
};
}
// 快速记录入口。颜色按类别分组(体重/疫苗=橙、便便/饮食=绿、异常/用药=蓝、消费/照片=紫),
// 靠颜色和图标区分,不再靠 emoji。
const QUICK_ITEMS = [
{ type: 'weight', icon: 'weight', label: '体重', tone: 'tone-1' },
{ type: 'poop', icon: 'poop', label: '便便', tone: 'tone-2' },
{ type: 'food', icon: 'food', label: '饮食', tone: 'tone-2' },
{ type: 'symptom', icon: 'symptom', label: '异常', tone: 'tone-3' },
{ type: 'cost', icon: 'cost', label: '消费', tone: 'tone-4' },
{ type: 'medicine', icon: 'medicine', label: '用药', tone: 'tone-3' },
{ type: 'photo', icon: 'photo', label: '照片', tone: 'tone-4' },
{ type: 'vaccine', icon: 'vaccine', label: '疫苗', tone: 'tone-1' },
];
// 门面上的状态 chip:健康状态 + 最多两条洞察
function heroChips(summary) {
const chips = [];
if (summary.health_status) {
chips.push({ text: summary.health_status, icon: 'check', tone: 'green' });
}
(summary.insights || []).slice(0, 2).forEach((it) => {
if (it && it.bold) chips.push({ text: it.bold, icon: 'trend', tone: '' });
});
return chips;
}
Page({
data: {
pet: {},
summary: { greeting: '', insights: [], week: [], advice: '', health_pct: 0, health_status: '正常' },
tasks: [],
quickItems: QUICK_ITEMS,
heroChips: [],
undoneText: '',
firstArticle: null,
selectedDate: '',
taskLabel: '今日任务',
@@ -75,7 +103,7 @@ Page({
if (!id) return;
api
.homeSummary(id)
.then((summary) => this.setData({ summary }))
.then((summary) => this.setData({ summary, heroChips: heroChips(summary) }))
.catch((e) => toastErr(e));
},
loadTasks() {
@@ -84,9 +112,19 @@ Page({
const date = this.data.selectedDate || this.data.todayDate;
api
.getTasks(id, date)
.then((tasks) => this.setData({ tasks: (tasks || []).map(mapTask) }))
.then((tasks) => this.setTasks((tasks || []).map(mapTask)))
.catch((e) => toastErr(e));
},
// 任务列表落地时顺手算「还有几件事没做完」,门面上要用
setTasks(tasks) {
const undone = tasks.filter((t) => !t.done).length;
this.setData({
tasks,
undoneText: tasks.length === 0
? '这天还没有安排'
: undone > 0 ? '还有 ' + undone + ' 件事没做完' : '今天的事都做完啦',
});
},
onTapDay(e) {
const { date, active } = e.currentTarget.dataset;
if (!date) return;
@@ -111,7 +149,9 @@ Page({
api
.toggleTask(t.id)
.then((res) => {
this.setData({ [`tasks[${i}].done`]: res.done });
const tasks = this.data.tasks.slice();
tasks[i] = Object.assign({}, tasks[i], { done: res.done });
this.setTasks(tasks);
this.loadSummary();
})
.catch(() => {});
@@ -122,7 +162,7 @@ Page({
api
.completeAllTasks(id)
.then((tasks) => {
this.setData({ tasks: (tasks || []).map(mapTask) });
this.setTasks((tasks || []).map(mapTask));
this.loadSummary();
})
.catch(() => {});