后端(新增 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 返回数组、 咨询时段跨年错误
317 行
6.0 KiB
Vue
317 行
6.0 KiB
Vue
<template>
|
|
<view class="hq-page">
|
|
<view class="head">
|
|
<text class="head-title">{{ detail.title || '测评' }}</text>
|
|
<text class="head-intro">{{ detail.intro }}</text>
|
|
<view class="progress-row">
|
|
<view class="hq-progress progress-track">
|
|
<view class="hq-progress-inner" :style="{ width: progress + '%' }"></view>
|
|
</view>
|
|
<text class="progress-text">{{ answered }}/{{ total }}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="hq-card q-card" v-for="(q, index) in detail.questions" :key="index">
|
|
<text class="q-title">{{ index + 1 }}. {{ q }}</text>
|
|
<view class="q-options">
|
|
<view
|
|
v-for="opt in detail.options"
|
|
:key="opt.value"
|
|
class="q-option"
|
|
:class="{ 'q-option-active': answers[index] === opt.value }"
|
|
@tap="choose(index, opt.value)"
|
|
>
|
|
<text class="q-option-text" :class="{ 'q-option-text-active': answers[index] === opt.value }">{{ opt.text }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="hq-btn submit" @tap="submit">
|
|
<text class="submit-text">{{ submitting ? '提交中…' : '查看结果' }}</text>
|
|
</view>
|
|
|
|
<view class="hq-card result" v-if="result">
|
|
<view class="result-head">
|
|
<text class="result-score">{{ result.score }}</text>
|
|
<text class="result-max">/ {{ result.max }} 分</text>
|
|
</view>
|
|
<text class="result-text">{{ result.result_text }}</text>
|
|
<view class="advice" v-for="(a, i) in result.advice" :key="i">
|
|
<view class="advice-dot"></view>
|
|
<text class="advice-text">{{ a }}</text>
|
|
</view>
|
|
<view class="crisis" v-if="result.risk_flag && result.crisis">
|
|
<text class="crisis-title">{{ result.crisis.title }}</text>
|
|
<text class="crisis-text">{{ result.crisis.text }}</text>
|
|
<view class="crisis-hotline" v-for="h in result.crisis.hotlines" :key="h.phone">
|
|
<text class="crisis-hotline-name">{{ h.name }}</text>
|
|
<text class="crisis-hotline-phone">{{ h.phone }}</text>
|
|
</view>
|
|
</view>
|
|
<text class="result-disclaimer">{{ result.disclaimer }}</text>
|
|
</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'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
id: 0,
|
|
detail: { questions: [], options: [] },
|
|
answers: [],
|
|
submitting: false,
|
|
result: null
|
|
}
|
|
},
|
|
computed: {
|
|
total() {
|
|
return (this.detail.questions || []).length
|
|
},
|
|
answered() {
|
|
return this.answers.filter((v) => v !== null && v !== undefined).length
|
|
},
|
|
progress() {
|
|
return this.total ? Math.round((this.answered / this.total) * 100) : 0
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
if (!store.token) {
|
|
uni.reLaunch({ url: '/pages/login/index' })
|
|
return
|
|
}
|
|
this.id = (options && options.id) || 0
|
|
this.load()
|
|
},
|
|
methods: {
|
|
async load() {
|
|
try {
|
|
const data = await api.assessmentDetail(this.id)
|
|
this.detail = data
|
|
this.answers = new Array((data.questions || []).length).fill(null)
|
|
uni.setNavigationBarTitle({ title: data.title || '测评' })
|
|
} catch (e) {}
|
|
},
|
|
choose(index, value) {
|
|
this.answers[index] = value
|
|
},
|
|
async submit() {
|
|
if (this.submitting) return
|
|
if (this.answered < this.total) {
|
|
uni.showToast({ title: '请完成全部题目', icon: 'none' })
|
|
return
|
|
}
|
|
this.submitting = true
|
|
try {
|
|
this.result = await api.assessmentSubmit(this.id, this.answers)
|
|
uni.pageScrollTo({ scrollTop: 99999, duration: 300 })
|
|
} catch (e) {
|
|
} finally {
|
|
this.submitting = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.head {
|
|
padding: 28rpx 0 20rpx;
|
|
}
|
|
|
|
.head-title {
|
|
font-size: 40rpx;
|
|
font-weight: 600;
|
|
color: #3E2C27;
|
|
}
|
|
|
|
.head-intro {
|
|
display: block;
|
|
margin-top: 10rpx;
|
|
font-size: 24rpx;
|
|
color: #8C7367;
|
|
line-height: 1.7;
|
|
}
|
|
|
|
.progress-row {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-top: 20rpx;
|
|
}
|
|
|
|
.progress-track {
|
|
flex: 1;
|
|
}
|
|
|
|
.progress-text {
|
|
margin-left: 16rpx;
|
|
font-size: 22rpx;
|
|
color: #B9A79E;
|
|
}
|
|
|
|
.q-card {
|
|
padding: 28rpx 32rpx;
|
|
}
|
|
|
|
.q-title {
|
|
font-size: 28rpx;
|
|
color: #3E2C27;
|
|
line-height: 1.7;
|
|
}
|
|
|
|
.q-options {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
margin-top: 16rpx;
|
|
}
|
|
|
|
.q-option {
|
|
padding: 12rpx 24rpx;
|
|
border-radius: 999rpx;
|
|
background-color: #FFF4EE;
|
|
margin: 0 12rpx 12rpx 0;
|
|
}
|
|
|
|
.q-option-active {
|
|
background: linear-gradient(135deg, #F58C7C 0%, #E8604C 100%);
|
|
}
|
|
|
|
.q-option-text {
|
|
font-size: 24rpx;
|
|
color: #8C7367;
|
|
}
|
|
|
|
.q-option-text-active {
|
|
color: #FFFFFF;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.submit {
|
|
margin-top: 8rpx;
|
|
}
|
|
|
|
.submit-text {
|
|
font-size: 30rpx;
|
|
color: #FFFFFF;
|
|
letter-spacing: 2rpx;
|
|
}
|
|
|
|
.result {
|
|
margin-top: 24rpx;
|
|
}
|
|
|
|
.result-head {
|
|
display: flex;
|
|
align-items: baseline;
|
|
}
|
|
|
|
.result-score {
|
|
font-size: 64rpx;
|
|
font-weight: 600;
|
|
color: #E8604C;
|
|
line-height: 1;
|
|
}
|
|
|
|
.result-max {
|
|
margin-left: 8rpx;
|
|
font-size: 24rpx;
|
|
color: #B9A79E;
|
|
}
|
|
|
|
.result-text {
|
|
display: block;
|
|
margin-top: 16rpx;
|
|
font-size: 28rpx;
|
|
color: #3E2C27;
|
|
line-height: 1.8;
|
|
}
|
|
|
|
.advice {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
margin-top: 16rpx;
|
|
}
|
|
|
|
.advice-dot {
|
|
width: 12rpx;
|
|
height: 12rpx;
|
|
border-radius: 50%;
|
|
background-color: #F5A65B;
|
|
margin-top: 14rpx;
|
|
margin-right: 14rpx;
|
|
}
|
|
|
|
.advice-text {
|
|
flex: 1;
|
|
font-size: 24rpx;
|
|
color: #8C7367;
|
|
line-height: 1.8;
|
|
}
|
|
|
|
.crisis {
|
|
margin-top: 24rpx;
|
|
padding: 24rpx;
|
|
border-radius: 24rpx;
|
|
background-color: #FFF3F0;
|
|
border: 2rpx solid #F8D7CF;
|
|
}
|
|
|
|
.crisis-title {
|
|
font-size: 28rpx;
|
|
font-weight: 600;
|
|
color: #C9482F;
|
|
}
|
|
|
|
.crisis-text {
|
|
display: block;
|
|
margin-top: 10rpx;
|
|
font-size: 24rpx;
|
|
color: #8C5B4F;
|
|
line-height: 1.8;
|
|
}
|
|
|
|
.crisis-hotline {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-top: 12rpx;
|
|
padding-top: 12rpx;
|
|
border-top: 2rpx solid #F8D7CF;
|
|
}
|
|
|
|
.crisis-hotline-name {
|
|
font-size: 24rpx;
|
|
color: #8C5B4F;
|
|
}
|
|
|
|
.crisis-hotline-phone {
|
|
font-size: 26rpx;
|
|
font-weight: 600;
|
|
color: #C9482F;
|
|
}
|
|
|
|
.result-disclaimer {
|
|
display: block;
|
|
margin-top: 20rpx;
|
|
font-size: 20rpx;
|
|
color: #B9A79E;
|
|
}
|
|
|
|
.footer {
|
|
padding: 24rpx 0;
|
|
text-align: center;
|
|
}
|
|
|
|
.footer-text {
|
|
font-size: 20rpx;
|
|
color: #C9B4AA;
|
|
}
|
|
</style>
|