index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  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="getInsightKey('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="getInsightKey('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. getInsightKey: function(prefix, idx) { return prefix + idx },
  346. onFamilyMemberSelect: function(member) {
  347. this.selectedMemberId = member.id
  348. },
  349. loadSectionConfig: function() {
  350. var baseSections = ['func_entries', 'recommended_reading']
  351. if (!uni.getStorageSync('token')) {
  352. this.visibleSections = baseSections
  353. return
  354. }
  355. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  356. var self = this
  357. getVisibleSections({ pageKey: 'wisdom', role: role }).then(function(res) {
  358. if (res.code === 200 && res.data) {
  359. var keys = res.data.map(function(s) { return s.sectionKey })
  360. var merged = baseSections.slice()
  361. keys.forEach(function(k) { if (merged.indexOf(k) === -1) merged.push(k) })
  362. self.visibleSections = merged
  363. }
  364. }).catch(function(e) {
  365. self.visibleSections = ['func_entries', 'recommended_reading']
  366. })
  367. },
  368. loadChildren: function() {
  369. var self = this
  370. getChildren().then(function(res) {
  371. if (res.code === 200 && res.data) {
  372. self.children = res.data
  373. if (self.children.length > 0) {
  374. var activeId = uni.getStorageSync('currentChildId')
  375. if (activeId) {
  376. for (var i = 0; i < self.children.length; i++) {
  377. if (self.children[i].id == activeId) {
  378. self.activeChildId = activeId
  379. self.activeChildName = self.children[i].nickname || self.children[i].name || ''
  380. break
  381. }
  382. }
  383. }
  384. // Fallback: 首次进入或未选孩子时,默认选第一个孩子以加载认知数据(仅本地状态,不触发全局切换)
  385. if (!self.activeChildId && self.children.length > 0) {
  386. self.activeChildId = self.children[0].id
  387. self.activeChildName = self.children[0].nickname || self.children[0].name || ''
  388. }
  389. }
  390. // Load cognitive report if activeChildId is available
  391. if (self.activeChildId) {
  392. self.loadCognitiveReport()
  393. }
  394. }
  395. }).catch(function(e) {})
  396. },
  397. loadFamilyMembersVisible: function() {
  398. var self = this
  399. getFamilyEnergySandbox().then(function(res) {
  400. if (res && res.data) {
  401. self.sandboxData = res.data.sandboxData || null
  402. self.dualDimension = res.data.dualDimension || null
  403. if (res.data.members) {
  404. self.familyMembersVisible = res.data.members
  405. }
  406. }
  407. }).catch(function(e) {})
  408. },
  409. loadCognitiveReport: function() {
  410. var self = this
  411. var memberId = this.activeChildId
  412. if (!memberId) return
  413. getAssessmentLatestResult(memberId).then(function(res) {
  414. if (res.code === 200 && res.data) {
  415. self.cognitiveReport = res.data
  416. 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:'相信能力可提升'}]; })();
  417. }
  418. }).catch(function(e) {})
  419. },
  420. onChildChanged: function(memberId) {
  421. this.activeChildId = memberId
  422. // FIX: 同步提交到 Vuex store
  423. this.$store.commit('switchToChild', memberId)
  424. for (var i = 0; i < this.children.length; i++) {
  425. if (this.children[i].id == memberId) {
  426. this.activeChildName = this.children[i].nickname || this.children[i].name || ''
  427. break
  428. }
  429. }
  430. this.loadFamilyMembersVisible()
  431. this.loadCognitiveReport()
  432. this.loadDanReports()
  433. },
  434. sectionVisible: function(key) {
  435. return this.visibleSections.length === 0 || this.visibleSections.indexOf(key) !== -1
  436. },
  437. onFuncClick: function(item) {
  438. if (item.needLogin && !this.isLoggedIn) {
  439. uni.showModal({
  440. title: '提示',
  441. content: '请先登录后使用此功能',
  442. success: function(res) { if (res.confirm) uni.navigateTo({ url: '/pages/login/login' }) }
  443. })
  444. return
  445. }
  446. if (item.page) {
  447. nav.goPage(item.page)
  448. }
  449. },
  450. scrollToSection: function(section) {},
  451. goCognitiveReport: function() {
  452. uni.navigateTo({ url: '/pages/wisdom-detail/cognitive-report' })
  453. },
  454. goTrainingHub: function() {
  455. uni.navigateTo({ url: '/pages/wisdom-detail/training-hub' })
  456. },
  457. goAssessment: function() {
  458. uni.navigateTo({ url: '/pages/assessment/apply' })
  459. },
  460. _watchPageReady() {
  461. var self = this
  462. var unwatch = this.$watch(function() {
  463. if (self.isLoggedIn) {
  464. return !!(self.cognitiveReport || self.sandboxData)
  465. } }, function(val) {
  466. if (val) {
  467. if (unwatch) unwatch()
  468. if (self.$refs.tabTransition) self.$refs.tabTransition.markReady()
  469. }
  470. })
  471. },
  472. // ===== DAN 报告 =====
  473. loadDanReports: function() {
  474. var self = this
  475. var memberId = self.activeChildId
  476. if (!memberId) return
  477. getDanReportByChild(memberId, 'wisdom').then(function(res) {
  478. if (res.code === 200 && res.data) {
  479. self.danReports = res.data
  480. }
  481. }).catch(function() {})
  482. },
  483. // ===== 肠胃与认知(肠脑轴认知指标) =====
  484. loadGutCognitionData: function() {
  485. var self = this
  486. var memberId = self.activeChildId
  487. if (!memberId) return
  488. getGutCognitionIndicators(memberId).then(function(res) {
  489. if (res.code === 200 && res.data) {
  490. var list = res.data
  491. self.cognitionGutIndicators = Array.isArray(list) ? list.slice(0, 6) : []
  492. } else {
  493. self.cognitionGutIndicators = []
  494. }
  495. }).catch(function() {
  496. self.cognitionGutIndicators = []
  497. })
  498. },
  499. indicatorColor: function(status) {
  500. if (status === 'abnormal' || status === '偏高' || status === '偏低' || status === '过高' || status === '缺乏') return '#EF4444'
  501. if (status === 'warning' || status === '注意' || status === '不足') return '#F59E0B'
  502. return '#10B981'
  503. },
  504. statusLabel: function(status) {
  505. if (status === 'normal') return '正常'
  506. if (status === 'abnormal') return '异常'
  507. if (status === 'warning') return '警讯'
  508. if (status === '过高' || status === '过多') return '偏高'
  509. if (status === '缺乏' || status === '不足') return '偏低'
  510. return status || '正常'
  511. },
  512. goReportUpload: function() {
  513. uni.navigateTo({ url: '/pages/health/report-upload' })
  514. },
  515. goDanUpload: function() {
  516. uni.navigateTo({ url: '/pages/dan-assessment/report-upload' })
  517. },
  518. viewDanReport: function(report) {
  519. var reportId = report.sourceReportId || report.id
  520. uni.navigateTo({ url: '/pages/dan-assessment/report-result?reportId=' + reportId })
  521. },
  522. formatDate: function(dateStr) {
  523. if (!dateStr) return ''
  524. var d = parseDate(dateStr)
  525. if (!d) return ''
  526. return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
  527. }
  528. }
  529. }
  530. </script>
  531. .view-toggle {
  532. display: flex;
  533. margin: 20rpx 30rpx;
  534. background: rgba(255,255,255,0.12);
  535. border-radius: 12rpx;
  536. padding: 6rpx;
  537. }
  538. .toggle-btn {
  539. flex: 1;
  540. text-align: center;
  541. padding: 12rpx 0;
  542. border-radius: 8rpx;
  543. font-size: 26rpx;
  544. color: rgba(255,255,255,0.65);
  545. }
  546. .toggle-btn.active {
  547. background: rgba(255,255,255,0.22);
  548. color: #fff;
  549. font-weight: 600;
  550. }
  551. /* 页面说明 */
  552. .section-sub {
  553. font-size: 22rpx;
  554. color: rgba(255,255,255,0.55);
  555. margin-top: 6rpx;
  556. display: block;
  557. }
  558. /* 得分解读卡片 */
  559. .score-explain-card {
  560. margin: 20rpx 30rpx;
  561. padding: 28rpx 24rpx;
  562. background: rgba(255,255,255,0.1);
  563. border-radius: 20rpx;
  564. border: 1rpx solid rgba(255,255,255,0.15);
  565. }
  566. .explain-header {
  567. display: flex;
  568. align-items: center;
  569. margin-bottom: 14rpx;
  570. }
  571. .explain-icon {
  572. font-size: 36rpx;
  573. margin-right: 10rpx;
  574. }
  575. .explain-title {
  576. font-size: 28rpx;
  577. font-weight: 600;
  578. color: #fff;
  579. }
  580. .explain-text {
  581. font-size: 26rpx;
  582. color: rgba(255,255,255,0.8);
  583. line-height: 1.6;
  584. }
  585. /* 子维度评分卡 */
  586. .subdim-section {
  587. margin: 20rpx 30rpx;
  588. }
  589. .subdim-cards {
  590. background: rgba(255,255,255,0.08);
  591. border-radius: 20rpx;
  592. overflow: hidden;
  593. border: 1rpx solid rgba(255,255,255,0.12);
  594. }
  595. .subdim-card {
  596. padding: 24rpx 28rpx;
  597. border-bottom: 1rpx solid rgba(255,255,255,0.08);
  598. }
  599. .subdim-card:last-child {
  600. border-bottom: none;
  601. }
  602. .subdim-card-left {
  603. display: flex;
  604. justify-content: space-between;
  605. align-items: center;
  606. margin-bottom: 12rpx;
  607. }
  608. .subdim-card-label {
  609. font-size: 28rpx;
  610. font-weight: 600;
  611. color: #fff;
  612. }
  613. .subdim-card-desc {
  614. font-size: 22rpx;
  615. color: rgba(255,255,255,0.5);
  616. margin-top: 4rpx;
  617. }
  618. .subdim-card-right {
  619. text-align: right;
  620. }
  621. .subdim-card-score {
  622. font-size: 36rpx;
  623. font-weight: 700;
  624. }
  625. .subdim-bar-track {
  626. height: 8rpx;
  627. background: rgba(255,255,255,0.1);
  628. border-radius: 4rpx;
  629. overflow: hidden;
  630. margin-top: 8rpx;
  631. }
  632. .subdim-bar-fill {
  633. height: 100%;
  634. border-radius: 4rpx;
  635. transition: width 0.5s ease;
  636. }
  637. <style scoped>
  638. .wisdom-container {
  639. min-height: 100vh;
  640. background: #f5f7fa;
  641. padding-bottom: 120rpx;
  642. }
  643. .func-section {
  644. margin: 20rpx 20rpx 0;
  645. }
  646. .func-grid {
  647. background: #fff;
  648. border-radius: 24rpx;
  649. padding: 30rpx 16rpx;
  650. display: flex;
  651. box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
  652. }
  653. .func-item {
  654. flex: 1;
  655. display: flex;
  656. flex-direction: column;
  657. align-items: center;
  658. }
  659. .func-item:active {
  660. opacity: 0.7;
  661. }
  662. .func-icon-wrap {
  663. width: 88rpx;
  664. height: 88rpx;
  665. border-radius: 50%;
  666. background: #FFF8E1;
  667. display: flex;
  668. align-items: center;
  669. justify-content: center;
  670. margin-bottom: 10rpx;
  671. }
  672. .func-icon {
  673. font-size: 40rpx;
  674. }
  675. .func-label {
  676. font-size: 24rpx;
  677. color: #333;
  678. font-weight: 500;
  679. }
  680. /* ===== Section ===== */
  681. .section {
  682. margin: 20rpx 20rpx;
  683. }
  684. .section-header {
  685. display: flex;
  686. justify-content: space-between;
  687. align-items: center;
  688. margin-bottom: 20rpx;
  689. }
  690. .section-title {
  691. font-size: 30rpx;
  692. font-weight: bold;
  693. color: #333;
  694. }
  695. .section-more {
  696. font-size: 24rpx;
  697. color: #999;
  698. }
  699. /* ===== 快捷操作按钮 ===== */
  700. .quick-actions {
  701. display: flex;
  702. flex-direction: row;
  703. flex-wrap: wrap;
  704. justify-content: space-between;
  705. }
  706. .action-btn {
  707. width: 48%;
  708. background: #fff;
  709. border-radius: 16rpx;
  710. padding: 24rpx 0;
  711. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  712. display: flex;
  713. flex-direction: column;
  714. align-items: center;
  715. margin-bottom: 20rpx;
  716. }
  717. .action-btn:active {
  718. opacity: 0.8;
  719. }
  720. .action-icon {
  721. font-size: 40rpx;
  722. margin-bottom: 10rpx;
  723. }
  724. .action-text {
  725. font-size: 26rpx;
  726. color: #333;
  727. font-weight: 500;
  728. }
  729. /* ===== 底部占位 ===== */
  730. .bottom-spacer {
  731. height: 120rpx;
  732. }
  733. /* DAN 报告卡片 */
  734. .dan-card {
  735. background: #fff;
  736. border-radius: 16rpx;
  737. padding: 24rpx;
  738. margin-bottom: 16rpx;
  739. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  740. }
  741. .dan-card-header {
  742. display: flex;
  743. justify-content: space-between;
  744. align-items: center;
  745. margin-bottom: 12rpx;
  746. }
  747. .dan-report-date {
  748. font-size: 26rpx;
  749. color: #666;
  750. }
  751. .dan-status {
  752. font-size: 22rpx;
  753. padding: 4rpx 16rpx;
  754. border-radius: 8rpx;
  755. }
  756. .dan-status.confirmed {
  757. background: #D1FAE5;
  758. color: #065F46;
  759. }
  760. .dan-status.pending {
  761. background: #FEF3C7;
  762. color: #92400E;
  763. }
  764. .dan-report-desc {
  765. font-size: 28rpx;
  766. color: #333;
  767. font-weight: 500;
  768. margin-bottom: 12rpx;
  769. display: block;
  770. }
  771. .dan-card-footer {
  772. text-align: right;
  773. }
  774. .dan-view-link {
  775. font-size: 26rpx;
  776. color: #6366F1;
  777. }
  778. .dan-empty {
  779. background: #fff;
  780. border-radius: 16rpx;
  781. padding: 40rpx 24rpx;
  782. text-align: center;
  783. }
  784. .dan-empty-text {
  785. font-size: 24rpx;
  786. color: #999;
  787. }
  788. .avg-badge {
  789. font-size: 20rpx;
  790. color: #94A3B8;
  791. margin-left: 12rpx;
  792. }
  793. /* 品牌定位语 */
  794. .brand-strap {
  795. margin: 16rpx 30rpx 0;
  796. padding: 20rpx 28rpx;
  797. background: linear-gradient(135deg, #F0F0FF, rgba(99,102,241,0.12));
  798. border-radius: 16rpx;
  799. border-left: 4rpx solid #6366F1;
  800. }
  801. .brand-strap-text {
  802. font-size: 26rpx;
  803. color: #3730A3;
  804. font-weight: 500;
  805. }
  806. /* 每月引导语 */
  807. .monthly-guidance {
  808. margin: 16rpx 30rpx 0;
  809. padding: 20rpx 28rpx;
  810. background: linear-gradient(135deg, #F0F0FF, rgba(99,102,241,0.08));
  811. border-radius: 16rpx;
  812. border-left: 4rpx solid #6366F1;
  813. display: flex;
  814. align-items: center;
  815. gap: 12rpx;
  816. }
  817. .guidance-icon { font-size: 32rpx; }
  818. .guidance-text {
  819. font-size: 26rpx;
  820. color: #3730A3;
  821. font-weight: 500;
  822. }
  823. /* ===== 肠胃与认知卡片 ===== */
  824. .gut-cog-subtitle {
  825. font-size: 24rpx;
  826. color: #6366F1;
  827. margin-bottom: 16rpx;
  828. display: block;
  829. }
  830. .gut-indicator-list {
  831. display: flex;
  832. flex-direction: column;
  833. gap: 12rpx;
  834. }
  835. .gut-indicator-item {
  836. display: flex;
  837. align-items: center;
  838. gap: 12rpx;
  839. }
  840. .gut-indicator-left {
  841. width: 80rpx;
  842. flex-shrink: 0;
  843. }
  844. .gut-indicator-name {
  845. font-size: 22rpx;
  846. color: #666;
  847. }
  848. .gut-indicator-bar-track {
  849. flex: 1;
  850. height: 16rpx;
  851. background: #F0F0F0;
  852. border-radius: 8rpx;
  853. overflow: hidden;
  854. }
  855. .gut-indicator-bar-fill {
  856. height: 100%;
  857. border-radius: 8rpx;
  858. transition: width 0.3s;
  859. }
  860. .gut-indicator-value {
  861. font-size: 22rpx;
  862. color: #666;
  863. width: 60rpx;
  864. text-align: right;
  865. }
  866. .gut-indicator-status {
  867. font-size: 20rpx;
  868. padding: 2rpx 12rpx;
  869. border-radius: 10rpx;
  870. width: 60rpx;
  871. text-align: center;
  872. }
  873. .status-normal {
  874. background: #D1FAE5;
  875. color: #059669;
  876. }
  877. .status-abnormal {
  878. background: #FEE2E2;
  879. color: #DC2626;
  880. }
  881. .status-warning {
  882. background: #FEF3C7;
  883. color: #D97706;
  884. }
  885. .gut-empty {
  886. display: flex;
  887. flex-direction: column;
  888. align-items: center;
  889. padding: 40rpx 0;
  890. }
  891. .gut-empty-icon {
  892. font-size: 56rpx;
  893. margin-bottom: 16rpx;
  894. }
  895. .gut-empty-text {
  896. font-size: 26rpx;
  897. color: #999;
  898. margin-bottom: 24rpx;
  899. }
  900. .gut-upload-btn {
  901. background: linear-gradient(135deg, #6366F1, #818CF8);
  902. color: #fff;
  903. font-size: 26rpx;
  904. font-weight: 600;
  905. border: none;
  906. border-radius: 40rpx;
  907. padding: 16rpx 64rpx;
  908. line-height: 1.6;
  909. margin: 0;
  910. }
  911. /* ===== 认知强项与提升卡片 ===== */
  912. .insight-group {
  913. margin-bottom: 16rpx;
  914. }
  915. .insight-group-title {
  916. font-size: 26rpx;
  917. font-weight: 600;
  918. color: #333;
  919. margin-bottom: 10rpx;
  920. display: block;
  921. }
  922. .insight-item {
  923. display: flex;
  924. align-items: center;
  925. padding: 12rpx 16rpx;
  926. background: #F8FAFF;
  927. border-radius: 12rpx;
  928. margin-bottom: 8rpx;
  929. }
  930. .insight-item-name {
  931. flex: 1;
  932. font-size: 26rpx;
  933. color: #333;
  934. }
  935. .insight-item-score {
  936. font-size: 24rpx;
  937. color: #666;
  938. margin-right: 12rpx;
  939. }
  940. .insight-item-tag {
  941. font-size: 20rpx;
  942. padding: 4rpx 16rpx;
  943. border-radius: 8rpx;
  944. font-weight: 500;
  945. }
  946. .insight-item-tag.tag-strong {
  947. background: #D1FAE5;
  948. color: #059669;
  949. }
  950. .insight-item-tag.tag-improve {
  951. background: #FEF3C7;
  952. color: #D97706;
  953. }
  954. .insight-tip {
  955. padding: 12rpx 16rpx;
  956. background: #EEF2FF;
  957. border-radius: 12rpx;
  958. }
  959. .insight-tip-text {
  960. font-size: 22rpx;
  961. color: #6366F1;
  962. }
  963. .insight-empty {
  964. display: flex;
  965. flex-direction: column;
  966. align-items: center;
  967. padding: 30rpx 0;
  968. }
  969. .insight-empty-text {
  970. font-size: 24rpx;
  971. color: #999;
  972. margin-bottom: 20rpx;
  973. }
  974. .insight-btn {
  975. background: linear-gradient(135deg, #6366F1, #818CF8);
  976. color: #fff;
  977. font-size: 26rpx;
  978. font-weight: 600;
  979. border: none;
  980. border-radius: 40rpx;
  981. padding: 14rpx 60rpx;
  982. line-height: 1.6;
  983. margin: 0;
  984. }
  985. </style>