screening.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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 app = getApp()
  225. const childId = app.globalData.currentChildId
  226. uni.request({
  227. url: config.API_BASE_URL + '/api/mind/screening/submit',
  228. method: 'POST',
  229. data: {
  230. childId: childId,
  231. screenType: this.currentScreen,
  232. answers: this.answers
  233. },
  234. success: (res) => {
  235. this.submitting = false
  236. if (res.data && res.data.code === 200) {
  237. this.result = res.data.data
  238. } else {
  239. uni.showToast({ title: res.data && res.data.message || '提交失败', icon: 'none' })
  240. }
  241. },
  242. fail: () => {
  243. this.submitting = false
  244. uni.showToast({ title: '网络错误', icon: 'none' })
  245. }
  246. })
  247. },
  248. resetScreen() {
  249. this.currentScreen = null
  250. this.currentStep = 0
  251. this.answers = []
  252. this.result = null
  253. },
  254. goTrend() {
  255. uni.navigateTo({ url: '/pages/mind/emotion-trend' })
  256. },
  257. riskFlagLabel(flag) {
  258. return this.riskFlagLabels[flag] || flag
  259. }
  260. }
  261. }
  262. </script>
  263. <style scoped>
  264. .screen-container {
  265. min-height: 100vh;
  266. background: linear-gradient(180deg, #F0F4FF 0%, #FFFFFF 100%);
  267. padding-bottom: 40rpx;
  268. }
  269. .screen-header {
  270. padding: 40rpx 32rpx 20rpx;
  271. }
  272. .screen-title {
  273. font-size: 36rpx;
  274. font-weight: 700;
  275. color: #333;
  276. display: block;
  277. }
  278. .screen-subtitle {
  279. font-size: 26rpx;
  280. color: #999;
  281. margin-top: 8rpx;
  282. display: block;
  283. }
  284. .section {
  285. margin: 20rpx 32rpx;
  286. background: #fff;
  287. border-radius: 20rpx;
  288. padding: 28rpx;
  289. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  290. }
  291. /* ===== 量表选择 ===== */
  292. .scale-card {
  293. display: flex;
  294. align-items: center;
  295. padding: 24rpx;
  296. background: #FAFAFA;
  297. border-radius: 16rpx;
  298. margin-bottom: 16rpx;
  299. gap: 20rpx;
  300. }
  301. .scale-card:active {
  302. background: #F0F0F0;
  303. }
  304. .scale-icon-wrap {
  305. width: 72rpx;
  306. height: 72rpx;
  307. border-radius: 36rpx;
  308. display: flex;
  309. align-items: center;
  310. justify-content: center;
  311. flex-shrink: 0;
  312. }
  313. .scale-icon {
  314. font-size: 36rpx;
  315. }
  316. .scale-info {
  317. flex: 1;
  318. }
  319. .scale-name {
  320. font-size: 28rpx;
  321. font-weight: 600;
  322. color: #333;
  323. display: block;
  324. }
  325. .scale-desc {
  326. font-size: 22rpx;
  327. color: #999;
  328. margin-top: 4rpx;
  329. display: block;
  330. }
  331. .scale-arrow {
  332. font-size: 28rpx;
  333. color: #ccc;
  334. }
  335. /* ===== 问卷 ===== */
  336. .quiz-header {
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. margin-bottom: 16rpx;
  341. }
  342. .quiz-title {
  343. font-size: 28rpx;
  344. font-weight: 600;
  345. color: #333;
  346. }
  347. .quiz-progress {
  348. font-size: 24rpx;
  349. color: #999;
  350. }
  351. .progress-track {
  352. height: 6rpx;
  353. background: #F0F0F0;
  354. border-radius: 3rpx;
  355. margin-bottom: 24rpx;
  356. overflow: hidden;
  357. }
  358. .progress-fill {
  359. height: 100%;
  360. background: linear-gradient(90deg, #6366F1, #8B5CF6);
  361. border-radius: 3rpx;
  362. transition: width 0.3s;
  363. }
  364. .question-card {
  365. background: #F8F6FF;
  366. border-radius: 16rpx;
  367. padding: 24rpx;
  368. margin-bottom: 24rpx;
  369. }
  370. .question-num {
  371. font-size: 22rpx;
  372. color: #8B5CF6;
  373. font-weight: 600;
  374. display: block;
  375. margin-bottom: 8rpx;
  376. }
  377. .question-text {
  378. font-size: 30rpx;
  379. color: #333;
  380. line-height: 1.5;
  381. }
  382. .options-list {
  383. display: flex;
  384. flex-direction: column;
  385. gap: 12rpx;
  386. }
  387. .option-btn {
  388. display: flex;
  389. align-items: center;
  390. padding: 20rpx 24rpx;
  391. border-radius: 14rpx;
  392. border: 2rpx solid #F0F0F0;
  393. gap: 16rpx;
  394. }
  395. .option-active {
  396. border-color: #8B5CF6;
  397. background: #F8F6FF;
  398. }
  399. .option-radio {
  400. width: 40rpx;
  401. height: 40rpx;
  402. border-radius: 20rpx;
  403. border: 3rpx solid #D0D0D0;
  404. display: flex;
  405. align-items: center;
  406. justify-content: center;
  407. flex-shrink: 0;
  408. }
  409. .radio-checked {
  410. border-color: #8B5CF6;
  411. }
  412. .radio-dot {
  413. width: 22rpx;
  414. height: 22rpx;
  415. border-radius: 11rpx;
  416. background: #8B5CF6;
  417. }
  418. .option-text {
  419. font-size: 28rpx;
  420. color: #444;
  421. }
  422. .option-active .option-text {
  423. color: #333;
  424. font-weight: 500;
  425. }
  426. .quiz-nav {
  427. display: flex;
  428. gap: 16rpx;
  429. margin-top: 32rpx;
  430. }
  431. .nav-btn {
  432. flex: 1;
  433. height: 80rpx;
  434. line-height: 80rpx;
  435. border-radius: 40rpx;
  436. font-size: 28rpx;
  437. text-align: center;
  438. }
  439. .prev-btn {
  440. background: #F0F0F0;
  441. color: #666;
  442. }
  443. .next-btn {
  444. background: #6366F1;
  445. color: #fff;
  446. }
  447. .submit-btn {
  448. background: linear-gradient(135deg, #6366F1, #8B5CF6);
  449. color: #fff;
  450. }
  451. /* ===== 结果 ===== */
  452. .result-header {
  453. display: flex;
  454. flex-direction: column;
  455. align-items: center;
  456. padding: 20rpx 0;
  457. }
  458. .result-type {
  459. font-size: 24rpx;
  460. color: #999;
  461. margin-bottom: 16rpx;
  462. }
  463. .result-score-circle {
  464. width: 120rpx;
  465. height: 120rpx;
  466. border-radius: 60rpx;
  467. display: flex;
  468. flex-direction: column;
  469. align-items: center;
  470. justify-content: center;
  471. margin-bottom: 12rpx;
  472. }
  473. .result-score {
  474. font-size: 48rpx;
  475. font-weight: 700;
  476. color: #fff;
  477. line-height: 1;
  478. }
  479. .result-score-label {
  480. font-size: 20rpx;
  481. color: rgba(255,255,255,0.8);
  482. margin-top: 2rpx;
  483. }
  484. .result-severity {
  485. font-size: 30rpx;
  486. font-weight: 600;
  487. }
  488. .severity-good { background: #10B981; color: #10B981; }
  489. .severity-mild { background: #F59E0B; color: #F59E0B; }
  490. .severity-moderate { background: #FF8C42; color: #FF8C42; }
  491. .severity-severe { background: #EF4444; color: #EF4444; }
  492. .result-score-circle.severity-good { background: #10B981; }
  493. .result-score-circle.severity-mild { background: #F59E0B; }
  494. .result-score-circle.severity-moderate { background: #FF8C42; }
  495. .result-score-circle.severity-severe { background: #EF4444; }
  496. .suggestion-card {
  497. background: #F0FFF4;
  498. border-radius: 14rpx;
  499. padding: 20rpx;
  500. margin-top: 16rpx;
  501. }
  502. .suggestion-title {
  503. font-size: 24rpx;
  504. color: #10B981;
  505. font-weight: 600;
  506. display: block;
  507. margin-bottom: 8rpx;
  508. }
  509. .suggestion-text {
  510. font-size: 26rpx;
  511. color: #555;
  512. line-height: 1.6;
  513. }
  514. .risk-section {
  515. margin-top: 16rpx;
  516. }
  517. .risk-item {
  518. display: flex;
  519. align-items: flex-start;
  520. gap: 8rpx;
  521. padding: 12rpx 16rpx;
  522. background: #FFF5F5;
  523. border-radius: 12rpx;
  524. margin-bottom: 8rpx;
  525. }
  526. .risk-icon {
  527. font-size: 24rpx;
  528. flex-shrink: 0;
  529. }
  530. .risk-text {
  531. font-size: 24rpx;
  532. color: #E53E3E;
  533. line-height: 1.5;
  534. }
  535. .crisis-banner {
  536. margin-top: 16rpx;
  537. padding: 24rpx;
  538. background: linear-gradient(135deg, #FF6B6B, #E53E3E);
  539. border-radius: 16rpx;
  540. text-align: center;
  541. }
  542. .crisis-title {
  543. font-size: 28rpx;
  544. color: #fff;
  545. font-weight: 700;
  546. display: block;
  547. }
  548. .crisis-phone {
  549. font-size: 22rpx;
  550. color: rgba(255,255,255,0.8);
  551. margin-top: 12rpx;
  552. display: block;
  553. }
  554. .crisis-number {
  555. font-size: 40rpx;
  556. color: #fff;
  557. font-weight: 700;
  558. margin-top: 4rpx;
  559. display: block;
  560. letter-spacing: 2rpx;
  561. }
  562. .crisis-hint {
  563. font-size: 20rpx;
  564. color: rgba(255,255,255,0.7);
  565. margin-top: 4rpx;
  566. display: block;
  567. }
  568. .result-actions {
  569. display: flex;
  570. gap: 16rpx;
  571. margin-top: 28rpx;
  572. }
  573. .action-btn {
  574. flex: 1;
  575. height: 76rpx;
  576. line-height: 76rpx;
  577. border-radius: 38rpx;
  578. font-size: 26rpx;
  579. text-align: center;
  580. }
  581. .primary-btn {
  582. background: #FF6B9D;
  583. color: #fff;
  584. }
  585. .secondary-btn {
  586. background: #F0F0F0;
  587. color: #666;
  588. }
  589. .loading-mask {
  590. position: fixed;
  591. top: 0;
  592. left: 0;
  593. right: 0;
  594. bottom: 0;
  595. background: rgba(0, 0, 0, 0.3);
  596. display: flex;
  597. align-items: center;
  598. justify-content: center;
  599. z-index: 999;
  600. }
  601. .loading-box {
  602. background: #fff;
  603. padding: 40rpx 60rpx;
  604. border-radius: 20rpx;
  605. }
  606. .loading-text {
  607. font-size: 28rpx;
  608. color: #666;
  609. }
  610. </style>