fix(fe): 补齐无宠物状态 + 用户操作失败不再静默

自查发现的四处,都属于「不报错但用户懵」:

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 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-29 14:23:58 +08:00
parent 7acdf916d5
commit e446019546
9 changed files with 53 additions and 7 deletions
+7 -2
View File
@@ -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');
},