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

657 行
14 KiB
Vue

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

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

<template>
<view class="hq-page">
<view class="head">
<text class="head-title">亲子教育</text>
<text class="head-sub">
{{ data.month_age === null ? '添加宝宝档案,获得分月龄建议' : (data.month_age < 0 ? '距离预产期还有 ' + Math.abs(data.month_age) + ' 天' : '宝宝 ' + data.month_age + ' 个月') }}
</text>
</view>
<!-- 宝宝档案 -->
<view class="hq-card">
<view class="hq-section-head">
<text class="hq-section-title">宝宝档案</text>
<text class="hq-muted" v-if="data.baby">{{ data.baby.nickname }}</text>
</view>
<view class="baby-form">
<input class="baby-input" v-model="baby.nickname" placeholder="宝宝小名" placeholder-class="ph" />
<picker mode="date" :value="baby.birthday" @change="onBirthday">
<view class="baby-picker"><text class="baby-picker-text">{{ baby.birthday || '生日 / 预产期' }}</text></view>
</picker>
</view>
<view class="baby-actions">
<view class="hq-btn-ghost baby-btn" @tap="saveBaby"><text class="baby-btn-text">保存档案</text></view>
<text class="baby-gender" @tap="toggleGender">{{ baby.gender === 2 ? '女宝' : (baby.gender === 1 ? '男宝' : '未知') }}</text>
</view>
</view>
<!-- 成长记录 -->
<view class="hq-card">
<view class="hq-section-head">
<text class="hq-section-title">成长记录</text>
<text class="hq-muted">{{ (data.growth || []).length }} 条</text>
</view>
<view class="growth-form">
<input class="growth-input" type="digit" v-model="growth.height" placeholder="身高 cm" placeholder-class="ph" />
<input class="growth-input" type="digit" v-model="growth.weight" placeholder="体重 kg" placeholder-class="ph" />
<view class="growth-btn" @tap="saveGrowth"><text class="growth-btn-text">记录</text></view>
</view>
<view class="growth" v-for="item in data.growth || []" :key="item.id">
<text class="growth-date">{{ item.record_date }}</text>
<text class="growth-value">{{ item.height ? item.height + 'cm' : '' }} {{ item.weight ? item.weight + 'kg' : '' }}</text>
<text class="growth-note">{{ item.milestone || item.note }}</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="vaccine" v-for="item in nextVaccines" :key="item.id">
<view class="vaccine-body">
<text class="vaccine-name">{{ item.name }}</text>
<text class="vaccine-note">{{ item.note }} · {{ item.due_date || '需先填生日' }}</text>
</view>
<text class="vaccine-status" :class="'vs-' + item.status">{{ vaccineStatusText(item) }}</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 activity" v-for="item in data.activities || []" :key="item.id" @tap="openContent(item)">
<hq-icon :name="contentIcon(item.type)" :size="40" :stroke="1.7" color="#E8604C" />
<view class="activity-body">
<text class="activity-title">{{ item.title }}</text>
<text class="activity-summary">{{ item.summary }}</text>
</view>
<text class="activity-lock" v-if="item.locked">会员</text>
</view>
<!-- 共育任务 -->
<view class="hq-card">
<view class="hq-section-head">
<text class="hq-section-title">家庭共育</text>
<text class="hq-muted">爸妈分工,一起带娃</text>
</view>
<view class="task" v-for="item in data.co_tasks || []" :key="item.id" @tap="toggleCoTask(item)">
<view class="task-check" :class="{ 'task-check-done': item.done }">
<hq-icon v-if="item.done" name="check" :size="24" :stroke="2.4" color="#FFFFFF" />
</view>
<text class="task-title" :class="{ 'task-title-done': item.done }">{{ item.title }}</text>
</view>
<view class="task-add">
<input class="task-input" v-model="coTaskTitle" placeholder="添加共育任务,如「周三晚哄睡」" placeholder-class="ph" />
<view class="task-add-btn" @tap="addCoTask"><text class="task-add-text">添加</text></view>
</view>
</view>
<!-- 育儿情绪 -->
<view class="hq-section-head">
<text class="hq-section-title">育儿情绪</text>
<text class="hq-section-more" @tap="goConsult">需要帮助 ›</text>
</view>
<view class="hq-card emotion" v-for="item in data.emotions || []" :key="'e' + item.id" @tap="openContent(item)">
<text class="emotion-title">{{ item.title }}</text>
<text class="emotion-summary">{{ item.summary }}</text>
</view>
<!-- 课程 -->
<view class="hq-section-head">
<text class="hq-section-title">育儿课程</text>
<text class="hq-section-more">医生/专家审核</text>
</view>
<view class="hq-card course" v-for="item in (data.courses && data.courses.list) || []" :key="'k' + item.id">
<view class="course-head">
<text class="course-title">{{ item.title }}</text>
<text class="course-badge" v-if="item.extra && item.extra.lessons">{{ item.extra.lessons }} 节</text>
</view>
<text class="course-summary">{{ item.summary }}</text>
<view class="course-actions">
<text class="course-read" @tap="openContent(item)">查看目录</text>
<view class="course-buy" @tap="buy(item)"><text class="course-buy-text">{{ item.locked ? '购买解锁' : '已解锁' }}</text></view>
</view>
</view>
<!-- 育儿测评 -->
<view class="hq-card" v-if="(data.assessments || []).length">
<view class="hq-section-head">
<text class="hq-section-title">育儿情绪筛查</text>
</view>
<view class="test" v-for="item in data.assessments || []" :key="'a' + item.id" @tap="startTest(item)">
<text class="test-title">{{ item.title }}</text>
<text class="test-action">开始 ›</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 { today as todayStr } from '@/utils/date.js'
import { iconForContentType } from '@/utils/icons.js'
import hqIcon from '@/components/hq-icon/hq-icon.vue'
export default {
components: { hqIcon },
data() {
return {
data: {},
baby: { nickname: '', birthday: '', gender: 0 },
growth: { height: '', weight: '' },
coTaskTitle: ''
}
},
computed: {
nextVaccines() {
const list = this.data.vaccines || []
return list.filter((v) => v.status !== 'later').slice(0, 6).length
? list.filter((v) => v.status !== 'later').slice(0, 6)
: list.slice(0, 4)
}
},
onShow() {
if (!store.token) {
uni.reLaunch({ url: '/pages/login/index' })
return
}
this.load()
},
methods: {
async load() {
try {
const data = await api.parentingIndex()
this.data = data || {}
if (data && data.baby) {
this.baby = {
nickname: data.baby.nickname || '',
birthday: data.baby.birthday || data.baby.due_date || '',
gender: data.baby.gender || 0
}
}
} catch (e) {}
},
contentIcon(type) {
return iconForContentType(type)
},
onBirthday(e) {
this.baby.birthday = e.detail.value
},
toggleGender() {
this.baby.gender = this.baby.gender === 2 ? 1 : (this.baby.gender === 1 ? 0 : 2)
},
async saveBaby() {
if (!this.baby.nickname) {
uni.showToast({ title: '请填写宝宝小名', icon: 'none' })
return
}
const payload = { nickname: this.baby.nickname, gender: this.baby.gender }
const today = todayStr()
if (this.baby.birthday) {
if (this.baby.birthday > today) {
payload.due_date = this.baby.birthday
} else {
payload.birthday = this.baby.birthday
}
}
try {
await api.babySave(payload)
uni.showToast({ title: '已保存', icon: 'none' })
this.load()
} catch (e) {}
},
async saveGrowth() {
if (!this.growth.height && !this.growth.weight) {
uni.showToast({ title: '请填写身高或体重', icon: 'none' })
return
}
try {
await api.growthSave({
record_date: todayStr(),
height: this.growth.height,
weight: this.growth.weight
})
this.growth = { height: '', weight: '' }
this.load()
} catch (e) {}
},
async toggleCoTask(item) {
try {
await api.coTaskDone(item.id)
this.load()
} catch (e) {}
},
async addCoTask() {
const title = (this.coTaskTitle || '').trim()
if (!title) {
uni.showToast({ title: '请输入任务', icon: 'none' })
return
}
try {
await api.coTaskSave({ title, category: 'care' })
this.coTaskTitle = ''
this.load()
} catch (e) {}
},
async buy(item) {
try {
const res = await api.courseBuy(item.id)
uni.showModal({
title: res && res.purchased ? '已解锁' : '订单已创建',
content: (res && res.pay_hint) || '',
showCancel: false,
confirmColor: '#E8604C'
})
this.load()
} catch (e) {}
},
startTest(item) {
uni.navigateTo({ url: '/pages/assessment/index?id=' + item.id })
},
openContent(item) {
uni.navigateTo({ url: '/pages/content/detail?id=' + item.id })
},
goConsult() {
uni.navigateTo({ url: '/pages/consult/index' })
},
vaccineStatusText(item) {
const map = { overdue: '已过期', upcoming: '近 30 天', later: '待接种', unknown: '待填生日' }
return map[item.status] || item.status
}
}
}
</script>
<style lang="scss" scoped>
.head {
padding: 28rpx 0 20rpx;
}
.head-title {
font-size: 44rpx;
font-weight: 600;
color: #3E2C27;
}
.head-sub {
display: block;
margin-top: 8rpx;
font-size: 24rpx;
color: #8C7367;
}
.baby-form {
display: flex;
align-items: center;
}
.baby-input {
flex: 1;
height: 76rpx;
padding: 0 24rpx;
background-color: #FFF9F5;
border-radius: 20rpx;
font-size: 26rpx;
color: #3E2C27;
}
.baby-picker {
margin-left: 12rpx;
height: 76rpx;
padding: 0 20rpx;
background-color: #FFF9F5;
border-radius: 20rpx;
display: flex;
align-items: center;
}
.baby-picker-text {
font-size: 24rpx;
color: #8C7367;
}
.baby-actions {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 16rpx;
}
.baby-btn {
height: 72rpx;
padding: 0 28rpx;
}
.baby-btn-text {
font-size: 24rpx;
color: #E8604C;
}
.baby-gender {
font-size: 22rpx;
color: #B5715B;
background-color: #FFF1E9;
padding: 8rpx 20rpx;
border-radius: 999rpx;
}
.growth-form {
display: flex;
align-items: center;
}
.growth-input {
flex: 1;
height: 72rpx;
padding: 0 20rpx;
background-color: #FFF9F5;
border-radius: 18rpx;
font-size: 24rpx;
color: #3E2C27;
margin-right: 10rpx;
}
.growth-btn {
height: 72rpx;
padding: 0 26rpx;
border-radius: 18rpx;
background: linear-gradient(135deg, #F58C7C 0%, #E8604C 100%);
display: flex;
align-items: center;
}
.growth-btn-text {
font-size: 24rpx;
color: #FFFFFF;
}
.growth {
display: flex;
align-items: center;
padding: 14rpx 0;
}
.growth + .growth {
border-top: 2rpx solid #F5E7DF;
}
.growth-date {
width: 170rpx;
font-size: 22rpx;
color: #B9A79E;
}
.growth-value {
flex: 1;
font-size: 24rpx;
color: #3E2C27;
}
.growth-note {
font-size: 20rpx;
color: #8C7367;
}
.vaccine {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14rpx 0;
}
.vaccine + .vaccine {
border-top: 2rpx solid #F5E7DF;
}
.vaccine-body {
flex: 1;
display: flex;
flex-direction: column;
}
.vaccine-name {
font-size: 24rpx;
color: #3E2C27;
}
.vaccine-note {
margin-top: 2rpx;
font-size: 18rpx;
color: #B9A79E;
}
.vaccine-status {
font-size: 18rpx;
padding: 4rpx 12rpx;
border-radius: 999rpx;
background-color: #FFF1E9;
color: #B5715B;
}
.vs-overdue {
background-color: #FFF0EE;
color: #C9482F;
}
.vs-upcoming {
background-color: #FFF6E6;
color: #B5802A;
}
.activity {
display: flex;
align-items: center;
padding: 22rpx 26rpx;
}
.activity-body {
flex: 1;
display: flex;
flex-direction: column;
}
.activity-title {
font-size: 26rpx;
color: #3E2C27;
}
.activity-summary {
margin-top: 4rpx;
font-size: 22rpx;
color: #8C7367;
}
.activity-lock {
font-size: 18rpx;
color: #C9482F;
background-color: #FFF1E0;
padding: 4rpx 12rpx;
border-radius: 999rpx;
}
.task {
display: flex;
align-items: center;
padding: 14rpx 0;
}
.task + .task {
border-top: 2rpx solid #F5E7DF;
}
.task-check {
width: 44rpx;
height: 44rpx;
border-radius: 50%;
border: 2rpx solid #E4D3C9;
display: flex;
align-items: center;
justify-content: center;
margin-right: 14rpx;
}
.task-check-done {
background: linear-gradient(135deg, #F58C7C 0%, #E8604C 100%);
border-color: #E8604C;
}
.task-title {
flex: 1;
font-size: 26rpx;
color: #3E2C27;
}
.task-title-done {
color: #B9A79E;
text-decoration: line-through;
}
.task-add {
display: flex;
align-items: center;
margin-top: 16rpx;
}
.task-input {
flex: 1;
height: 72rpx;
padding: 0 20rpx;
background-color: #FFF9F5;
border-radius: 18rpx;
font-size: 24rpx;
color: #3E2C27;
}
.task-add-btn {
margin-left: 10rpx;
height: 72rpx;
padding: 0 24rpx;
border-radius: 18rpx;
background-color: #FFF1E9;
display: flex;
align-items: center;
}
.task-add-text {
font-size: 24rpx;
color: #E8604C;
}
.emotion {
padding: 22rpx 26rpx;
}
.emotion-title {
font-size: 26rpx;
color: #3E2C27;
}
.emotion-summary {
display: block;
margin-top: 4rpx;
font-size: 22rpx;
color: #8C7367;
}
.course {
padding: 24rpx 26rpx;
}
.course-head {
display: flex;
align-items: center;
justify-content: space-between;
}
.course-title {
font-size: 26rpx;
font-weight: 500;
color: #3E2C27;
}
.course-badge {
font-size: 18rpx;
color: #B5715B;
background-color: #FFF1E9;
padding: 4rpx 12rpx;
border-radius: 999rpx;
}
.course-summary {
display: block;
margin-top: 6rpx;
font-size: 22rpx;
color: #8C7367;
}
.course-actions {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 14rpx;
padding-top: 14rpx;
border-top: 2rpx solid #F5E7DF;
}
.course-read {
font-size: 22rpx;
color: #8C7367;
}
.course-buy {
padding: 10rpx 20rpx;
border-radius: 999rpx;
background: linear-gradient(135deg, #F58C7C 0%, #E8604C 100%);
}
.course-buy-text {
font-size: 20rpx;
color: #FFFFFF;
}
.test {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14rpx 0;
}
.test + .test {
border-top: 2rpx solid #F5E7DF;
}
.test-title {
font-size: 24rpx;
color: #3E2C27;
}
.test-action {
font-size: 22rpx;
color: #E8604C;
}
.ph {
color: #C9B4AA;
font-size: 22rpx;
}
.footer {
padding: 16rpx 0 24rpx;
text-align: center;
}
.footer-text {
font-size: 20rpx;
color: #C9B4AA;
}
</style>