index.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  1. <template>
  2. <view class="wisdom-container">
  3. <!-- Tabbar 切换过渡页 -->
  4. <tab-transition v-if="showTabTransition" dimCode="wisdom" ref="tabTransition" @close="showTabTransition = false" />
  5. <!-- 品牌定位语(登录前显示) -->
  6. <view class="brand-strap" v-if="!isLoggedIn">
  7. <text class="brand-strap-text">提升全家认知能力与学习效率</text>
  8. </view>
  9. <!-- 2. 学习能力评估图(始终显示,无数据时仅显示人群平均值) -->
  10. <view class="section">
  11. <view class="section-header">
  12. <text class="section-title">学习能力评估</text>
  13. <text class="section-sub">通过测评了解全家认知能力,找出可以提升的方向</text>
  14. <text class="avg-badge" v-if="!cognitiveReport">同龄平均值 · 完成认知测评后显示个人数据</text>
  15. <text class="section-more" v-if="isLoggedIn" @click="goCognitiveReport">查看详情 ›</text>
  16. </view>
  17. <RadarChart
  18. :dimensions="cognitiveDimensions"
  19. :scores="cognitiveScores"
  20. :avg-scores="cognitiveAvgScores"
  21. :childName="activeChildName"
  22. fillColor="#6366F1"
  23. gridColor="#E0E7FF"
  24. labelColor="#3730A3" />
  25. </view>
  26. <!-- 家庭成员选择条 -->
  27. <FamilyMemberStrip
  28. v-if="currentView === 'self' && isLoggedIn"
  29. :members="familyMembersVisible"
  30. :selectedMemberId="selectedMemberId"
  31. @select="onFamilyMemberSelect"
  32. @removed="loadFamilyMembersVisible" />
  33. <!-- 游客引导语 -->
  34. <view class="monthly-guidance" v-if="!isLoggedIn">
  35. <text class="guidance-icon">⚡</text>
  36. <text class="guidance-text">{{ monthlyGuidance }}</text>
  37. </view>
  38. <!-- 4. 五维能量条(登录后) -->
  39. <FamilyEnergyBar
  40. v-if="isLoggedIn"
  41. dimensionCode="wisdom"
  42. :sandboxData="sandboxData"
  43. :dualDimension="dualDimension" />
  44. <!-- 认知七维 -->
  45. <dimension-sub-dims
  46. v-if="isLoggedIn && wisdomSubDims.length > 0"
  47. title="⚡ 认知七维"
  48. subtitle="学习能力的七个核心方面"
  49. accent-color="#6366F1"
  50. :dims="wisdomSubDims" />
  51. <!-- 学习解读 -->
  52. <view class="section score-explain-card" v-if="isLoggedIn && currentView === 'self' && dualDimension">
  53. <view class="explain-header">
  54. <text class="explain-icon">{{ (dualDimension.primary && dualDimension.primary.score || 0) >= 80 ? '✅' : (dualDimension.primary && dualDimension.primary.score || 0) >= 60 ? '⚠️' : '❗' }}</text>
  55. <text class="explain-title">学习解读</text>
  56. </view>
  57. <text class="explain-text">{{ (dualDimension.primary && dualDimension.primary.score || 0) >= 80 ? '学习能力良好,继续保持学习节奏。' : (dualDimension.primary && dualDimension.primary.score || 0) >= 60 ? '学习能力一般,建议多做认知训练。' : '学习能力需要提升,建议进行专业评估。' }}</text>
  58. </view>
  59. <!-- ===== 认知强项与提升空间 ===== -->
  60. <view class="section cognitive-insight" v-if="isLoggedIn && cognitiveReport">
  61. <view class="section-header">
  62. <text class="section-title">📈 认知强项与提升</text>
  63. </view>
  64. <template v-if="cogStrengths.length > 0 || cogImproves.length > 0">
  65. <view class="insight-group" v-if="cogStrengths.length > 0">
  66. <text class="insight-group-title">💪 你的强项</text>
  67. <view class="insight-item" v-for="(item, idx) in cogStrengths" :key="'s' + idx">
  68. <text class="insight-item-name">{{ item.label }}</text>
  69. <text class="insight-item-score">{{ item.score }}分</text>
  70. <text class="insight-item-tag tag-strong">强项</text>
  71. </view>
  72. </view>
  73. <view class="insight-group" v-if="cogImproves.length > 0">
  74. <text class="insight-group-title">🌱 提升空间</text>
  75. <view class="insight-item" v-for="(item, idx) in cogImproves" :key="'i' + idx">
  76. <text class="insight-item-name">{{ item.label }}</text>
  77. <text class="insight-item-score">{{ item.score }}分</text>
  78. <text class="insight-item-tag tag-improve">待提升</text>
  79. </view>
  80. </view>
  81. <view class="insight-tip" v-if="cogStrengths.length > 0 && cogImproves.length > 0">
  82. <text class="insight-tip-text">强项保持,薄弱维建议通过训练中心针对性提升</text>
  83. </view>
  84. </template>
  85. <view class="insight-empty" v-else-if="!cognitiveReport || !hasCognitiveScore">
  86. <text class="insight-empty-text">完成认知测评,查看强项与提升建议</text>
  87. <button class="insight-btn" @click="goCognitiveReport">去测评</button>
  88. </view>
  89. </view>
  90. <!-- ===== DAN 报告(登录后) ===== -->
  91. <view class="section" v-if="isLoggedIn">
  92. <view class="section-header">
  93. <text class="section-title">&#x1F4CA; DAN 报告</text>
  94. <text class="section-more" @click="goDanUpload">上传 +</text>
  95. </view>
  96. <view class="dan-card" v-for="report in danReports" :key="report.id" @click="viewDanReport(report)">
  97. <view class="dan-card-header">
  98. <text class="dan-report-date">{{ formatDate(report.assessmentDate) }}</text>
  99. <text :class="['dan-status', report.draftStatus === 'confirmed' ? 'confirmed' : 'pending']">
  100. {{ report.draftStatus === 'confirmed' ? '已确认' : '待确认' }}
  101. </text>
  102. </view>
  103. <text class="dan-report-desc">DAN B4 智维度测评报告</text>
  104. </view>
  105. <view class="dan-empty" v-if="danReports.length === 0">
  106. <text class="dan-empty-text">暂无 DAN 报告,点击上方「上传 +」上传测评报告</text>
  107. </view>
  108. </view>
  109. <!-- 肠胃与认知卡片(有菌群报告显示认知指标,无报告引导上传) -->
  110. <view class="section gut-cognition-card" v-if="isLoggedIn">
  111. <view class="section-header">
  112. <text class="section-title">🦠 肠胃与认知</text>
  113. </view>
  114. <text class="gut-cog-subtitle">肠脑轴 · 肠道菌群,影响学习与思维</text>
  115. <template v-if="cognitionGutIndicators && cognitionGutIndicators.length > 0">
  116. <view class="gut-indicator-list">
  117. <view class="gut-indicator-item" v-for="ind in cognitionGutIndicators" :key="ind.id">
  118. <view class="gut-indicator-left">
  119. <text class="gut-indicator-name">{{ ind.indicatorName || ind.name }}</text>
  120. </view>
  121. <view class="gut-indicator-bar-track">
  122. <view class="gut-indicator-bar-fill" :style="{ width: (ind.value || 0) + '%', background: indicatorColor(ind.status) }"></view>
  123. </view>
  124. <text class="gut-indicator-value">{{ ind.value }}{{ ind.unit || '%' }}</text>
  125. <text :class="['gut-indicator-status', 'status-' + (ind.status || 'normal')]">{{ statusLabel(ind.status) }}</text>
  126. </view>
  127. </view>
  128. </template>
  129. <view class="gut-empty" v-else>
  130. <text class="gut-empty-icon">📄</text>
  131. <text class="gut-empty-text">上传菌群报告,查看认知相关指标</text>
  132. <button class="gut-upload-btn" @click="goReportUpload">去上传</button>
  133. </view>
  134. </view>
  135. <!-- 6. 功能入口 -->
  136. <view class="func-section" v-if="sectionVisible('func_entries')">
  137. <view class="func-grid">
  138. <view class="func-item" v-for="item in funcList" :key="item.label" @click="onFuncClick(item)">
  139. <view class="func-icon-wrap">
  140. <text class="func-icon">{{ item.icon }}</text>
  141. </view>
  142. <text class="func-label">{{ item.label }}</text>
  143. </view>
  144. </view>
  145. </view>
  146. <!-- 11. 快捷操作按钮 -->
  147. <view class="section quick-actions" v-if="isLoggedIn">
  148. <view class="action-btn" @click="goCognitiveReport">
  149. <text class="action-icon">📊</text>
  150. <text class="action-text">认知报告</text>
  151. </view>
  152. <view class="action-btn" @click="goTrainingHub">
  153. <text class="action-icon">🧠</text>
  154. <text class="action-text">认知训练</text>
  155. </view>
  156. <view class="action-btn" @click="goAssessment">
  157. <text class="action-icon">📋</text>
  158. <text class="action-text">测评预约</text>
  159. </view>
  160. <view class="action-btn" @click="goDanUpload">
  161. <text class="action-icon">📄</text>
  162. <text class="action-text">上传报告</text>
  163. </view>
  164. </view>
  165. <!-- 智维度介绍卡片(登录后显示) -->
  166. <DimensionIntroCard dimCode="wisdom" v-if="isLoggedIn" learn-more-url="/pages/wisdom-detail/dimension-intro" />
  167. <!-- 底部占位 -->
  168. <view class="bottom-spacer"></view>
  169. <FloatingAvatar />
  170. </view>
  171. </template>
  172. <script>
  173. import nav from '../../utils/nav'
  174. import TabTransition from '../../components/tab-transition.vue'
  175. import RadarChart from '../../components/RadarChart.vue'
  176. import DimensionSubDims from '../../components/DimensionSubDims.vue'
  177. import FamilyEnergyBar from '../../components/FamilyEnergyBar.vue'
  178. import FloatingAvatar from '../../components/AIFloatingAvatar.vue'
  179. import FamilyMemberStrip from '../../components/FamilyMemberStrip.vue'
  180. import DimensionIntroCard from '../../components/DimensionIntroCard.vue'
  181. import { getVisibleSections, getChildren, getFamilyEnergySandbox, getEnergySandbox, getAssessmentLatestResult, getDanReportByChild, getGutCognitionIndicators } from '../../utils/api.js'
  182. import { parseDate } from '../../utils/format.js'
  183. export default {
  184. components: { TabTransition, RadarChart, FamilyEnergyBar, DimensionSubDims, FloatingAvatar, FamilyMemberStrip, DimensionIntroCard },
  185. data() {
  186. return {
  187. isLoggedIn: false,
  188. role: null,
  189. showTabTransition: true,
  190. activeChildId: null,
  191. activeChildName: '',
  192. userName: '',
  193. children: [],
  194. familyMembersVisible: [],
  195. selectedMemberId: null,
  196. wisdomSubDims: [],
  197. sandboxData: null,
  198. currentView: 'self', // 'self' | 'family'
  199. dualDimension: null,
  200. visibleSections: [],
  201. cognitiveReport: null,
  202. articles: [],
  203. /** Mock 平均值(7维认知):感知/专注/记忆/逻辑/空间/加工速度/成长型思维 */
  204. cognitiveAvgScores: [70, 65, 72, 68, 66, 71, 70],
  205. danReports: [],
  206. cognitionGutIndicators: [],
  207. funcList: [
  208. { icon: '\u{1F4CA}', label: '认知报告', needLogin: true, page: '/pages/wisdom-detail/cognitive-report' },
  209. { icon: '\u{1F9E0}', label: '训练中心', needLogin: true, page: '/pages/wisdom-detail/training-hub' },
  210. { icon: '\u{1F3AF}', label: '测评预约', needLogin: false, page: '/pages/assessment/apply' },
  211. { icon: '\u{1F4D6}', label: '阅读天地', needLogin: false, page: '/pages/mind-extra/articles' }
  212. ]
  213. }
  214. },
  215. computed: {
  216. wisdomArticles: function() {
  217. if (!this.articles || this.articles.length === 0) return []
  218. var result = []
  219. for (var i = 0; i < this.articles.length; i++) {
  220. var a = this.articles[i]
  221. if (a.relatedDimensions && a.relatedDimensions.indexOf('wisdom') !== -1) {
  222. result.push(a)
  223. }
  224. }
  225. if (result.length === 0) return this.articles.slice(0, 5)
  226. return result.slice(0, 5)
  227. },
  228. cognitiveDimensions: function() {
  229. return [
  230. { label: '感知能力', key: 'perceptionScore' },
  231. { label: '专注力', key: 'focusScore' },
  232. { label: '记忆力', key: 'memoryScore' },
  233. { label: '逻辑思维', key: 'logicScore' },
  234. { label: '空间思维', key: 'spatialScore' },
  235. { label: '加工速度', key: 'processingSpeedScore' },
  236. { label: '成长型思维', key: 'wisdomGrowthMindset' }
  237. ]
  238. },
  239. cognitiveScores: function() {
  240. if (!this.cognitiveReport) return []
  241. var dims = this.cognitiveDimensions
  242. var scores = []
  243. // 解析 structuredAnalysis 中的成长型思维
  244. var growthMindset = 0
  245. if (this.cognitiveReport.structuredAnalysis) {
  246. try {
  247. var analysis = JSON.parse(this.cognitiveReport.structuredAnalysis)
  248. if (analysis && analysis.extra && analysis.extra.growthMindset) {
  249. var gm = analysis.extra.growthMindset
  250. var vals = Object.values(gm)
  251. if (vals.length > 0) growthMindset = parseInt(vals[0]) || 0
  252. }
  253. } catch (e) { /* ignore parse error */ }
  254. }
  255. for (var i = 0; i < dims.length; i++) {
  256. var key = dims[i].key
  257. if (key === 'wisdomGrowthMindset') {
  258. scores.push(growthMindset)
  259. } else {
  260. scores.push(this.cognitiveReport[key] || 0)
  261. }
  262. }
  263. return scores
  264. },
  265. /** 认知测评是否已有有效得分(任一维度 > 0) */
  266. hasCognitiveScore: function() {
  267. if (!this.cognitiveReport) return false
  268. var dims = this.cognitiveDimensions
  269. for (var i = 0; i < dims.length; i++) {
  270. var key = dims[i].key
  271. var v = 0
  272. if (key === 'wisdomGrowthMindset') {
  273. v = this.cognitiveScores[this.cognitiveDimensions.length - 1] || 0
  274. } else {
  275. v = this.cognitiveReport[key] || 0
  276. }
  277. if (v > 0) return true
  278. }
  279. return false
  280. },
  281. /** 认知强项:得分 ≥75 的维度 */
  282. cogStrengths: function() {
  283. var dims = this.cognitiveDimensions
  284. var result = []
  285. for (var i = 0; i < dims.length; i++) {
  286. var score = this.cognitiveScores[i] || 0
  287. if (score >= 75) {
  288. result.push({ label: dims[i].label, score: score })
  289. }
  290. }
  291. return result
  292. },
  293. /** 认知提升空间:得分 <60 的维度 */
  294. cogImproves: function() {
  295. var dims = this.cognitiveDimensions
  296. var result = []
  297. for (var i = 0; i < dims.length; i++) {
  298. var score = this.cognitiveScores[i] || 0
  299. if (score > 0 && score < 60) {
  300. result.push({ label: dims[i].label, score: score })
  301. }
  302. }
  303. return result
  304. },
  305. /** 每月引导语 */
  306. monthlyGuidance: function() {
  307. var month = new Date().getMonth()
  308. var messages = [
  309. '一月:新年新目标,制定学习计划',
  310. '二月:春节收获知识,拓展认知边界',
  311. '三月:植树节到,播种智慧种子',
  312. '四月:清明踏青,激发创造力',
  313. '五月:劳动节后,专注能力提升',
  314. '六月:考试季,科学备考策略',
  315. '七月:暑期黄金期,查漏补缺',
  316. '八月:开学准备,提前规划学习',
  317. '九月:新学期,设定学习目标',
  318. '十月:国庆假期,阅读充电',
  319. '十一月:年终冲刺,巩固知识',
  320. '十二月:年度总结,规划来年学习'
  321. ]
  322. return messages[month] || messages[0]
  323. }
  324. },
  325. onShow() {
  326. this.showTabTransition = true
  327. var token = uni.getStorageSync('token')
  328. this.isLoggedIn = !!token
  329. if (this.isLoggedIn) {
  330. this.role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  331. this.userName = uni.getStorageSync('nickname') || uni.getStorageSync('userName') || '家长'
  332. }
  333. this.loadSectionConfig()
  334. if (this.isLoggedIn) {
  335. this.loadChildren()
  336. this.loadFamilyMembersVisible()
  337. this.loadCognitiveReport()
  338. this.loadDanReports()
  339. this.loadGutCognitionData()
  340. }
  341. // 游客也能浏览文章
  342. this._watchPageReady()
  343. },
  344. methods: {
  345. onFamilyMemberSelect: function(member) {
  346. this.selectedMemberId = member.id
  347. },
  348. loadSectionConfig: function() {
  349. var baseSections = ['func_entries', 'recommended_reading']
  350. if (!uni.getStorageSync('token')) {
  351. this.visibleSections = baseSections
  352. return
  353. }
  354. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  355. var self = this
  356. getVisibleSections({ pageKey: 'wisdom', role: role }).then(function(res) {
  357. if (res.code === 200 && res.data) {
  358. var keys = res.data.map(function(s) { return s.sectionKey })
  359. var merged = baseSections.slice()
  360. keys.forEach(function(k) { if (merged.indexOf(k) === -1) merged.push(k) })
  361. self.visibleSections = merged
  362. }
  363. }).catch(function(e) {
  364. self.visibleSections = ['func_entries', 'recommended_reading']
  365. })
  366. },
  367. loadChildren: function() {
  368. var self = this
  369. getChildren().then(function(res) {
  370. if (res.code === 200 && res.data) {
  371. self.children = res.data
  372. if (self.children.length > 0) {
  373. var activeId = uni.getStorageSync('currentChildId')
  374. if (activeId) {
  375. for (var i = 0; i < self.children.length; i++) {
  376. if (self.children[i].id == activeId) {
  377. self.activeChildId = activeId
  378. self.activeChildName = self.children[i].nickname || self.children[i].name || ''
  379. break
  380. }
  381. }
  382. }
  383. // Fallback: 首次进入或未选孩子时,默认选第一个孩子以加载认知数据(仅本地状态,不触发全局切换)
  384. if (!self.activeChildId && self.children.length > 0) {
  385. self.activeChildId = self.children[0].id
  386. self.activeChildName = self.children[0].nickname || self.children[0].name || ''
  387. }
  388. }
  389. // Load cognitive report if activeChildId is available
  390. if (self.activeChildId) {
  391. self.loadCognitiveReport()
  392. }
  393. }
  394. }).catch(function(e) {})
  395. },
  396. loadFamilyMembersVisible: function() {
  397. var self = this
  398. getFamilyEnergySandbox().then(function(res) {
  399. if (res && res.data) {
  400. self.sandboxData = res.data.sandboxData || null
  401. self.dualDimension = res.data.dualDimension || null
  402. if (res.data.members) {
  403. self.familyMembersVisible = res.data.members
  404. }
  405. }
  406. }).catch(function(e) {})
  407. },
  408. loadCognitiveReport: function() {
  409. var self = this
  410. var memberId = this.activeChildId
  411. if (!memberId) return
  412. getAssessmentLatestResult(memberId).then(function(res) {
  413. if (res.code === 200 && res.data) {
  414. self.cognitiveReport = res.data
  415. self.wisdomSubDims = (function() { var r = self.cognitiveReport || {}; return [{label:'感知能力', score:r.perceptionScore||0, desc:'通过感官获取信息'}, {label:'专注力', score:r.focusScore||0, desc:'保持注意力集中'}, {label:'记忆力', score:r.memoryScore||0, desc:'记忆和回忆信息'}, {label:'逻辑思维', score:r.logicScore||0, desc:'分析和推理能力'}, {label:'空间思维', score:r.spatialScore||0, desc:'操作空间关系'}, {label:'加工速度', score:r.processingSpeedScore||0, desc:'快速处理信息'}, {label:'成长型思维', score:r.growthMindset||0, desc:'相信能力可提升'}]; })();
  416. }
  417. }).catch(function(e) {})
  418. },
  419. onChildChanged: function(memberId) {
  420. this.activeChildId = memberId
  421. // FIX: 同步提交到 Vuex store
  422. this.$store.commit('switchToChild', memberId)
  423. for (var i = 0; i < this.children.length; i++) {
  424. if (this.children[i].id == memberId) {
  425. this.activeChildName = this.children[i].nickname || this.children[i].name || ''
  426. break
  427. }
  428. }
  429. this.loadFamilyMembersVisible()
  430. this.loadCognitiveReport()
  431. this.loadDanReports()
  432. },
  433. sectionVisible: function(key) {
  434. return this.visibleSections.length === 0 || this.visibleSections.indexOf(key) !== -1
  435. },
  436. onFuncClick: function(item) {
  437. if (item.needLogin && !this.isLoggedIn) {
  438. uni.showModal({
  439. title: '提示',
  440. content: '请先登录后使用此功能',
  441. success: function(res) { if (res.confirm) uni.navigateTo({ url: '/pages/login/login' }) }
  442. })
  443. return
  444. }
  445. if (item.page) {
  446. nav.goPage(item.page)
  447. }
  448. },
  449. scrollToSection: function(section) {},
  450. goCognitiveReport: function() {
  451. uni.navigateTo({ url: '/pages/wisdom-detail/cognitive-report' })
  452. },
  453. goTrainingHub: function() {
  454. uni.navigateTo({ url: '/pages/wisdom-detail/training-hub' })
  455. },
  456. goAssessment: function() {
  457. uni.navigateTo({ url: '/pages/assessment/apply' })
  458. },
  459. _watchPageReady() {
  460. var self = this
  461. var unwatch = this.$watch(function() {
  462. if (self.isLoggedIn) {
  463. return !!(self.cognitiveReport || self.sandboxData)
  464. } }, function(val) {
  465. if (val) {
  466. if (unwatch) unwatch()
  467. if (self.$refs.tabTransition) self.$refs.tabTransition.markReady()
  468. }
  469. })
  470. },
  471. // ===== DAN 报告 =====
  472. loadDanReports: function() {
  473. var self = this
  474. var memberId = self.activeChildId
  475. if (!memberId) return
  476. getDanReportByChild(memberId, 'wisdom').then(function(res) {
  477. if (res.code === 200 && res.data) {
  478. self.danReports = res.data
  479. }
  480. }).catch(function() {})
  481. },
  482. // ===== 肠胃与认知(肠脑轴认知指标) =====
  483. loadGutCognitionData: function() {
  484. var self = this
  485. var memberId = self.activeChildId
  486. if (!memberId) return
  487. getGutCognitionIndicators(memberId).then(function(res) {
  488. if (res.code === 200 && res.data) {
  489. var list = res.data
  490. self.cognitionGutIndicators = Array.isArray(list) ? list.slice(0, 6) : []
  491. } else {
  492. self.cognitionGutIndicators = []
  493. }
  494. }).catch(function() {
  495. self.cognitionGutIndicators = []
  496. })
  497. },
  498. indicatorColor: function(status) {
  499. if (status === 'abnormal' || status === '偏高' || status === '偏低' || status === '过高' || status === '缺乏') return '#EF4444'
  500. if (status === 'warning' || status === '注意' || status === '不足') return '#F59E0B'
  501. return '#10B981'
  502. },
  503. statusLabel: function(status) {
  504. if (status === 'normal') return '正常'
  505. if (status === 'abnormal') return '异常'
  506. if (status === 'warning') return '警讯'
  507. if (status === '过高' || status === '过多') return '偏高'
  508. if (status === '缺乏' || status === '不足') return '偏低'
  509. return status || '正常'
  510. },
  511. goReportUpload: function() {
  512. uni.navigateTo({ url: '/pages/health/report-upload' })
  513. },
  514. goDanUpload: function() {
  515. uni.navigateTo({ url: '/pages/dan-assessment/report-upload' })
  516. },
  517. viewDanReport: function(report) {
  518. var reportId = report.sourceReportId || report.id
  519. uni.navigateTo({ url: '/pages/dan-assessment/report-result?reportId=' + reportId })
  520. },
  521. formatDate: function(dateStr) {
  522. if (!dateStr) return ''
  523. var d = parseDate(dateStr)
  524. if (!d) return ''
  525. return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
  526. }
  527. }
  528. }
  529. </script>
  530. .view-toggle {
  531. display: flex;
  532. margin: 20rpx 30rpx;
  533. background: rgba(255,255,255,0.12);
  534. border-radius: 12rpx;
  535. padding: 6rpx;
  536. }
  537. .toggle-btn {
  538. flex: 1;
  539. text-align: center;
  540. padding: 12rpx 0;
  541. border-radius: 8rpx;
  542. font-size: 26rpx;
  543. color: rgba(255,255,255,0.65);
  544. }
  545. .toggle-btn.active {
  546. background: rgba(255,255,255,0.22);
  547. color: #fff;
  548. font-weight: 600;
  549. }
  550. /* 页面说明 */
  551. .section-sub {
  552. font-size: 22rpx;
  553. color: rgba(255,255,255,0.55);
  554. margin-top: 6rpx;
  555. display: block;
  556. }
  557. /* 得分解读卡片 */
  558. .score-explain-card {
  559. margin: 20rpx 30rpx;
  560. padding: 28rpx 24rpx;
  561. background: rgba(255,255,255,0.1);
  562. border-radius: 20rpx;
  563. border: 1rpx solid rgba(255,255,255,0.15);
  564. }
  565. .explain-header {
  566. display: flex;
  567. align-items: center;
  568. margin-bottom: 14rpx;
  569. }
  570. .explain-icon {
  571. font-size: 36rpx;
  572. margin-right: 10rpx;
  573. }
  574. .explain-title {
  575. font-size: 28rpx;
  576. font-weight: 600;
  577. color: #fff;
  578. }
  579. .explain-text {
  580. font-size: 26rpx;
  581. color: rgba(255,255,255,0.8);
  582. line-height: 1.6;
  583. }
  584. /* 子维度评分卡 */
  585. .subdim-section {
  586. margin: 20rpx 30rpx;
  587. }
  588. .subdim-cards {
  589. background: rgba(255,255,255,0.08);
  590. border-radius: 20rpx;
  591. overflow: hidden;
  592. border: 1rpx solid rgba(255,255,255,0.12);
  593. }
  594. .subdim-card {
  595. padding: 24rpx 28rpx;
  596. border-bottom: 1rpx solid rgba(255,255,255,0.08);
  597. }
  598. .subdim-card:last-child {
  599. border-bottom: none;
  600. }
  601. .subdim-card-left {
  602. display: flex;
  603. justify-content: space-between;
  604. align-items: center;
  605. margin-bottom: 12rpx;
  606. }
  607. .subdim-card-label {
  608. font-size: 28rpx;
  609. font-weight: 600;
  610. color: #fff;
  611. }
  612. .subdim-card-desc {
  613. font-size: 22rpx;
  614. color: rgba(255,255,255,0.5);
  615. margin-top: 4rpx;
  616. }
  617. .subdim-card-right {
  618. text-align: right;
  619. }
  620. .subdim-card-score {
  621. font-size: 36rpx;
  622. font-weight: 700;
  623. }
  624. .subdim-bar-track {
  625. height: 8rpx;
  626. background: rgba(255,255,255,0.1);
  627. border-radius: 4rpx;
  628. overflow: hidden;
  629. margin-top: 8rpx;
  630. }
  631. .subdim-bar-fill {
  632. height: 100%;
  633. border-radius: 4rpx;
  634. transition: width 0.5s ease;
  635. }
  636. <style scoped>
  637. .wisdom-container {
  638. min-height: 100vh;
  639. background: #f5f7fa;
  640. padding-bottom: 120rpx;
  641. }
  642. .func-section {
  643. margin: 20rpx 20rpx 0;
  644. }
  645. .func-grid {
  646. background: #fff;
  647. border-radius: 24rpx;
  648. padding: 30rpx 16rpx;
  649. display: flex;
  650. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  651. }
  652. .func-item {
  653. flex: 1;
  654. display: flex;
  655. flex-direction: column;
  656. align-items: center;
  657. }
  658. .func-item:active {
  659. opacity: 0.7;
  660. }
  661. .func-icon-wrap {
  662. width: 88rpx;
  663. height: 88rpx;
  664. border-radius: 50%;
  665. background: #FFF8E1;
  666. display: flex;
  667. align-items: center;
  668. justify-content: center;
  669. margin-bottom: 10rpx;
  670. }
  671. .func-icon {
  672. font-size: 40rpx;
  673. }
  674. .func-label {
  675. font-size: 24rpx;
  676. color: #333;
  677. font-weight: 500;
  678. }
  679. /* ===== Section ===== */
  680. .section {
  681. margin: 20rpx 20rpx;
  682. }
  683. .section-header {
  684. display: flex;
  685. justify-content: space-between;
  686. align-items: center;
  687. margin-bottom: 20rpx;
  688. }
  689. .section-title {
  690. font-size: 30rpx;
  691. font-weight: bold;
  692. color: #333;
  693. }
  694. .section-more {
  695. font-size: 24rpx;
  696. color: #999;
  697. }
  698. /* ===== 快捷操作按钮 ===== */
  699. .quick-actions {
  700. display: flex;
  701. flex-direction: row;
  702. flex-wrap: wrap;
  703. justify-content: space-between;
  704. }
  705. .action-btn {
  706. width: 48%;
  707. background: #fff;
  708. border-radius: 16rpx;
  709. padding: 24rpx 0;
  710. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  711. display: flex;
  712. flex-direction: column;
  713. align-items: center;
  714. margin-bottom: 20rpx;
  715. }
  716. .action-btn:active {
  717. opacity: 0.8;
  718. }
  719. .action-icon {
  720. font-size: 40rpx;
  721. margin-bottom: 10rpx;
  722. }
  723. .action-text {
  724. font-size: 26rpx;
  725. color: #333;
  726. font-weight: 500;
  727. }
  728. /* ===== 底部占位 ===== */
  729. .bottom-spacer {
  730. height: 120rpx;
  731. }
  732. /* DAN 报告卡片 */
  733. .dan-card {
  734. background: #fff;
  735. border-radius: 16rpx;
  736. padding: 24rpx;
  737. margin-bottom: 16rpx;
  738. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  739. }
  740. .dan-card-header {
  741. display: flex;
  742. justify-content: space-between;
  743. align-items: center;
  744. margin-bottom: 12rpx;
  745. }
  746. .dan-report-date {
  747. font-size: 26rpx;
  748. color: #666;
  749. }
  750. .dan-status {
  751. font-size: 22rpx;
  752. padding: 4rpx 16rpx;
  753. border-radius: 8rpx;
  754. }
  755. .dan-status.confirmed {
  756. background: #D1FAE5;
  757. color: #065F46;
  758. }
  759. .dan-status.pending {
  760. background: #FEF3C7;
  761. color: #92400E;
  762. }
  763. .dan-report-desc {
  764. font-size: 28rpx;
  765. color: #333;
  766. font-weight: 500;
  767. margin-bottom: 12rpx;
  768. display: block;
  769. }
  770. .dan-card-footer {
  771. text-align: right;
  772. }
  773. .dan-view-link {
  774. font-size: 26rpx;
  775. color: #6366F1;
  776. }
  777. .dan-empty {
  778. background: #fff;
  779. border-radius: 16rpx;
  780. padding: 40rpx 24rpx;
  781. text-align: center;
  782. }
  783. .dan-empty-text {
  784. font-size: 24rpx;
  785. color: #999;
  786. }
  787. .avg-badge {
  788. font-size: 20rpx;
  789. color: #94A3B8;
  790. margin-left: 12rpx;
  791. }
  792. /* 品牌定位语 */
  793. .brand-strap {
  794. margin: 16rpx 30rpx 0;
  795. padding: 20rpx 28rpx;
  796. background: linear-gradient(135deg, #F0F0FF, rgba(99,102,241,0.12));
  797. border-radius: 16rpx;
  798. border-left: 4rpx solid #6366F1;
  799. }
  800. .brand-strap-text {
  801. font-size: 26rpx;
  802. color: #3730A3;
  803. font-weight: 500;
  804. }
  805. /* 每月引导语 */
  806. .monthly-guidance {
  807. margin: 16rpx 30rpx 0;
  808. padding: 20rpx 28rpx;
  809. background: linear-gradient(135deg, #F0F0FF, rgba(99,102,241,0.08));
  810. border-radius: 16rpx;
  811. border-left: 4rpx solid #6366F1;
  812. display: flex;
  813. align-items: center;
  814. gap: 12rpx;
  815. }
  816. .guidance-icon { font-size: 32rpx; }
  817. .guidance-text {
  818. font-size: 26rpx;
  819. color: #3730A3;
  820. font-weight: 500;
  821. }
  822. /* ===== 肠胃与认知卡片 ===== */
  823. .gut-cog-subtitle {
  824. font-size: 24rpx;
  825. color: #6366F1;
  826. margin-bottom: 16rpx;
  827. display: block;
  828. }
  829. .gut-indicator-list {
  830. display: flex;
  831. flex-direction: column;
  832. gap: 12rpx;
  833. }
  834. .gut-indicator-item {
  835. display: flex;
  836. align-items: center;
  837. gap: 12rpx;
  838. }
  839. .gut-indicator-left {
  840. width: 80rpx;
  841. flex-shrink: 0;
  842. }
  843. .gut-indicator-name {
  844. font-size: 22rpx;
  845. color: #666;
  846. }
  847. .gut-indicator-bar-track {
  848. flex: 1;
  849. height: 16rpx;
  850. background: #F0F0F0;
  851. border-radius: 8rpx;
  852. overflow: hidden;
  853. }
  854. .gut-indicator-bar-fill {
  855. height: 100%;
  856. border-radius: 8rpx;
  857. transition: width 0.3s;
  858. }
  859. .gut-indicator-value {
  860. font-size: 22rpx;
  861. color: #666;
  862. width: 60rpx;
  863. text-align: right;
  864. }
  865. .gut-indicator-status {
  866. font-size: 20rpx;
  867. padding: 2rpx 12rpx;
  868. border-radius: 10rpx;
  869. width: 60rpx;
  870. text-align: center;
  871. }
  872. .status-normal {
  873. background: #D1FAE5;
  874. color: #059669;
  875. }
  876. .status-abnormal {
  877. background: #FEE2E2;
  878. color: #DC2626;
  879. }
  880. .status-warning {
  881. background: #FEF3C7;
  882. color: #D97706;
  883. }
  884. .gut-empty {
  885. display: flex;
  886. flex-direction: column;
  887. align-items: center;
  888. padding: 40rpx 0;
  889. }
  890. .gut-empty-icon {
  891. font-size: 56rpx;
  892. margin-bottom: 16rpx;
  893. }
  894. .gut-empty-text {
  895. font-size: 26rpx;
  896. color: #999;
  897. margin-bottom: 24rpx;
  898. }
  899. .gut-upload-btn {
  900. background: linear-gradient(135deg, #6366F1, #818CF8);
  901. color: #fff;
  902. font-size: 26rpx;
  903. font-weight: 600;
  904. border: none;
  905. border-radius: 40rpx;
  906. padding: 16rpx 64rpx;
  907. line-height: 1.6;
  908. margin: 0;
  909. }
  910. /* ===== 认知强项与提升卡片 ===== */
  911. .insight-group {
  912. margin-bottom: 16rpx;
  913. }
  914. .insight-group-title {
  915. font-size: 26rpx;
  916. font-weight: 600;
  917. color: #333;
  918. margin-bottom: 10rpx;
  919. display: block;
  920. }
  921. .insight-item {
  922. display: flex;
  923. align-items: center;
  924. padding: 12rpx 16rpx;
  925. background: #F8FAFF;
  926. border-radius: 12rpx;
  927. margin-bottom: 8rpx;
  928. }
  929. .insight-item-name {
  930. flex: 1;
  931. font-size: 26rpx;
  932. color: #333;
  933. }
  934. .insight-item-score {
  935. font-size: 24rpx;
  936. color: #666;
  937. margin-right: 12rpx;
  938. }
  939. .insight-item-tag {
  940. font-size: 20rpx;
  941. padding: 4rpx 16rpx;
  942. border-radius: 8rpx;
  943. font-weight: 500;
  944. }
  945. .insight-item-tag.tag-strong {
  946. background: #D1FAE5;
  947. color: #059669;
  948. }
  949. .insight-item-tag.tag-improve {
  950. background: #FEF3C7;
  951. color: #D97706;
  952. }
  953. .insight-tip {
  954. padding: 12rpx 16rpx;
  955. background: #EEF2FF;
  956. border-radius: 12rpx;
  957. }
  958. .insight-tip-text {
  959. font-size: 22rpx;
  960. color: #6366F1;
  961. }
  962. .insight-empty {
  963. display: flex;
  964. flex-direction: column;
  965. align-items: center;
  966. padding: 30rpx 0;
  967. }
  968. .insight-empty-text {
  969. font-size: 24rpx;
  970. color: #999;
  971. margin-bottom: 20rpx;
  972. }
  973. .insight-btn {
  974. background: linear-gradient(135deg, #6366F1, #818CF8);
  975. color: #fff;
  976. font-size: 26rpx;
  977. font-weight: 600;
  978. border: none;
  979. border-radius: 40rpx;
  980. padding: 14rpx 60rpx;
  981. line-height: 1.6;
  982. margin: 0;
  983. }
  984. </style>