文件
huaqiapp/pages/mood/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

713 行
14 KiB
Vue

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

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

<template>
<view class="hq-page">
<!-- 今日情绪 -->
<view class="hq-card mood-card">
<view class="mood-head">
<text class="mood-title">今天的心情</text>
<text class="mood-date">{{ todayLabel }}</text>
</view>
<view class="mood-picker">
<view
v-for="m in moods"
:key="m.key"
class="mood-option"
:class="{ 'mood-option-active': form.mood === m.key }"
@tap="form.mood = m.key"
>
<hq-icon
:name="m.icon"
:size="50"
:stroke="1.8"
:color="form.mood === m.key ? '#E8604C' : '#B5715B'"
/>
<text class="mood-option-text" :class="{ 'mood-option-text-active': form.mood === m.key }">{{ m.text }}</text>
</view>
</view>
<view class="intensity">
<text class="intensity-label">情绪强度</text>
<view class="intensity-dots">
<view
v-for="n in 5"
:key="n"
class="intensity-dot"
:class="{ 'intensity-dot-active': form.intensity >= n }"
@tap="form.intensity = n"
></view>
</view>
<text class="intensity-text">{{ intensityText }}</text>
</view>
<view class="triggers">
<text class="field-label">发生了什么(可选)</text>
<view class="chip-row">
<view
v-for="t in triggerOptions"
:key="t"
class="hq-chip"
:class="{ 'hq-chip-active': form.triggers.indexOf(t) > -1 }"
@tap="toggleTrigger(t)"
>
<text class="chip-text">{{ t }}</text>
</view>
</view>
</view>
<textarea
class="mood-note"
v-model="form.content"
placeholder="写下来,情绪就轻一点…"
placeholder-class="note-placeholder"
maxlength="1000"
auto-height
/>
<view class="hq-btn save-btn" @tap="save">
<text class="save-btn-text">{{ saving ? '保存中…' : '记录此刻心情' }}</text>
</view>
</view>
<!-- 急救包入口 -->
<view class="firstaid" @tap="goFirstaid">
<view class="firstaid-left">
<text class="firstaid-title">情绪急救包</text>
<text class="firstaid-sub">478 呼吸 · 接地练习 · 敲击放松</text>
</view>
<view class="firstaid-btn"><text class="firstaid-btn-text">立即进入</text></view>
</view>
<!-- 情绪趋势 -->
<view class="hq-card">
<view class="hq-section-head">
<text class="hq-section-title">情绪趋势</text>
<view class="range-switch">
<text
class="range-item"
:class="{ 'range-item-active': range === 7 }"
@tap="changeRange(7)"
>7 天</text>
<text
class="range-item"
:class="{ 'range-item-active': range === 30 }"
@tap="changeRange(30)"
>30 天</text>
</view>
</view>
<view class="trend-chart">
<view class="trend-col" v-for="(d, i) in trend.list" :key="i">
<view class="trend-bar-wrap">
<view
class="trend-bar"
:class="{ 'trend-bar-empty': !d.score }"
:style="{ height: (d.score ? 16 + d.score * 14 : 10) + 'rpx' }"
></view>
</view>
<text class="trend-label" v-if="range === 7">{{ d.label }}</text>
</view>
</view>
<view class="trend-foot">
<text class="trend-foot-text" v-if="trend.recorded">
已记录 {{ trend.recorded }} 天 · 情绪均值 {{ trend.avg_score }}/5
<text v-if="trend.top_mood"> · 主情绪 {{ trend.top_mood.text }}</text>
</text>
<text class="trend-foot-text" v-else>这段时间还没有记录,从今天开始吧</text>
</view>
</view>
<!-- 情绪记录 -->
<view class="hq-section-head">
<text class="hq-section-title">情绪日记</text>
<text class="hq-section-more">{{ records.length }} 条</text>
</view>
<view class="hq-card record-card" v-if="records.length">
<view class="record" v-for="item in records" :key="item.id">
<view class="record-left">
<hq-icon :name="moodIcon(item.mood)" :size="36" :stroke="1.7" :color="item.color" />
</view>
<view class="record-body">
<view class="record-head">
<text class="record-mood" :style="{ color: item.color }">{{ item.mood_text }}</text>
<text class="record-time">{{ item.date_text }} {{ item.week_text }} {{ item.time_text }}</text>
</view>
<text class="record-content" v-if="item.content">{{ item.content }}</text>
<view class="record-tags" v-if="item.triggers">
<text class="record-tag">{{ item.triggers }}</text>
</view>
</view>
<view class="record-del" @tap="removeRecord(item.id)">
<text class="record-del-text">×</text>
</view>
</view>
</view>
<view class="hq-card" v-else>
<view class="hq-empty">
<hq-icon name="moon" :size="96" :stroke="1.6" color="#E6D3C9" />
<text class="hq-empty-text">还没有情绪记录\n记录一次,就能看见自己的情绪脉络</text>
</view>
</view>
<!-- 疗愈内容 -->
<view class="hq-section-head">
<text class="hq-section-title">温柔疗愈</text>
<text class="hq-section-more">为你挑选</text>
</view>
<view class="hq-card content-card" v-for="item in contents" :key="item.id" @tap="openContent(item)">
<view class="content-left">
<hq-icon :name="contentIcon(item.type)" :size="42" :stroke="1.7" color="#E8604C" />
</view>
<view class="content-body">
<text class="content-title">{{ item.title }}</text>
<text class="content-summary">{{ item.summary }}</text>
</view>
<view class="content-right">
<text class="content-lock" v-if="item.locked">会员</text>
<text class="content-arrow" v-else>›</text>
</view>
</view>
<view class="footer">
<text class="footer-text">情绪波动有生理基础,如需帮助请寻求专业支持</text>
</view>
<hq-tabbar current="mood" />
</view>
</template>
<script>
import api from '@/utils/api.js'
import store from '@/utils/store.js'
import { dayText, weekText, today as todayStr } from '@/utils/date.js'
import { iconForMood, iconForContentType } from '@/utils/icons.js'
import hqIcon from '@/components/hq-icon/hq-icon.vue'
import hqTabbar from '@/components/hq-tabbar/hq-tabbar.vue'
export default {
components: { hqIcon, hqTabbar },
data() {
return {
moods: [
{ key: 'happy', text: '开心', icon: 'sun' },
{ key: 'calm', text: '平静', icon: 'cloud-sun' },
{ key: 'anxious', text: '焦虑', icon: 'wind' },
{ key: 'low', text: '低落', icon: 'cloud-rain' },
{ key: 'angry', text: '烦躁', icon: 'bolt' }
],
triggerOptions: ['工作', '关系', '身体', '睡眠', '家人', '天气'],
form: {
mood: '',
intensity: 3,
triggers: [],
content: ''
},
range: 7,
trend: { list: [], recorded: 0, avg_score: 0, top_mood: null },
records: [],
contents: [],
saving: false
}
},
computed: {
todayLabel() {
return dayText(todayStr()) + ' ' + weekText(todayStr())
},
intensityText() {
const map = { 1: '很轻', 2: '较轻', 3: '一般', 4: '较强', 5: '强烈' }
return map[this.form.intensity] || ''
}
},
onShow() {
if (!store.token) {
uni.reLaunch({ url: '/pages/login/index' })
return
}
this.loadAll()
},
methods: {
async loadAll() {
this.loadTrend()
this.loadRecords()
this.loadContents()
},
async loadTrend() {
try {
const data = await api.moodTrend(this.range)
this.trend = data || this.trend
} catch (e) {}
},
async loadRecords() {
try {
const data = await api.moodList({ limit: 20 })
this.records = (data && data.list) || []
} catch (e) {}
},
async loadContents() {
try {
const data = await api.contentList({ type: 'meditation', limit: 3 })
this.contents = (data && data.list) || []
} catch (e) {}
},
moodIcon(mood) {
return iconForMood(mood)
},
contentIcon(type) {
return iconForContentType(type)
},
changeRange(days) {
this.range = days
this.loadTrend()
},
toggleTrigger(tag) {
const index = this.form.triggers.indexOf(tag)
if (index > -1) {
this.form.triggers.splice(index, 1)
} else {
this.form.triggers.push(tag)
}
},
async save() {
if (this.saving) return
if (!this.form.mood) {
uni.showToast({ title: '请先选择一个心情', icon: 'none' })
return
}
this.saving = true
try {
await api.moodSave({
log_date: todayStr(),
mood: this.form.mood,
intensity: this.form.intensity,
triggers: this.form.triggers.join('、'),
content: this.form.content
})
uni.showToast({ title: '记录成功', icon: 'none' })
this.form.content = ''
this.form.triggers = []
this.loadTrend()
this.loadRecords()
} catch (e) {
} finally {
this.saving = false
}
},
removeRecord(id) {
uni.showModal({
title: '删除这条记录?',
content: '删除后不可恢复',
confirmColor: '#E8604C',
success: async (res) => {
if (!res.confirm) return
try {
await api.moodRemove(id)
uni.showToast({ title: '已删除', icon: 'none' })
this.loadRecords()
this.loadTrend()
} catch (e) {}
}
})
},
goFirstaid() {
uni.navigateTo({ url: '/pages/mood/firstaid' })
},
openContent(item) {
uni.navigateTo({ url: '/pages/content/detail?id=' + item.id })
}
}
}
</script>
<style lang="scss" scoped>
.mood-card {
padding-bottom: 32rpx;
}
.mood-head {
display: flex;
align-items: baseline;
justify-content: space-between;
}
.mood-title {
font-size: 34rpx;
font-weight: 600;
color: #3E2C27;
}
.mood-date {
font-size: 22rpx;
color: #B9A79E;
}
.mood-picker {
display: flex;
justify-content: space-between;
margin-top: 28rpx;
}
.mood-option {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
padding: 24rpx 0;
border-radius: 26rpx;
background-color: #FFF9F5;
margin-right: 12rpx;
}
.mood-option:last-child {
margin-right: 0;
}
.mood-option-active {
background-color: #FFE9E0;
border: 2rpx solid #E8604C;
}
.mood-option-text {
margin-top: 10rpx;
font-size: 23rpx;
color: #8C7367;
}
.mood-option-text-active {
color: #E8604C;
font-weight: 600;
}
.intensity {
display: flex;
align-items: center;
margin-top: 28rpx;
}
.intensity-label {
font-size: 24rpx;
color: #8C7367;
margin-right: 20rpx;
}
.intensity-dots {
display: flex;
align-items: center;
}
.intensity-dot {
width: 52rpx;
height: 12rpx;
border-radius: 999rpx;
background-color: #F5E7DF;
margin-right: 10rpx;
}
.intensity-dot-active {
background: linear-gradient(90deg, #F5A65B 0%, #E8604C 100%);
}
.intensity-text {
margin-left: 8rpx;
font-size: 22rpx;
color: #B9A79E;
}
.triggers {
margin-top: 28rpx;
}
.field-label {
font-size: 24rpx;
color: #8C7367;
margin-bottom: 14rpx;
display: block;
}
.chip-row {
display: flex;
flex-wrap: wrap;
}
.chip-text {
font-size: 24rpx;
}
.mood-note {
width: 100%;
min-height: 140rpx;
margin-top: 20rpx;
padding: 24rpx;
box-sizing: border-box;
background-color: #FFF9F5;
border-radius: 24rpx;
font-size: 26rpx;
color: #3E2C27;
line-height: 1.7;
}
.note-placeholder {
color: #C9B4AA;
font-size: 24rpx;
}
.save-btn {
margin-top: 28rpx;
}
.save-btn-text {
font-size: 30rpx;
color: #FFFFFF;
letter-spacing: 2rpx;
}
.firstaid {
display: flex;
align-items: center;
justify-content: space-between;
padding: 26rpx 30rpx;
border-radius: 32rpx;
background: linear-gradient(135deg, #FFF1E0 0%, #FFE3D3 100%);
border: 2rpx solid #F7DCC8;
margin-bottom: 24rpx;
}
.firstaid-left {
flex: 1;
display: flex;
flex-direction: column;
}
.firstaid-title {
font-size: 30rpx;
font-weight: 600;
color: #A8452F;
}
.firstaid-sub {
margin-top: 6rpx;
font-size: 22rpx;
color: #B5715B;
}
.firstaid-btn {
padding: 14rpx 26rpx;
border-radius: 999rpx;
background-color: #FFFFFF;
}
.firstaid-btn-text {
font-size: 22rpx;
color: #C9482F;
}
.range-switch {
display: flex;
background-color: #FFF4EE;
border-radius: 999rpx;
padding: 4rpx;
}
.range-item {
padding: 8rpx 24rpx;
font-size: 22rpx;
color: #8C7367;
border-radius: 999rpx;
}
.range-item-active {
background-color: #FFFFFF;
color: #E8604C;
font-weight: 600;
}
.trend-chart {
display: flex;
align-items: flex-end;
height: 180rpx;
margin-top: 12rpx;
}
.trend-col {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
}
.trend-bar-wrap {
height: 140rpx;
display: flex;
align-items: flex-end;
}
.trend-bar {
width: 60%;
border-radius: 999rpx;
background: linear-gradient(180deg, #F5A65B 0%, #E8604C 100%);
}
.trend-bar-empty {
background-color: #F5E7DF;
}
.trend-label {
margin-top: 8rpx;
font-size: 18rpx;
color: #B9A79E;
}
.trend-foot {
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 2rpx solid #F5E7DF;
}
.trend-foot-text {
font-size: 22rpx;
color: #8C7367;
}
.record-card {
padding: 8rpx 32rpx;
}
.record {
display: flex;
align-items: flex-start;
padding: 24rpx 0;
}
.record + .record {
border-top: 2rpx solid #F5E7DF;
}
.record-left {
width: 76rpx;
height: 76rpx;
border-radius: 24rpx;
background-color: #FFF4EE;
display: flex;
align-items: center;
justify-content: center;
}
.record-body {
flex: 1;
margin-left: 20rpx;
display: flex;
flex-direction: column;
}
.record-head {
display: flex;
align-items: baseline;
justify-content: space-between;
}
.record-mood {
font-size: 28rpx;
font-weight: 600;
}
.record-time {
font-size: 20rpx;
color: #B9A79E;
}
.record-content {
margin-top: 6rpx;
font-size: 24rpx;
color: #5C4A43;
line-height: 1.7;
}
.record-tags {
margin-top: 8rpx;
}
.record-tag {
font-size: 20rpx;
color: #B5715B;
background-color: #FFF1E9;
padding: 4rpx 14rpx;
border-radius: 999rpx;
}
.record-del {
width: 48rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
}
.record-del-text {
font-size: 30rpx;
color: #D8C6BD;
}
.content-card {
display: flex;
align-items: center;
padding: 24rpx 28rpx;
}
.content-left {
width: 84rpx;
height: 84rpx;
border-radius: 26rpx;
background-color: #FFF4EE;
display: flex;
align-items: center;
justify-content: center;
}
.content-body {
flex: 1;
margin-left: 20rpx;
display: flex;
flex-direction: column;
}
.content-title {
font-size: 28rpx;
color: #3E2C27;
font-weight: 500;
}
.content-summary {
margin-top: 4rpx;
font-size: 22rpx;
color: #8C7367;
}
.content-right {
margin-left: 12rpx;
}
.content-lock {
font-size: 18rpx;
color: #C9482F;
background-color: #FFF1E0;
padding: 4rpx 12rpx;
border-radius: 999rpx;
}
.content-arrow {
font-size: 28rpx;
color: #D8C6BD;
}
.footer {
padding: 8rpx 0 24rpx;
text-align: center;
}
.footer-text {
font-size: 20rpx;
color: #C9B4AA;
}
</style>