feat: support shared pet care tasks and smooth daily page return
This commit is contained in:
@@ -4,6 +4,7 @@ const { localDate, shiftDate } = require("../../utils/date");
|
||||
Page({
|
||||
data: {
|
||||
pets: [],
|
||||
petOptions: [],
|
||||
tasks: [],
|
||||
taskBusyIds: [],
|
||||
completingAll: false,
|
||||
@@ -32,10 +33,11 @@ Page({
|
||||
if (date !== this.data.date) return;
|
||||
const tasks = result.items.map((t) => ({
|
||||
...t,
|
||||
petName: (pets.find((p) => p.id === t.pet_id) || {}).name || "宠物",
|
||||
petName: t.all_pets ? "全部宠物" : (pets.find((p) => p.id === t.pet_id) || {}).name || "宠物",
|
||||
}));
|
||||
this.setData({
|
||||
pets,
|
||||
petOptions: [...pets, { id: "", name: "全部宠物" }],
|
||||
tasks,
|
||||
undoneCount: tasks.filter((t) => !t.completed).length,
|
||||
done: tasks.filter((t) => t.completed).length,
|
||||
@@ -78,7 +80,7 @@ Page({
|
||||
showForm: true,
|
||||
editingId: task.id,
|
||||
title: task.title,
|
||||
petIndex: Math.max(petIndex, 0),
|
||||
petIndex: task.all_pets ? this.data.pets.length : Math.max(petIndex, 0),
|
||||
category: task.category,
|
||||
time_of_day: task.time_of_day,
|
||||
repeat_rule: task.repeat_rule,
|
||||
@@ -125,7 +127,9 @@ Page({
|
||||
this.data.editingId ? "/tasks/" + this.data.editingId : "/tasks",
|
||||
this.data.editingId ? "PUT" : "POST",
|
||||
{
|
||||
pet_id: this.data.pets[this.data.petIndex].id,
|
||||
...(this.data.petIndex === this.data.pets.length
|
||||
? { all_pets: true }
|
||||
: { pet_id: this.data.pets[this.data.petIndex].id }),
|
||||
title: this.data.title.trim(),
|
||||
category: this.data.category,
|
||||
time_of_day: this.data.time_of_day,
|
||||
|
||||
Reference in New Issue
Block a user