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

507 行
11 KiB
Vue

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

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

<template>
<view class="hq-page">
<view class="head">
<text class="head-title">两性关系</text>
<text class="head-sub">关系也需要被好好照顾</text>
</view>
<!-- 关系测评 -->
<view class="hq-section-head">
<text class="hq-section-title">关系测评</text>
<text class="hq-section-more">了解彼此的沟通模式</text>
</view>
<view class="hq-card test" v-for="item in data.assessments || []" :key="item.id" @tap="startTest(item)">
<view class="test-body">
<text class="test-title">{{ item.title }}</text>
<text class="test-sub">{{ item.intro }}</text>
<text class="test-meta" v-if="item.last_date">上次:{{ item.last_date }} · {{ item.last_score }} 分</text>
</view>
<view class="test-action">
<text class="test-action-text">{{ item.last_date ? '再测一次' : '开始' }}</text>
</view>
</view>
<!-- 双人任务 -->
<view class="hq-card">
<view class="hq-section-head">
<text class="hq-section-title">双人小任务</text>
<text class="hq-muted">{{ stats.task_done || 0 }}/{{ stats.task_total || 0 }} 完成</text>
</view>
<view class="task" v-for="item in data.tasks || []" :key="item.id" @tap="toggleTask(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="taskTitle" placeholder="添加一件两人想一起做的事" placeholder-class="ph" />
<view class="task-add-btn" @tap="addTask"><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">引导卡与冲突工具</text>
</view>
<view class="hq-card card" v-for="item in [...(data.cards || []), ...(data.conflicts || [])]" :key="'c' + item.id" @tap="openContent(item)">
<view class="card-head">
<hq-icon :name="contentIcon(item.type)" :size="38" :stroke="1.7" color="#E8604C" style="margin-right: 16rpx" />
<text class="card-title">{{ item.title }}</text>
<text class="card-lock" v-if="item.locked">会员</text>
</view>
<text class="card-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-price" 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">
<view class="hq-section-head">
<text class="hq-section-title">爱的纪念</text>
<text class="hq-muted">{{ stats.memory_total || 0 }} 条</text>
</view>
<view class="memory" v-for="item in data.memories || []" :key="item.id">
<view class="memory-body">
<text class="memory-title">{{ item.title }}</text>
<text class="memory-date">{{ item.memory_date }} · 第 {{ item.days_since }} 天</text>
</view>
<text class="memory-next" v-if="item.days_to_next !== null">还有 {{ item.days_to_next }} 天</text>
</view>
<view class="memory-add">
<input class="memory-input" v-model="memoryForm.title" placeholder="纪念日名称,如「在一起」" placeholder-class="ph" />
<picker mode="date" :value="memoryForm.memory_date" @change="onMemoryDate">
<view class="memory-date-picker"><text class="memory-date-text">{{ memoryForm.memory_date }}</text></view>
</picker>
<view class="memory-add-btn" @tap="addMemory"><text class="memory-add-text">保存</text></view>
</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: {},
stats: {},
taskTitle: '',
memoryForm: { title: '', memory_date: todayStr() }
}
},
onShow() {
if (!store.token) {
uni.reLaunch({ url: '/pages/login/index' })
return
}
this.load()
},
methods: {
async load() {
try {
const data = await api.relationIndex()
this.data = data || {}
this.stats = (data && data.stats) || {}
} catch (e) {}
},
contentIcon(type) {
return iconForContentType(type)
},
startTest(item) {
uni.navigateTo({ url: '/pages/assessment/index?id=' + item.id })
},
async toggleTask(item) {
try {
const res = await api.relationTaskDone(item.id)
this.data.tasks = res.list
this.load()
} catch (e) {}
},
async addTask() {
const title = (this.taskTitle || '').trim()
if (!title) {
uni.showToast({ title: '请输入内容', icon: 'none' })
return
}
try {
const res = await api.relationTaskSave({ title, category: 'daily' })
this.data.tasks = res.list
this.taskTitle = ''
} catch (e) {}
},
async buy(item) {
try {
const res = await api.courseBuy(item.id)
if (res && res.purchased) {
uni.showToast({ title: '已解锁', icon: 'none' })
this.load()
return
}
uni.showModal({
title: '订单已创建',
content: (res && res.pay_hint) || '支付通道接入中',
showCancel: false,
confirmColor: '#E8604C'
})
} catch (e) {}
},
onMemoryDate(e) {
this.memoryForm.memory_date = e.detail.value
},
async addMemory() {
const title = (this.memoryForm.title || '').trim()
if (!title) {
uni.showToast({ title: '请输入纪念日名称', icon: 'none' })
return
}
try {
await api.memorySave({ title, memory_date: this.memoryForm.memory_date, type: 'anniversary' })
this.memoryForm.title = ''
this.load()
} catch (e) {}
},
openContent(item) {
uni.navigateTo({ url: '/pages/content/detail?id=' + item.id })
}
}
}
</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;
}
.test {
display: flex;
align-items: center;
padding: 24rpx 28rpx;
}
.test-body {
flex: 1;
display: flex;
flex-direction: column;
}
.test-title {
font-size: 28rpx;
color: #3E2C27;
font-weight: 500;
}
.test-sub {
margin-top: 4rpx;
font-size: 22rpx;
color: #8C7367;
}
.test-meta {
margin-top: 6rpx;
font-size: 20rpx;
color: #B9A79E;
}
.test-action {
padding: 12rpx 24rpx;
border-radius: 999rpx;
background-color: #FFF1E9;
}
.test-action-text {
font-size: 22rpx;
color: #E8604C;
}
.task {
display: flex;
align-items: center;
padding: 16rpx 0;
}
.task + .task {
border-top: 2rpx solid #F5E7DF;
}
.task-check {
width: 46rpx;
height: 46rpx;
border-radius: 50%;
border: 2rpx solid #E4D3C9;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16rpx;
}
.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: 76rpx;
padding: 0 24rpx;
background-color: #FFF9F5;
border-radius: 20rpx;
font-size: 24rpx;
color: #3E2C27;
}
.task-add-btn {
margin-left: 12rpx;
height: 76rpx;
padding: 0 28rpx;
border-radius: 20rpx;
background-color: #FFF1E9;
display: flex;
align-items: center;
justify-content: center;
}
.task-add-text {
font-size: 24rpx;
color: #E8604C;
}
.card {
padding: 24rpx 28rpx;
}
.card-head {
display: flex;
align-items: center;
}
.card-title {
flex: 1;
font-size: 28rpx;
color: #3E2C27;
font-weight: 500;
}
.card-lock {
font-size: 18rpx;
color: #C9482F;
background-color: #FFF1E0;
padding: 4rpx 12rpx;
border-radius: 999rpx;
}
.card-summary {
display: block;
margin-top: 6rpx;
font-size: 22rpx;
color: #8C7367;
line-height: 1.6;
}
.course {
padding: 26rpx 28rpx;
}
.course-head {
display: flex;
align-items: center;
justify-content: space-between;
}
.course-title {
font-size: 28rpx;
font-weight: 500;
color: #3E2C27;
}
.course-price {
font-size: 20rpx;
color: #B5715B;
background-color: #FFF1E9;
padding: 4rpx 14rpx;
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: 16rpx;
padding-top: 16rpx;
border-top: 2rpx solid #F5E7DF;
}
.course-read {
font-size: 22rpx;
color: #8C7367;
}
.course-buy {
padding: 10rpx 22rpx;
border-radius: 999rpx;
background: linear-gradient(135deg, #F58C7C 0%, #E8604C 100%);
}
.course-buy-text {
font-size: 22rpx;
color: #FFFFFF;
}
.memory {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16rpx 0;
}
.memory + .memory {
border-top: 2rpx solid #F5E7DF;
}
.memory-body {
display: flex;
flex-direction: column;
}
.memory-title {
font-size: 26rpx;
color: #3E2C27;
}
.memory-date {
margin-top: 4rpx;
font-size: 20rpx;
color: #B9A79E;
}
.memory-next {
font-size: 22rpx;
color: #E8604C;
}
.memory-add {
display: flex;
align-items: center;
margin-top: 16rpx;
}
.memory-input {
flex: 1;
height: 72rpx;
padding: 0 20rpx;
background-color: #FFF9F5;
border-radius: 20rpx;
font-size: 24rpx;
color: #3E2C27;
}
.memory-date-picker {
margin-left: 10rpx;
height: 72rpx;
padding: 0 18rpx;
background-color: #FFF9F5;
border-radius: 20rpx;
display: flex;
align-items: center;
}
.memory-date-text {
font-size: 22rpx;
color: #8C7367;
}
.memory-add-btn {
margin-left: 10rpx;
height: 72rpx;
padding: 0 24rpx;
border-radius: 20rpx;
background-color: #FFF1E9;
display: flex;
align-items: center;
}
.memory-add-text {
font-size: 24rpx;
color: #E8604C;
}
.ph {
color: #C9B4AA;
font-size: 24rpx;
}
.footer {
padding: 16rpx 0 24rpx;
text-align: center;
}
.footer-text {
font-size: 20rpx;
color: #C9B4AA;
}
</style>