From e4460195463ac572a23fafac01ca0c70d7fec932 Mon Sep 17 00:00:00 2001 From: Blizzard Date: Wed, 29 Jul 2026 14:23:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(fe):=20=E8=A1=A5=E9=BD=90=E6=97=A0=E5=AE=A0?= =?UTF-8?q?=E7=89=A9=E7=8A=B6=E6=80=81=20+=20=E7=94=A8=E6=88=B7=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=A4=B1=E8=B4=A5=E4=B8=8D=E5=86=8D=E9=9D=99=E9=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 自查发现的四处,都属于「不报错但用户懵」: 1. record/plan/report 三页在 currentPetId 为空时直接 return,留下一堆 空卡片却不解释——用户以为坏了。加统一的 .no-pet 引导块,说清建档后 会有什么,并给一个建档按钮。 2. 首页门面卡在没建档时点击会打开「编辑宠物」的空表单。改成没档案就走 「添加」,文案也跟着变成「点这里建一份档案」。 3. 没建档时在快速记录弹层点「保存」,createAndClose 因为拿不到 petID 直接 close 掉——用户以为存上了,其实什么都没发生。改成明确提示。 4. 用户主动触发的操作失败不再静默:勾任务、全部完成、勾计划节点、点赞 四处的 .catch(() => {}) 换成 toast。后台加载类的静默保持不变—— 那些失败了重进页面会自愈,弹 toast 反而是噪音。 事件绑定做了一次全量扫描:18 个 wxml 里所有 bind/catch 绑的方法在对应 js 里都有实现,没有「点了没反应」的死按钮。 Co-Authored-By: Claude Opus 5 --- pets-fe/app.wxss | 14 ++++++++++++++ pets-fe/components/bottom-sheet/bottom-sheet.js | 7 ++++++- pets-fe/pages/community/community.js | 2 +- pets-fe/pages/home/home.js | 9 +++++++-- pets-fe/pages/home/home.wxml | 4 ++-- pets-fe/pages/plan/plan.js | 3 ++- pets-fe/pages/plan/plan.wxml | 7 +++++++ pets-fe/pages/record/record.wxml | 7 +++++++ pets-fe/pages/report/report.wxml | 7 +++++++ 9 files changed, 53 insertions(+), 7 deletions(-) diff --git a/pets-fe/app.wxss b/pets-fe/app.wxss index 519d25d..abbe876 100644 --- a/pets-fe/app.wxss +++ b/pets-fe/app.wxss @@ -343,3 +343,17 @@ page{scrollbar-width:none;-ms-overflow-style:none} .msg{max-width:88%;border-radius:var(--r-md);padding:var(--sp-3) var(--sp-4);font-size:var(--fs-md);line-height:1.55} .msg.ai{background:var(--green-soft);align-self:flex-start} .msg.user{background:var(--primary-soft);align-self:flex-end} + +/* 没有宠物时的引导块。四个主页面都会 currentPetId 为空直接 return, + 留下一堆空卡片却不解释为什么——用户以为是坏了。 */ +.no-pet{ + background:#fff;border-radius:var(--r-lg);box-shadow:var(--sd-1); + padding:var(--sp-6) var(--sp-5);text-align:center;margin-bottom:var(--sp-4); +} +.no-pet-ic{ + width:104rpx;height:104rpx;border-radius:var(--r-md);margin:0 auto var(--sp-3); + display:flex;align-items:center;justify-content:center; + background:var(--primary-soft);color:var(--primary-ink); +} +.no-pet-b{font-size:var(--fs-lg);font-weight:var(--fw-b)} +.no-pet-p{color:var(--muted);font-size:var(--fs-sm);margin:var(--sp-2) 0 var(--sp-4);line-height:1.6} diff --git a/pets-fe/components/bottom-sheet/bottom-sheet.js b/pets-fe/components/bottom-sheet/bottom-sheet.js index 1be5ea5..4984391 100644 --- a/pets-fe/components/bottom-sheet/bottom-sheet.js +++ b/pets-fe/components/bottom-sheet/bottom-sheet.js @@ -584,10 +584,15 @@ Component({ async createAndClose(rec) { const id = store.currentPetId(); - if (!rec || !id) { + if (!rec) { this.close(); return; } + // 没建档时点「保存」原来是静默关掉弹层,用户以为存上了,其实什么都没发生 + if (!id) { + wx.showToast({ title: '先建一份宠物档案再记录', icon: 'none' }); + return; + } if (this.data.saving) return; this.setData({ saving: true }); try { diff --git a/pets-fe/pages/community/community.js b/pets-fe/pages/community/community.js index b2c994d..9de9097 100644 --- a/pets-fe/pages/community/community.js +++ b/pets-fe/pages/community/community.js @@ -80,7 +80,7 @@ Page({ .then((res) => { this.setData({ [`posts[${i}].like_count`]: res.like_count, [`posts[${i}].liked`]: true }); }) - .catch(() => {}); + .catch((e) => toastErr(e, '点赞失败')); }, openComments(e) { this.setData({ sheetPostId: e.currentTarget.dataset.id, sheetType: 'comments', sheetShow: true }); diff --git a/pets-fe/pages/home/home.js b/pets-fe/pages/home/home.js index 488a97d..f4e559a 100644 --- a/pets-fe/pages/home/home.js +++ b/pets-fe/pages/home/home.js @@ -154,7 +154,7 @@ Page({ this.setTasks(tasks); this.loadSummary(); }) - .catch(() => {}); + .catch((e) => toastErr(e, '操作失败')); }, completeTasks() { const id = store.currentPetId(); @@ -165,7 +165,7 @@ Page({ this.setTasks((tasks || []).map(mapTask)); this.loadSummary(); }) - .catch(() => {}); + .catch((e) => toastErr(e, '操作失败')); }, openSheet(e) { this.openSheetType(e.currentTarget.dataset.type); @@ -185,6 +185,11 @@ Page({ onAddPet() { this.openSheetType('addPet'); }, + // 没建档时点门面卡应该去「添加」,而不是打开一个空的编辑表单 + onHeroTap() { + if (this.data.pet && this.data.pet.id) this.openSheetType('editPet'); + else this.openSheetType('addPet'); + }, onEditPet() { this.openSheetType('editPet'); }, diff --git a/pets-fe/pages/home/home.wxml b/pets-fe/pages/home/home.wxml index 6aa8c07..aa928af 100644 --- a/pets-fe/pages/home/home.wxml +++ b/pets-fe/pages/home/home.wxml @@ -16,7 +16,7 @@ - + {{summary.health_pct}}% @@ -24,7 +24,7 @@ {{pet.name || '还没有毛孩子'}} - {{undoneText}} + {{pet.id ? undoneText : '点这里建一份档案,任务和提醒会自动排好'}} {{item.text}} diff --git a/pets-fe/pages/plan/plan.js b/pets-fe/pages/plan/plan.js index 528b853..304e7d8 100644 --- a/pets-fe/pages/plan/plan.js +++ b/pets-fe/pages/plan/plan.js @@ -1,5 +1,6 @@ const store = require('../../utils/store.js'); const api = require('../../utils/api.js'); +const { toastErr } = require('../../utils/ui.js'); // "2026-07-04" → "7月4日" function fmtMD(date) { @@ -131,7 +132,7 @@ Page({ // 计划明细勾选 toggleTimelineTask(e) { const id = e.currentTarget.dataset.id; - api.togglePlanTask(id).then(() => this.loadTimeline()).catch(() => {}); + api.togglePlanTask(id).then(() => this.loadTimeline()).catch((e) => toastErr(e, '操作失败')); }, // AI 计划 onAiInput(e) { diff --git a/pets-fe/pages/plan/plan.wxml b/pets-fe/pages/plan/plan.wxml index edcc95f..b1b3270 100644 --- a/pets-fe/pages/plan/plan.wxml +++ b/pets-fe/pages/plan/plan.wxml @@ -4,6 +4,13 @@ + + + 还没有毛孩子的档案 + 建好档会按它的年龄阶段自动排好 30 天计划和疫苗驱虫提醒。 + 建一份档案 + + diff --git a/pets-fe/pages/record/record.wxml b/pets-fe/pages/record/record.wxml index 68a12ec..64203d9 100644 --- a/pets-fe/pages/record/record.wxml +++ b/pets-fe/pages/record/record.wxml @@ -4,6 +4,13 @@ + + + 还没有毛孩子的档案 + 建好档才能记体重、便便、饮食这些,趋势图也是从这些记录里长出来的。 + 建一份档案 + + 记一笔 diff --git a/pets-fe/pages/report/report.wxml b/pets-fe/pages/report/report.wxml index be7b06a..9d14b12 100644 --- a/pets-fe/pages/report/report.wxml +++ b/pets-fe/pages/report/report.wxml @@ -4,6 +4,13 @@ + + + 还没有毛孩子的档案 + 成长报告和账单都基于记录生成,先建个档开始记吧。 + 建一份档案 + + 本周成长报告{{report.health_status || '稳定成长'}} {{report.summary || '暂无本周数据'}}