diff --git a/UI/activity_history/code.html b/UI/activity_history/code.html deleted file mode 100644 index 6a99a2b..0000000 --- a/UI/activity_history/code.html +++ /dev/null @@ -1,196 +0,0 @@ - - - - -历史记录 - - - - - - - - - - - -
-
-

历史记录

- -
-
-
- - - -
-
-
-
-
-
-
-

今天, 11月14日

-
-
-
-
-shield -
-
-
-
-
-

已忍住

-成功 -
-

4:20 PM

-
- -sentiment_stressed - 压力大 - -
-
-
-
-
-
-smoking_rooms -
-
-
-
-

已抽烟

-间隔 1小时30分 -
-

1:15 PM

-
- -mood_bad - 无聊 - -
-
-
-
-
-
-smoking_rooms -
-
-
-
-

已抽烟

-今日第一支 -
-

11:45 AM

-
- -sunny - 晨间习惯 - -
-
-
-
-
-
-

昨天, 11月13日

-
-
-
-
-smoking_rooms -
-
-
-
- - -
-
-
-

已抽烟

-间隔 4小时12分 -
-

9:30 PM

-
- -local_bar - 社交 - -
-
-
-
-
-
-
- -
-
- - \ No newline at end of file diff --git a/UI/activity_history/screen.png b/UI/activity_history/screen.png deleted file mode 100644 index 0ac132e..0000000 Binary files a/UI/activity_history/screen.png and /dev/null differ diff --git a/UI/ai_quit_assistant/code.html b/UI/ai_quit_assistant/code.html deleted file mode 100644 index ad09906..0000000 --- a/UI/ai_quit_assistant/code.html +++ /dev/null @@ -1,159 +0,0 @@ - - - - -AI 戒烟助手 - - - - - - - - - - - -
-
-menu -
-
-

AI 戒烟助手

-
- -在线 -
-
-
-
-
-
-
-
-
-
-
-

第 18/30 天

-
-
-
-

当前减量计划阶段

-

阶段 2:减量期

-

本阶段还剩 12 天

-
-
-
-阶段进度 -40% -
-
-
-
-
-
-
-
-
-
-smart_toy -

每日 AI 分析

-
-
-
-
-
-
-
-
-
-
-

AI 教练

-• 刚刚 -
-
-

早上好 Alex。昨天你的吸烟量比限额少了 2 支。这是一个巨大的胜利!🏆

-

数据显示你的烟瘾在下午 2 点左右达到顶峰——今天试着那个时候去散散步。

-
-
-
-
-
-
-

今日目标

-已完成 1/3 -
- - - -
-
-
- -
- - \ No newline at end of file diff --git a/UI/ai_quit_assistant/screen.png b/UI/ai_quit_assistant/screen.png deleted file mode 100644 index fbe9c10..0000000 Binary files a/UI/ai_quit_assistant/screen.png and /dev/null differ diff --git a/UI/home_dashboard/code.html b/UI/home_dashboard/code.html deleted file mode 100644 index 63a8bfa..0000000 --- a/UI/home_dashboard/code.html +++ /dev/null @@ -1,166 +0,0 @@ - - - - -首页控制台 - - - - - - - - - -
-
-
-
-
-
-
-
-

早上好,Alex

-保持连胜纪录!🔥 -
-
- -
-
-
-
-
-psychology -
-
-

发现规律

-

你的烟瘾通常在下午2点达到高峰。我们为你准备了一个快速呼吸练习。

-
- -
-
-
-
-
- - - - -
-距上次抽烟 -

02:45:12

-
-auto_awesome -

下次建议: 16:30

