feat(fe): 建档挑方案、计划页套方案、阶段漂移提示

后端上一轮做完了但小程序上看不到,这次接上。

## 建档第四步:挑方案
方案按阶段取,所以必须排在「资料」之后(阶段是第三步定的)。卡片上按重复方式
分开报数(每天 3 项 / 每周 2 项 / 一次性 2 项),不报一个总数——4 条「每天」
套一整月就是 120 多条,只给总数用户会以为出 bug。

「先空着,我自己排」是个平等的选项,和方案卡长一样、就在下面一眼能看到,
不是藏起来的退路:已经养熟的宠物主人有自己的节奏,硬塞一套只会被删掉。

默认选第一套——多数用户是新手,给一个合理默认比让他面对空白好。

编辑档案时不出现第四步:改档案不该顺手改计划。

套方案失败不算建档失败:档案已经建好了,方案之后在计划页还能套,
不该把用户退回表单。

## 计划页:空月份和平时都能套
空月份的提示条带「套一套方案」按钮 —— 空着让用户从零排,多数人会直接退出去。
但「+ 加一件」始终在,不能只给套用。

浮层里写明「套用是往里加,不会覆盖你已经排好的」,因为服务端就是按
「日期+标题」去重的,这句话是真的。套完 toast 报排了几件;一件都没排
(全都已存在)时说「这个月已经有这些安排了」,不说「成功」。

## 阶段漂移提示
首页门面卡下面一张卡:「钞票已经 17个月,从幼年期进入成年期了」,
带上新阶段的划分依据、养护重点和体型说明,点进去到建档页改。

用主色不用红色 —— 这是「可以做一下」不是「出问题了」。
改完回首页 onShow 重拉一次,卡片自然消失。

不在首页直接改阶段:改完要不要套新方案是同一件事,放在建档页一起做才连贯。

## 顺手把合并的尾巴清了
manageTasks 那一支删了:它管的是 DailyTask,而今日任务已经并进计划节点,
增删改都在计划页。留着会出现「这里加的任务」和「计划页加的节点」进不同的表。

连带清掉 7 个死方法 + taskSheets + 一个死 require(简易表单那套早随记录表单
搬到 pages/addrecord 了)。首页现在一个弹层都不开,bottom-sheet 组件也去掉了。

弹层累计:js 1110 → 689 行,wxml 485 → 278 行。

## 验证(预生产库实跑)
  建档四步    6 个月柯基 → 幼年期 → 拉到「幼犬标准照护」→ 套用本月 7 条
              → 首页今日任务 4 条
  先空着      今日任务 0 条,疫苗驱虫提醒仍然建
  计划页套用  0 → 7 条;重复套用 0 条(去重生效)
  漂移检测    17 个月柯基存着幼年期 → drifted=true,给出依据/重点/体型
              改成成年期 → drifted=false
              没生日 → 不提示(算不出就不猜)
              「刚到家」→ 不提示(叠加层不是年龄段)

第一版验证脚本把阶段改成了和算出来一样的值,drifted=False 是对的,
但我的 print 无条件打了提示文案,看着像 bug。重测才验到真的。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-30 12:59:27 +08:00
parent cff6982613
commit 6fd4977f46
13 changed files with 228 additions and 112 deletions
+38 -2
View File
@@ -41,7 +41,7 @@ Page({
editing: false,
petId: '',
step: 0,
steps: ['名字', '品种', '资料'],
steps: ['名字', '品种', '资料', '方案'],
genders: GENDERS,
stages: [],
stageRules: [],
@@ -54,7 +54,11 @@ Page({
species: 'cat', breed: '',
gender: '不确定', birthday: '', arrived_at: '',
weight: '', color: '', stage: '',
// 第四步挑的方案。'' 是「先空着自己排」,不是「没选」——
// 所以初始值给 null,用来区分「还没走到第四步」
template_id: null,
},
tplOptions: [],
breedShow: false,
breedGroups: [],
breedAnchor: '',
@@ -192,6 +196,25 @@ Page({
this.setData({ breedAnchor: 'bi-' + e.currentTarget.dataset.i });
},
loadTemplates() {
const f = this.data.form;
api
.careTemplates(f.species, f.stage)
.then((opts) => {
const list = opts || [];
this.setData({
tplOptions: list,
// 默认选第一套:多数用户是新手,给一个合理默认比让他面对空白好。
// 但「先空着」就在下面,一眼能看到,不是藏起来的
'form.template_id': list.length ? list[0].id : '',
});
})
.catch(() => this.setData({ tplOptions: [], 'form.template_id': '' }));
},
pickTemplate(e) {
this.setData({ 'form.template_id': e.currentTarget.dataset.id });
},
// ── 分步 ──
prev() {
if (this.data.step > 0) this.setData({ step: this.data.step - 1 });
@@ -202,6 +225,7 @@ Page({
const f = this.data.form;
if (this.data.step === 0 && !f.name.trim()) return '先给它起个名字';
if (this.data.step === 1 && !f.species) return '选一下是猫还是狗';
if (this.data.step === 2 && !f.stage) return '选一下现在是哪个阶段 —— 方案是按阶段配的';
return '';
},
next() {
@@ -209,7 +233,12 @@ Page({
if (!this.data.editing) {
const err = this.stepError();
if (err) return wx.showToast({ title: err, icon: 'none' });
if (this.data.step < 2) return this.setData({ step: this.data.step + 1 });
if (this.data.step < 3) {
const next = this.data.step + 1;
this.setData({ step: next });
if (next === 3) this.loadTemplates(); // 方案按阶段取,得等第三步填完
return;
}
} else if (!this.data.form.name.trim()) {
return wx.showToast({ title: '名字不能空', icon: 'none' });
}
@@ -239,8 +268,15 @@ Page({
submit() {
this.setData({ saving: true });
const b = this.body();
const tplID = this.data.form.template_id;
const req = this.data.editing ? api.updatePet(this.data.petId, b) : api.createPet(b);
req
// 套方案要等档案建出来才有 pet id。套用失败不算建档失败——
// 档案已经建好了,方案之后在计划页还能套,不该把用户退回表单
.then((pet) => {
if (this.data.editing || !tplID || !pet || !pet.id) return;
return api.applyTemplate(pet.id, tplID, 0).catch(() => {});
})
.then(() => store.loadPets())
.then(() => {
this.setData({ saving: false });