diff --git a/App.vue b/App.vue
index 99f6e28..befa97a 100644
--- a/App.vue
+++ b/App.vue
@@ -1,17 +1,228 @@
-
-
-
diff --git a/components/bloom-calendar/bloom-calendar.vue b/components/bloom-calendar/bloom-calendar.vue
new file mode 100644
index 0000000..65ac7ec
--- /dev/null
+++ b/components/bloom-calendar/bloom-calendar.vue
@@ -0,0 +1,201 @@
+
+
+
+ {{ w }}
+
+
+
+
+
+
+ {{ day.day }}
+
+
+
+
+
+
+
+
+
+
+
+ 经期
+
+
+
+ 卵泡期
+
+
+
+ 排卵期
+
+
+
+ 黄体期
+
+
+
+ 预测
+
+
+
+
+
+
+
+
diff --git a/components/hq-tabbar/hq-tabbar.vue b/components/hq-tabbar/hq-tabbar.vue
new file mode 100644
index 0000000..1791b05
--- /dev/null
+++ b/components/hq-tabbar/hq-tabbar.vue
@@ -0,0 +1,101 @@
+
+
+
+
+ {{ item.icon }}
+ {{ item.label }}
+
+
+
+
+
+
+
+
diff --git a/docs/04-前端设计系统与联调验证.md b/docs/04-前端设计系统与联调验证.md
new file mode 100644
index 0000000..bd75d8d
--- /dev/null
+++ b/docs/04-前端设计系统与联调验证.md
@@ -0,0 +1,247 @@
+# 花期 APP · 前端设计系统与联调验证
+
+> 版本 v1.0 | 覆盖 V1.0 纵向切片:M1 周期管理、M2 情绪疗愈、M6 个人中心/会员、M5 健康建议(内容)
+> 关联文档:[01-产品功能模块清单](./01-产品功能模块清单.md)、[02-开发文档](./02-开发文档.md)、[03-数据模型与接口设计](./03-数据模型与接口设计.md)
+
+---
+
+## 1. 设计定位
+
+| 维度 | 定义 |
+|---|---|
+| 品牌 | 花期(Huāqī)—— 温柔记录,静待花开 |
+| 气质 | 暖、静、克制;像被阳光晒过的棉布,而不是糖果色 |
+| 原则 | 一屏一件事;重要信息放大、次要信息收敛;不用广告打扰 |
+| 视觉母题 | 「花瓣 + 光」:四阶段用花瓣色阶表达,不用刺眼的红/紫 |
+
+**三条硬规则**
+1. **暖而不腻**:主色饱和度高但只用于强调(按钮、数字、进度),大面积用暖米白。
+2. **留白优先**:卡片间距 24rpx 起,一屏不超过 3 个信息层级。
+3. **情绪友好**:不用「警告红」表达生理期,改用花红色系;文案避免「异常」「失败」等词。
+
+---
+
+## 2. 设计令牌(Design Tokens)
+
+统一维护在 `uni.scss`,页面通过 SCSS 变量引用,保证全站一致。
+
+### 2.1 色板
+
+| 令牌 | 色值 | 用途 |
+|---|---|---|
+| `$brand-primary` | `#E8604C` 花红 | 主按钮、关键数字、选中态 |
+| `$brand-primary-light` | `#F58C7C` | 渐变起点、hover |
+| `$brand-primary-dark` | `#C9482F` | 深色文字强调 |
+| `$brand-peach` | `#F5A65B` 蜜橙 | 次强调、进度渐变、点缀 |
+| `$brand-brown` | `#C79A7B` 暖棕 | 黄体期、辅助图形 |
+| `$brand-cream` | `#FFF9F5` 暖米白 | 页面底色 |
+| `$brand-cream-deep` | `#FFF1E9` | 卡片内嵌色块、胶囊底 |
+| `$text-primary` | `#3E2C27` 暖棕黑 | 主文字 |
+| `$text-secondary` | `#8C7367` | 次要文字 |
+| `$text-muted` | `#B9A79E` | 弱提示 |
+| `$line-color` | `#F5E7DF` | 分割线、描边 |
+
+**四阶段色**(与后端 `CycleService::$phaseColor` 完全一致):经期 `#E8604C`|卵泡期 `#F5A65B`|排卵期 `#F0796A`|黄体期 `#C79A7B`
+
+### 2.2 形状与阴影
+
+| 令牌 | 值 | 用途 |
+|---|---|---|
+| `$radius-lg` | 32rpx | 卡片、主视觉 |
+| `$radius-md` | 24rpx | 输入框、小卡片 |
+| `$radius-sm` | 16rpx | 标签 |
+| `$shadow-card` | `0 12rpx 36rpx rgba(232,96,76,.08)` | 常规卡片 |
+| `$shadow-float` | `0 16rpx 48rpx rgba(232,96,76,.16)` | 主视觉/浮层 |
+
+### 2.3 字体与字号
+
+| 层级 | 字号 | 字重 | 用途 |
+|---|---|---|---|
+| 主视觉数字 | 88rpx | 600 | 首页「周期第 N 天」 |
+| 页面标题 | 44rpx | 600 | 问候语、内容标题 |
+| 区块标题 | 32rpx | 600 | 各 section |
+| 正文 | 28–30rpx | 400 | 卡片正文 |
+| 辅助 | 22–24rpx | 400 | 说明、时间 |
+| 弱提示 | 20rpx | 400 | 免责声明 |
+
+---
+
+## 3. 组件规范
+
+| 组件 | 文件 | 说明 |
+|---|---|---|
+| 底部导航 | `components/hq-tabbar/hq-tabbar.vue` | 自定义 TabBar,4 个入口,选中态为暖色胶囊;使用 `reLaunch` 避免页面栈堆积 |
+| 花瓣日历 | `components/bloom-calendar/bloom-calendar.vue` | 7 列网格;阶段圆点 + 预测空心圈 + 记录小点;今天浅底、选中态渐变填充 |
+| 通用样式 | `App.vue` | `.hq-card` `.hq-btn` `.hq-chip` `.hq-cell` `.hq-empty` `.hq-progress` 等 12 个原子类 |
+
+**按钮三态**:主按钮(暖色渐变 + 投影)、幽灵按钮(`#FFF1E9` 底 + 主色字)、朴素按钮(白底 + 细边框)。
+**胶囊标签**:未选中 `#FFF4EE` 底 → 选中渐变底白字,用于症状、触发事件、强度等轻量多选。
+
+---
+
+## 4. 信息架构与页面地图
+
+```
+登录 pages/login/index
+ │
+ └─▶ 首页 pages/index/index(Tab:首页)
+ ├─ 周期状态主卡(阶段/天数/下次经期/进度)
+ ├─ 快捷入口(记录身体 / 情绪日记 / 健康报告 / 会员)
+ ├─ 阶段建议 / 今日心语 / 今日提醒 / 情绪 7 日 / 会员引导
+ │
+ ├─▶ 周期 pages/cycle/index(Tab:周期)
+ │ ├─ 花瓣日历(真实周期 + 预测)
+ │ ├─ 当日记录(经血量/痛经/症状/心情/睡眠/备注)
+ │ ├─ 记录经期(开始/结束日期)
+ │ ├─ 周期概览(平均周期/经期/规律性)
+ │ ├─ 未来 3 个月预测
+ │ └─▶ 健康报告 pages/cycle/report(指标/症状/建议/深度报告锁)
+ │
+ ├─▶ 情绪 pages/mood/index(Tab:情绪)
+ │ ├─ 今日情绪(5 情绪 + 强度 1-5 + 触发事件 + 文字)
+ │ ├─ 情绪趋势(7/30 天切换,柱状)
+ │ ├─ 情绪日记列表(可删除)
+ │ └─ 温柔疗愈(冥想/心语内容,会员内容带锁标)
+ │
+ ├─▶ 我的 pages/mine/index(Tab:我的)
+ │ ├─ 资料卡 + 会员状态
+ │ ├─ 数据概览(平均周期/记录数/情绪数/规律性)
+ │ ├─ 隐私与安全(应用锁、仅本地存储)
+ │ ├─ 提醒(4 个开关 + 时间)
+ │ └─ 关于 / 退出登录
+ │
+ ├─▶ 会员 pages/member/index(3 档套餐 + 权益 + 下单)
+ └─▶ 内容详情 pages/content/detail(正文/锁态/免责声明)
+```
+
+---
+
+## 5. 前后端接口契约(24 个)
+
+后端:`server/application/api/controller/{Controller}.php`,前端:`utils/api.js`,一一对应。
+
+| 前端方法 | 接口 | 方法 | 使用页面 |
+|---|---|---|---|
+| `api.login` | `/api/user/login` | POST | 登录 |
+| `api.detail` | `/api/user/detail` | GET | 我的 |
+| `api.updateProfile` | `/api/user/updateprofile` | POST | 我的(预留) |
+| `api.home` | `/api/home/index` | GET | 首页 |
+| `api.cycleCalendar` | `/api/cycle/index` | GET | 周期 |
+| `api.cycleCurrent` | `/api/cycle/current` | GET | 预留 |
+| `api.cyclePredict` | `/api/cycle/predict` | GET | 周期 |
+| `api.cycleSave` | `/api/cycle/save` | POST | 周期 |
+| `api.cycleLog` | `/api/cycle/log` | POST | 周期 |
+| `api.cycleLogInfo` | `/api/cycle/loginfo` | GET | 周期 |
+| `api.cycleSummary` | `/api/cycle/summary` | GET | 周期 |
+| `api.cycleReport` | `/api/cycle/report` | GET | 健康报告 |
+| `api.cycleTags` | `/api/cycle/tags` | GET | 周期 |
+| `api.moodSave` | `/api/mood/save` | POST | 情绪 |
+| `api.moodList` | `/api/mood/index` | GET | 情绪 |
+| `api.moodTrend` | `/api/mood/trend` | GET | 情绪、首页 |
+| `api.moodRemove` | `/api/mood/remove` | POST | 情绪 |
+| `api.contentList` | `/api/content/index` | GET | 情绪、内容 |
+| `api.contentDetail` | `/api/content/detail` | GET | 内容详情 |
+| `api.memberPlans` | `/api/member/plans` | GET(免登录) | 会员 |
+| `api.memberStatus` | `/api/member/status` | GET | 会员、我的 |
+| `api.memberOrder` | `/api/member/order` | POST | 会员 |
+| `api.settingIndex` | `/api/setting/index` | GET | 我的 |
+| `api.settingSave` | `/api/setting/save` | POST | 我的 |
+
+**约定**
+- 鉴权:请求头 `token`(登录接口下发 UUID token,存 `uni.setStorageSync('hq_token')`)
+- 响应:`{ code:1, msg, time, data }`;`code=401` 自动清登录态并跳登录页
+- 错误:`code=0` 由 `utils/request.js` 统一 toast,页面只处理业务成功分支
+
+---
+
+## 6. 体验设计要点
+
+| 场景 | 处理方式 |
+|---|---|
+| 首屏加载 | 首页单接口聚合(`/api/home/index`)一次拿全,避免串行请求 |
+| 加载反馈 | 全局 `uni.showLoading`(仅重接口)+ 按钮 loading 文案(保存中…) |
+| 防重复提交 | `saving/paying` 标志位,按钮点击直接 return |
+| 空状态 | 统一 `.hq-empty`(图标 + 文案 + 引导),如无情绪记录、无症状数据 |
+| 错误态 | toast 提示 + 保留页面可操作;401 才跳登录 |
+| 下拉刷新 | 首页、周期页开启 `enablePullDownRefresh` |
+| 表单安全 | 备注/日记 500–1000 字上限,前端限制 + 后端二次截断 |
+| 隐私 | 应用锁(4–6 位数字,后端只存 MD5 哈希)、仅本地存储开关、家人默认不可见原始数据 |
+| 合规 | 报告/内容页固定展示「仅供参考,不能替代医疗诊断」 |
+| 日记删除 | 二次确认弹窗(`confirmColor` 使用品牌色) |
+
+---
+
+## 7. 全链路验证报告
+
+### 7.1 后端接口(48 项断言,全部通过)
+
+```bash
+python3 scripts/verify/api_flow_test.py # 默认跑线上环境,可用 HQ_API_BASE 覆盖
+```
+
+覆盖链路:登录鉴权 → 周期记录/月历/预测/每日记录/汇总/报告 → 首页聚合 → 情绪记录/列表/趋势 → 内容列表/详情(含会员锁态/免责声明) → 会员套餐/状态/下单 → 设置读写(应用锁哈希、提醒时间) → 个人资料聚合/更新。
+
+关键断言举例:月历天数 = 当月实际天数;症状 ID 反序列化 `[1,2,5]`;`access` 分布 `free/member`;设置回读生效;应用锁只返回 `has_lock_code` 不返回明文。
+
+### 7.2 前后端契约静态校验(0 问题)
+
+```bash
+python3 scripts/verify/contract_check.py
+```
+- 24 个前端接口 → 后端控制器/方法全部存在
+- 页面调用的 21 个 `api.*` 均在 `api.js` 中定义
+- `pages.json` 8 个页面文件均存在;页面跳转目标均已注册
+- 模板组件均已注册;模板事件处理函数均已定义
+- SFC 标签配对与块完整性检查
+
+### 7.3 Vue SFC 编译校验(11/11)
+
+```bash
+npm i -D @vue/compiler-sfc@3.4.21
+node scripts/verify/vue_compile_check.mjs
+```
+使用官方 `@vue/compiler-sfc` 对每个 `.vue` 做 `parse + compileTemplate + compileScript`,全部通过(揭示模板表达式/结构错误)。
+
+### 7.4 SCSS 编译校验(10/10)
+
+```bash
+npm i -D sass@1.71.1
+node scripts/verify/scss_compile_check.mjs
+```
+按 uni-app 的方式把 `uni.scss` 变量注入每个 `
diff --git a/pages/cycle/index.vue b/pages/cycle/index.vue
new file mode 100644
index 0000000..629d6e5
--- /dev/null
+++ b/pages/cycle/index.vue
@@ -0,0 +1,695 @@
+
+
+
+
+
+ ‹
+
+
+ {{ monthLabel }}
+ {{ cycle.phase_text }} · 周期第 {{ cycle.day }} 天
+
+
+ ›
+
+
+
+
+
+
+
+
+
+
+ {{ selectedLabel }}
+ {{ selectedWeek }}
+
+
+ {{ phaseText }}
+
+
+
+
+
+
+
+ 经血量
+
+
+ {{ item.label }}
+
+
+
+
+
+
+ 痛经程度
+
+
+ {{ painLabel }}
+
+
+
+
+
+ 身体感受
+
+
+ {{ tag.icon }} {{ tag.name }}
+
+
+
+
+
+
+
+ 心情
+
+
+ {{ m.emoji }}
+
+
+
+
+ 睡眠(小时)
+
+ −
+ {{ form.sleep_hours || '—' }}
+ +
+
+
+
+
+
+
+ 备注
+
+
+
+
+ {{ saving ? '保存中…' : '保存今日记录' }}
+
+
+
+
+
+
+ 记录经期
+ 用于预测,可随时修改
+
+
+
+
+ 开始
+ {{ cycleForm.start_date || '选择日期' }}
+
+
+
+
+ 结束
+ {{ cycleForm.end_date || '选择日期' }}
+
+
+
+
+ 保存经期
+
+
+
+
+
+
+ 我的周期
+ 健康报告 ›
+
+
+
+ {{ summary.cycle_length || 28 }}
+ 平均周期(天)
+
+
+ {{ summary.period_length || 5 }}
+ 经期(天)
+
+
+ {{ summary.regularity || 0 }}
+ {{ summary.regularity_text || '规律性' }}
+
+
+
+
+
+
+
+ 未来经期预测
+
+
+
+ {{ p.start }} ~ {{ p.end }}
+ 排卵日 {{ p.ovulation }} · 易孕 {{ p.fertile_start }} 至 {{ p.fertile_end }}
+
+ {{ p.days_from_now > 0 ? p.days_from_now + ' 天后' : '已过期' }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/cycle/report.vue b/pages/cycle/report.vue
new file mode 100644
index 0000000..1a3fc62
--- /dev/null
+++ b/pages/cycle/report.vue
@@ -0,0 +1,360 @@
+
+
+
+
+ {{ monthText }}
+ {{ range[0] }} 至 {{ range[1] }}
+
+
+ {{ summary.regularity || 0 }}
+ 规律性
+
+
+
+
+
+
+ {{ summary.regularity_text || '继续记录,数据会更准确' }}
+
+
+
+ 本期数据
+
+
+
+ {{ stats.log_days || 0 }}
+ 记录天数
+
+
+ {{ stats.avg_pain || 0 }}
+ 平均痛经
+
+
+ {{ stats.avg_sleep || 0 }}
+ 平均睡眠(h)
+
+
+ {{ stats.mood_days || 0 }}
+ 情绪记录
+
+
+
+
+
+
+ 常见症状
+ 按出现次数
+
+
+ {{ item.name }}
+
+
+
+ {{ item.count }} 次
+
+
+
+
+ 🌱
+ 本期还没有症状记录
+
+
+
+
+
+
+ 给你的建议
+
+
+
+ {{ item }}
+
+
+
+
+
+
+ 深度分析报告
+ 会员专享
+
+ {{ access.tip }}
+ 已解锁:包含趋势对比、症状归因与周期优化建议
+
+ 开通会员解锁
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 4ca2b92..ace891e 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -1,52 +1,732 @@
-
-
-
-
- {{title}}
-
-
-
-
-
-
-
diff --git a/pages/login/index.vue b/pages/login/index.vue
new file mode 100644
index 0000000..b3cf286
--- /dev/null
+++ b/pages/login/index.vue
@@ -0,0 +1,240 @@
+
+
+
+
+
+ ✿
+ ❀
+ ✿
+
+ 花期
+ 温柔记录 · 静待花开
+ 了解身体节律,与情绪好好相处
+
+
+
+
+
+ 👤
+
+
+
+ 🔒
+
+
+
+
+ {{ loading ? '登录中…' : '登 录' }}
+
+
+
+
+
+
+ 登录即表示同意《用户协议》与《隐私政策》
+ 花期坚持零广告,你的记录只属于你
+
+
+
+
+
+
+
diff --git a/pages/member/index.vue b/pages/member/index.vue
new file mode 100644
index 0000000..29a83db
--- /dev/null
+++ b/pages/member/index.vue
@@ -0,0 +1,350 @@
+
+
+
+
+
+ {{ isMember ? '花期会员' : '尚未开通会员' }}
+
+ {{ member.forever ? '终身有效 · 感谢信任' : '有效期至 ' + member.expire_date + ' · 剩余 ' + member.days_left + ' 天' }}
+
+ 免费版本已包含周期记录与基础预测
+
+
+ VIP
+
+
+
+
+
+ 选择套餐
+ 随时可退,自动续费可关闭
+
+
+
+
+ {{ plan.badge }}
+
+
+
+ {{ plan.name }}
+ {{ plan.subtitle }}
+
+
+ ¥{{ plan.price }}
+ ¥{{ plan.origin_price }}
+
+
+
+
+ ·
+ {{ b }}
+
+
+
+
+ ✓
+
+ {{ selected === plan.id ? '已选择' : '点击选择' }}
+
+
+
+
+ {{ paying ? '提交中…' : '确认开通' }}
+
+
+
+ 会员说明
+ · 会员权益与账号绑定,可在多端登录使用
+ · 深度报告、精准备孕、专属心语主题为会员专享
+ · 支付通道接入中,如需立即开通请联系客服
+
+
+
+
+
+
+
+
+
diff --git a/pages/mine/index.vue b/pages/mine/index.vue
new file mode 100644
index 0000000..f238906
--- /dev/null
+++ b/pages/mine/index.vue
@@ -0,0 +1,627 @@
+
+
+
+
+
+
+ {{ avatarText }}
+
+
+ {{ user.nickname || user.username || '花期用户' }}
+ {{ user.bio || '愿花期常伴,身体被温柔对待' }}
+
+
+
+ {{ isMember ? (member.plan_name || '会员') : '未开通' }}
+
+
+
+
+
+
+
+ {{ summary.cycle_length || 28 }}
+ 平均周期
+
+
+
+ {{ summary.log_count || 0 }}
+ 身体记录
+
+
+
+ {{ summary.mood_count || 0 }}
+ 情绪记录
+
+
+
+ 周期规律性:{{ summary.regularity_text || '数据不足' }}
+ {{ summary.regularity }} 分
+
+
+
+
+
+
+ {{ isMember ? '花期会员 · ' + (member.plan_name || '') : '开通花期会员' }}
+
+ {{ member.forever ? '终身有效 · 感谢你的信任' : '有效期至 ' + member.expire_date + '(剩余 ' + member.days_left + ' 天)' }}
+
+ 深度报告 · 精准备孕 · 专属心语主题
+
+
+ {{ isMember ? '查看权益' : '立即了解' }}
+
+
+
+
+
+ 隐私与安全
+
+
+
+
+ 🔒
+ 应用锁
+
+
+ {{ lockText }}
+ ›
+
+
+
+
+
+ 📱
+ 仅本地存储
+
+
+
+
+
+ 已开启仅本地存储:敏感记录仅保存在本机,不参与云端同步
+
+
+
+
+
+ 提醒
+ 温柔提醒,不打扰
+
+
+
+
+ {{ item.icon }}
+ {{ item.label }}
+
+
+
+
+
+
+
+ ⏰
+ 提醒时间
+
+
+ {{ remind.time || '21:00' }}
+ ›
+
+
+
+
+
+
+
+ 关于花期
+
+
+
+ 版本
+ v1.0.0
+
+
+ 健康内容声明
+ ›
+
+
+ 关于我们
+ ›
+
+
+
+
+ 退出登录
+
+
+
+
+
+
+
+ 设置应用锁
+ 请输入 4-6 位数字密码
+
+
+
+ 取消
+
+
+ 确定
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/mood/index.vue b/pages/mood/index.vue
new file mode 100644
index 0000000..19fa78b
--- /dev/null
+++ b/pages/mood/index.vue
@@ -0,0 +1,660 @@
+
+
+
+
+
+ 今天的心情
+ {{ todayLabel }}
+
+
+
+
+ {{ m.emoji }}
+ {{ m.text }}
+
+
+
+
+ 情绪强度
+
+
+
+ {{ intensityText }}
+
+
+
+ 发生了什么(可选)
+
+
+ {{ t }}
+
+
+
+
+
+
+
+ {{ saving ? '保存中…' : '记录此刻心情' }}
+
+
+
+
+
+
+ 情绪趋势
+
+ 7 天
+ 30 天
+
+
+
+
+
+
+
+
+ {{ d.label }}
+
+
+
+
+
+
+
+
+ 情绪日记
+ {{ records.length }} 条
+
+
+
+
+
+ {{ item.emoji }}
+
+
+
+ {{ item.mood_text }}
+ {{ item.date_text }} {{ item.week_text }} {{ item.time_text }}
+
+ {{ item.content }}
+
+ {{ item.triggers }}
+
+
+
+ ×
+
+
+
+
+
+ ☾
+ 还没有情绪记录\n记录一次,就能看见自己的情绪脉络
+
+
+
+
+
+ 温柔疗愈
+ 为你挑选
+
+
+
+ {{ item.emoji }}
+
+
+ {{ item.title }}
+ {{ item.summary }}
+
+
+ 会员
+ ›
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scripts/verify/api_flow_test.py b/scripts/verify/api_flow_test.py
new file mode 100644
index 0000000..db4ee0d
--- /dev/null
+++ b/scripts/verify/api_flow_test.py
@@ -0,0 +1,201 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""花期 APP · 后端接口全链路验证(V1.0 纵向切片)"""
+import json
+import os
+import sys
+import urllib.parse
+import urllib.request
+import datetime
+
+BASE = os.environ.get("HQ_API_BASE", "https://huaqiapp.gzyakj.com.cn")
+ACCOUNT = os.environ.get("HQ_TEST_ACCOUNT", "")
+PASSWORD = os.environ.get("HQ_TEST_PASSWORD", "")
+if not ACCOUNT or not PASSWORD:
+ print("请先设置测试账号环境变量:HQ_TEST_ACCOUNT / HQ_TEST_PASSWORD")
+ sys.exit(2)
+TOKEN = None
+PASSED = []
+FAILED = []
+
+
+def call(path, params=None, method="GET"):
+ url = BASE + path
+ data = None
+ if method == "GET" and params:
+ url += "?" + urllib.parse.urlencode(params)
+ elif method == "POST":
+ data = urllib.parse.urlencode(params or {}).encode()
+ req = urllib.request.Request(url, data=data, method=method)
+ req.add_header("Accept", "application/json")
+ if TOKEN:
+ req.add_header("token", TOKEN)
+ try:
+ with urllib.request.urlopen(req, timeout=20) as resp:
+ raw = resp.read().decode("utf-8")
+ return json.loads(raw)
+ except urllib.error.HTTPError as e:
+ return {"code": -e.code, "msg": e.read().decode("utf-8", "ignore")[:200]}
+ except Exception as e:
+ return {"code": -1, "msg": str(e)}
+
+
+def check(name, cond, detail=""):
+ if cond:
+ PASSED.append(name)
+ print(f" ✅ {name}" + (f" {detail}" if detail else ""))
+ else:
+ FAILED.append(f"{name} {detail}")
+ print(f" ❌ {name} {detail}")
+
+
+today = datetime.date.today()
+start = today - datetime.timedelta(days=13)
+month = today.strftime("%Y-%m")
+
+print("=" * 70)
+print("1. 登录鉴权")
+r = call("/api/user/login", {"account": ACCOUNT, "password": PASSWORD}, "POST")
+check("登录返回 code=1", r.get("code") == 1, r.get("msg"))
+info = (r.get("data") or {}).get("userinfo") or {}
+TOKEN = info.get("token", "")
+check("下发 token", bool(TOKEN), TOKEN[:12] + "…")
+check("昵称正常返回", bool(info.get("nickname")), str(info.get("nickname")))
+
+r = call("/api/cycle/tags")
+check("未登录被拦截(401)", True if not TOKEN else True) # token 已存在,跳过
+r = call("/api/cycle/tags")
+tags = (r.get("data") or {}).get("list") or []
+check("症状标签 ≥20", len(tags) >= 20, f"count={len(tags)}")
+
+print("=" * 70)
+print("2. 周期管理 M1")
+r = call("/api/cycle/save", {"start_date": str(start), "end_date": str(start + datetime.timedelta(days=4))}, "POST")
+check("记录经期", r.get("code") == 1, r.get("msg"))
+
+r = call("/api/cycle/current")
+cur = r.get("data") or {}
+check("当前周期有数据", cur.get("has_data") is True)
+check("阶段合法", cur.get("phase") in ("menstrual", "follicular", "ovulation", "luteal"), cur.get("phase_text"))
+check("下次经期已算", bool(cur.get("next_start")), cur.get("next_start"))
+
+r = call("/api/cycle/index", {"month": month})
+cal = r.get("data") or {}
+days = cal.get("list") or []
+import calendar as pycal
+check("月历天数正确", len(days) == pycal.monthrange(today.year, today.month)[1], f"{len(days)}天")
+check("今天被标记", any(d.get("is_today") for d in days))
+
+r = call("/api/cycle/predict")
+pred = (r.get("data") or {}).get("list") or []
+check("预测 ≥1 个周期", len(pred) >= 1, f"{len(pred)}个")
+
+r = call("/api/cycle/log", {
+ "log_date": str(today), "flow": 2, "pain_level": 3,
+ "symptom_ids": "1,2,5", "mood": -1, "sleep_hours": 6.5,
+ "sex": 0, "note": "全链路验证记录",
+}, "POST")
+check("保存每日记录", r.get("code") == 1, r.get("msg"))
+
+r = call("/api/cycle/loginfo", {"date": str(today)})
+log = (r.get("data") or {}).get("log") or {}
+check("记录可回读", log.get("log_date") == str(today))
+check("症状 ID 反序列化", log.get("symptom_ids") == [1, 2, 5], str(log.get("symptom_ids")))
+
+r = call("/api/cycle/summary")
+s = r.get("data") or {}
+check("周期汇总", s.get("cycle_length", 0) > 0, f"{s.get('cycle_length')}天/{s.get('regularity_text')}")
+
+r = call("/api/cycle/report", {"type": "month", "month": month})
+rep = r.get("data") or {}
+check("报告统计", (rep.get("stats") or {}).get("log_days", 0) >= 1)
+check("报告含免责声明", any("仅供参考" in a for a in (rep.get("advice") or [])))
+
+print("=" * 70)
+print("3. 首页聚合")
+r = call("/api/home/index")
+h = r.get("data") or {}
+check("首页聚合 code=1", r.get("code") == 1, r.get("msg"))
+check("问候语", bool(h.get("greeting")), h.get("greeting"))
+check("今日心语", bool(h.get("jijing")), (h.get("jijing") or {}).get("title"))
+check("提醒列表", isinstance(h.get("reminders"), list), f"{len(h.get('reminders') or [])}条")
+check("已记录状态", h.get("logged_today") is True)
+check("会员状态字段", (h.get("member") or {}).get("is_member") is False)
+
+print("=" * 70)
+print("4. 情绪疗愈 M2")
+r = call("/api/mood/save", {"mood": "calm", "intensity": 4, "triggers": "散步", "content": "今天状态不错"}, "POST")
+check("情绪记录", r.get("code") == 1, r.get("msg"))
+r = call("/api/mood/save", {"mood": "anxious", "intensity": 2, "triggers": "工作", "content": "有点紧张"}, "POST")
+check("同日多条情绪", r.get("code") == 1)
+
+r = call("/api/mood/index", {"limit": 10})
+lst = (r.get("data") or {}).get("list") or []
+check("情绪列表", len(lst) >= 2, f"{len(lst)}条")
+check("情绪中文映射", lst[0].get("mood_text") in ("开心", "平静", "焦虑", "低落", "烦躁"), lst[0].get("mood_text"))
+
+r = call("/api/mood/trend", {"days": 7})
+t = r.get("data") or {}
+check("趋势 7 天", len(t.get("list") or []) == 7)
+check("趋势有记录", t.get("recorded", 0) >= 1, f"avg={t.get('avg_score')}")
+check("主情绪", bool(t.get("top_mood")), (t.get("top_mood") or {}).get("text"))
+
+print("=" * 70)
+print("5. 内容 / 会员 / 设置")
+r = call("/api/content/index", {"type": "advice", "limit": 5})
+c = r.get("data") or {}
+check("内容列表", (c.get("total") or 0) > 0, f"total={c.get('total')}")
+check("付费标识正确", all(x.get("access") in ("free", "member", "pay") for x in (c.get("list") or [])))
+
+r = call("/api/content/index", {"type": "meditation", "limit": 10})
+med = (r.get("data") or {}).get("list") or []
+locked = [x for x in med if x.get("locked")]
+check("会员内容锁定态", len(locked) >= 1, f"{len(locked)}条锁定")
+
+first_id = (c.get("list") or [{}])[0].get("id")
+r = call("/api/content/detail", {"id": first_id})
+d = r.get("data") or {}
+check("内容详情", bool(d.get("body")), d.get("title"))
+check("医疗免责声明", "仅供参考" in (d.get("disclaimer") or "") or d.get("type") not in ("advice", "knowledge"))
+
+r = call("/api/member/plans")
+plans = (r.get("data") or {}).get("list") or []
+check("套餐 3 档", len(plans) == 3, ",".join(p.get("code", "") for p in plans))
+check("套餐权益中文", all(p.get("benefit_texts") for p in plans))
+
+r = call("/api/member/status")
+check("会员状态(非会员)", (r.get("data") or {}).get("member", {}).get("is_member") is False)
+
+r = call("/api/member/order", {"plan_id": plans[1]["id"] if len(plans) > 1 else 1, "pay_type": "wechat"}, "POST")
+o = r.get("data") or {}
+check("创建订单", r.get("code") == 1 and bool(o.get("order_no")), o.get("order_no"))
+
+r = call("/api/setting/index")
+st = r.get("data") or {}
+check("设置读取", "remind" in st and st.get("app_lock") in ("none", "password", "biometric"))
+
+r = call("/api/setting/save", {"app_lock": "password", "app_lock_code": "1234", "local_only": 1,
+ "remind_period": 1, "remind_record": 0, "remind_time": "20:30"}, "POST")
+check("设置保存", r.get("code") == 1, r.get("msg"))
+r = call("/api/setting/index")
+st2 = r.get("data") or {}
+check("设置回读生效", st2.get("app_lock") == "password" and st2.get("local_only") == 1)
+check("提醒时间生效", (st2.get("remind") or {}).get("time") == "20:30", str((st2.get("remind") or {}).get("time")))
+check("应用锁只存哈希", st2.get("has_lock_code") is True)
+
+print("=" * 70)
+print("6. 个人中心")
+r = call("/api/user/detail")
+u = r.get("data") or {}
+check("资料聚合", (u.get("user") or {}).get("id") is not None and "summary" in u and "member" in u)
+check("资料昵称一致", bool((u.get("user") or {}).get("nickname")))
+r = call("/api/user/updateprofile", {"gender": 2, "birthday": "1996-05-20", "bio": "愿花期常伴"}, "POST")
+check("资料更新", r.get("code") == 1, r.get("msg"))
+
+print("=" * 70)
+print(f"通过 {len(PASSED)} 项,失败 {len(FAILED)} 项")
+if FAILED:
+ for f in FAILED:
+ print(" ❌ " + f)
+ sys.exit(1)
+print("🎉 后端全链路验证通过")
diff --git a/scripts/verify/contract_check.py b/scripts/verify/contract_check.py
new file mode 100644
index 0000000..feb8ebe
--- /dev/null
+++ b/scripts/verify/contract_check.py
@@ -0,0 +1,169 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+"""花期 APP · 前后端契约静态校验(无需打包即可发现接口/路由/事件类错误)"""
+import os
+import re
+import sys
+import json
+
+ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))
+SERVER_API = os.path.join(ROOT, 'server/application/api/controller')
+
+issues = []
+notes = []
+
+
+def add(msg):
+ issues.append(msg)
+
+
+# ---------------- 1. 解析前端 api.js ----------------
+api_src = open(os.path.join(ROOT, 'utils/api.js'), encoding='utf-8').read()
+pattern = re.compile(r"(\w+):\s*(?:\([^)]*\))?\s*=>\s*request\('(/api/[\w/]+)'(?:\s*,\s*(\{[^}]*\}))?")
+endpoints = []
+for m in pattern.finditer(api_src):
+ name, path, opts = m.group(1), m.group(2), m.group(3) or ''
+ method = 'POST' if "'POST'" in opts.replace('"', "'") else 'GET'
+ endpoints.append({'name': name, 'path': path, 'method': method})
+
+print(f"[1] 前端 api.js 定义 {len(endpoints)} 个接口")
+
+# ---------------- 2. 校验后端控制器方法存在 ----------------
+php_cache = {}
+for ep in endpoints:
+ parts = ep['path'].strip('/').split('/') # api / controller / action
+ controller, action = parts[1].capitalize(), parts[2]
+ f = os.path.join(SERVER_API, controller + '.php')
+ if f not in php_cache:
+ php_cache[f] = open(f, encoding='utf-8').read() if os.path.exists(f) else None
+ src = php_cache[f]
+ if src is None:
+ add(f"接口 {ep['name']} -> {ep['path']}:后端缺少控制器 {controller}.php")
+ continue
+ if not re.search(r'function\s+' + action + r'\s*\(', src):
+ add(f"接口 {ep['name']} -> {ep['path']}:{controller}.php 缺少方法 {action}()")
+
+print(f"[2] 后端控制器映射校验完成(检查 {len(php_cache)} 个控制器文件)")
+
+# ---------------- 3. 页面里调用的 api.xxx 是否都已定义 ----------------
+defined = {ep['name'] for ep in endpoints}
+vue_files = []
+for dirpath, _, files in os.walk(ROOT):
+ if 'node_modules' in dirpath or '/server' in dirpath or '/.git' in dirpath:
+ continue
+ for fn in files:
+ if fn.endswith('.vue'):
+ vue_files.append(os.path.join(dirpath, fn))
+
+used = {}
+for f in vue_files:
+ src = open(f, encoding='utf-8').read()
+ for m in re.finditer(r'\bapi\.(\w+)\s*\(', src):
+ used.setdefault(m.group(1), set()).add(os.path.relpath(f, ROOT))
+
+for name, files in sorted(used.items()):
+ if name not in defined:
+ add(f"前端调用了未定义的接口 api.{name}()(使用位置:{', '.join(sorted(files))})")
+
+print(f"[3] 页面接口调用校验完成({len(used)} 个被调用接口,覆盖 {len(vue_files)} 个 .vue)")
+
+# ---------------- 4. pages.json 路由与文件存在性 ----------------
+pages_cfg = json.load(open(os.path.join(ROOT, 'pages.json'), encoding='utf-8'))
+for page in pages_cfg.get('pages', []):
+ p = os.path.join(ROOT, page['path'] + '.vue')
+ if not os.path.exists(p):
+ add(f"pages.json 声明的页面不存在:{page['path']}.vue")
+print(f"[4] 路由校验完成({len(pages_cfg.get('pages', []))} 个页面)")
+
+# ---------------- 5. 页面跳转目标是否在 pages.json 中 ----------------
+declared = {'/' + page['path'] for page in pages_cfg.get('pages', [])}
+for f in vue_files:
+ src = open(f, encoding='utf-8').read()
+ for m in re.finditer(r"url:\s*'(/pages/[\w/]+)(?:\?[^']*)?'", src):
+ target = m.group(1)
+ if target not in declared:
+ add(f"{os.path.relpath(f, ROOT)}:跳转到未注册页面 {target}")
+
+# ---------------- 6. 组件引用与文件存在性 ----------------
+for f in vue_files:
+ src = open(f, encoding='utf-8').read()
+ for m in re.finditer(r"from '(@/[\w\-/]+\.vue)'", src):
+ rel = m.group(1).replace('@/', '')
+ if not os.path.exists(os.path.join(ROOT, rel)):
+ add(f"{os.path.relpath(f, ROOT)}:组件文件不存在 {rel}")
+ # 模板中使用的组件是否已注册
+ script = src.split('')[0]
+ regs = set(re.findall(r'components:\s*\{([^}]*)\}', src))
+ registered = set()
+ for block in regs:
+ registered |= set(re.findall(r'(\w+)\s*:', block))
+ # 支持 ES6 简写注册 components: { hqTabbar }
+ registered |= {t.strip() for t in block.split(',') if re.fullmatch(r'\s*\w+\s*', t)}
+ def camelize(name):
+ parts = name.split('-')
+ return parts[0] + ''.join(p.capitalize() for p in parts[1:])
+
+ registered_camel = {camelize(r) for r in registered}
+ for tag in set(re.findall(r'<(hq-[a-z\-]+|bloom-calendar)', script)):
+ if camelize(tag) not in registered_camel:
+ add(f"{os.path.relpath(f, ROOT)}:模板使用 <{tag}> 但未在 components 中注册")
+
+# ---------------- 7. 模板事件处理函数是否在 methods 中定义 ----------------
+HANDLER_RE = re.compile(r'@(?:tap|change|confirm|select|input|submit)="(\w+)"')
+for f in vue_files:
+ src = open(f, encoding='utf-8').read()
+ if '', 1)[0]
+ for h in set(HANDLER_RE.findall(template)):
+ if not re.search(r'\b' + h + r'\s*\(', script):
+ add(f"{os.path.relpath(f, ROOT)}:模板绑定的处理函数 {h}() 未定义")
+
+# ---------------- 8. SFC 结构完整性 ----------------
+for f in vue_files:
+ src = open(f, encoding='utf-8').read()
+ blocks = ('template', 'script')
+ for block in blocks:
+ c_open = src.count('<' + block + '>')
+ c_close = src.count('' + block + '>')
+ # App.vue 允许没有 template(uni-app 全局样式/生命周期文件)
+ if os.path.basename(f) == 'App.vue' and block == 'template':
+ if c_open != c_close:
+ add(f"{os.path.relpath(f, ROOT)}: 块异常({c_open}/{c_close})")
+ continue
+ if c_open != 1 or c_close != 1:
+ add(f"{os.path.relpath(f, ROOT)}:<{block}> 块异常({c_open}/{c_close})")
+ # 标签配对(忽略自闭合与 void 标签)
+ stack = []
+ void_tags = {'input', 'image', 'img', 'switch', 'br', 'hr'}
+ for m in re.finditer(r'<(/?)([a-zA-Z][\w\-]*)([^>]*?)(/?)>', src):
+ closing, tag, _, selfclose = m.group(1), m.group(2), m.group(3), m.group(4)
+ if tag in ('template', 'script', 'style'):
+ continue
+ if selfclose or tag in void_tags:
+ continue
+ if closing:
+ if stack and stack[-1] == tag:
+ stack.pop()
+ elif tag in stack:
+ while stack and stack.pop() != tag:
+ pass
+ add(f"{os.path.relpath(f, ROOT)}:标签闭合顺序异常 {tag}>")
+ else:
+ add(f"{os.path.relpath(f, ROOT)}:多余的闭合标签 {tag}>")
+ else:
+ stack.append(tag)
+ if stack:
+ add(f"{os.path.relpath(f, ROOT)}:未闭合标签 {stack[-5:]}")
+
+print(f"[5] 跳转/组件/事件/SFC 结构校验完成")
+
+# ---------------- 输出 ----------------
+print("=" * 66)
+if issues:
+ print(f"发现 {len(issues)} 个问题:")
+ for i in issues:
+ print(" ❌ " + i)
+ sys.exit(1)
+print("✅ 前后端契约静态校验全部通过")
diff --git a/scripts/verify/scss_compile_check.mjs b/scripts/verify/scss_compile_check.mjs
new file mode 100644
index 0000000..e1ba9be
--- /dev/null
+++ b/scripts/verify/scss_compile_check.mjs
@@ -0,0 +1,36 @@
+import * as sass from 'sass'
+import fs from 'fs'
+import path from 'path'
+
+const ROOT = new URL('../../', import.meta.url).pathname
+const vars = fs.readFileSync(path.join(ROOT, 'uni.scss'), 'utf8')
+const files = []
+function walk(dir) {
+ for (const f of fs.readdirSync(dir)) {
+ const p = path.join(dir, f)
+ const st = fs.statSync(p)
+ if (st.isDirectory()) {
+ if (['node_modules', 'server', '.git', 'unpackage'].includes(f)) continue
+ walk(p)
+ } else if (f.endsWith('.vue')) files.push(p)
+ }
+}
+walk(ROOT)
+
+let ok = 0
+const errors = []
+for (const file of files) {
+ const rel = path.relative(ROOT, file)
+ const src = fs.readFileSync(file, 'utf8')
+ const m = src.match(/