feat: 补齐 M1–M9 全部 47 个功能点并打通前后端
后端(新增 7 控制器 + 2 服务 + 17 张表) - Prepare:排卵预测、BBT(双向体温识别)、试纸识别(规则引擎+额度)、备孕任务、同房指导 - Family:邀请码绑定(≤5)、话术库、爱心积分、私密留言、家庭健康视图 - Health:按周期阶段输出饮食/运动/睡眠/痛经四类建议 - Relation:关系测评、引导卡、冲突工具、课程下单、双人任务(联动记忆)、纪念日 - Parenting:宝宝档案、成长记录、月龄活动匹配、共育任务、育儿情绪、疫苗儿保排期 - Consult:咨询师(资质/定价/时段)、预约下单/取消、量表测评(4 套)、危机干预转介 - Setting:自定义提醒 CRUD、数据备份快照与恢复(保留 5 份) - Mood 增补急救包;Home 提醒合并自定义提醒 - 服务层:ContentService(统一内容/锁态/购买态)、AssessmentService(计分分级+危机识别) 前端(新增 8 页面) - 备孕、家人共护、健康建议、两性关系、亲子教育、心理咨询、测评执行页、情绪急救包 - 首页快捷入口扩至 8 个模块;我的页新增提醒中心与数据备份 - utils/api.js 扩至 84 个接口 数据(可重复执行脚本) - 03_modules.sql:fa_reminder/bbt/lh_test/task/family_bind/care_message/point_log/memory/ assessment(+record)/course_order/baby/growth_record/vaccine/counselor/consult_order/user_backup - 04_module_seed.sql:话术6/引导卡6/冲突3/急救4/同房3/课程6/活动6/育儿情绪4/知识7、 4 套量表、17 项疫苗儿保、3 位咨询师 验证(全部通过) - 接口全链路 82 项断言(M1–M9,含高风险测评危机干预、备份恢复) - 契约校验 84 接口 0 偏差;Vue SFC 19/19、SCSS 18/18 编译通过 - 修复 3 个真实缺陷:action 内调用 action 导致响应被劫持、coTasks 返回数组、 咨询时段跨年错误
这个提交包含在:
511
pages/relation/index.vue
普通文件
511
pages/relation/index.vue
普通文件
@@ -0,0 +1,511 @@
|
||||
<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 }">
|
||||
<text class="task-check-text" v-if="item.done">✓</text>
|
||||
</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">
|
||||
<text class="card-emoji">{{ item.emoji }}</text>
|
||||
<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'
|
||||
|
||||
export default {
|
||||
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) {}
|
||||
},
|
||||
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: 40rpx;
|
||||
height: 40rpx;
|
||||
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-check-text {
|
||||
font-size: 20rpx;
|
||||
color: #FFFFFF;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.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-emoji {
|
||||
font-size: 30rpx;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
.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>
|
||||
在新工单中引用
屏蔽一个用户