文件
huaqiapp/pages/cycle/index.vue
linda ea2be7af8c style(ui): 图标整体放大并与页面比例协调
按 6 级尺寸阶梯统一放大图标,避免小而散、提升大气感:
- 底部导航 40 -> 48,容器 104 -> 116,标签 22 -> 23
- 首页快捷入口 40 -> 52,容器 96 -> 112、圆角 32 -> 36,标签 22 -> 24
- 首页品牌花标 40 -> 46,牌标容器 72 -> 84
- 今日心语 52 -> 62,提醒 38 -> 46
- 情绪选择 40 -> 50(容器 76),记录 30 -> 36,疗愈内容 34 -> 42
- 健康 Tab 26 -> 32(Tab 76 -> 84),建议项 34 -> 42(容器 84)
- 我的设置项 32 -> 40,头像 108 -> 116
- 备孕/关系/亲子勾选 20 -> 24(容器 40 -> 46),会员勾选 18 -> 22
- 咨询师头像 40 -> 50(容器 100),热线 34/36 -> 42,急救工具 44 -> 54
- 空状态与会员锁 72 -> 96,内容详情头图 64 -> 78,登录花瓣与输入框图标同步放大
- 大尺寸图标描边降至 1.6-1.8,小尺寸保持 1.8-2.4,线宽视觉统一
- 文档补充「图标尺寸阶梯」规范

验证:no_emoji 0 问题 / 契约 84 接口 0 偏差 / Vue 20-20 / SCSS 19-19
2026-11-06 10:25:41 +08:00

707 行
15 KiB
Vue

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

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