-
-
-
-
-
-
-
-
-今日已抽 -
-
-3 / 10 -较昨日 -2 -
-
-
-
-
-
-
-
-烟瘾发作 -
-
-5 -已抵抗 -
-
-
-
-
-
-
-
-
-
- - -
-
- - - \ No newline at end of file diff --git a/UI/home_dashboard/screen.png b/UI/home_dashboard/screen.png deleted file mode 100644 index 6755868..0000000 Binary files a/UI/home_dashboard/screen.png and /dev/null differ diff --git a/UI/profile_&_settings/code.html b/UI/profile_&_settings/code.html deleted file mode 100644 index f3c8008..0000000 --- a/UI/profile_&_settings/code.html +++ /dev/null @@ -1,178 +0,0 @@ - - - - -个人中心 - - - - - - - - - -
-
-
-arrow_back -
-

个人中心

-
-

编辑

-
-
-
-
-
-
-
-photo_camera -
-
-
-

Alex Doe

-
- - 目标:12月1日戒烟 🎯 - -
-

已连续戒烟 12 天 🔥

-
-
-
-
-

我的进程

-
-
-
-track_changes -
-
-

目标设定

-

调整每日限额与戒烟日期

-
-chevron_right -
-
-
-psychology -
-
-

AI 计划调整

-

个性化辅导风格

-
-chevron_right -
-
-
-
-

偏好设置

-
-
-
-notifications -
-
-

通知设置

-
-chevron_right -
-
-
-diamond -
-
-

解锁会员

-PRO -
-chevron_right -
-
-
-
-

通用

-
-
-
-settings -
-
-

基础设置

-
-chevron_right -
-
-
-security -
-
-

隐私与数据

-
-chevron_right -
-
-
-
- -

版本 1.0.2

-
-
-
-
-home -首页 -
-
-bar_chart -追踪 -
-
-person -我的 -
-
-
- - \ No newline at end of file diff --git a/UI/profile_&_settings/screen.png b/UI/profile_&_settings/screen.png deleted file mode 100644 index 96b6614..0000000 Binary files a/UI/profile_&_settings/screen.png and /dev/null differ diff --git a/UI/smoking_statistics/code.html b/UI/smoking_statistics/code.html deleted file mode 100644 index 1766cf7..0000000 --- a/UI/smoking_statistics/code.html +++ /dev/null @@ -1,243 +0,0 @@ - - - - -数据统计分析 - - - - - - - - - - - - -
-
- -

数据统计分析

- -
-
-
-
- - - -
-
-
-
-
-auto_awesome -
-
-

每周洞察

-

你在周末的吸烟量明显减少。非常棒!试着在这周一保持这个良好的势头。

-
-
-
-
-
-

吸烟趋势

-
-trending_down -减少 20% -
-
-
-
-

日均吸烟量

-
-4 -支 / 天 -
-
-
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
-

健康与储蓄

-
-
-
-savings -
-
- - - - -
-已省 -¥145 -
-
-
-

节省金额

-

目标 ¥200

-
-
-
-
-pulmonology -
-
- - - - -
-40% -
-
-
-

肺部功能恢复

-

当前进度

-
-
-
-
-
-
-
-local_fire_department -连续记录 -
-

12 天

-

未吸烟

-
-
-
-block -已拒绝 -
-

24 次

-

对抗烟瘾

