report-result.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. <template>
  2. <view class="container" :style="{ '--font-scale': fontScale }">
  3. <!-- ==================== Hero 头部 ==================== -->
  4. <view class="hero">
  5. <view class="hero-bg-circle hero-bg-circle-1"></view>
  6. <view class="hero-bg-circle hero-bg-circle-2"></view>
  7. <view class="hero-nav" :style="'padding-top:' + (statusBarHeight > 0 ? statusBarHeight : 20) + 'px'">
  8. <view class="hero-nav-back" hover-class="hero-nav-back-hover" @click="goBack">
  9. <text class="hero-nav-back-icon">←</text>
  10. </view>
  11. <text class="hero-nav-title">{{ dimensionLabel }}</text>
  12. </view>
  13. <view class="hero-top">
  14. <text class="hero-name">{{ childName }}</text>
  15. <view class="hero-dim-row">
  16. <text class="hero-dim-badge">{{ dimensionLabel }}</text>
  17. <text class="hero-level-badge" v-if="level">等级 {{ level }}</text>
  18. <text class="hero-date">{{ dateText }}</text>
  19. </view>
  20. </view>
  21. <!-- 总分区 -->
  22. <view class="hero-score-wrap" v-if="totalScore !== null">
  23. <view class="hero-score-col">
  24. <text class="hero-score-num">{{ totalScore }}</text>
  25. <text class="hero-score-label">{{ percentile !== null ? '总得分' : '综合得分' }}</text>
  26. </view>
  27. <template v-if="percentile !== null">
  28. <view class="hero-score-divider"></view>
  29. <view class="hero-score-col">
  30. <text class="hero-score-num hero-score-num-pct">{{ percentile }}<text class="hero-score-pct-unit">%</text></text>
  31. <text class="hero-score-label">百分位</text>
  32. </view>
  33. </template>
  34. </view>
  35. <!-- 百分位进度条:位置标记 -->
  36. <view class="hero-pct-bar-wrap" v-if="percentile !== null">
  37. <view class="hero-pct-track">
  38. <view class="hero-pct-fill" :style="'width:' + percentile + '%'"></view>
  39. <view class="hero-pct-marker" :style="'left:' + percentile + '%'"></view>
  40. </view>
  41. <view class="hero-pct-foot">
  42. <text class="hero-pct-foot-text">超过 {{ percentile }}% 的同龄人</text>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="body">
  47. <view class="loading-wrap" v-if="loading">
  48. <text class="loading-text">加载中...</text>
  49. </view>
  50. <template v-else-if="hasContent">
  51. <!-- ==================== 核心能力(认知/综合能力类,百分位制) ==================== -->
  52. <view class="card" v-if="abilityBlock">
  53. <view class="card-title-row">
  54. <view class="card-title-bar"></view>
  55. <text class="card-title">{{ abilityBlock.title }}</text>
  56. <text class="card-title-sub" v-if="!showAbilityRadar">百分位制,50 为同龄平均</text>
  57. </view>
  58. <!-- 认知能力:3 项及以上数值 → 雷达图 -->
  59. <view class="radar-wrap" v-if="showAbilityRadar">
  60. <RadarChart
  61. :dimensions="abilityRadarDims"
  62. :scores="abilityRadarScores"
  63. :population-scores="abilityRadarPopulation"
  64. :fill-color="chartColors.wisdomFill"
  65. :grid-color="chartColors.grid"
  66. :label-color="chartColors.label"
  67. :width="600"
  68. :height="600"
  69. :child-name="childName" />
  70. </view>
  71. <view v-else>
  72. <view class="metric-row" v-for="(m, mi) in abilityMetrics" :key="mi">
  73. <view class="metric-head">
  74. <text class="metric-name">{{ m.name }}</text>
  75. <view class="metric-value-wrap">
  76. <text class="metric-warn-badge" v-if="m.warn">需关注</text>
  77. <text class="metric-value" :class="m.warn ? 'metric-value-warn' : ''">{{ m.value }}<text class="metric-unit">%</text></text>
  78. </view>
  79. </view>
  80. <view class="metric-track">
  81. <view class="metric-fill" :class="m.warn ? 'metric-fill-warn' : 'metric-fill-main'"
  82. :style="'width:' + m.pct + '%'"></view>
  83. <view class="metric-ref-line" style="left:50%"></view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <!-- ==================== 大五人格(1-5 分制,5 项 → 雷达图) ==================== -->
  89. <view class="card" v-if="bigFiveBlock">
  90. <view class="card-title-row">
  91. <view class="card-title-bar"></view>
  92. <text class="card-title">{{ bigFiveBlock.title }}</text>
  93. <text class="card-title-sub">1 ~ 5 分,虚线为同龄平均</text>
  94. </view>
  95. <view class="radar-wrap" v-if="showBigFiveRadar">
  96. <RadarChart
  97. :dimensions="bigFiveRadarDims"
  98. :scores="bigFiveRadarScores"
  99. :population-scores="bigFiveRadarPopulation"
  100. :fill-color="chartColors.violetFill"
  101. :grid-color="chartColors.gridViolet"
  102. :label-color="chartColors.labelViolet"
  103. :width="600"
  104. :height="600"
  105. :child-name="childName" />
  106. </view>
  107. <view v-else>
  108. <view class="bf-row" v-for="(m, mi) in bigFiveMetrics" :key="mi">
  109. <view class="bf-head">
  110. <text class="bf-name">{{ m.name }}</text>
  111. <text class="bf-value">{{ m.value }}</text>
  112. </view>
  113. <view class="bf-track">
  114. <view class="bf-fill" :class="m.tone" :style="'width:' + m.pct + '%'"></view>
  115. <view class="bf-avg-line"></view>
  116. </view>
  117. <text class="bf-hint" v-if="m.hint">{{ m.hint }}</text>
  118. </view>
  119. </view>
  120. </view>
  121. <!-- ==================== 情绪状态(4 分测验,0-15 分制) ==================== -->
  122. <view class="card" v-if="emotionBlock">
  123. <view class="card-title-row">
  124. <view class="card-title-bar"></view>
  125. <text class="card-title">{{ emotionBlock.title }}</text>
  126. </view>
  127. <view class="emo-summary" v-if="emotionSummary.total || emotionSummary.avg">
  128. <text class="emo-summary-text">情绪不稳定总分 {{ emotionSummary.total || '-' }} 分,同龄平均 {{ emotionSummary.avg || '-' }} 分</text>
  129. </view>
  130. <view class="emo-row" v-for="(m, mi) in emotionMetrics" :key="mi">
  131. <view class="emo-chip">
  132. <text class="emo-name">{{ m.name }}</text>
  133. <text class="emo-value">{{ m.value }}</text>
  134. </view>
  135. <view class="emo-track">
  136. <view class="emo-fill" :style="'width:' + m.pct + '%'"></view>
  137. </view>
  138. </view>
  139. </view>
  140. <!-- ==================== 体质健康(身高/体重/BMI + 生活习惯) ==================== -->
  141. <view class="card" v-if="bodyBaseMetrics.length > 0 || bodyHabitMetrics.length > 0">
  142. <view class="card-title-row">
  143. <view class="card-title-bar"></view>
  144. <text class="card-title">体质健康</text>
  145. </view>
  146. <view class="info-grid" v-if="bodyBaseMetrics.length > 0">
  147. <view class="info-cell" v-for="(m, mi) in bodyBaseMetrics" :key="mi">
  148. <text class="info-value">{{ m.value }}<text class="info-unit" v-if="m.unit">{{ m.unit }}</text></text>
  149. <text class="info-name">{{ m.name }}</text>
  150. </view>
  151. </view>
  152. <view class="habit-row" v-for="(m, mi) in bodyHabitMetrics" :key="mi">
  153. <text class="habit-name">{{ m.name }}</text>
  154. <text class="habit-value">{{ m.value }}</text>
  155. </view>
  156. </view>
  157. <!-- ==================== 通用指标块(自我概念/自驱力等,量纲自适应) ==================== -->
  158. <view class="card" v-for="(blk, bi) in genericBlocks" :key="getBlockKey(bi)">
  159. <view class="card-title-row">
  160. <view class="card-title-bar"></view>
  161. <text class="card-title">{{ blk.title }}</text>
  162. </view>
  163. <view class="metric-row" v-for="(m, mi) in blk.metrics" :key="mi">
  164. <!-- 非数值指标(如依恋类型)只展示名称与取值,不画条 -->
  165. <view class="metric-plain-row" v-if="m.nonNumeric">
  166. <text class="metric-name">{{ m.name }}</text>
  167. <text class="metric-plain-value">{{ m.value }}</text>
  168. </view>
  169. <template v-else>
  170. <view class="metric-head">
  171. <text class="metric-name">{{ m.name }}</text>
  172. <view class="metric-value-wrap">
  173. <text class="metric-warn-badge" v-if="m.warn">需关注</text>
  174. <text class="metric-value" :class="m.warn ? 'metric-value-warn' : ''">{{ m.value }}</text>
  175. </view>
  176. </view>
  177. <view class="metric-track">
  178. <view class="metric-fill" :class="m.warn ? 'metric-fill-warn' : 'metric-fill-main'"
  179. :style="'width:' + m.pct + '%'"></view>
  180. </view>
  181. </template>
  182. </view>
  183. </view>
  184. <!-- ==================== 基本信息(身高体重等,过滤噪音) ==================== -->
  185. <view class="card" v-if="otherMetrics.length > 0">
  186. <view class="card-title-row">
  187. <view class="card-title-bar"></view>
  188. <text class="card-title">基本信息</text>
  189. </view>
  190. <view class="info-grid">
  191. <view class="info-cell" v-for="(m, mi) in otherMetrics" :key="mi">
  192. <text class="info-value">{{ m.value }}<text class="info-unit" v-if="m.unit">{{ m.unit }}</text></text>
  193. <text class="info-name">{{ m.name }}</text>
  194. </view>
  195. </view>
  196. </view>
  197. <!-- ==================== 成长建议(长文本折叠) ==================== -->
  198. <view class="card" v-if="adviceText">
  199. <view class="card-title-row">
  200. <view class="card-title-bar card-title-bar-gold"></view>
  201. <text class="card-title">{{ adviceTitle }}</text>
  202. </view>
  203. <text class="advice-content" :class="!adviceExpanded ? 'advice-clamped' : ''">{{ adviceText }}</text>
  204. <view class="advice-toggle" @click="adviceExpanded = !adviceExpanded" v-if="adviceText.length > 160">
  205. <text class="advice-toggle-text">{{ adviceExpanded ? '收起 ▲' : '展开全部 ▼' }}</text>
  206. </view>
  207. </view>
  208. <!-- ==================== 报告评语 ==================== -->
  209. <view class="card" v-if="summaryText">
  210. <view class="card-title-row">
  211. <view class="card-title-bar"></view>
  212. <text class="card-title">报告评语</text>
  213. </view>
  214. <text class="advice-content">{{ summaryText }}</text>
  215. </view>
  216. <view class="foot-note">
  217. <text class="foot-note-text">本报告由 DAN 测评系统生成,结果仅供成长参考</text>
  218. </view>
  219. </template>
  220. <view class="empty-wrap" v-else>
  221. <text class="empty-text">暂无数据</text>
  222. </view>
  223. </view>
  224. <view class="bottom-spacer"></view>
  225. </view>
  226. </template>
  227. <script>
  228. import { getDanReportDetail } from '../../utils/api.js'
  229. import RadarChart from '../../components/RadarChart.vue'
  230. // 噪音指标过滤(报告头/OCR 带出的非测评数据,对历史数据同样生效)
  231. var NOISE_NAME_KEYS = ['联系电话', '报告编码', '测试时间', '档案', '具体情况', '页', '公众号',
  232. '出生', '年份', '编码', '编号', '手机', '身份证', '总均分', '邮箱']
  233. // 百分位制 category(0-100)
  234. var PERCENT_CATEGORIES = ['overall', 'cognitive']
  235. import fontScaleMixin from '@/mixins/font-scale.js'
  236. export default {
  237. mixins: [fontScaleMixin],
  238. components: { RadarChart },
  239. data() {
  240. return {
  241. reportId: null,
  242. statusBarHeight: 0,
  243. loading: true,
  244. childName: '',
  245. dateText: '',
  246. dimension: '',
  247. reportType: '',
  248. level: '',
  249. totalScore: null,
  250. percentile: null,
  251. blocks: [],
  252. catMap: {},
  253. adviceExpanded: false,
  254. adviceSourceTitle: '',
  255. adviceSourceText: '',
  256. summarySourceText: ''
  257. }
  258. },
  259. computed: {
  260. hasContent() {
  261. return this.blocks.length > 0
  262. },
  263. dimensionLabel() {
  264. var map = {
  265. mind: '心维度',
  266. wisdom: '智维度',
  267. cognition: '认知维度',
  268. learning: '学习能力',
  269. behavior: '行为教养',
  270. career: '职业发展',
  271. campus: '校园标准',
  272. adolescent: '青春期挑战'
  273. }
  274. var base = map[this.dimension] || ''
  275. if (this.reportType) base += ' · ' + this.reportType
  276. return base || 'DAN 测评'
  277. },
  278. // 核心能力块(优先"认知能力",其次含"能力"的块)
  279. abilityBlock() {
  280. var fallback = null
  281. for (var i = 0; i < this.blocks.length; i++) {
  282. var b = this.blocks[i]
  283. if (b.type !== 'indicator' || !b.items || !b.items.length) continue
  284. var t = String(b.title || '')
  285. if (t.indexOf('认知') >= 0) return b
  286. if (t.indexOf('能力') >= 0 && !fallback) fallback = b
  287. }
  288. return fallback
  289. },
  290. abilityMetrics() {
  291. if (!this.abilityBlock) return []
  292. var self = this
  293. return (this.abilityBlock.items || []).filter(function(it) {
  294. return !self.isNoise(it.name)
  295. }).map(function(it) {
  296. var v = parseFloat(it.value)
  297. var pct = isNaN(v) ? 0 : self.clampPct(v)
  298. return {
  299. name: String(it.name).replace('百分位', ''),
  300. value: it.value,
  301. pct: pct,
  302. warn: !isNaN(v) && v < 50
  303. }
  304. })
  305. },
  306. // 认知能力雷达图模式:标题含「认知」且数值项 >= 3
  307. showAbilityRadar() {
  308. var b = this.abilityBlock
  309. if (!b) return false
  310. var t = String(b.title || '')
  311. return t.indexOf('认知') >= 0 && this.abilityMetrics.length >= 3
  312. },
  313. abilityRadarDims() {
  314. return this.abilityMetrics.map(function(m) {
  315. return { label: m.name + ' ' + m.value + '%', key: m.name }
  316. })
  317. },
  318. abilityRadarScores() {
  319. return this.abilityMetrics.map(function(m) {
  320. var v = parseFloat(m.value)
  321. return isNaN(v) ? 0 : Math.min(100, Math.max(0, Math.round(v)))
  322. })
  323. },
  324. // 同龄平均位置:50 百分位
  325. abilityRadarPopulation() {
  326. var arr = []
  327. for (var i = 0; i < this.abilityMetrics.length; i++) { arr.push(50) }
  328. return arr
  329. },
  330. // 大五人格块
  331. bigFiveBlock() {
  332. for (var i = 0; i < this.blocks.length; i++) {
  333. var b = this.blocks[i]
  334. if (b.type === 'indicator' && b.title && String(b.title).indexOf('人格') >= 0) {
  335. return b
  336. }
  337. }
  338. return null
  339. },
  340. bigFiveMetrics() {
  341. if (!this.bigFiveBlock) return []
  342. return (this.bigFiveBlock.items || []).map(function(it) {
  343. var v = parseFloat(it.value)
  344. var pct = isNaN(v) ? 0 : Math.min(100, Math.max(0, v / 5 * 100))
  345. var tone = 'bf-neutral'
  346. var hint = ''
  347. if (!isNaN(v)) {
  348. if (v >= 4) { tone = 'bf-high'; hint = '突出优势' }
  349. else if (v <= 2.5) { tone = 'bf-low'; hint = '低于同龄平均' }
  350. }
  351. return { name: it.name, value: it.value, pct: Math.round(pct), tone: tone, hint: hint }
  352. })
  353. },
  354. // 大五人格雷达图模式:5 个维度齐全时用雷达图(1-5 分制换算成 0-100)
  355. showBigFiveRadar() {
  356. return this.bigFiveMetrics.length >= 3
  357. },
  358. bigFiveRadarDims() {
  359. return this.bigFiveMetrics.map(function(m) {
  360. return { label: m.name + ' ' + m.value, key: m.name }
  361. })
  362. },
  363. bigFiveRadarScores() {
  364. return this.bigFiveMetrics.map(function(m) {
  365. var v = parseFloat(m.value)
  366. return isNaN(v) ? 0 : Math.round(v / 5 * 100)
  367. })
  368. },
  369. // 同龄平均位置:3 分(1-5 分制)
  370. bigFiveRadarPopulation() {
  371. var arr = []
  372. for (var i = 0; i < this.bigFiveMetrics.length; i++) { arr.push(60) }
  373. return arr
  374. },
  375. // 情绪状态块
  376. emotionBlock() {
  377. for (var i = 0; i < this.blocks.length; i++) {
  378. var b = this.blocks[i]
  379. if (b.type === 'indicator' && b.title && String(b.title).indexOf('情绪') >= 0) {
  380. return b
  381. }
  382. }
  383. return null
  384. },
  385. emotionMetrics() {
  386. if (!this.emotionBlock) return []
  387. var self = this
  388. return (this.emotionBlock.items || []).filter(function(it) {
  389. if (self.isNoise(it.name)) return false
  390. var n = String(it.name)
  391. return n.indexOf('总得分') < 0 && n.indexOf('平均分') < 0
  392. }).map(function(it) {
  393. var v = parseFloat(it.value)
  394. // 分测验为 0-15 分制(PDF 标尺 1/10/15)
  395. var pct = isNaN(v) ? 0 : Math.min(100, Math.max(0, v / 15 * 100))
  396. return { name: it.name, value: it.value, pct: Math.round(pct) }
  397. })
  398. },
  399. // 情绪稳定性总分 / 同龄平均分(单独成行展示,不与分测验混在同一量纲)
  400. emotionSummary() {
  401. var out = { total: '', avg: '' }
  402. if (!this.emotionBlock) return out
  403. var items = this.emotionBlock.items || []
  404. for (var i = 0; i < items.length; i++) {
  405. var n = String(items[i].name)
  406. if (n.indexOf('总得分') >= 0) out.total = items[i].value
  407. else if (n.indexOf('平均分') >= 0) out.avg = items[i].value
  408. }
  409. return out
  410. },
  411. // 体质健康块(身高/体重/BMI + 饮食/睡眠/运动习惯)
  412. bodyBlock() {
  413. for (var i = 0; i < this.blocks.length; i++) {
  414. var b = this.blocks[i]
  415. if (b.type !== 'indicator' || !b.items || !b.items.length) continue
  416. var t = String(b.title || '')
  417. if (t.indexOf('体质') >= 0 || t.indexOf('健康') >= 0 || t.indexOf('身体') >= 0) {
  418. return b
  419. }
  420. }
  421. return null
  422. },
  423. bodyBlockItems() {
  424. var self = this
  425. if (!this.bodyBlock) return []
  426. return (this.bodyBlock.items || []).filter(function(it) {
  427. return !self.isNoise(it.name)
  428. })
  429. },
  430. // 体质卡片上部:数值型指标(身高/体重/BMI)
  431. bodyBaseMetrics() {
  432. return this.bodyBlockItems.filter(function(it) {
  433. var n = String(it.name)
  434. return n.indexOf('身高') >= 0 || n.indexOf('体重') >= 0 || n.indexOf('BMI') >= 0
  435. }).map(function(it) {
  436. var name = String(it.name)
  437. var unit = ''
  438. if (name.indexOf('身高') >= 0) unit = 'cm'
  439. else if (name.indexOf('体重') >= 0) unit = 'kg'
  440. return { name: name, value: it.value, unit: unit }
  441. })
  442. },
  443. // 体质卡片下部:等级与生活习惯(文本/量纲不一,用列表行展示)
  444. bodyHabitMetrics() {
  445. return this.bodyBlockItems.filter(function(it) {
  446. var n = String(it.name)
  447. return n.indexOf('身高') < 0 && n.indexOf('体重') < 0 && n.indexOf('BMI') < 0
  448. })
  449. },
  450. // 其他指标("其他指标"块,过滤噪音,提取身高体重等)
  451. otherMetrics() {
  452. for (var i = 0; i < this.blocks.length; i++) {
  453. var b = this.blocks[i]
  454. if (b.type === 'indicator' && b.title && String(b.title).indexOf('其他') >= 0) {
  455. var self = this
  456. return (b.items || []).filter(function(it) {
  457. return !self.isNoise(it.name)
  458. }).map(function(it) {
  459. var unit = ''
  460. var name = String(it.name)
  461. if (name.indexOf('身高') >= 0) { unit = 'cm' }
  462. if (name.indexOf('体重') >= 0) { unit = 'kg' }
  463. return { name: name, value: it.value, unit: unit }
  464. })
  465. }
  466. }
  467. return []
  468. },
  469. // 通用指标块(自我概念/自驱力/社会关系等未专项渲染的 indicator)
  470. genericBlocks() {
  471. var taken = []
  472. if (this.abilityBlock) taken.push(this.abilityBlock)
  473. if (this.bigFiveBlock) taken.push(this.bigFiveBlock)
  474. if (this.emotionBlock) taken.push(this.emotionBlock)
  475. if (this.bodyBlock) taken.push(this.bodyBlock)
  476. var self = this
  477. return this.blocks.filter(function(b) {
  478. if (b.type !== 'indicator') return false
  479. if (taken.indexOf(b) >= 0) return false
  480. if (b.title && String(b.title).indexOf('其他') >= 0) return false
  481. return b.items && b.items.length > 0
  482. }).map(function(b) {
  483. var title = String(b.title || '')
  484. return {
  485. title: b.title,
  486. metrics: (b.items || []).filter(function(it) {
  487. return !self.isNoise(it.name)
  488. }).map(function(it) {
  489. return self.toMetric(it, title)
  490. })
  491. }
  492. }).filter(function(b) { return b.metrics.length > 0 })
  493. },
  494. adviceTitle() {
  495. return this.adviceSourceTitle || '成长建议'
  496. },
  497. adviceText() {
  498. return this.adviceSourceText || ''
  499. },
  500. summaryText() {
  501. return this.summarySourceText || ''
  502. }
  503. },
  504. onLoad(options) {
  505. try {
  506. var info = uni.getWindowInfo && uni.getWindowInfo()
  507. if (info && info.statusBarHeight) this.statusBarHeight = info.statusBarHeight
  508. } catch (e) {}
  509. this.reportId = options.reportId ? parseInt(options.reportId) : null
  510. if (this.reportId) this.loadData()
  511. },
  512. methods: {
  513. goBack() {
  514. var pages = getCurrentPages()
  515. if (pages && pages.length > 1) {
  516. uni.navigateBack()
  517. } else {
  518. uni.reLaunch({ url: '/pages/index-home/index' })
  519. }
  520. },
  521. getBlockKey(bi) {
  522. return 'g' + bi
  523. },
  524. isNoise(name) {
  525. if (!name) return true
  526. for (var i = 0; i < NOISE_NAME_KEYS.length; i++) {
  527. if (String(name).indexOf(NOISE_NAME_KEYS[i]) >= 0) return true
  528. }
  529. return false
  530. },
  531. clampPct(v) {
  532. return Math.round(Math.min(100, Math.max(0, v)))
  533. },
  534. // 依据 category / 名称推断量纲上限
  535. resolveMax(name, category) {
  536. if (name && String(name).indexOf('百分位') >= 0) return 100
  537. if (category === 'bigFive') return 5
  538. if (category === 'social') return 100
  539. if (PERCENT_CATEGORIES.indexOf(category) >= 0) return 100
  540. return 10
  541. },
  542. // blockTitle:调用方(通用指标块)可显式指定量纲,如社会关系传 100
  543. toMetric(it, blockTitle) {
  544. var v = parseFloat(it.value)
  545. if (isNaN(v)) {
  546. // 非数值(如依恋类型「安全型/安全型/安全型」)不画条,仅展示取值
  547. return { name: it.name, value: it.value, pct: 0, warn: false, nonNumeric: true }
  548. }
  549. var cat = this.catMap[it.name] || ''
  550. var max = null
  551. if (blockTitle) {
  552. var t = String(blockTitle)
  553. if (t.indexOf('社会') >= 0 || t.indexOf('关系') >= 0) max = 100
  554. }
  555. if (max === null) max = this.resolveMax(it.name, cat)
  556. var pct = Math.min(100, Math.max(0, v / max * 100))
  557. // 仅百分位制指标(A2 认知等)低于 50 才告警;人格/自我概念等非能力项不告警
  558. var warn = (max === 100) && v < 50
  559. return { name: it.name, value: it.value, pct: Math.round(pct), warn: warn, nonNumeric: false }
  560. },
  561. loadData() {
  562. var self = this
  563. this.loading = true
  564. getDanReportDetail(this.reportId).then(function(res) {
  565. self.loading = false
  566. if (res.code !== 200 || !res.data) {
  567. uni.showToast({ title: res.message || '加载失败', icon: 'none' })
  568. return
  569. }
  570. var data = res.data
  571. var result = data.result || {}
  572. self.childName = result.childName || data.childName || ''
  573. var dateRaw = result.assessmentDate || data.confirmedAt || ''
  574. self.dateText = dateRaw ? String(dateRaw).substring(0, 10) : ''
  575. self.dimension = data.dimension || ''
  576. self.reportType = data.reportType || ''
  577. self.level = result.danLevel || ''
  578. self.blocks = (data.blocks || []).filter(function(b) {
  579. return b && ((b.items && b.items.length) || b.content)
  580. })
  581. // 从 structuredAnalysis 构建 名称→category 映射(blocks item 已丢 category)
  582. var catMap = {}
  583. if (result.structuredAnalysis) {
  584. try {
  585. var arr = JSON.parse(result.structuredAnalysis)
  586. for (var ai = 0; ai < arr.length; ai++) {
  587. if (arr[ai] && arr[ai].name) catMap[arr[ai].name] = arr[ai].category || ''
  588. }
  589. } catch (e) {}
  590. }
  591. self.catMap = catMap
  592. // 提取总分/百分位(score 块)
  593. for (var i = 0; i < self.blocks.length; i++) {
  594. var b = self.blocks[i]
  595. if (b.type === 'score' && b.items) {
  596. for (var j = 0; j < b.items.length; j++) {
  597. var it = b.items[j]
  598. var label = String(it.label)
  599. if (label.indexOf('总') >= 0) {
  600. var tv = parseFloat(it.value)
  601. if (!isNaN(tv)) self.totalScore = tv
  602. } else if (label.indexOf('百分位') >= 0) {
  603. var pv = parseFloat(it.value)
  604. if (!isNaN(pv)) self.percentile = Math.min(100, Math.max(0, pv))
  605. }
  606. }
  607. }
  608. }
  609. // 兜底:无 score 块(如 B4 智维度)时,用 result.overallScore 作综合得分
  610. if (self.totalScore === null && result.overallScore !== null && result.overallScore !== undefined) {
  611. var ov = parseFloat(result.overallScore)
  612. if (!isNaN(ov)) self.totalScore = ov
  613. }
  614. // text 块:成长建议优先(非空 content),评语单独
  615. for (var k = 0; k < self.blocks.length; k++) {
  616. var tb = self.blocks[k]
  617. if (tb.type === 'text' && tb.content) {
  618. if (String(tb.title).indexOf('建议') >= 0) {
  619. self.adviceSourceTitle = tb.title
  620. self.adviceSourceText = tb.content
  621. } else {
  622. self.summarySourceText = tb.content
  623. }
  624. }
  625. }
  626. // 兜底:无 text 建议块时用 result.growthSuggestions
  627. if (!self.adviceSourceText && result.growthSuggestions) {
  628. self.adviceSourceText = result.growthSuggestions
  629. }
  630. }).catch(function(e) {
  631. self.loading = false
  632. uni.showToast({ title: '加载异常', icon: 'none' })
  633. })
  634. }
  635. }
  636. }
  637. </script>
  638. <style scoped lang="scss">
  639. // ===== DAN 报告页专属色阶(紫罗兰主题 + 图表色板,单页专用;约定见 uni.scss §14)=====
  640. $c-rpt-bg: #F3F2FA; // 页面底(淡紫)
  641. $c-rpt-brown: $mat-orange-900; // 深棕徽章文字
  642. $c-rpt-cyan-1: #A5F3FC; // 渐变青浅档(星级光谱)
  643. $c-rpt-cyan-2: #67E8F9; // 渐变青深档
  644. $c-rpt-orange: $mat-orange-300; // 需关注暖橙(徽章/渐变/边框)
  645. $c-rpt-grid: #EEF0F6; // 图表网格灰
  646. $c-rpt-violet-grid: #F0ECFA; // 雷达网格/底(浅紫)
  647. $c-rpt-gray-line: #C7C9D9; // 灰色分隔
  648. $c-rpt-violet-soft: $accent-violet-300; // 紫罗兰浅渐变起
  649. $c-rpt-yellow: $accent-amber-light; // 黄渐变起
  650. $c-rpt-violet-text: $violet-700; // 紫罗兰文字
  651. $c-rpt-line: #F1F2F7; // 浅紫分隔线
  652. $c-rpt-body: $facade-text-gray-600; // 正文灰
  653. $c-rpt-foot: #B0B3C3; // 脚注灰
  654. $c-rpt-mask-ink: #000; // 遮罩渐变异色(mask-image)
  655. .container { min-height: 100vh; background: $c-rpt-bg; padding-bottom: 40rpx; }
  656. /* ==================== Hero ==================== */
  657. .hero {
  658. position: relative;
  659. background: linear-gradient(160deg, $dim-wisdom-deep 0%, $facade-violet-deep 55%, $facade-violet 100%);
  660. padding: 0 36rpx 44rpx;
  661. overflow: hidden;
  662. border-bottom-left-radius: 24rpx;
  663. border-bottom-right-radius: 24rpx;
  664. }
  665. .hero-nav {
  666. position: relative; z-index: 2;
  667. display: flex; align-items: center;
  668. padding-bottom: 20rpx;
  669. }
  670. .hero-nav-back {
  671. width: 64rpx; height: 64rpx; border-radius: 50%;
  672. background: rgba(255,255,255,0.22);
  673. display: flex; align-items: center; justify-content: center;
  674. margin-right: 16rpx;
  675. }
  676. .hero-nav-back-hover { background: rgba(255,255,255,0.38); }
  677. .hero-nav-back-icon { color: #fff; font-size: 44rpx; line-height: 1; font-weight: 700; }
  678. .hero-nav-title { color: rgba(255,255,255,0.95); font-size: calc(30rpx * var(--font-scale, 1)); font-weight: 600; }
  679. .hero-bg-circle { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.06); }
  680. .hero-bg-circle-1 { width: 380rpx; height: 380rpx; right: -120rpx; top: -140rpx; }
  681. .hero-bg-circle-2 { width: 220rpx; height: 220rpx; left: -80rpx; bottom: -60rpx; }
  682. .hero-top { position: relative; z-index: 1; }
  683. .hero-name { font-size: calc(44rpx * var(--font-scale, 1)); font-weight: 700; color: $app-surface; display: block; }
  684. .hero-dim-row { display: flex; align-items: center; margin-top: 14rpx; flex-wrap: wrap; }
  685. .hero-dim-badge {
  686. font-size: calc(22rpx * var(--font-scale, 1)); color: $app-surface;
  687. background: rgba(255,255,255,0.22);
  688. border-radius: 24rpx; padding: 6rpx 18rpx;
  689. margin-right: 14rpx;
  690. }
  691. .hero-level-badge {
  692. font-size: calc(22rpx * var(--font-scale, 1)); color: $c-rpt-brown; font-weight: 600;
  693. background: linear-gradient(135deg, $status-warning-light, $status-warning);
  694. border-radius: 24rpx; padding: 6rpx 18rpx;
  695. margin-right: 14rpx;
  696. }
  697. .hero-date { font-size: calc(24rpx * var(--font-scale, 1)); color: rgba(255,255,255,0.75); }
  698. .hero-score-wrap {
  699. position: relative; z-index: 1;
  700. display: flex; align-items: center; justify-content: center;
  701. margin-top: 36rpx;
  702. }
  703. .hero-score-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
  704. .hero-score-divider { width: 1rpx; height: 72rpx; background: rgba(255,255,255,0.25); }
  705. .hero-score-num { font-size: calc(80rpx * var(--font-scale, 1)); font-weight: 700; color: $app-surface; line-height: 1; }
  706. .hero-score-num-pct { font-size: calc(72rpx * var(--font-scale, 1)); }
  707. .hero-score-pct-unit { font-size: calc(32rpx * var(--font-scale, 1)); font-weight: 400; margin-left: 2rpx; }
  708. .hero-score-label { font-size: calc(24rpx * var(--font-scale, 1)); color: rgba(255,255,255,0.75); margin-top: 12rpx; }
  709. .hero-pct-bar-wrap { position: relative; z-index: 1; margin-top: 32rpx; }
  710. .hero-pct-track {
  711. position: relative; height: 14rpx; border-radius: 8rpx;
  712. background: rgba(255,255,255,0.18);
  713. }
  714. .hero-pct-fill {
  715. height: 100%; border-radius: 8rpx;
  716. background: linear-gradient(90deg, $c-rpt-cyan-1, $c-rpt-cyan-2, $status-warning-light);
  717. }
  718. .hero-pct-marker {
  719. position: absolute; top: -6rpx; width: 4rpx; height: 26rpx;
  720. background: $app-surface; border-radius: 8rpx; transform: translateX(-2rpx);
  721. }
  722. .hero-pct-foot { margin-top: 12rpx; text-align: center; }
  723. .hero-pct-foot-text { font-size: calc(22rpx * var(--font-scale, 1)); color: rgba(255,255,255,0.85); }
  724. /* ==================== 通用卡片 ==================== */
  725. .body { padding: 28rpx 24rpx 0; }
  726. .card {
  727. background: $app-surface;
  728. border-radius: 24rpx;
  729. padding: 28rpx 26rpx;
  730. margin-bottom: 22rpx;
  731. box-shadow: 0 4rpx 16rpx rgba(99,102,241,0.06);
  732. }
  733. .card-title-row { display: flex; align-items: baseline; margin-bottom: 24rpx; }
  734. .card-title-bar {
  735. width: 8rpx; height: 30rpx; border-radius: 8rpx;
  736. background: linear-gradient(180deg, $dim-wisdom, $facade-violet);
  737. margin-right: 12rpx; align-self: center;
  738. }
  739. .card-title-bar-gold { background: linear-gradient(180deg, $dim-wealth, $brand-primary); }
  740. .card-title { font-size: calc(30rpx * var(--font-scale, 1)); font-weight: 600; color: $facade-text-gray-800; }
  741. .card-title-sub { font-size: calc(22rpx * var(--font-scale, 1)); color: $facade-text-gray-400; margin-left: 14rpx; }
  742. /* ==================== 指标条 ==================== */
  743. .metric-row { margin-bottom: 26rpx; }
  744. .metric-row:last-child { margin-bottom: 4rpx; }
  745. .metric-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12rpx; }
  746. .metric-name { font-size: calc(26rpx * var(--font-scale, 1)); color: $facade-text-gray-700; font-weight: 500; }
  747. .metric-value-wrap { display: flex; align-items: center; }
  748. .metric-value { font-size: calc(30rpx * var(--font-scale, 1)); font-weight: 700; color: $dim-wisdom-deep; }
  749. .metric-value-warn { color: $brand-primary-dark; }
  750. .metric-unit { font-size: calc(20rpx * var(--font-scale, 1)); font-weight: 400; }
  751. .metric-warn-badge {
  752. font-size: calc(20rpx * var(--font-scale, 1)); color: $brand-primary-dark;
  753. background: $uni-primary-pale; border: 1rpx solid $c-rpt-orange;
  754. border-radius: 16rpx; padding: 2rpx 12rpx; margin-right: 10rpx;
  755. }
  756. .metric-track {
  757. position: relative; height: 16rpx; border-radius: 8rpx; background: $c-rpt-grid;
  758. }
  759. .metric-fill { height: 100%; border-radius: 8rpx; }
  760. .metric-fill-main { background: linear-gradient(90deg, $dim-wisdom-light, $dim-wisdom); }
  761. .metric-fill-warn { background: linear-gradient(90deg, $c-rpt-orange, $brand-primary-dark); }
  762. .metric-ref-line {
  763. position: absolute; top: -4rpx; width: 2rpx; height: 24rpx;
  764. background: $c-rpt-gray-line; border-radius: 8rpx;
  765. }
  766. /* 非数值指标行(名称 + 取值,无进度条) */
  767. .metric-plain-row {
  768. display: flex; justify-content: space-between; align-items: center;
  769. padding: 10rpx 0;
  770. }
  771. .metric-plain-value { font-size: calc(26rpx * var(--font-scale, 1)); color: $dim-wisdom-deep; font-weight: 600; }
  772. /* ==================== 大五人格 ==================== */
  773. .bf-row { margin-bottom: 24rpx; }
  774. .bf-row:last-child { margin-bottom: 4rpx; }
  775. .bf-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10rpx; }
  776. .bf-name { font-size: calc(26rpx * var(--font-scale, 1)); color: $facade-text-gray-700; font-weight: 500; }
  777. .bf-value { font-size: calc(30rpx * var(--font-scale, 1)); font-weight: 700; color: $facade-violet-deep; }
  778. .bf-track { position: relative; height: 14rpx; border-radius: 8rpx; background: $c-rpt-violet-grid; }
  779. .bf-fill { height: 100%; border-radius: 8rpx; }
  780. .bf-neutral { background: linear-gradient(90deg, $c-rpt-violet-soft, $facade-violet); }
  781. .bf-high { background: linear-gradient(90deg, $status-success-light-2, $status-success); }
  782. .bf-low { background: linear-gradient(90deg, $c-rpt-yellow, $dim-wealth); }
  783. .bf-avg-line {
  784. position: absolute; top: -5rpx; left: 60%; width: 2rpx; height: 24rpx;
  785. background: $facade-text-gray-400; border-radius: 8rpx;
  786. }
  787. .bf-hint { display: block; font-size: calc(20rpx * var(--font-scale, 1)); color: $facade-text-gray-400; margin-top: 6rpx; }
  788. /* ==================== 情绪状态 ==================== */
  789. .emo-row { display: flex; align-items: center; margin-bottom: 20rpx; }
  790. .emo-row:last-child { margin-bottom: 4rpx; }
  791. .emo-chip {
  792. display: flex; align-items: baseline;
  793. background: $facade-violet-tint-2; border-radius: 16rpx;
  794. padding: 10rpx 18rpx; margin-right: 18rpx; flex-shrink: 0;
  795. }
  796. .emo-name { font-size: calc(24rpx * var(--font-scale, 1)); color: $c-rpt-violet-text; margin-right: 12rpx; }
  797. .emo-value { font-size: calc(28rpx * var(--font-scale, 1)); font-weight: 700; color: $facade-violet-deep; }
  798. .emo-track { flex: 1; height: 12rpx; border-radius: 8rpx; background: $c-rpt-violet-grid; overflow: hidden; }
  799. .emo-fill { height: 100%; border-radius: 8rpx; background: linear-gradient(90deg, $facade-violet-light, $facade-violet-deep); }
  800. /* ==================== 雷达图容器 ==================== */
  801. .radar-wrap {
  802. display: flex;
  803. flex-direction: column;
  804. align-items: center;
  805. margin-bottom: 8rpx;
  806. }
  807. /* ==================== 情绪总分行 ==================== */
  808. .emo-summary {
  809. background: $facade-violet-tint-2;
  810. border-radius: 16rpx;
  811. padding: 16rpx 20rpx;
  812. margin-bottom: 20rpx;
  813. }
  814. .emo-summary-text { font-size: calc(24rpx * var(--font-scale, 1)); color: $c-rpt-violet-text; }
  815. /* ==================== 体质健康 ==================== */
  816. .habit-row {
  817. display: flex;
  818. justify-content: space-between;
  819. align-items: center;
  820. padding: 14rpx 0;
  821. border-bottom: 1rpx solid $c-rpt-line;
  822. }
  823. .habit-row:last-child { border-bottom: none; }
  824. .habit-name { font-size: calc(26rpx * var(--font-scale, 1)); color: $facade-text-gray-700; }
  825. .habit-value { font-size: calc(26rpx * var(--font-scale, 1)); color: $dim-wisdom-deep; font-weight: 600; }
  826. /* ==================== 基本信息 ==================== */
  827. .info-grid { display: flex; flex-wrap: wrap; }
  828. .info-cell {
  829. width: 33.33%; display: flex; flex-direction: column; align-items: center;
  830. margin-bottom: 16rpx;
  831. }
  832. .info-value { font-size: calc(36rpx * var(--font-scale, 1)); font-weight: 700; color: $facade-text-gray-800; }
  833. .info-unit { font-size: calc(20rpx * var(--font-scale, 1)); font-weight: 400; color: $facade-text-gray-400; margin-left: 4rpx; }
  834. .info-name { font-size: calc(22rpx * var(--font-scale, 1)); color: $facade-text-gray-400; margin-top: 6rpx; }
  835. /* ==================== 成长建议/评语 ==================== */
  836. .advice-content {
  837. font-size: calc(26rpx * var(--font-scale, 1)); color: $c-rpt-body; line-height: 1.8;
  838. white-space: pre-wrap; word-break: break-all;
  839. }
  840. .advice-clamped {
  841. max-height: 320rpx; overflow: hidden;
  842. -webkit-mask-image: linear-gradient(180deg, $c-rpt-mask-ink 60%, transparent 100%);
  843. mask-image: linear-gradient(180deg, $c-rpt-mask-ink 60%, transparent 100%);
  844. }
  845. .advice-toggle { text-align: center; margin-top: 16rpx; }
  846. .advice-toggle-text { font-size: calc(24rpx * var(--font-scale, 1)); color: $dim-wisdom; font-weight: 500; }
  847. .foot-note { text-align: center; padding: 18rpx 0 8rpx; }
  848. .foot-note-text { font-size: calc(20rpx * var(--font-scale, 1)); color: $c-rpt-foot; }
  849. /* ==================== 其他 ==================== */
  850. .loading-wrap { display: flex; justify-content: center; padding: 140rpx 0; }
  851. .loading-text { font-size: calc(28rpx * var(--font-scale, 1)); color: $facade-text-muted; }
  852. .empty-wrap { display: flex; justify-content: center; padding: 140rpx 0; }
  853. .empty-text { font-size: calc(28rpx * var(--font-scale, 1)); color: $facade-text-muted; }
  854. .bottom-spacer { height: 60rpx; }
  855. </style>