# 设计文档:P13 小程序前端联调补齐与格式统一 ## 概述 本设计覆盖 P13 PRD 中所有前端改动项。核心策略:通用规则先行(G1~G4),再逐页面修复功能点,最后统一格式化审查。 ## 涉及文件 ### 工具函数(新建/修改) - `apps/miniprogram/miniprogram/utils/storage-level.ts`(新建)— 储值等级计算 - `apps/miniprogram/miniprogram/utils/money.ts`(修改)— 补充 formatTrendValue - `apps/miniprogram/miniprogram/utils/time.ts`(修改)— 补充 formatDateShort、formatDateFull、formatDays - `apps/miniprogram/miniprogram/utils/format.wxs`(修改)— 补充 WXS 侧格式化函数 ### 页面文件(按 PRD 编号) - P1 task-list:`pages/task-list/task-list.ts` + `.wxml` - P2 performance:`pages/performance/performance.ts` + `.wxml` - P3 performance-records:`pages/performance-records/performance-records.ts` + `.wxml` - P4 task-detail:`pages/task-detail/task-detail.ts` + `.wxml` - P5 customer-service-records:`pages/customer-service-records/customer-service-records.ts` + `.wxml` - P6 board-finance:`pages/board-finance/board-finance.ts` + `.wxml` - P10 coach-detail:`pages/coach-detail/coach-detail.ts` + `.wxml` ### 服务层 - `apps/miniprogram/miniprogram/services/api.ts` — 确认接口字段对齐 ## 设计决策 ### G1 微信头像 - 全局用户信息存储在 app.globalData 或独立 store 中 - 三个 banner 页面(task-list、performance、performance-records)在 onShow 时从全局读取 avatarUrl - 无头像时使用默认占位图(已有 avatar-color.ts 可复用) ### G2 当月预估判断 - 纯前端逻辑:`isCurrentMonth = (year === nowYear && month === nowMonth)` - 影响 performance、performance-records、board-finance 三个页面 - 条件渲染"预估"标签和标题文案 ### G3 绩效折算 - 后端已返回 hours 和 hoursRaw 字段 - 前端条件:`hoursRaw !== hours` 时显示"折前 Xh" - 汇总统计同理 ### G4 储值等级 - 新建 `utils/storage-level.ts`,导出 `formatStorageLevel(balance: number): string` - 阈值:0→"无"、<200→"少"、<500→"一般"、<1500→"多"、≥1500→"非常多" ### 格式化工具函数补充 - `formatDateShort(date)` → "3月15日" - `formatDateFull(date)` → "2026-03-15" - `formatDays(days)` → "3天" - `formatTrendValue(value)` → "+¥1,200" / "-¥800" - 所有函数遵循缺省值 `--` 规则 ## 执行策略 按 PRD 第四节实施优先级分三批执行,每个页面逐一审查: 1. 通用规则(G1~G4)审查修改 2. 数据格式统一标准审查修改 3. 页面专属功能点审查修改 每个页面由子代理独立处理,最大并行数 2。