Add one-way task completion and exportable pet identity cards
This commit is contained in:
+14
-13
@@ -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);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user