screening.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. <template>
  2. <view class="screen-container">
  3. <!-- 头部 -->
  4. <view class="screen-header">
  5. <text class="screen-title">心理状态自评</text>
  6. <text class="screen-subtitle">定期评估,了解自己的心理状态</text>
  7. </view>
  8. <!-- 量表选择 -->
  9. <view class="section" v-if="!currentScreen">
  10. <view class="scale-card" @click="startScreen('PHQ9')">
  11. <view class="scale-icon-wrap" style="background:#FFF0F5">
  12. <text class="scale-icon">&#x1F9E0;</text>
  13. </view>
  14. <view class="scale-info">
  15. <text class="scale-name">PHQ-9 抑郁筛查</text>
  16. <text class="scale-desc">过去两周,您是否被以下问题困扰?</text>
  17. </view>
  18. <text class="scale-arrow">&gt;</text>
  19. </view>
  20. <view class="scale-card" @click="startScreen('GAD7')">
  21. <view class="scale-icon-wrap" style="background:#F0F4FF">
  22. <text class="scale-icon">&#x1F4A8;</text>
  23. </view>
  24. <view class="scale-info">
  25. <text class="scale-name">GAD-7 焦虑筛查</text>
  26. <text class="scale-desc">过去两周,您是否被以下问题困扰?</text>
  27. </view>
  28. <text class="scale-arrow">&gt;</text>
  29. </view>
  30. </view>
  31. <!-- 问卷页面 -->
  32. <view class="section" v-if="currentScreen">
  33. <view class="quiz-header">
  34. <text class="quiz-title">{{ currentScreen === 'PHQ9' ? 'PHQ-9 抑郁筛查' : 'GAD-7 焦虑筛查' }}</text>
  35. <text class="quiz-progress">{{ currentStep + 1 }}/{{ questions.length }}</text>
  36. </view>
  37. <view class="progress-track">
  38. <view class="progress-fill" :style="{ width: ((currentStep + 1) / questions.length * 100) + '%' }"></view>
  39. </view>
  40. <!-- 当前问题 -->
  41. <view class="question-card">
  42. <text class="question-num">Q{{ currentStep + 1 }}</text>
  43. <text class="question-text">{{ questions[currentStep] }}</text>
  44. </view>
  45. <!-- 选项 -->
  46. <view class="options-list">
  47. <view
  48. v-for="(opt, oi) in answerOptions"
  49. :key="oi"
  50. :class="['option-btn', answers[currentStep] === oi ? 'option-active' : '']"
  51. @click="selectAnswer(oi)">
  52. <view :class="['option-radio', answers[currentStep] === oi ? 'radio-checked' : '']">
  53. <view v-if="answers[currentStep] === oi" class="radio-dot"></view>
  54. </view>
  55. <text class="option-text">{{ opt }}</text>
  56. </view>
  57. </view>
  58. <!-- 导航按钮 -->
  59. <view class="quiz-nav">
  60. <button class="nav-btn prev-btn" v-if="currentStep > 0" @click="prevStep">上一题</button>
  61. <button class="nav-btn next-btn" v-if="currentStep < questions.length - 1" @click="nextStep">下一题</button>
  62. <button class="nav-btn submit-btn" v-if="currentStep === questions.length - 1" @click="submitScreen">提交问卷</button>
  63. </view>
  64. </view>
  65. <!-- 结果页面 -->
  66. <view class="section" v-if="result">
  67. <view class="result-header">
  68. <text class="result-type">{{ currentScreen === 'PHQ9' ? 'PHQ-9 抑郁筛查' : 'GAD-7 焦虑筛查' }}</text>
  69. <view :class="['result-score-circle', severityClass]">
  70. <text class="result-score">{{ result.totalScore }}</text>
  71. <text class="result-score-label">分</text>
  72. </view>
  73. <text :class="['result-severity', severityClass]">{{ severityLabel }}</text>
  74. </view>
  75. <!-- 自动建议 -->
  76. <view class="suggestion-card">
  77. <text class="suggestion-title">评估建议</text>
  78. <text class="suggestion-text">{{ result.suggestions }}</text>
  79. </view>
  80. <!-- 风险标志 -->
  81. <view class="risk-section" v-if="result.riskFlags && result.riskFlags.length > 0">
  82. <view class="risk-item" v-for="flag in result.riskFlags" :key="flag">
  83. <text class="risk-icon">&#x26A0;&#xFE0F;</text>
  84. <text class="risk-text">{{ riskFlagLabel(flag) }}</text>
  85. </view>
  86. </view>
  87. <!-- 危机热线 -->
  88. <view class="crisis-banner" v-if="showCrisisBanner">
  89. <text class="crisis-title">&#x1F6A8; 需要帮助?</text>
  90. <text class="crisis-phone">全国心理危机干预热线</text>
  91. <text class="crisis-number">400-161-9995</text>
  92. <text class="crisis-hint">24小时 · 免费 · 专业</text>
  93. </view>
  94. <view class="result-actions">
  95. <button class="action-btn primary-btn" @click="goTrend">查看情绪趋势</button>
  96. <button class="action-btn secondary-btn" @click="resetScreen">再测一次</button>
  97. </view>
  98. </view>
  99. <!-- 提交中 / 历史记录 -->
  100. <view class="loading-mask" v-if="submitting">
  101. <view class="loading-box">
  102. <text class="loading-text">提交中...</text>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import config from '../../config'
  109. export default {
  110. data() {
  111. return {
  112. currentScreen: null, // null / 'PHQ9' / 'GAD7'
  113. currentStep: 0,
  114. answers: [],
  115. submitting: false,
  116. result: null,
  117. // PHQ-9 题目
  118. phq9Questions: [
  119. '做事时提不起劲或没有兴趣',
  120. '感到心情低落、沮丧或绝望',
  121. '入睡困难、睡不安稳或睡眠过多',
  122. '感觉疲倦或没有活力',
  123. '食欲不振或吃太多',
  124. '觉得自己很糟——或觉得自己很失败,或让自己或家人失望',
  125. '对事物专注有困难,例如阅读报纸或看电视时',
  126. '行动或说话速度缓慢到别人已经觉察?或正好相反——比平常更多话',
  127. '有不如死掉或用某种方式伤害自己的念头'
  128. ],
  129. // GAD-7 题目
  130. gad7Questions: [
  131. '感到紧张、焦虑或烦躁',
  132. '无法停止或控制担忧',
  133. '对各种各样的事情担忧过多',
  134. '很难放松下来',
  135. '由于不安而无法静坐',
  136. '变得容易烦恼或急躁',
  137. '感到害怕,好像可能发生可怕的事情'
  138. ],
  139. answerOptions: [
  140. '完全不会',
  141. '好几天',
  142. '一半以上的天数',
  143. '几乎每天'
  144. ],
  145. riskFlagLabels: {
  146. 'suicide_ideation': '存在自杀/自伤相关念头,请立即寻求帮助',
  147. 'core_depression_symptoms': '核心抑郁症状明显,建议关注',
  148. 'core_anxiety_symptoms': '核心焦虑症状明显,建议关注'
  149. }
  150. }
  151. },
  152. computed: {
  153. questions() {
  154. if (this.currentScreen === 'PHQ9') return this.phq9Questions
  155. if (this.currentScreen === 'GAD7') return this.gad7Questions
  156. return []
  157. },
  158. severityLabel() {
  159. if (!this.result) return ''
  160. var map = {
  161. 'none': '状态良好',
  162. 'mild': '轻度',
  163. 'moderate': '中度',
  164. 'moderately_severe': '中重度',
  165. 'severe': '重度'
  166. }
  167. return map[this.result.severityLevel] || this.result.severityLevel
  168. },
  169. severityClass() {
  170. if (!this.result) return ''
  171. var map = {
  172. 'none': 'severity-good',
  173. 'mild': 'severity-mild',
  174. 'moderate': 'severity-moderate',
  175. 'moderately_severe': 'severity-moderate',
  176. 'severe': 'severity-severe'
  177. }
  178. return map[this.result.severityLevel] || ''
  179. },
  180. showCrisisBanner() {
  181. if (!this.result || !this.result.riskFlags) return false
  182. return this.result.riskFlags.indexOf('suicide_ideation') !== -1
  183. }
  184. },
  185. onLoad() {
  186. // 加载历史记录(可选)
  187. },
  188. methods: {
  189. startScreen(type) {
  190. this.currentScreen = type
  191. this.currentStep = 0
  192. this.answers = []
  193. this.result = null
  194. var count = type === 'PHQ9' ? 9 : 7
  195. for (var i = 0; i < count; i++) {
  196. this.answers.push(-1)
  197. }
  198. },
  199. selectAnswer(oi) {
  200. var newAnswers = this.answers.slice()
  201. newAnswers[this.currentStep] = oi
  202. this.answers = newAnswers
  203. },
  204. nextStep() {
  205. if (this.answers[this.currentStep] === -1) {
  206. uni.showToast({ title: '请先选择一项', icon: 'none' })
  207. return
  208. }
  209. this.currentStep++
  210. },
  211. prevStep() {
  212. if (this.currentStep > 0) this.currentStep--
  213. },
  214. submitScreen() {
  215. // 检查所有题目是否已回答
  216. for (var i = 0; i < this.answers.length; i++) {
  217. if (this.answers[i] === -1) {
  218. uni.showToast({ title: '请回答所有问题', icon: 'none' })
  219. this.currentStep = i
  220. return
  221. }
  222. }
  223. this.submitting = true
  224. const memberId = uni.getStorageSync('currentChildId')
  225. uni.request({
  226. url: config.API_BASE_URL + '/api/mind/screening/submit',
  227. method: 'POST',
  228. data: {
  229. memberId: memberId,
  230. screenType: this.currentScreen,
  231. answers: this.answers
  232. },
  233. success: (res) => {
  234. this.submitting = false
  235. if (res.data && res.data.code === 200) {
  236. this.result = res.data.data
  237. } else {
  238. uni.showToast({ title: res.data && res.data.message || '提交失败', icon: 'none' })
  239. }
  240. },
  241. fail: () => {
  242. this.submitting = false
  243. uni.showToast({ title: '网络错误', icon: 'none' })
  244. }
  245. })
  246. },
  247. resetScreen() {
  248. this.currentScreen = null
  249. this.currentStep = 0
  250. this.answers = []
  251. this.result = null
  252. },
  253. goTrend() {
  254. uni.navigateTo({ url: '/pages/mind/emotion-trend' })
  255. },
  256. riskFlagLabel(flag) {
  257. return this.riskFlagLabels[flag] || flag
  258. }
  259. }
  260. }
  261. </script>
  262. <style scoped>
  263. .screen-container {
  264. min-height: 100vh;
  265. background: linear-gradient(180deg, #F0F4FF 0%, #FFFFFF 100%);
  266. padding-bottom: 40rpx;
  267. }
  268. .screen-header {
  269. padding: 40rpx 32rpx 20rpx;
  270. }
  271. .screen-title {
  272. font-size: 36rpx;
  273. font-weight: 700;
  274. color: #333;
  275. display: block;
  276. }
  277. .screen-subtitle {
  278. font-size: 26rpx;
  279. color: #999;
  280. margin-top: 8rpx;
  281. display: block;
  282. }
  283. .section {
  284. margin: 20rpx 32rpx;
  285. background: #fff;
  286. border-radius: 20rpx;
  287. padding: 28rpx;
  288. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  289. }
  290. /* ===== 量表选择 ===== */
  291. .scale-card {
  292. display: flex;
  293. align-items: center;
  294. padding: 24rpx;
  295. background: #FAFAFA;
  296. border-radius: 16rpx;
  297. margin-bottom: 16rpx;
  298. gap: 20rpx;
  299. }
  300. .scale-card:active {
  301. background: #F0F0F0;
  302. }
  303. .scale-icon-wrap {
  304. width: 72rpx;
  305. height: 72rpx;
  306. border-radius: 36rpx;
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. flex-shrink: 0;
  311. }
  312. .scale-icon {
  313. font-size: 36rpx;
  314. }
  315. .scale-info {
  316. flex: 1;
  317. }
  318. .scale-name {
  319. font-size: 28rpx;
  320. font-weight: 600;
  321. color: #333;
  322. display: block;
  323. }
  324. .scale-desc {
  325. font-size: 22rpx;
  326. color: #999;
  327. margin-top: 4rpx;
  328. display: block;
  329. }
  330. .scale-arrow {
  331. font-size: 28rpx;
  332. color: #ccc;
  333. }
  334. /* ===== 问卷 ===== */
  335. .quiz-header {
  336. display: flex;
  337. justify-content: space-between;
  338. align-items: center;
  339. margin-bottom: 16rpx;
  340. }
  341. .quiz-title {
  342. font-size: 28rpx;
  343. font-weight: 600;
  344. color: #333;
  345. }
  346. .quiz-progress {
  347. font-size: 24rpx;
  348. color: #999;
  349. }
  350. .progress-track {
  351. height: 6rpx;
  352. background: #F0F0F0;
  353. border-radius: 3rpx;
  354. margin-bottom: 24rpx;
  355. overflow: hidden;
  356. }
  357. .progress-fill {
  358. height: 100%;
  359. background: linear-gradient(90deg, #6366F1, #8B5CF6);
  360. border-radius: 3rpx;
  361. transition: width 0.3s;
  362. }
  363. .question-card {
  364. background: #F8F6FF;
  365. border-radius: 16rpx;
  366. padding: 24rpx;
  367. margin-bottom: 24rpx;
  368. }
  369. .question-num {
  370. font-size: 22rpx;
  371. color: #8B5CF6;
  372. font-weight: 600;
  373. display: block;
  374. margin-bottom: 8rpx;
  375. }
  376. .question-text {
  377. font-size: 30rpx;
  378. color: #333;
  379. line-height: 1.5;
  380. }
  381. .options-list {
  382. display: flex;
  383. flex-direction: column;
  384. gap: 12rpx;
  385. }
  386. .option-btn {
  387. display: flex;
  388. align-items: center;
  389. padding: 20rpx 24rpx;
  390. border-radius: 14rpx;
  391. border: 2rpx solid #F0F0F0;
  392. gap: 16rpx;
  393. }
  394. .option-active {
  395. border-color: #8B5CF6;
  396. background: #F8F6FF;
  397. }
  398. .option-radio {
  399. width: 40rpx;
  400. height: 40rpx;
  401. border-radius: 20rpx;
  402. border: 3rpx solid #D0D0D0;
  403. display: flex;
  404. align-items: center;
  405. justify-content: center;
  406. flex-shrink: 0;
  407. }
  408. .radio-checked {
  409. border-color: #8B5CF6;
  410. }
  411. .radio-dot {
  412. width: 22rpx;
  413. height: 22rpx;
  414. border-radius: 11rpx;
  415. background: #8B5CF6;
  416. }
  417. .option-text {
  418. font-size: 28rpx;
  419. color: #444;
  420. }
  421. .option-active .option-text {
  422. color: #333;
  423. font-weight: 500;
  424. }
  425. .quiz-nav {
  426. display: flex;
  427. gap: 16rpx;
  428. margin-top: 32rpx;
  429. }
  430. .nav-btn {
  431. flex: 1;
  432. height: 80rpx;
  433. line-height: 80rpx;
  434. border-radius: 40rpx;
  435. font-size: 28rpx;
  436. text-align: center;
  437. }
  438. .prev-btn {
  439. background: #F0F0F0;
  440. color: #666;
  441. }
  442. .next-btn {
  443. background: #6366F1;
  444. color: #fff;
  445. }
  446. .submit-btn {
  447. background: linear-gradient(135deg, #6366F1, #8B5CF6);
  448. color: #fff;
  449. }
  450. /* ===== 结果 ===== */
  451. .result-header {
  452. display: flex;
  453. flex-direction: column;
  454. align-items: center;
  455. padding: 20rpx 0;
  456. }
  457. .result-type {
  458. font-size: 24rpx;
  459. color: #999;
  460. margin-bottom: 16rpx;
  461. }
  462. .result-score-circle {
  463. width: 120rpx;
  464. height: 120rpx;
  465. border-radius: 60rpx;
  466. display: flex;
  467. flex-direction: column;
  468. align-items: center;
  469. justify-content: center;
  470. margin-bottom: 12rpx;
  471. }
  472. .result-score {
  473. font-size: 48rpx;
  474. font-weight: 700;
  475. color: #fff;
  476. line-height: 1;
  477. }
  478. .result-score-label {
  479. font-size: 20rpx;
  480. color: rgba(255,255,255,0.8);
  481. margin-top: 2rpx;
  482. }
  483. .result-severity {
  484. font-size: 30rpx;
  485. font-weight: 600;
  486. }
  487. .severity-good { background: #10B981; color: #10B981; }
  488. .severity-mild { background: #F59E0B; color: #F59E0B; }
  489. .severity-moderate { background: #FF8C42; color: #FF8C42; }
  490. .severity-severe { background: #EF4444; color: #EF4444; }
  491. .result-score-circle.severity-good { background: #10B981; }
  492. .result-score-circle.severity-mild { background: #F59E0B; }
  493. .result-score-circle.severity-moderate { background: #FF8C42; }
  494. .result-score-circle.severity-severe { background: #EF4444; }
  495. .suggestion-card {
  496. background: #F0FFF4;
  497. border-radius: 14rpx;
  498. padding: 20rpx;
  499. margin-top: 16rpx;
  500. }
  501. .suggestion-title {
  502. font-size: 24rpx;
  503. color: #10B981;
  504. font-weight: 600;
  505. display: block;
  506. margin-bottom: 8rpx;
  507. }
  508. .suggestion-text {
  509. font-size: 26rpx;
  510. color: #555;
  511. line-height: 1.6;
  512. }
  513. .risk-section {
  514. margin-top: 16rpx;
  515. }
  516. .risk-item {
  517. display: flex;
  518. align-items: flex-start;
  519. gap: 8rpx;
  520. padding: 12rpx 16rpx;
  521. background: #FFF5F5;
  522. border-radius: 12rpx;
  523. margin-bottom: 8rpx;
  524. }
  525. .risk-icon {
  526. font-size: 24rpx;
  527. flex-shrink: 0;
  528. }
  529. .risk-text {
  530. font-size: 24rpx;
  531. color: #E53E3E;
  532. line-height: 1.5;
  533. }
  534. .crisis-banner {
  535. margin-top: 16rpx;
  536. padding: 24rpx;
  537. background: linear-gradient(135deg, #FF6B6B, #E53E3E);
  538. border-radius: 16rpx;
  539. text-align: center;
  540. }
  541. .crisis-title {
  542. font-size: 28rpx;
  543. color: #fff;
  544. font-weight: 700;
  545. display: block;
  546. }
  547. .crisis-phone {
  548. font-size: 22rpx;
  549. color: rgba(255,255,255,0.8);
  550. margin-top: 12rpx;
  551. display: block;
  552. }
  553. .crisis-number {
  554. font-size: 40rpx;
  555. color: #fff;
  556. font-weight: 700;
  557. margin-top: 4rpx;
  558. display: block;
  559. letter-spacing: 2rpx;
  560. }
  561. .crisis-hint {
  562. font-size: 20rpx;
  563. color: rgba(255,255,255,0.7);
  564. margin-top: 4rpx;
  565. display: block;
  566. }
  567. .result-actions {
  568. display: flex;
  569. gap: 16rpx;
  570. margin-top: 28rpx;
  571. }
  572. .action-btn {
  573. flex: 1;
  574. height: 76rpx;
  575. line-height: 76rpx;
  576. border-radius: 38rpx;
  577. font-size: 26rpx;
  578. text-align: center;
  579. }
  580. .primary-btn {
  581. background: #FF6B9D;
  582. color: #fff;
  583. }
  584. .secondary-btn {
  585. background: #F0F0F0;
  586. color: #666;
  587. }
  588. .loading-mask {
  589. position: fixed;
  590. top: 0;
  591. left: 0;
  592. right: 0;
  593. bottom: 0;
  594. background: rgba(0, 0, 0, 0.3);
  595. display: flex;
  596. align-items: center;
  597. justify-content: center;
  598. z-index: 999;
  599. }
  600. .loading-box {
  601. background: #fff;
  602. padding: 40rpx 60rpx;
  603. border-radius: 20rpx;
  604. }
  605. .loading-text {
  606. font-size: 28rpx;
  607. color: #666;
  608. }
  609. </style>