<template>
<view class="hq-page">
<!-- 月份切换 -->
<view class="month-bar">
<view class="month-nav" @tap="changeMonth(-1)">
<text class="month-nav-text">‹</text>
</view>
<view class="month-title">
<text class="month-title-text">{{ monthLabel }}</text>
<text class="month-title-sub" v-if="cycle.has_data">{{ cycle.phase_text }} · 周期第 {{ cycle.day }} 天</text>
</view>
<view class="month-nav" @tap="changeMonth(1)">
<text class="month-nav-text">›</text>
</view>
</view>
<!-- 花瓣日历 -->
<bloom-calendar :days="days" :month="month" :selected="selected" @select="selectDay" />
<!-- 选中日详情 + 记录 -->
<view class="hq-card day-card">
<view class="day-head">
<view class="day-head-left">
<text class="day-date">{{ selectedLabel }}</text>
<text class="day-week">{{ selectedWeek }}</text>
</view>
<view class="day-phase" :style="{ backgroundColor: phaseColor + '1A', color: phaseColor }">
<text class="day-phase-text">{{ phaseText }}</text>
</view>
</view>
<view class="hq-divider"></view>
<!-- 经血量 -->
<view class="field">
<text class="field-label">经血量</text>
<view class="chip-row">
<view
v-for="item in flowOptions"
:key="item.value"
class="hq-chip"
:class="{ 'hq-chip-active': form.flow === item.value }"
@tap="form.flow = item.value"
>
<text class="chip-text">{{ item.label }}</text>
</view>
</view>
</view>
<!-- 痛经程度 -->
<view class="field">
<text class="field-label">痛经程度</text>
<view class="pain-row">
<view
v-for="n in 5"
:key="n"
class="pain-dot"
:class="{ 'pain-dot-active': form.pain_level >= n }"
@tap="form.pain_level = form.pain_level === n ? 0 : n"
></view>
<text class="pain-text">{{ painLabel }}</text>
</view>
</view>
<!-- 症状标签 -->
<view class="field">
<text class="field-label">身体感受</text>
<view class="chip-row">
<view
v-for="tag in tags"
:key="tag.id"
class="hq-chip"
:class="{ 'hq-chip-active': form.symptom_ids.indexOf(tag.id) > -1 }"
@tap="toggleTag(tag.id)"
>
<hq-icon :name="symptomIcon(tag.category)" :size="28" :stroke="1.7" color="#B5715B" class="chip-icon" />
<text class="chip-text">{{ tag.name }}</text>
</view>
</view>
</view>
<!-- 情绪 & 睡眠 -->
<view class="two-col">
<view class="col">
<text class="field-label">心情</text>
<view class="mood-row">
<view
v-for="m in moodOptions"
:key="m.value"
class="mood-btn"
:class="{ 'mood-btn-active': form.mood === m.value }"
@tap="form.mood = form.mood === m.value ? 0 : m.value"
>
<hq-icon
:name="m.icon"
:size="36"
:stroke="1.8"
:color="form.mood === m.value ? '#E8604C' : '#B5715B'"
/>
</view>
</view>
</view>
<view class="col">
<text class="field-label">睡眠(小时)</text>
<view class="sleep-row">
<view class="sleep-btn" @tap="changeSleep(-0.5)"><text class="sleep-btn-text">−</text></view>
<text class="sleep-value">{{ form.sleep_hours || '—' }}</text>
<view class="sleep-btn" @tap="changeSleep(0.5)"><text class="sleep-btn-text">+</text></view>
</view>
</view>
</view>
<!-- 备注 -->
<view class="field">
<text class="field-label">备注</text>
<input
class="note-input"
v-model="form.note"
placeholder="今天身体的感觉,想对自己说点什么…"
placeholder-class="note-placeholder"
maxlength="500"
/>
</view>
<view class="hq-btn save-btn" @tap="saveLog">
<text class="save-btn-text">{{ saving ? '保存中…' : '保存今日记录' }}</text>
</view>
</view>
<!-- 记录经期 -->
<view class="hq-card">
<view class="hq-section-head">
<text class="hq-section-title">记录经期</text>
<text class="hq-muted">用于预测,可随时修改</text>
</view>
<view class="cycle-form">
<picker mode="date" :value="cycleForm.start_date" :end="today" @change="onStartChange">
<view class="date-picker">
<text class="date-picker-label">开始</text>
<text class="date-picker-value">{{ cycleForm.start_date || '选择日期' }}</text>
</view>
</picker>
<picker mode="date" :value="cycleForm.end_date" :end="today" @change="onEndChange">
<view class="date-picker">
<text class="date-picker-label">结束</text>
<text class="date-picker-value">{{ cycleForm.end_date || '选择日期' }}</text>
</view>
</picker>
</view>
<view class="hq-btn-ghost cycle-save" @tap="saveCycle">
<text class="cycle-save-text">保存经期</text>
</view>
</view>
<!-- 周期概览 -->
<view class="hq-card">
<view class="hq-section-head">
<text class="hq-section-title">我的周期</text>
<text class="hq-section-more" @tap="goReport">健康报告 ›</text>
</view>
<view class="stat-row">
<view class="stat">
<text class="stat-value">{{ summary.cycle_length || 28 }}</text>
<text class="stat-label">平均周期(天)</text>
</view>
<view class="stat">
<text class="stat-value">{{ summary.period_length || 5 }}</text>
<text class="stat-label">经期(天)</text>
</view>
<view class="stat">
<text class="stat-value">{{ summary.regularity || 0 }}</text>
<text class="stat-label">{{ summary.regularity_text || '规律性' }}</text>
</view>
</view>
</view>
<!-- 预测 -->
<view class="hq-card" v-if="predict.list && predict.list.length">
<view class="hq-section-head">
<text class="hq-section-title">未来经期预测</text>
</view>
<view class="predict-item" v-for="(p, i) in predict.list" :key="i">
<view class="predict-left">
<text class="predict-date">{{ p.start }} ~ {{ p.end }}</text>
<text class="predict-sub">排卵日 {{ p.ovulation }} · 易孕 {{ p.fertile_start }} 至 {{ p.fertile_end }}</text>
</view>
<text class="predict-tag">{{ p.days_from_now > 0 ? p.days_from_now + ' 天后' : '已过期' }}</text>
</view>
</view>
<view class="footer">
<text class="footer-text">预测基于历史记录推算,仅供参考</text>
</view>
<hq-tabbar current="cycle" />
</view>
</template>
<script>
import api from '@/utils/api.js'
import store from '@/utils/store.js'
import { today as todayStr, monthOf, addMonths, monthText, dayText, weekText } from '@/utils/date.js'
import { iconForSymptom } from '@/utils/icons.js'
import hqIcon from '@/components/hq-icon/hq-icon.vue'
import bloomCalendar from '@/components/bloom-calendar/bloom-calendar.vue'
import hqTabbar from '@/components/hq-tabbar/hq-tabbar.vue'
const EMPTY_FORM = () => ({
flow: 0,
pain_level: 0,
symptom_ids: [],
mood: 0,
sleep_hours: null,
note: ''
})
export default {
components: { hqIcon, bloomCalendar, hqTabbar },
data() {
return {
month: monthOf(new Date()),
days: [],
cycle: {},
selected: todayStr(),
tags: [],
form: EMPTY_FORM(),
summary: {},
predict: { list: [] },
cycleForm: { start_date: '', end_date: '' },
today: todayStr(),
saving: false,
flowOptions: [
{ label: '无', value: 0 },
{ label: '少量', value: 1 },
{ label: '中等', value: 2 },
{ label: '较多', value: 3 }
],
moodOptions: [
{ icon: 'cloud-rain', value: -2 },
{ icon: 'cloud', value: -1 },
{ icon: 'cloud-sun', value: 0 },
{ icon: 'sun', value: 1 },
{ icon: 'heart', value: 2 }
]
}
},
computed: {
monthLabel() {
return monthText(this.month)
},
selectedLabel() {
return dayText(this.selected)
},
selectedWeek() {
return weekText(this.selected)
},
selectedDay() {
return this.days.find((d) => d.date === this.selected) || {}
},
phaseText() {
return this.selectedDay.phase_text || '待记录'
},
phaseColor() {
return this.selectedDay.color || '#C79A7B'
},
painLabel() {
const map = { 0: '无痛', 1: '轻微', 2: '可忍', 3: '明显', 4: '较重', 5: '难忍' }
return map[this.form.pain_level] || '无痛'
}
},
onShow() {
if (!store.token) {
uni.reLaunch({ url: '/pages/login/index' })
return
}
this.load()
},
onPullDownRefresh() {
this.load().finally(() => uni.stopPullDownRefresh())
},
methods: {
async load() {
try {
const [cal, summary, predict] = await Promise.all([
api.cycleCalendar(this.month),
api.cycleSummary(),
api.cyclePredict()
])
this.days = (cal && cal.list) || []
this.cycle = (cal && cal.cycle) || {}
this.summary = summary || {}
this.predict = predict || { list: [] }
await this.loadDay(this.selected)
if (this.cycle.has_data && !this.cycleForm.start_date) {
this.cycleForm.start_date = this.cycle.start_date
this.cycleForm.end_date = this.cycle.start_date
}
} catch (e) {}
},
async loadDay(date) {
this.selected = date
try {
const data = await api.cycleLogInfo(date)
this.tags = (data && data.tags) || []
const log = (data && data.log) || {}
this.form = {
flow: log.flow || 0,
pain_level: log.pain_level || 0,
symptom_ids: Array.isArray(log.symptom_ids) ? log.symptom_ids : [],
mood: log.mood || 0,
sleep_hours: log.sleep_hours ? Number(log.sleep_hours) : null,
note: log.note || ''
}
} catch (e) {}
},
changeMonth(delta) {
this.month = addMonths(this.month, delta)
this.load()
},
selectDay(day) {
this.loadDay(day.date)
},
symptomIcon(category) {
return iconForSymptom(category)
},
toggleTag(id) {
const index = this.form.symptom_ids.indexOf(id)
if (index > -1) {
this.form.symptom_ids.splice(index, 1)
} else {
this.form.symptom_ids.push(id)
}
},
changeSleep(delta) {
const current = this.form.sleep_hours === null ? 7 : this.form.sleep_hours
let next = Math.round((current + delta) * 2) / 2
next = Math.min(14, Math.max(0, next))
this.form.sleep_hours = next
},
async saveLog() {
if (this.saving) return
this.saving = true
try {
await api.cycleLog({
log_date: this.selected,
flow: this.form.flow,
pain_level: this.form.pain_level,
symptom_ids: this.form.symptom_ids.join(','),
mood: this.form.mood,
sleep_hours: this.form.sleep_hours === null ? '' : this.form.sleep_hours,
note: this.form.note
})
uni.showToast({ title: '已保存', icon: 'none' })
this.load()
} catch (e) {
} finally {
this.saving = false
}
},
onStartChange(e) {
this.cycleForm.start_date = e.detail.value
if (!this.cycleForm.end_date || this.cycleForm.end_date < this.cycleForm.start_date) {
this.cycleForm.end_date = this.cycleForm.start_date
}
},
onEndChange(e) {
this.cycleForm.end_date = e.detail.value
},
async saveCycle() {
if (!this.cycleForm.start_date) {
uni.showToast({ title: '请选择开始日期', icon: 'none' })
return
}
try {
await api.cycleSave({
start_date: this.cycleForm.start_date,
end_date: this.cycleForm.end_date || this.cycleForm.start_date
})
uni.showToast({ title: '经期已记录', icon: 'none' })
this.load()
} catch (e) {}
},
goReport() {
uni.navigateTo({ url: '/pages/cycle/report?month=' + this.month })
}
}
}
</script>
<style lang="scss" scoped>
.month-bar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 0 24rpx;
}
.month-nav {
width: 72rpx;
height: 72rpx;
border-radius: 24rpx;
background-color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 8rpx 24rpx rgba(232, 96, 76, 0.08);
}
.month-nav-text {
font-size: 36rpx;
color: #E8604C;
line-height: 1;
}
.month-title {
display: flex;
flex-direction: column;
align-items: center;
}
.month-title-text {
font-size: 34rpx;
font-weight: 600;
color: #3E2C27;
letter-spacing: 2rpx;
}
.month-title-sub {
margin-top: 4rpx;
font-size: 22rpx;
color: #8C7367;
}
.day-card {
margin-top: 24rpx;
}
.day-head {
display: flex;
align-items: center;
justify-content: space-between;
}
.day-head-left {
display: flex;
align-items: baseline;
}
.day-date {
font-size: 34rpx;
font-weight: 600;
color: #3E2C27;
}
.day-week {
margin-left: 12rpx;
font-size: 24rpx;
color: #8C7367;
}
.day-phase {
padding: 8rpx 22rpx;
border-radius: 999rpx;
}
.day-phase-text {
font-size: 22rpx;
font-weight: 500;
}
.field {
margin-top: 24rpx;
}
.field-label {
font-size: 26rpx;
color: #8C7367;
margin-bottom: 16rpx;
display: block;
}
.chip-row {
display: flex;
flex-wrap: wrap;
}
.chip-text {
font-size: 24rpx;
}
.chip-icon {
margin-right: 8rpx;
}
.pain-row {
display: flex;
align-items: center;
}
.pain-dot {
width: 44rpx;
height: 12rpx;
border-radius: 999rpx;
background-color: #F5E7DF;
margin-right: 10rpx;
}
.pain-dot-active {
background: linear-gradient(90deg, #F5A65B 0%, #E8604C 100%);
}
.pain-text {
margin-left: 12rpx;
font-size: 22rpx;
color: #B9A79E;
}
.two-col {
display: flex;
margin-top: 24rpx;
}
.col {
flex: 1;
}
.mood-row {
display: flex;
align-items: center;
}
.mood-btn {
width: 76rpx;
height: 76rpx;
border-radius: 24rpx;
background-color: #FFF4EE;
display: flex;
align-items: center;
justify-content: center;
margin-right: 10rpx;
}
.mood-btn-active {
background-color: #FFE6DC;
border: 2rpx solid #E8604C;
}
.sleep-row {
display: flex;
align-items: center;
}
.sleep-btn {
width: 56rpx;
height: 56rpx;
border-radius: 18rpx;
background-color: #FFF4EE;
display: flex;
align-items: center;
justify-content: center;
}
.sleep-btn-text {
font-size: 28rpx;
color: #E8604C;
line-height: 1;
}
.sleep-value {
width: 90rpx;
text-align: center;
font-size: 28rpx;
color: #3E2C27;
}
.note-input {
height: 88rpx;
padding: 0 24rpx;
background-color: #FFF9F5;
border-radius: 20rpx;
font-size: 26rpx;
color: #3E2C27;
}
.note-placeholder {
color: #C9B4AA;
font-size: 24rpx;
}
.save-btn {
margin-top: 32rpx;
}
.save-btn-text {
font-size: 30rpx;
color: #FFFFFF;
letter-spacing: 2rpx;
}
.cycle-form {
display: flex;
justify-content: space-between;
}
.date-picker {
flex: 1;
background-color: #FFF9F5;
border-radius: 20rpx;
padding: 20rpx 24rpx;
margin-right: 16rpx;
display: flex;
flex-direction: column;
}
.date-picker-label {
font-size: 22rpx;
color: #B9A79E;
}
.date-picker-value {
margin-top: 6rpx;
font-size: 28rpx;
color: #3E2C27;
}
.cycle-save {
margin-top: 24rpx;
height: 80rpx;
}
.cycle-save-text {
font-size: 28rpx;
color: #E8604C;
}
.stat-row {
display: flex;
align-items: center;
}
.stat {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
.stat-value {
font-size: 44rpx;
font-weight: 600;
color: #E8604C;
}
.stat-label {
margin-top: 4rpx;
font-size: 22rpx;
color: #8C7367;
}
.predict-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 0;
}
.predict-item + .predict-item {
border-top: 2rpx solid #F5E7DF;
}
.predict-left {
flex: 1;
display: flex;
flex-direction: column;
}
.predict-date {
font-size: 28rpx;
color: #3E2C27;
}
.predict-sub {
margin-top: 4rpx;
font-size: 22rpx;
color: #B9A79E;
}
.predict-tag {
font-size: 22rpx;
color: #E8604C;
background-color: #FFF1E9;
padding: 6rpx 16rpx;
border-radius: 999rpx;
}
.footer {
padding: 8rpx 0 24rpx;
text-align: center;
}
.footer-text {
font-size: 20rpx;
color: #C9B4AA;
}
</style>