feat(fe): 今日任务完成走记录表单,去掉「全部完成」

- 去掉首页「全部完成」按钮,避免一键刷完不留记录
- 勾选带记录类型的任务 → 跳记录表单,保存成功后才回填任务完成,
  返回首页 onShow 自动刷新任务勾选 + 最近记录(带 taskId 传参)
- 只对未完成任务传 taskId,避免重复完成把已完成任务 toggle 回去
- 无记录类型的任务(如遛狗)仍直接勾选完成

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-31 09:03:27 +08:00
parent 603bd5773e
commit 96c92f2cfb
3 changed files with 13 additions and 12 deletions
+7 -1
View File
@@ -41,6 +41,8 @@ Page({
},
onLoad(q) {
const code = (q && q.type) || '';
// 从首页「今日任务」勾选进来会带 taskId:这一笔记录保存后要把那条任务标完成
this.taskId = (q && q.taskId) || '';
const d = today();
this.setData({ code, date: d, dateLabel: fmtDate(d) });
store
@@ -151,9 +153,13 @@ Page({
this.setData({ saving: true });
api
.createRecord(id, this.buildBody())
.then(() => {
// 从任务勾选进来的:记录存好后把那条任务标完成(失败不影响记录已保存)
if (this.taskId) return api.toggleTask(this.taskId).catch(() => {});
})
.then(() => {
this.setData({ saving: false });
wx.showToast({ title: '已记录', icon: 'success' });
wx.showToast({ title: this.taskId ? '已完成' : '已记录', icon: 'success' });
setTimeout(() => wx.navigateBack(), 600);
})
.catch((e) => {