index.vue 34 KB

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