Add one-way task completion and exportable pet identity cards
ci-cd / verify (push) Successful in 1m31s
ci-cd / deploy (push) Skipped

This commit is contained in:
2026-10-05 11:32:32 +08:00
parent f0ee63e642
commit cb4ffa13e9
21 changed files with 999 additions and 117 deletions
+14 -13
View File
@@ -1,4 +1,5 @@
const { secure, toast } = require("../../utils/api");
const completion = require("../../utils/task-completion");
const { secure } = require("../../utils/api");
const { localDate } = require("../../utils/date");
const environment = require("../../utils/environment");
function dateLabel() {
@@ -12,6 +13,9 @@ Page({
pets: [],
selected: [],
tasks: [],
taskBusyIds: [],
completingAll: false,
undoneCount: 0,
walkCount: 0,
name: "铲屎官",
loading: true,
@@ -100,6 +104,7 @@ Page({
pets,
selected: chosen.filter((id) => pets.some((p) => p.id === id)),
tasks: tasks.items,
undoneCount: tasks.items.filter((t) => !t.completed).length,
walkCount: walks.filter((w) => w.started_at.slice(0, 7) === month)
.length,
name: me.nickname || "毛孩家长",
@@ -138,17 +143,13 @@ Page({
goWalks() {
wx.navigateTo({ url: "/pages/walk-records/walk-records" });
},
async complete(e) {
const id = e.currentTarget.dataset.id,
task = this.data.tasks.find((t) => t.id === id);
try {
await secure("/tasks/" + id + "/completion", "PUT", {
date: localDate(),
completed: !task.completed,
});
await this.load();
} catch (err) {
toast(err);
}
complete(e) {
return completion.complete(
this,
this.data.tasks.find((t) => t.id === e.currentTarget.dataset.id),
);
},
completeAll() {
return completion.completeAll(this);
},
});
+8 -3
View File
@@ -70,23 +70,28 @@
<text class="section-title">今天要做的事</text>
<text class="link" bindtap="goTasks">全部任务 ›</text>
</view>
<view wx:if="{{tasks.length}}" class="completion-toolbar">
<text>{{undoneCount ? '还有 '+undoneCount+' 项小事' : '这一份日常,已全部照顾好'}}</text>
<button wx:if="{{undoneCount}}" class="finish-all" bindtap="completeAll" loading="{{completingAll}}" disabled="{{completingAll || taskBusyIds.length}}">一键完成</button>
<text wx:else class="all-done">全部完成</text>
</view>
<view class="card tasks">
<view
wx:for="{{tasks}}"
wx:key="id"
class="task"
class="task {{item.completed?'task-completed':''}}"
data-id="{{item.id}}"
bindtap="complete"
>
<view class="check {{item.completed?'done':''}}">
{{item.completed?'✓':''}}
{{item.completed?'✓':taskBusyIds[0]===item.id?'…':''}}
</view>
<view class="task-icon">
<app-icon kind="{{item.category}}" size="36" />
</view>
<view class="task-main">
<text class="task-name">{{item.title}}</text>
<text class="muted">{{item.time_of_day}}</text>
<text class="muted">{{item.time_of_day}} · {{item.completed?'已完成':taskBusyIds[0]===item.id?'正在记录…':'点击完成'}}</text>
</view>
</view>
<view wx:if="{{!tasks.length}}" class="empty">