文件
huaqiapp/pages/cycle/report.vue
linda 5ea1b461f3 feat: 花期 V1.0 纵向切片(暖色调设计系统 + 周期/情绪/会员全链路)
前端(uni-app · Vue3)
- 设计系统:uni.scss 品牌令牌(花红 #E8604C / 蜜橙 #F5A65B / 暖米白 #FFF9F5),
  App.vue 全局原子类(卡片/按钮/胶囊/单元格/空态/进度)
- 页面:登录、首页(聚合)、周期(花瓣日历+当日记录+预测+概览)、情绪(记录+趋势+日记+疗愈)、
  我的(资料/会员/隐私/提醒)、健康报告、会员套餐、内容详情
- 组件:hq-tabbar(自定义底栏)、bloom-calendar(阶段日历)
- 基础层:utils/{config,request,store,api,date}.js(统一 token、401 处理、接口集中定义)

后端(FastAdmin / ThinkPHP 5.0)
- 新增 api 控制器:Home / Cycle / Mood / Content / Member / Setting,User 增补 detail、updateprofile
- 新增服务层:CycleService(四阶段计算、预测、月历、汇总)、MemberService(权益判定)
- 新增表:fa_cycle / fa_cycle_log / fa_symptom_tag / fa_mood_log / fa_content /
  fa_content_category / fa_member_plan / fa_member_order / fa_user_setting
- 初始化数据:20 个症状标签、28 条内容(心语/科普/知识/食谱/运动/睡眠/痛经/冥想)、3 档会员

验证(全部通过)
- 接口全链路 48 项断言(登录→周期→首页→情绪→内容→会员→设置→资料)
- 前后端契约静态校验 24 个接口 0 偏差
- Vue SFC 编译 11/11、SCSS 编译 10/10
- 验证脚本见 scripts/verify/,报告见 docs/04-前端设计系统与联调验证.md
2026-11-05 22:54:02 +08:00

361 行
7.3 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<view class="hq-page">
<view class="report-head">
<view class="report-month">
<text class="report-month-text">{{ monthText }}</text>
<text class="report-month-sub">{{ range[0] }} 至 {{ range[1] }}</text>
</view>
<view class="report-score">
<text class="report-score-value">{{ summary.regularity || 0 }}</text>
<text class="report-score-label">规律性</text>
</view>
</view>
<view class="score-bar">
<view class="score-bar-inner" :style="{ width: (summary.regularity || 0) + '%' }"></view>
</view>
<text class="score-text">{{ summary.regularity_text || '继续记录,数据会更准确' }}</text>
<!-- 关键指标 -->
<view class="hq-section-head">
<text class="hq-section-title">本期数据</text>
</view>
<view class="metrics">
<view class="metric">
<text class="metric-value">{{ stats.log_days || 0 }}</text>
<text class="metric-label">记录天数</text>
</view>
<view class="metric">
<text class="metric-value">{{ stats.avg_pain || 0 }}</text>
<text class="metric-label">平均痛经</text>
</view>
<view class="metric">
<text class="metric-value">{{ stats.avg_sleep || 0 }}</text>
<text class="metric-label">平均睡眠(h)</text>
</view>
<view class="metric">
<text class="metric-value">{{ stats.mood_days || 0 }}</text>
<text class="metric-label">情绪记录</text>
</view>
</view>
<!-- 常见症状 -->
<view class="hq-card" v-if="stats.top_symptoms && stats.top_symptoms.length">
<view class="hq-section-head">
<text class="hq-section-title">常见症状</text>
<text class="hq-muted">按出现次数</text>
</view>
<view class="symptom-row" v-for="item in stats.top_symptoms" :key="item.name">
<text class="symptom-name">{{ item.name }}</text>
<view class="symptom-bar-wrap">
<view class="symptom-bar" :style="{ width: Math.min(100, item.count * 20) + '%' }"></view>
</view>
<text class="symptom-count">{{ item.count }} 次</text>
</view>
</view>
<view class="hq-card" v-else>
<view class="hq-empty">
<text class="hq-empty-emoji">🌱</text>
<text class="hq-empty-text">本期还没有症状记录</text>
</view>
</view>
<!-- 建议 -->
<view class="hq-card">
<view class="hq-section-head">
<text class="hq-section-title">给你的建议</text>
</view>
<view class="advice-item" v-for="(item, index) in advice" :key="index">
<view class="advice-dot"></view>
<text class="advice-text">{{ item }}</text>
</view>
</view>
<!-- 深度报告(会员权益) -->
<view class="deep-card">
<view class="deep-head">
<text class="deep-title">深度分析报告</text>
<text class="deep-tag" v-if="!access.deep">会员专享</text>
</view>
<text class="deep-desc" v-if="!access.deep">{{ access.tip }}</text>
<text class="deep-desc" v-else>已解锁:包含趋势对比、症状归因与周期优化建议</text>
<view class="deep-btn" v-if="!access.deep" @tap="goMember">
<text class="deep-btn-text">开通会员解锁</text>
</view>
</view>
<view class="footer">
<text class="footer-text">以上内容仅供参考,不能替代医疗诊断</text>
</view>
</view>
</template>
<script>
import api from '@/utils/api.js'
import store from '@/utils/store.js'
import { monthOf, monthText } from '@/utils/date.js'
export default {
data() {
return {
month: monthOf(new Date()),
range: ['', ''],
summary: {},
stats: {},
advice: [],
access: { deep: false, tip: '' }
}
},
computed: {
monthText() {
return monthText(this.month)
}
},
onLoad(options) {
if (!store.token) {
uni.reLaunch({ url: '/pages/login/index' })
return
}
if (options && options.month) {
this.month = options.month
}
this.load()
},
methods: {
async load() {
try {
const data = await api.cycleReport('month', this.month)
this.range = (data && data.range) || ['', '']
this.summary = (data && data.summary) || {}
this.stats = (data && data.stats) || {}
this.advice = (data && data.advice) || []
this.access = (data && data.access) || { deep: false, tip: '' }
} catch (e) {}
},
goMember() {
uni.navigateTo({ url: '/pages/member/index' })
}
}
}
</script>
<style lang="scss" scoped>
.report-head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 32rpx 0 20rpx;
}
.report-month {
display: flex;
flex-direction: column;
}
.report-month-text {
font-size: 40rpx;
font-weight: 600;
color: #3E2C27;
letter-spacing: 2rpx;
}
.report-month-sub {
margin-top: 6rpx;
font-size: 22rpx;
color: #B9A79E;
}
.report-score {
display: flex;
flex-direction: column;
align-items: flex-end;
}
.report-score-value {
font-size: 56rpx;
font-weight: 600;
color: #E8604C;
line-height: 1;
}
.report-score-label {
margin-top: 4rpx;
font-size: 20rpx;
color: #B9A79E;
}
.score-bar {
height: 12rpx;
border-radius: 999rpx;
background-color: #FFF1E9;
overflow: hidden;
}
.score-bar-inner {
height: 100%;
border-radius: 999rpx;
background: linear-gradient(90deg, #F5A65B 0%, #E8604C 100%);
}
.score-text {
display: block;
margin-top: 12rpx;
font-size: 22rpx;
color: #8C7367;
}
.metrics {
display: flex;
flex-wrap: wrap;
margin-bottom: 12rpx;
}
.metric {
width: 50%;
box-sizing: border-box;
background-color: #FFFFFF;
border-radius: 28rpx;
padding: 28rpx;
margin-bottom: 16rpx;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 10rpx 28rpx rgba(232, 96, 76, 0.06);
}
.metric:nth-child(odd) {
width: calc(50% - 8rpx);
margin-right: 16rpx;
}
.metric:nth-child(even) {
width: calc(50% - 8rpx);
}
.metric-value {
font-size: 44rpx;
font-weight: 600;
color: #3E2C27;
}
.metric-label {
margin-top: 6rpx;
font-size: 22rpx;
color: #8C7367;
}
.symptom-row {
display: flex;
align-items: center;
padding: 14rpx 0;
}
.symptom-name {
width: 140rpx;
font-size: 26rpx;
color: #3E2C27;
}
.symptom-bar-wrap {
flex: 1;
height: 12rpx;
border-radius: 999rpx;
background-color: #FFF1E9;
overflow: hidden;
margin: 0 16rpx;
}
.symptom-bar {
height: 100%;
border-radius: 999rpx;
background: linear-gradient(90deg, #F5A65B 0%, #E8604C 100%);
}
.symptom-count {
font-size: 22rpx;
color: #B9A79E;
}
.advice-item {
display: flex;
align-items: flex-start;
padding: 12rpx 0;
}
.advice-dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
background-color: #F5A65B;
margin-top: 14rpx;
margin-right: 14rpx;
}
.advice-text {
flex: 1;
font-size: 26rpx;
color: #5C4A43;
line-height: 1.8;
}
.deep-card {
border-radius: 32rpx;
padding: 32rpx;
background: linear-gradient(135deg, #FFF1E0 0%, #FFE0CE 100%);
border: 2rpx solid #F7DCC8;
}
.deep-head {
display: flex;
align-items: center;
justify-content: space-between;
}
.deep-title {
font-size: 30rpx;
font-weight: 600;
color: #A8452F;
}
.deep-tag {
font-size: 20rpx;
color: #FFFFFF;
background: linear-gradient(135deg, #F5A65B 0%, #E8604C 100%);
padding: 6rpx 16rpx;
border-radius: 999rpx;
}
.deep-desc {
display: block;
margin-top: 12rpx;
font-size: 22rpx;
color: #B5715B;
line-height: 1.7;
}
.deep-btn {
margin-top: 24rpx;
height: 80rpx;
border-radius: 40rpx;
background-color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
}
.deep-btn-text {
font-size: 26rpx;
color: #C9482F;
}
.footer {
padding: 24rpx 0;
text-align: center;
}
.footer-text {
font-size: 20rpx;
color: #C9B4AA;
}
</style>