3ea50efb7d
## 弹层里塞 24 个表单是走不通的 弹层高度受 .sheet-scroll 的 78vh 限制,字段一多就变成内滚;24 项的选择器 挤在弹层里更难看(用户原话「很丑」)。整体搬成页面。 ## pages/addrecord —— 一个页面吃掉全部 24 种 形态:记录宠物 / 记录时间 / 类型专属字段 / 描述 + 照片 / 底部固定保存键。 关键在「类型专属字段」整段是后端驱动的:前端不认识「体重」「金额」这些业务词, 只认识 number / options / text 三种渲染方式,以及每个字段的值该落到哪儿。 record_types 加了 fields 列,后台用紧凑写法配(一行一个): number:体重:kg 数值 → num_value options:状态:正常|软便|拉稀 单选 → category options:症状:呕吐|拉稀|精神差:- 末尾 - 表示不落 category,只进标题 text:吃了什么 文本 → 只进标题 (空) 只要 时间+描述+照片 解析放服务端不放前端:配错了要在后台保存时就报出来(第几行、错在哪), 不能等用户点开表单才发现渲染不出东西。读取时解析失败只让这一种事项没有额外 字段并打 warn,不让一条烂配置把整个记录页打空。 ## 那个 - 开关不是过度设计 异常观察有两个单选(症状 + 严重程度),而 category 只有一个坑, 周报的高风险数按 category='高' 统计(report.go:46)——必须能指定谁占这个坑。 同理账单按 cost 的 category 分组聚合(report.go:134), 食便相关性排除 poop 的 category='正常'。这三处口径都得严丝合缝对上。 ## 记录页瘦成纯列表 只留分组宫格。健康洞察 / 体重趋势 / 健康时间轴整页搬到 pages/history, 从报告页「记录与趋势」进——报告页才是看数据的地方,而一个「我要记一笔」的 页面上摆三块只读图表,用户每次都得先滚过去才能找到要点的东西。 **没有直接删掉那三块**:时间轴是唯一能看和删历史记录的地方,报告页只有 周报/账单这些聚合。删了用户就再也看不到自己记过什么。搬页面用的是 git 里 改动前的完整版复制,比往 report.js 里合并代码安全。 ## 弹层瘦了一圈 9 个记录分支删掉,连带 17 个方法、SIMPLE_HINT、buildRecord 的 7 个 case 和一批只有它们在用的 data 字段。 js 1089 → 857 行 wxml 480 → 335 行 弹层现在只管「不是记一笔」的事:提醒、海报、档案、发帖、评论、导出、反馈。 buildRecord 只剩 vetSummary 一个分支(它写一条 note 留痕,不是用户填的表单)。 ## 验证(预生产库实跑) 24 种的字段配置逐个核对解析结果,然后照 addrecord 的 buildBody 组装落库: 体重 title='体重:4.6kg' num=4.6 → 宠物档案回写成 4.6kg ✓ 记账 title='记账:128元 医疗' num=128 cat=医疗 → 账单 total=128 分类[(医疗,128)] ✓ 异常 title='异常:呕吐 高' cat=高 → 周报 high_risk_count=1 ✓ 排便 cat=软便 食便相关性口径保住 饮食 title='饮食:幼猫粮 45g 偏少' cat=偏少 喝水 num=180(新类型带数值,老代码没有它的分支也不影响) 洗澡 title='洗澡'(无额外字段) 看病 num=320(两个字段:文本+数值) 体重趋势 1 个点、值 4.6,没被其他 7 条污染。 回填踩过一次坑:fields 列是服务启动时 AutoMigrate 才建的,我在启动前就跑了 回填,Update 报错被忽略、13 行静默没写进去。第二版加了 HasColumn 前置检查 和逐行错误统计才发现。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
135 lines
7.0 KiB
Plaintext
135 lines
7.0 KiB
Plaintext
<nav-bar title="肉垫计划"></nav-bar>
|
||
|
||
<view class="top-bar"><pet-switch bind:add="onAddPet"></pet-switch></view>
|
||
|
||
<scroll-view class="page-scroll" scroll-y="{{true}}" enhanced="{{true}}" show-scrollbar="{{false}}">
|
||
<view class="page-body">
|
||
<view class="top-row">
|
||
<view class="greeting">
|
||
<view class="greet-h2">{{summary.greeting || '你好'}}</view>
|
||
<view class="greet-p">今天也要照顾好 {{pet.name}}</view>
|
||
</view>
|
||
<view class="icon-stack">
|
||
<view class="icon-btn" data-type="reminders" bindtap="openSheet"><pt-icon name="bell" size="{{36}}"></pt-icon></view>
|
||
<view class="icon-btn" bindtap="goSettings"><pt-icon name="settings" size="{{36}}"></pt-icon></view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 门面:完成度环 + 当下状态。点进去编辑档案 -->
|
||
<view class="card hero-card" bindtap="onHeroTap">
|
||
<view class="hero-row">
|
||
<stat-ring percent="{{summary.health_pct}}" size="{{168}}">
|
||
<view class="ring-num">{{summary.health_pct}}<text class="ring-unit">%</text></view>
|
||
<view class="ring-cap">完成度</view>
|
||
</stat-ring>
|
||
<view class="hero-main">
|
||
<view class="hero-title">{{pet.name || '还没有毛孩子'}}</view>
|
||
<view class="hero-sub">{{pet.id ? undoneText : '点这里建一份档案,任务和提醒会自动排好'}}</view>
|
||
<view class="chip-row">
|
||
<view wx:for="{{heroChips}}" wx:key="text" class="chip {{item.tone}}">
|
||
<pt-icon name="{{item.icon}}" size="{{22}}"></pt-icon>{{item.text}}
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="hero-meta">{{pet.age}}|{{pet.weight}}|{{pet.stage}}</view>
|
||
</view>
|
||
|
||
<!-- 日期带:默认一周,展开成整月。原来这是计划页的「日历」tab,
|
||
但「哪天要做什么」和「今天要做什么」本来就是一件事,分两个 tab 只是让人多点两下 -->
|
||
<view class="date-band">
|
||
<view wx:if="{{!calOpen}}" class="date-strip">
|
||
<view wx:for="{{summary.week}}" wx:key="date"
|
||
class="day {{item.active ? 'active' : ''}} {{item.date === selectedDate ? 'sel' : ''}} {{item.has_dot ? 'has-dot' : ''}}"
|
||
data-date="{{item.date}}" data-active="{{item.active}}" bindtap="onTapDay">
|
||
<text>{{item.weekday}}</text><text class="day-b">{{item.day}}</text>
|
||
</view>
|
||
</view>
|
||
<view wx:else class="card cal-card">
|
||
<view class="cal-head"><text>{{calLabel}}</text></view>
|
||
<view class="cal-grid">
|
||
<text class="cal-w">一</text><text class="cal-w">二</text><text class="cal-w">三</text><text class="cal-w">四</text><text class="cal-w">五</text><text class="cal-w">六</text><text class="cal-w">日</text>
|
||
<view wx:for="{{calCells}}" wx:key="index"
|
||
class="cal-cell {{item.today ? 'today' : ''}} {{item.tasked ? 'tasked' : ''}} {{item.day === 0 ? 'blank' : ''}} {{item.date && item.date === selectedDate ? 'sel' : ''}}"
|
||
data-date="{{item.date}}" data-active="{{item.date === todayDate}}" bindtap="onTapDay">{{item.day || ''}}</view>
|
||
</view>
|
||
</view>
|
||
<view class="cal-toggle" bindtap="toggleCal">
|
||
{{calOpen ? '收起' : '展开整月'}}<pt-icon name="{{calOpen ? 'up' : 'down'}}" size="{{24}}"></pt-icon>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="card">
|
||
<view class="section-head">
|
||
<view class="sh-title">{{taskLabel}}</view>
|
||
<view class="head-links">
|
||
<view class="link" data-type="manageTasks" bindtap="openSheet">管理</view>
|
||
<view wx:if="{{selectedDate && selectedDate !== todayDate}}" class="link" bindtap="backToToday">回今天</view>
|
||
<view wx:else class="link" bindtap="completeTasks">全部完成</view>
|
||
</view>
|
||
</view>
|
||
<view class="task-list">
|
||
<view wx:for="{{tasks}}" wx:key="title" class="task {{item.done ? 'done' : ''}}" data-index="{{index}}" bindtap="onTapTask">
|
||
<view class="circle"><pt-icon wx:if="{{item.done}}" name="check" size="{{22}}"></pt-icon></view>
|
||
<view class="task-text"><text class="tt-b">{{item.title}}</text><view wx:if="{{item.sub}}" class="tt-p">{{item.sub}}</view></view>
|
||
<view wx:if="{{item.priority}}" class="priority">{{item.priority}}</view>
|
||
</view>
|
||
<view wx:if="{{tasks.length === 0}}" class="empty">这天没有任务记录</view>
|
||
</view>
|
||
|
||
<!-- 这天还挂着的计划节点和提醒。只读,勾选走计划页/提醒弹层 -->
|
||
<view wx:if="{{dayNodes.length || dayReminders.length}}" class="day-detail">
|
||
<view wx:for="{{dayNodes}}" wx:key="title" class="dd-item">
|
||
<text class="dd-tag plan">计划</text><text class="dd-b {{item.done ? 'done' : ''}}">{{item.title}}</text>
|
||
</view>
|
||
<view wx:for="{{dayReminders}}" wx:key="title" class="dd-item" data-type="reminders" bindtap="openSheet">
|
||
<text class="dd-tag rem">提醒</text><text class="dd-b">{{item.title}}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 接下来:30 天计划里最近几个还没做的节点。计划页降级成二级页后,
|
||
这张卡是它在首页的唯一露出,没有它计划就等于消失了 -->
|
||
<view wx:if="{{upcoming.length}}" class="card">
|
||
<view class="section-head">
|
||
<view class="sh-title">接下来</view>
|
||
<view class="link" bindtap="goPlan">完整计划</view>
|
||
</view>
|
||
<view wx:if="{{planPct >= 0}}" class="progress-row"><text>30 天计划完成度</text><text>{{planPct}}%</text></view>
|
||
<view wx:if="{{planPct >= 0}}" class="bar"><view class="bar-fill" style="width:{{planPct}}%"></view></view>
|
||
<view class="up-list">
|
||
<view wx:for="{{upcoming}}" wx:key="id" class="up-item" data-id="{{item.id}}" bindtap="goPlan">
|
||
<view class="up-when">{{item.whenLabel}}</view>
|
||
<view class="up-body"><text class="tt-b">{{item.title}}</text><view wx:if="{{item.description}}" class="tt-p">{{item.description}}</view></view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="card">
|
||
<view class="section-head">
|
||
<view class="sh-title">快速记录</view>
|
||
<view class="link" bindtap="goRecord">更多</view>
|
||
</view>
|
||
<view class="quick-grid">
|
||
<view wx:for="{{quickItems}}" wx:key="code" class="quick {{item.tone}}" data-type="{{item.code}}" bindtap="goAdd">
|
||
<pt-icon name="{{item.icon}}" size="{{44}}" fallback="note"></pt-icon>{{item.label}}
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="card">
|
||
<view class="section-head">
|
||
<view class="sh-title">新手内容</view>
|
||
<view class="link" bindtap="goLearn">查看</view>
|
||
</view>
|
||
<view wx:if="{{firstArticle}}" class="article-card no-shadow" style="margin-bottom:0" bindtap="openFirstArticle">
|
||
<view class="article-icon"><pt-icon name="{{firstArticle.icon}}" size="{{48}}" fallback="book"></pt-icon></view>
|
||
<view><text class="ac-b">{{firstArticle.title}}</text><view class="ac-p">{{firstArticle.desc}}</view></view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
|
||
<fab icon="plus" bind:tap="onQuickRecord"></fab>
|
||
<bottom-sheet show="{{sheetShow}}" type="{{sheetType}}" bind:close="closeSheet" bind:saved="onSheetSave"></bottom-sheet>
|