index.vue 33 KB

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