-
-
-
- -
- - \ No newline at end of file diff --git a/UI/smoking_statistics/screen.png b/UI/smoking_statistics/screen.png deleted file mode 100644 index 7028b5b..0000000 Binary files a/UI/smoking_statistics/screen.png and /dev/null differ diff --git a/api/smoke.js b/api/smoke.js index 3affa81..e14dd89 100644 --- a/api/smoke.js +++ b/api/smoke.js @@ -4,6 +4,10 @@ export function getDashboard(params = {}) { return request.get('/smoke/dashboard', params) } +export function getHome(params = {}) { + return request.get('/smoke/home', params) +} + export function getNextSmokeTime(params = {}) { return request.get('/smoke/next_smoke_time', params) } diff --git a/components/smoke-record-dialog/smoke-record-dialog.vue b/components/smoke-record-dialog/smoke-record-dialog.vue index 28e0025..fd3e4d2 100644 --- a/components/smoke-record-dialog/smoke-record-dialog.vue +++ b/components/smoke-record-dialog/smoke-record-dialog.vue @@ -29,7 +29,7 @@ - + 抽烟数量 @@ -41,9 +41,9 @@ - + - 烟瘾程度 + {{ type === 'smoke' ? '烟瘾程度' : '忍住强度' }} Level {{ formData.level }} 0`),`resisted` 表示忍住记录(`num=0`) + +说明: +- 列表按时间倒序返回(优先 `smoke_at`,其次 `createtime`,最后 `smoke_time`)。 成功响应示例: @@ -199,6 +203,125 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \ - 权限:会员用户直接可用;非会员需要先对该 `date` 完成“看广告解锁”(见下一个接口)。 - 建议结果会按 `uid + date + prompt_version` 缓存(表:`fa_smoke_ai_advice`)。 +## 9) 首页整合接口(Home Dashboard) + +`GET /api/v1/smoke/home` + +此接口把首页 UI 所需核心模块一次返回,避免前端串行请求多个接口。返回示例: + +```json +{ + "code": 200, + "message": "success", + "data": { + "greeting": { + "title": "早安,Alex", + "subtitle": "今天也是清爽的一天", + "nickname": "Alex", + "time_of_day": "morning", + "avatar_url": "https://example.com/avatar.jpg" + }, + "profile": { + "exists": true, + "is_completed": true, + "awake_minutes": 900, + "baseline_interval_minutes": 60, + "profile": { + "baseline_cigs_per_day": 10, + "pack_price_cent": 3200, + "wake_up_time": "07:20", + "sleep_time": "23:30" + } + }, + "advice_card": { + "title": "智能控烟建议", + "date": "2026-01-04", + "message": "根据你的习惯,下午2点是烟瘾高峰,可以试试短暂散步。", + "status": "available" + }, + "campaign_card": { + "title": "绿色生活,从戒烟开始", + "subtitle": "BRAND CAMPAIGN", + "badge": "广告" + }, + "timer": { + "label": "距上次抽烟", + "last_smoke_at": "2026-01-05T07:42:00+08:00", + "seconds_since_last": 9900, + "next_suggested_at": "2026-01-05T10:30:00+08:00", + "next_suggested_clock": "10:30", + "not_before_at": "2026-01-05T10:30:00+08:00", + "suggestion_source": "default", + "suggestion_algorithm": "staircase_delay_v1" + }, + "summary": { + "today_count": 3, + "daily_target": 10, + "resisted_count": 1, + "reduced_from_yesterday": 2, + "exceeded_yesterday": false, + "profile_completed": true + }, + "motivation": { + "message": "太棒了!你刚刚成功抵抗了一次烟瘾", + "type": "praise" + }, + "quick_actions": [ + { "type": "log_smoke", "title": "记录抽烟", "primary": false }, + { "type": "resist", "title": "想抽忍住了", "primary": true } + ], + "data_sources": { + "ai_advice_date": "2026-01-04", + "plan_date": "2026-01-05" + } + } +} +``` + +字段说明: +- `greeting.title`:问候语 + 昵称(如“下午好,Alex”)。 +- `greeting.subtitle`:副标题/心情提示文案。 +- `greeting.nickname`:昵称(无昵称时使用“朋友”)。 +- `greeting.time_of_day`:时间段标识(`morning`/`noon`/`afternoon`/`evening`)。 +- `greeting.avatar_url`:头像 URL。 +- `profile.exists`:是否存在用户档案。 +- `profile.profile`:档案详情对象(可能为空)。 +- `profile.is_completed`:是否已完成 onboarding。 +- `profile.awake_minutes`:清醒时长(分钟)。 +- `profile.baseline_interval_minutes`:基准间隔(分钟)。 +- `advice_card.title`:AI 提示卡片标题。 +- `advice_card.date`:建议对应日期。 +- `advice_card.message`:AI 建议内容。 +- `advice_card.status`:`available`、`locked`(需解锁)、`unavailable`(AI 服务未配置)、`no_data`(所需日期没有记录)、`empty`(初始化)。 +- `advice_card.model`:模型名称(有则返回)。 +- `campaign_card.title`:活动标题。 +- `campaign_card.subtitle`:活动副标题。 +- `campaign_card.badge`:活动角标(如“广告”)。 +- `timer.label`:展示标题(如“距上次抽烟”)。 +- `timer.last_smoke_at`:最近一次实际抽烟时间(RFC3339)。 +- `timer.seconds_since_last`:距上次抽烟的秒数(无记录返回 `-1`)。 +- `timer.next_suggested_at`:建议下次抽烟时间(RFC3339)。 +- `timer.next_suggested_clock`:仅时分显示(如“16:30”)。 +- `timer.not_before_at`:不早于的时间点(当前与 `next_suggested_at` 一致)。 +- `timer.suggestion_source`:建议来源(`default`/`ai`)。 +- `timer.suggestion_algorithm`:算法版本(`staircase_delay_v1`)。 +- `timer` 说明:`seconds_since_last` 基于服务器当前时间计算,`last_smoke_at` 若补录未来时间会截断到 `as_of`;当 `plan_date=今天` 时会补齐过期间隔确保 `next_suggested_at` 在未来。 +- `summary.today_count`:今日吸烟支数累加。 +- `summary.daily_target`:每日目标(线性递减:以 `onboarding_completed_at` 为起点,按 `quit_date` 线性下降到 0)。 +- `summary.resisted_count`:今日忍住次数。 +- `summary.reduced_from_yesterday`:与昨日的绝对差值(非负)。 +- `summary.exceeded_yesterday`:是否比昨天多。 +- `summary.profile_completed`:是否已完成基础信息。 +- `motivation.message`:激励语文案。 +- `motivation.type`:激励语类型。 +- `quick_actions[].type`:动作类型(`log_smoke`/`resist`)。 +- `quick_actions[].title`:按钮文案。 +- `quick_actions[].primary`:是否主按钮。 +- `data_sources.ai_advice_date`:AI 建议日期。 +- `data_sources.plan_date`:当前计划日期。 + +如需 AI 时间节点完整版,可继续调用 `GET /ai/next_smoke_time`;首页接口只返回默认建议,避免额外的 AI 生成成本。 + 未满足权限时的建议响应(示例): ```json { @@ -223,7 +346,7 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \ } ``` -## 9) 看广告解锁(用于非会员) +## 10) 看广告解锁(用于非会员) `POST /api/v1/smoke/ai/advice_unlocks` @@ -241,7 +364,7 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \ - 解锁是“按天”的:观看一次广告解锁一天内的 AI 生成功能(可用于「每日 AI 建议」以及「AI 下次抽烟时间节点」)。 - 如果你要生成“明天”的 AI 时间节点,请把 `date` 传为明天日期(例如 `2026-01-06`)。 -## 10) 获取用户基础信息(首次进入:判断是否需要补全) +## 11) 获取用户基础信息(首次进入:判断是否需要补全) `GET /api/v1/smoke/profile` @@ -269,6 +392,7 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \ "quit_motivations": ["身体健康", "省钱"], "wake_up_time": "07:30", "sleep_time": "23:30", + "quit_date": "2026-02-28T00:00:00+08:00", "onboarding_completed_at": "2026-01-05T10:00:00+08:00" }, "is_completed": true, @@ -299,8 +423,9 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \ - `smoke_motivations`(抽烟动机):如 `压力大/无聊/社交/提神`,用于 AI 在分析 remark 时更有针对性。 - `quit_motivations`(戒烟动力):如 `身体健康/家人孩子/省钱`,当用户产生动摇时 AI 可用这些信息做“情感阻断/自我提醒”。 - `wake_up_time` + `sleep_time`(作息时间):用于自动规避睡眠时间,防止在用户睡觉时提醒其“坚持”。 +- `quit_date`(目标戒烟日期):用于阶段规划或到期提醒。 -## 11) 补全/更新用户基础信息(Upsert) +## 12) 补全/更新用户基础信息(Upsert) `POST /api/v1/smoke/profile` @@ -319,13 +444,14 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \ "smoke_motivations": ["压力大", "社交"], "quit_motivations": ["身体健康", "省钱"], "wake_up_time": "07:30", - "sleep_time": "23:30" + "sleep_time": "23:30", + "quit_date": "2026-02-28" } ``` 成功响应:同 `GET /api/v1/smoke/profile`(返回最新 `profile` + `is_completed` + `baseline_interval_minutes`)。 -## 12) 想抽但忍住了(写入一条 level=0,num=0 的记录) +## 13) 想抽但忍住了(写入一条 level=0,num=0 的记录) `POST /api/v1/smoke/logs/resisted` @@ -334,7 +460,9 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \ { "smoke_time": "2026-01-05", "smoke_at": "2026-01-05 10:20:00", - "remark": "压力大,想抽但忍住了" + "remark": "压力大,想抽但忍住了", + "level": 0, + "num": 0 } ``` @@ -342,7 +470,7 @@ curl -X GET 'http://127.0.0.1:8080/api/v1/smoke/logs/5202' \ - 该接口会在 `fa_smoke_log` 中新增一条记录:`level=0` 且 `num=0`,用于更直观记录“想抽/忍住”的过程。 - 这类记录不会影响 `today_count/weekly.count` 的支数统计(因为 `num=0`)。 -## 13) 获取“下次抽烟记录时间”(默认 + AI 自动切换) +## 14) 获取“下次抽烟记录时间”(默认 + AI 自动切换) `GET /api/v1/smoke/next_smoke_time` @@ -430,11 +558,11 @@ AI 生成说明: 字段说明(新增首页字段): - `last_smoke_at`:上次“实际抽烟”时间(忽略忍住记录),格式 `RFC3339`(含时区)。 - `today_count`:今日抽烟支数(累加 `num`)。 -- `resisted_count`:今日克制次数(`level=0 && num=0`)。 +- `resisted_count`:今日克制次数(`num=0`)。 - `reduced_from_yesterday`:较昨日减少的支数(允许为负数;为负时表示“今天超出昨日”)。 - `exceeded_yesterday`:是否超出昨日(`true` 表示今天超出昨日,前端可用作单独标识)。 -## 14) 数据统计分析(趋势 + 健康 + 省钱) +## 15) 数据统计分析(趋势 + 健康 + 省钱) `GET /api/v1/smoke/stats?range=week|month|year&date=2026-01-07` @@ -493,9 +621,11 @@ AI 生成说明: 字段说明: - `change_percent`:与上一个同周期对比的变化比例(可为负)。 - `money.available=false`:表示缺少 `baseline_cigs_per_day` 或 `pack_price_cent`。 +- `money.expected_total`:按“统计周期内有记录的天数”×`baseline_cigs_per_day` 计算;不统计无日志的天数。 +- `money.saved_cent`:按 `max(expected_total - actual_total, 0)` 计算,避免出现负值。 - `health.available=false`:表示无历史记录。 -## 15) 激励语(后端统一生成) +## 16) 激励语(后端统一生成) `GET /api/v1/smoke/motivation` diff --git a/pages/index/index.vue b/pages/index/index.vue index 261dd2d..8f3b951 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -16,8 +16,8 @@ @@ -25,10 +25,10 @@ - + 🤖 - 发现规律 + {{ aiTipTitle }} {{ aiTipText }} × @@ -55,7 +55,7 @@ {{ todayCount }} / {{ dailyTarget }} - {{ changeText }} + {{ changeText }} @@ -98,27 +98,27 @@