index.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. <template>
  2. <view class="container">
  3. <block v-if="!isLoggedIn">
  4. <!-- 品牌定位语 -->
  5. <view class="brand-strap"><text class="brand-strap-text">科学管理全家健康数据</text></view>
  6. <!-- 痛点卡 -->
  7. <view class="pain-card">
  8. <text class="pain-quote">指标正常 ≠ 健康</text>
  9. <text class="pain-desc">孩子反复生病,你扛了多少次了?</text>
  10. </view>
  11. <!-- 功能预览 -->
  12. <view class="guest-features">
  13. <view class="feat-card" @click="goPage('/pages/health/report-upload')">
  14. <text class="feat-icon">📋</text>
  15. <text class="feat-title">上传健康报告</text>
  16. <text class="feat-desc">体检/肠道/舌诊 · 解读</text>
  17. </view>
  18. <view class="feat-card" @click="goPage('/pages/body/detail')">
  19. <text class="feat-icon">🧠</text>
  20. <text class="feat-title">认知能力测评</text>
  21. <text class="feat-desc">记忆力·注意力·逻辑推理</text>
  22. </view>
  23. <view class="feat-card" @click="goPage('/pages/mind/index')">
  24. <text class="feat-icon">💖</text>
  25. <text class="feat-title">心理健康测评</text>
  26. <text class="feat-desc">情绪稳定·抗压能力</text>
  27. </view>
  28. <view class="feat-card" @click="goPlanSummary">
  29. <text class="feat-icon">📝</text>
  30. <text class="feat-title">健康方案</text>
  31. <text class="feat-desc">选维度·选成员·定目标</text>
  32. </view>
  33. <view class="feat-card" @click="goPage('/pages/health/health-status-form')">
  34. <text class="feat-icon">📋</text>
  35. <text class="feat-title">健康档案</text>
  36. <text class="feat-desc">身高体重·血压血糖·疾病史</text>
  37. </view>
  38. </view>
  39. <!-- 自测入口 -->
  40. <view class="self-test-card" @click="goSelfTest">
  41. <view class="self-test-head">
  42. <text class="self-test-icon">⚡</text>
  43. <view class="self-test-info">
  44. <text class="self-test-title">15题五维健康自检</text>
  45. <text class="self-test-sub">约20秒,了解家人健康概况</text>
  46. </view>
  47. <text class="self-test-arrow">›</text>
  48. </view>
  49. </view>
  50. <RadarChart :dimensions="demoBodyDims" :scores="demoBodyScores" fillColor="#FF8C42" childName="示例" width="560" height="460" />
  51. <view class="demo-chart-title-row">
  52. <text class="demo-chart-name">🧠 认知雷达</text>
  53. <text class="demo-chart-tag">示例</text>
  54. </view>
  55. <RadarChart :dimensions="demoCogDims" :scores="demoCogScores" fillColor="#6366F1" childName="示例" width="560" height="460" />
  56. <!-- 五维健康体系 -->
  57. <view class="wuxing-section">
  58. <view class="wuxing-title">身·心·智·行·富 · 看得见的健康闭环</view>
  59. <view class="wuxing-desc">五行相生相克,从报告和测评里,真正读懂家人的身体</view>
  60. <view class="wuxing-relations">
  61. <view class="rel-group">
  62. <text class="rel-title">相生 → 系统前进</text>
  63. <view class="rel-chain">
  64. <text class="rel-item">🌏 身</text>
  65. <text class="rel-arrow">→</text>
  66. <text class="rel-item">⚡ 智</text>
  67. <text class="rel-arrow">→</text>
  68. <text class="rel-item">💧 富</text>
  69. <text class="rel-arrow">→</text>
  70. <text class="rel-item">🌿 行</text>
  71. <text class="rel-arrow">→</text>
  72. <text class="rel-item">🔥 心</text>
  73. <text class="rel-arrow">→</text>
  74. <text class="rel-item">🌏 身</text>
  75. </view>
  76. <text class="rel-hint">健康孕育智慧,智慧创造价值,价值滋养关系,关系反哺心灵,心灵守护健康</text>
  77. </view>
  78. <view class="rel-group">
  79. <text class="rel-title">相克 → 系统平衡</text>
  80. <view class="rel-chain">
  81. <text class="rel-item">🌏 身</text>
  82. <text class="rel-op">克</text>
  83. <text class="rel-item">💧 富</text>
  84. <text class="rel-dot">·</text>
  85. <text class="rel-item">⚡ 智</text>
  86. <text class="rel-op">克</text>
  87. <text class="rel-item">🌿 行</text>
  88. <text class="rel-dot">·</text>
  89. <text class="rel-item">💧 富</text>
  90. <text class="rel-op">克</text>
  91. <text class="rel-item">🔥 心</text>
  92. <text class="rel-dot">·</text>
  93. <text class="rel-item">🌿 行</text>
  94. <text class="rel-op">克</text>
  95. <text class="rel-item">🌏 身</text>
  96. <text class="rel-dot">·</text>
  97. <text class="rel-item">🔥 心</text>
  98. <text class="rel-op">克</text>
  99. <text class="rel-item">⚡ 智</text>
  100. </view>
  101. <text class="rel-hint">莫以健康换金钱,真诚胜过算计,财富服务家庭,关爱有度、大爱留白</text>
  102. </view>
  103. </view>
  104. <view class="wuxing-cards">
  105. <view class="wc-card wc-body" @click="goPage('/pages/body-detail/index')">
  106. <text class="wc-icon">🌏</text>
  107. <view class="wc-info">
  108. <text class="wc-name">身 · 主动健康</text>
  109. <text class="wc-text">读懂每一份报告,看见全家体质的变化</text>
  110. </view>
  111. </view>
  112. <view class="wc-card wc-wisdom" @click="goPage('/pages/wisdom-detail/index')">
  113. <text class="wc-icon">⚡</text>
  114. <view class="wc-info">
  115. <text class="wc-name">智 · 赋能未来</text>
  116. <text class="wc-text">一次测评,看见孩子真实的专注与潜能</text>
  117. </view>
  118. </view>
  119. <view class="wc-card wc-wealth" @click="goPage('/pages/wealth/index')">
  120. <text class="wc-icon">💧</text>
  121. <view class="wc-info">
  122. <text class="wc-name">富 · 利他创富</text>
  123. <text class="wc-text">看懂健康与财富的关系,明白身体是最大的本钱</text>
  124. </view>
  125. </view>
  126. <view class="wc-card wc-action" @click="goPage('/pages/action-detail/member-action-detail')">
  127. <text class="wc-icon">🌿</text>
  128. <view class="wc-info">
  129. <text class="wc-name">行 · 人际和谐</text>
  130. <text class="wc-text">看懂关系里的情绪,看见家人真实的需求</text>
  131. </view>
  132. </view>
  133. <view class="wc-card wc-mind" @click="goPage('/pages/mind-detail/index')">
  134. <text class="wc-icon">🔥</text>
  135. <view class="wc-info">
  136. <text class="wc-name">心 · 大爱相随</text>
  137. <text class="wc-text">读懂情绪的信号,听懂家人没说出口的话</text>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. <!-- 登录引导 -->
  143. <view class="login-guide-section">
  144. <LoginGuideCard
  145. title="解锁全家健康数据"
  146. :items="[
  147. '查看七维雷达图与健康报告解读',
  148. '完成测评获取个性化健康方案',
  149. '每日打卡追踪身体/情绪/认知趋势'
  150. ]" />
  151. </view>
  152. </block>
  153. <block v-else>
  154. <view class="tab-bar">
  155. <view v-for="tab in tabs" :key="tab.code" class="tab-item" :class="{ active: currentTab === tab.code }" @click="switchTab(tab.code)">
  156. <text class="tab-icon">{{ tab.icon }}</text>
  157. <text class="tab-label">{{ tab.label }}</text>
  158. <view v-if="currentTab === tab.code" class="tab-underline" :style="{ background: tab.color }"></view>
  159. </view>
  160. </view>
  161. <view class="section section-chart">
  162. <RadarChart :dimensions="currentDimensions" :scores="currentScores" :fillColor="currentColor" :childName="selectedMemberName" :avgScores="currentAvgScores" width="640" height="520" />
  163. <view class="chart-empty" v-if="chartIsEmpty">
  164. <text class="empty-text">{{ currentTabLabel }}数据待采集</text>
  165. <text class="empty-sub">完成测评或上传报告即可解锁{{ currentTabLabel }}数据</text>
  166. </view>
  167. </view>
  168. <view class="section section-dc-header">
  169. <view class="dc-title-row">
  170. <text class="dc-icon">🔍</text>
  171. <text class="dc-title">看见 · 健康数据中心</text>
  172. </view>
  173. </view>
  174. <view class="section section-data-collect">
  175. <view class="data-card" @click="goPage('/pages/health/report-upload')">
  176. <view class="data-card-icon" style="background:rgba(249,115,22,0.12)"><text>📋</text></view>
  177. <view class="data-card-info">
  178. <text class="data-card-title">上传健康报告</text>
  179. <text class="data-card-desc">体检/肠道/舌诊报告 · 解读</text>
  180. </view>
  181. <text class="data-card-arrow">›</text>
  182. </view>
  183. <view class="data-card data-card-assessment">
  184. <view class="data-card-head">
  185. <text class="data-card-title">在线测评</text>
  186. <text class="data-card-subtitle">多维度自测评估</text>
  187. </view>
  188. <view v-for="quiz in quizzes" :key="quiz.code" class="quiz-item">
  189. <view class="quiz-info">
  190. <text class="quiz-icon">{{ quiz.icon }}</text>
  191. <text class="quiz-label">{{ quiz.label }}</text>
  192. </view>
  193. <view v-if="quiz.score" class="quiz-score">
  194. <text class="score-value">{{ quiz.score }}</text>
  195. <text class="score-unit">分</text>
  196. </view>
  197. <button v-else class="quiz-btn" @click.stop="goQuiz(quiz.code)">开始</button>
  198. </view>
  199. </view>
  200. </view>
  201. <view class="section section-data-view">
  202. <view class="section-header">
  203. <text class="section-title">最近记录</text>
  204. <text class="section-more" @click="goPage('/pages/health/report-list')">查看全部 ›</text>
  205. </view>
  206. <view v-if="reports.length > 0">
  207. <view class="report-card" v-for="(report, idx) in reports.slice(0, 3)" :key="idx" @click="goReportDetail(report)">
  208. <view class="report-type-badge" :class="'badge-' + _reportTypeClass(report.reportType)">{{ _reportTypeLabel(report.reportType) }}</view>
  209. <view class="report-info">
  210. <text class="report-name">{{ report.childName || report.personName || '健康报告' }}</text>
  211. <text class="report-meta">{{ report.reportDate || '' }}{{ report.gutType ? ' · ' + report.gutType : '' }}</text>
  212. </view>
  213. <view class="report-score-wrap">
  214. <text v-if="report.overallScore != null" class="report-score">{{ report.overallScore }}</text>
  215. <text class="report-status" :class="'status-' + _statusClass(report.status)">{{ report.status === 'resolved' ? '已解析' : '待确认' }}</text>
  216. </view>
  217. <text class="report-arrow">›</text>
  218. </view>
  219. </view>
  220. <view v-else class="empty-hint">
  221. <text class="empty-text">暂无报告和测评结果</text>
  222. <text class="empty-sub">上传报告或完成测评开启健康之旅</text>
  223. </view>
  224. </view>
  225. <view class="section section-plan">
  226. <view class="plan-card">
  227. <view class="plan-head">
  228. <text class="plan-title">📋 健康方案</text>
  229. <button class="plan-btn" @click="goPlanSummary">{{ lastPlan ? '查看方案' : '生成新方案' }}</button>
  230. </view>
  231. <text v-if="lastPlan" class="plan-goal">{{ lastPlan }}</text>
  232. <text v-else class="plan-hint">选维度 + 选成员 + 设定目标 → 生成</text>
  233. </view>
  234. </view>
  235. <ArticleBookshelf :articles="healthArticles" :isLoggedIn="true" @articleClick="goArticleDetail" @moreArticles="goMoreArticles" />
  236. </block>
  237. </view>
  238. </template>
  239. <script>
  240. import LoginGuideCard from '../../components/LoginGuideCard.vue'
  241. import RadarChart from '../../components/RadarChart.vue'
  242. import ArticleBookshelf from '../../components/ArticleBookshelf.vue'
  243. export default {
  244. components: { LoginGuideCard, RadarChart, ArticleBookshelf },
  245. data() {
  246. return {
  247. isLoggedIn: false,
  248. currentTab: 'body',
  249. selectedMemberName: '',
  250. selectedMemberId: '',
  251. reports: [],
  252. lastPlan: '',
  253. healthArticles: [],
  254. hasAiQHistory: false,
  255. tabs: [
  256. { code: 'body', label: '健康', icon: '🟠', color: '#FF8C42' },
  257. { code: 'cognitive', label: '认知', icon: '🧠', color: '#6366F1' },
  258. { code: 'mental', label: '心理', icon: '💖', color: '#FF6B9D' },
  259. { code: 'relationship', label: '社会性', icon: '🤝', color: '#10B981' },
  260. { code: 'wealth', label: '财富', icon: '💧', color: '#F59E0B' }
  261. ],
  262. quizzes: [
  263. { code: 'cognitive', label: '认知能力测评', icon: '🧠', score: null },
  264. { code: 'mental', label: '心理健康测评', icon: '💖', score: null },
  265. { code: 'relationship', label: '关系质量测评', icon: '🤝', score: null }
  266. ],
  267. demoBodyDims: [
  268. { label: '生长发育', key: 'growth' },
  269. { label: '睡眠质量', key: 'sleep' },
  270. { label: '视力健康', key: 'vision' },
  271. { label: '免疫力', key: 'immunity' },
  272. { label: '营养均衡', key: 'nutrition' },
  273. { label: '肠胃健康', key: 'gut' },
  274. { label: '运动活力', key: 'exercise' }
  275. ],
  276. demoCogDims: [
  277. { label: '记忆力', key: 'memory' },
  278. { label: '注意力', key: 'attention' },
  279. { label: '逻辑推理', key: 'logic' },
  280. { label: '空间想象', key: 'spatial' },
  281. { label: '语言表达', key: 'language' }
  282. ],
  283. demoCogScores: [78, 72, 85, 68, 80],
  284. // 真实数据缓存
  285. bodyData: null,
  286. cognitiveData: null,
  287. cognitiveFamilyData: [],
  288. emiData: null,
  289. emiFamilyData: [],
  290. relationshipData: [],
  291. energySandbox: null,
  292. wealthDetail: null,
  293. childrenList: [],
  294. relationshipEmpty: false
  295. }
  296. },
  297. computed: {
  298. currentTabLabel: function() {
  299. var tab = this.tabs.filter(function(t) { return t.code === this.currentTab }.bind(this))[0]
  300. return tab ? tab.label : ''
  301. },
  302. currentColor: function() {
  303. var tab = this.tabs.filter(function(t) { return t.code === this.currentTab }.bind(this))[0]
  304. return tab ? tab.color : '#FF8C42'
  305. },
  306. currentDimensions: function() {
  307. if (this.currentTab === 'cognitive') {
  308. return [{ label:'记忆力',key:'memory'},{ label:'注意力',key:'attention'},{ label:'逻辑推理',key:'logic'},{ label:'空间想象',key:'spatial'},{ label:'感知能力',key:'perception'},{ label:'专注力',key:'focus'},{ label:'加工速度',key:'processingSpeed' }]
  309. }
  310. if (this.currentTab === 'mental') {
  311. return [{ label:'开放性',key:'openness'},{ label:'尽责性',key:'conscientiousness'},{ label:'外向性',key:'extraversion'},{ label:'宜人性',key:'agreeableness'},{ label:'神经质',key:'neuroticism'},{ label:'自主性',key:'driveAutonomy'},{ label:'胜任感',key:'driveCompetence'},{ label:'归属感',key:'driveRelatedness'},{ label:'情绪稳定性',key:'emotionStability'},{ label:'自我概念',key:'selfConceptOverall' }]
  312. }
  313. if (this.currentTab === 'relationship') {
  314. return [{ label:'亲子信任',key:'parentTrust'},{ label:'亲子亲密度',key:'parentIntimacy'},{ label:'沟通质量',key:'communication'},{ label:'关系健康度',key:'healthStatus'},{ label:'最近互动',key:'lastInteraction' }]
  315. }
  316. if (this.currentTab === 'wealth') {
  317. var isChild = !!uni.getStorageSync('currentChildId')
  318. if (isChild) {
  319. return [{ label:'学业能力',key:'skill'},{ label:'利他贡献',key:'altruism'},{ label:'积分积累',key:'income'},{ label:'财务素养',key:'fx' }]
  320. }
  321. return [{ label:'个人能力',key:'skill'},{ label:'利他贡献',key:'altruism'},{ label:'CF值积累',key:'income'},{ label:'财务素养',key:'fx' }]
  322. }
  323. return [{ label:'生长发育',key:'growth'},{ label:'睡眠质量',key:'sleep'},{ label:'视力健康',key:'vision'},{ label:'免疫力',key:'immunity'},{ label:'营养均衡',key:'nutrition'},{ label:'肠胃健康',key:'gut'},{ label:'运动活力',key:'exercise' }]
  324. },
  325. currentScores: function() {
  326. if (this.chartIsEmpty) {
  327. var dims = this.currentDimensions, scores = []
  328. for (var i = 0; i < dims.length; i++) scores.push(0)
  329. return scores
  330. }
  331. if (this.currentTab === 'cognitive') {
  332. return [
  333. this._cognitiveScore('memoryScore'),
  334. this._cognitiveScore('attentionScore'),
  335. this._cognitiveScore('logicScore'),
  336. this._cognitiveScore('spatialScore'),
  337. this._cognitiveScore('perceptionScore'),
  338. this._cognitiveScore('focusScore'),
  339. this._cognitiveScore('processingSpeedScore')
  340. ]
  341. }
  342. if (this.currentTab === 'mental') {
  343. return [
  344. this._emiScore('opennessScore'),
  345. this._emiScore('conscientiousnessScore'),
  346. this._emiScore('extraversionScore'),
  347. this._emiScore('agreeablenessScore'),
  348. this._emiScore('neuroticismScore'),
  349. this._emiScore('driveAutonomy'),
  350. this._emiScore('driveCompetence'),
  351. this._emiScore('driveRelatedness'),
  352. this._emiScore('emotionStability'),
  353. this._emiScore('selfConceptOverall')
  354. ]
  355. }
  356. if (this.currentTab === 'relationship') {
  357. return [
  358. this._relScore('trustScore'),
  359. this._relScore('intimacyScore'),
  360. this._relScore('communicationScore'),
  361. this._relScore('totalScore'),
  362. 0
  363. ]
  364. }
  365. if (this.currentTab === 'wealth') {
  366. var d = this.wealthDetail
  367. if (!d) return [0, 0, 0, 0]
  368. return [d.wealthSkill || 0, d.wealthAltruism || 0, d.wealthIncome || 0, d.wealthFx || 0]
  369. }
  370. // body: 从 API 真实维度数据取分
  371. if (this.bodyData && this.bodyData.dimensions && this.bodyData.dimensions.length > 0) {
  372. return this.bodyData.dimensions.map(function(d) { return Number(d.score) || 0 })
  373. }
  374. // body: fallback to demo
  375. if (this.reports.length > 0) {
  376. var latest = this.reports[0]
  377. if (latest.overallScore) return [72, 68, 75, 80, 70, 78, 82]
  378. }
  379. return [72, 68, 75, 80, 70, 78, 82]
  380. },
  381. currentAvgScores: function() {
  382. if (this.chartIsEmpty) return []
  383. if (this.currentTab === 'cognitive' && this.cognitiveFamilyData.length > 0) {
  384. var keys = ['memoryScore','attentionScore','logicScore','spatialScore','perceptionScore','focusScore','processingSpeedScore']
  385. var avgs = []
  386. for (var k = 0; k < keys.length; k++) {
  387. var sum = 0
  388. for (var i = 0; i < this.cognitiveFamilyData.length; i++) {
  389. var v = this.cognitiveFamilyData[i][keys[k]]
  390. if (typeof v === 'number' && v > 0) sum += v
  391. }
  392. avgs.push(Math.round(sum / this.cognitiveFamilyData.length))
  393. }
  394. return avgs
  395. }
  396. if (this.currentTab === 'mental' && this.emiFamilyData.length > 0) {
  397. var keys2 = ['opennessScore','conscientiousnessScore','extraversionScore','agreeablenessScore','neuroticismScore','driveAutonomy','driveCompetence','driveRelatedness','emotionStability','selfConceptOverall']
  398. var avgs2 = []
  399. for (var k2 = 0; k2 < keys2.length; k2++) {
  400. var sum2 = 0
  401. for (var i2 = 0; i2 < this.emiFamilyData.length; i2++) {
  402. var v2 = this.emiFamilyData[i2][keys2[k2]]
  403. if (typeof v2 === 'number' && v2 > 0) sum2 += v2
  404. }
  405. avgs2.push(Math.round(sum2 / this.emiFamilyData.length))
  406. }
  407. return avgs2
  408. }
  409. if (this.currentTab === 'relationship' && this.relationshipData.length > 0) {
  410. return [this._relScore('trustScore'), this._relScore('intimacyScore'), this._relScore('communicationScore'), this._relScore('totalScore'), 0]
  411. }
  412. if (this.currentTab === 'wealth' && this.wealthDetail) {
  413. var d = this.wealthDetail
  414. return [d.wealthSkill || 0, d.wealthAltruism || 0, d.wealthIncome || 0, d.wealthFx || 0]
  415. }
  416. return []
  417. },
  418. chartIsEmpty: function() {
  419. if (this.currentTab === 'body') return !this.bodyData || !this.bodyData.dimensions || this.bodyData.dimensions.length === 0
  420. if (this.currentTab === 'cognitive') return !this.cognitiveData || !this.cognitiveData.overallScore
  421. if (this.currentTab === 'mental') return !this.emiData || !this.emiData.overallScore
  422. if (this.currentTab === 'relationship') return !this.relationshipData || this.relationshipData.length === 0
  423. if (this.currentTab === 'wealth') return !this.wealthDetail
  424. var quiz = this.quizzes.filter(function(q) { return q.code === this.currentTab }.bind(this))[0]
  425. return !(quiz && quiz.score)
  426. }
  427. },
  428. onShow() {
  429. this.isLoggedIn = !!uni.getStorageSync('token')
  430. if (this.isLoggedIn) {
  431. var stored = uni.getStorageSync('currentChildId') || uni.getStorageSync('currentMemberId') || ''
  432. if (stored) {
  433. this.selectedMemberId = stored
  434. this.selectedMemberName = uni.getStorageSync('currentChildName') || '成员'
  435. }
  436. this.loadHealthData()
  437. this.loadPlanList()
  438. }
  439. },
  440. methods: {
  441. _cognitiveScore: function(key) {
  442. if (!this.cognitiveData) return 0
  443. var v = this.cognitiveData[key]
  444. return (typeof v === 'number' && v > 0) ? v : 0
  445. },
  446. _emiScore: function(key) {
  447. if (!this.emiData) return 0
  448. var v = this.emiData[key]
  449. return (typeof v === 'number' && v > 0) ? v : 0
  450. },
  451. _relScore: function(key) {
  452. if (!this.relationshipData || this.relationshipData.length === 0) return 0
  453. var total = 0, count = 0
  454. for (var i = 0; i < this.relationshipData.length; i++) {
  455. var item = this.relationshipData[i]
  456. if (item[key] != null) { total += Number(item[key]); count++ }
  457. }
  458. return count > 0 ? Math.round(total / count) : 0
  459. },
  460. _wealthScore: function(key) {
  461. if (!this.energySandbox) return 0
  462. var v = this.energySandbox[key]
  463. return (typeof v === 'number' && v > 0) ? v : 0
  464. },
  465. switchTab: function(code) { this.currentTab = code },
  466. goPage: function(url) { uni.navigateTo({ url: url }) },
  467. goQuiz: function(code) {
  468. var url = '/pages/body-detail/dimension-questionnaire?dim=' + code
  469. if (this.selectedMemberId) url += '&memberId=' + this.selectedMemberId
  470. uni.navigateTo({ url: url })
  471. },
  472. goReportDetail: function(report) {
  473. if (!report || !report.id) return
  474. var type = report.reportType || 'gut_flora'
  475. var url = '/pages/health/report-detail?reportType=' + type + '&reportId=' + report.id
  476. // 肠道菌群报告:从列表点击直接进入编辑模式,跳过查看过渡页
  477. if (type === 'gut_flora') {
  478. url += '&mode=edit'
  479. }
  480. uni.navigateTo({ url: url })
  481. },
  482. _reportTypeLabel: function(type) {
  483. var map = { gut_flora: '肠道', physical_exam: '体检', tongue: '舌诊', blood: '血液' }
  484. return map[type] || '健康报告'
  485. },
  486. _reportTypeClass: function(type) {
  487. var map = { gut_flora: 'gut', physical_exam: 'exam', tongue: 'tongue', blood: 'blood' }
  488. return map[type] || 'default'
  489. },
  490. _statusClass: function(status) {
  491. return status === 'resolved' ? 'resolved' : 'pending'
  492. },
  493. goSelfTest: function() { uni.navigateTo({ url: '/pages/health/survey-questionnaire?dim=all' }) },
  494. goPlanSummary: function() {
  495. var url = '/pages/health/health-plan-summary'
  496. if (this.selectedMemberId) url += '?memberId=' + this.selectedMemberId
  497. uni.navigateTo({ url: url })
  498. },
  499. loadHealthData: function() {
  500. var self = this
  501. try {
  502. var api = require('../../utils/api.js')
  503. var memberId = uni.getStorageSync('currentChildId') || uni.getStorageSync('currentMemberId') || uni.getStorageSync('userId') || ''
  504. // 健康报告(memberId 为空时不调用,避免后端 400)
  505. if (memberId) {
  506. api.getReportList(memberId).then(function(res) {
  507. if (res.code === 200 && res.data) {
  508. var list = Array.isArray(res.data) ? res.data : (res.data.list || [])
  509. self.reports = list
  510. }
  511. }).catch(function() {})
  512. }
  513. // 身体七维概览
  514. if (memberId) {
  515. api.getDimensionOverview({ memberId: memberId }).then(function(res) {
  516. if (res.code === 200 && res.data) self.bodyData = res.data
  517. }).catch(function() {})
  518. }
  519. // 文章
  520. api.getFeaturedArticles({ size: 3, dimensionCode: 'body' }).then(function(res) {
  521. if (res.code === 200 && res.data) {
  522. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  523. self.healthArticles = list.slice(0, 3) || []
  524. }
  525. }).catch(function() {})
  526. // 认知测评得分
  527. if (memberId) {
  528. api.getCognitiveChildScores(memberId).then(function(res) {
  529. if (res.code === 200) self.cognitiveData = res.data || null
  530. }).catch(function() {})
  531. api.getCognitiveFamilyScores().then(function(res) {
  532. if (res.code === 200 && Array.isArray(res.data)) self.cognitiveFamilyData = res.data
  533. }).catch(function() {})
  534. }
  535. // EMI心理报告
  536. if (memberId) {
  537. api.getEmiReport(memberId).then(function(res) {
  538. if (res.code === 200) self.emiData = res.data || null
  539. }).catch(function() {})
  540. }
  541. // 关系质量评分
  542. api.getRelationshipScores().then(function(res) {
  543. if (res.code === 200 && Array.isArray(res.data) && res.data.length > 0) {
  544. self.relationshipData = res.data
  545. self.relationshipEmpty = false
  546. } else {
  547. self.relationshipEmpty = true
  548. }
  549. }).catch(function() { self.relationshipEmpty = true })
  550. // 财富子维度(富维度四子维度:能力/利他/财务/素养)
  551. if (memberId) {
  552. var memberType = uni.getStorageSync('currentChildId') ? 'child' : 'parent'
  553. api.getWealthDetail(memberId, memberType).then(function(res) {
  554. if (res.code === 200 && res.data) {
  555. self.wealthDetail = res.data
  556. }
  557. }).catch(function() {})
  558. }
  559. } catch (e) { console.error('加载健康数据失败', e) }
  560. },
  561. loadPlanList: function() {
  562. var self = this
  563. var api = require('../../utils/api.js')
  564. api.getHealthPlanList({}).then(function(res) {
  565. if (res && res.code === 200 && res.data) {
  566. var list = res.data.list || res.data
  567. if (Array.isArray(list) && list.length > 0) self.lastPlan = list[0].goal || ''
  568. }
  569. }).catch(function() {})
  570. },
  571. goArticleDetail: function(article) {
  572. var id = article && article.id || article
  573. uni.navigateTo({ url: '/pages/article-center/article-detail?id=' + id })
  574. },
  575. goMoreArticles: function() {
  576. uni.navigateTo({ url: '/pages/article-center/index?dimension=body' })
  577. }
  578. }
  579. }
  580. </script>
  581. <style scoped>
  582. .container { background: #F8F8F8; min-height: 100vh; padding-bottom: calc(160rpx + env(safe-area-inset-bottom)); }
  583. .section { margin: 16rpx 24rpx; }
  584. .tab-bar { display: flex; background: #fff; margin: 0 24rpx 16rpx; border-radius: 16rpx; padding: 8rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  585. .tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 12rpx 0; position: relative; border-radius: 12rpx; }
  586. .tab-item.active { background: #FFF7ED; }
  587. .tab-icon { font-size: 32rpx; margin-bottom: 4rpx; }
  588. .tab-label { font-size: 26rpx; color: #666; font-weight: 500; }
  589. .tab-item.active .tab-label { color: #333; font-weight: bold; }
  590. .tab-underline { width: 40rpx; height: 4rpx; border-radius: 2rpx; margin-top: 6rpx; }
  591. .section-chart { position: relative; margin: 0 24rpx 16rpx; }
  592. .chart-empty { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; z-index: 3; background: rgba(255,255,255,0.85); border-radius: 12rpx; padding: 20rpx 30rpx; }
  593. .chart-empty .empty-text { font-size: 28rpx; color: #333; font-weight: 500; display: block; }
  594. .chart-empty .empty-sub { font-size: 22rpx; color: #999; display: block; margin-top: 4rpx; }
  595. .section-dc-header { margin: 20rpx 24rpx 8rpx; }
  596. .dc-title-row { display: flex; align-items: center; }
  597. .dc-icon { font-size: 32rpx; margin-right: 8rpx; }
  598. .dc-title { font-size: 32rpx; font-weight: bold; color: #333; }
  599. .section-data-collect { margin: 8rpx 24rpx; }
  600. .data-card { display: flex; align-items: center; background: #fff; border-radius: 20rpx; padding: 24rpx; margin-bottom: 12rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  601. .data-card-icon { width: 88rpx; height: 88rpx; border-radius: 20rpx; display: flex; align-items: center; justify-content: center; margin-right: 20rpx; font-size: 40rpx; }
  602. .data-card-info { flex: 1; }
  603. .data-card-title { font-size: 28rpx; font-weight: bold; color: #333; display: block; margin-bottom: 6rpx; }
  604. .data-card-desc { font-size: 22rpx; color: #999; }
  605. .data-card-arrow { font-size: 36rpx; color: #ccc; }
  606. .data-card-assessment { flex-direction: column; align-items: stretch; padding: 24rpx; }
  607. .data-card-head { display: flex; align-items: center; margin-bottom: 16rpx; }
  608. .data-card-subtitle { font-size: 22rpx; color: #999; margin-left: 12rpx; }
  609. .quiz-item { display: flex; align-items: center; padding: 16rpx 0; border-top: 1rpx solid #f0f0f0; }
  610. .quiz-item:first-of-type { border-top: none; }
  611. .quiz-info { display: flex; align-items: center; flex: 1; }
  612. .quiz-icon { font-size: 36rpx; margin-right: 16rpx; }
  613. .quiz-label { font-size: 28rpx; color: #333; }
  614. .quiz-score { display: flex; align-items: baseline; margin-right: 16rpx; }
  615. .score-value { font-size: 36rpx; font-weight: bold; color: #F97316; }
  616. .score-unit { font-size: 22rpx; color: #999; margin-left: 4rpx; }
  617. .quiz-btn { background: #F97316; color: #fff; font-size: 24rpx; border: none; border-radius: 20rpx; padding: 10rpx 30rpx; height: 56rpx; line-height: 36rpx; margin: 0; }
  618. .section-data-view { margin: 16rpx 24rpx; }
  619. .section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12rpx; }
  620. .section-title { font-size: 28rpx; font-weight: bold; color: #333; }
  621. .section-more { font-size: 24rpx; color: #F97316; }
  622. .report-card { display: flex; align-items: center; background: #fff; border-radius: 16rpx; padding: 16rpx 20rpx; margin-bottom: 10rpx; }
  623. .report-type-badge { font-size: 20rpx; padding: 4rpx 12rpx; border-radius: 8rpx; margin-right: 12rpx; flex-shrink: 0; font-weight: 600; }
  624. .report-type-badge.badge-gut { background: rgba(249,115,22,0.12); color: #F97316; }
  625. .report-type-badge.badge-exam { background: rgba(99,102,241,0.12); color: #6366F1; }
  626. .report-type-badge.badge-tongue { background: rgba(16,185,129,0.12); color: #10B981; }
  627. .report-type-badge.badge-blood { background: rgba(239,68,68,0.12); color: #EF4444; }
  628. .report-type-badge.badge-default { background: rgba(107,114,128,0.12); color: #6B7280; }
  629. .report-info { flex: 1; min-width: 0; }
  630. .report-name { font-size: 26rpx; color: #333; font-weight: 600; display: block; margin-bottom: 4rpx; }
  631. .report-meta { font-size: 20rpx; color: #999; display: block; }
  632. .report-score-wrap { display: flex; flex-direction: column; align-items: flex-end; margin-right: 8rpx; flex-shrink: 0; }
  633. .report-score { font-size: 32rpx; font-weight: bold; color: #F97316; line-height: 1; }
  634. .report-status { font-size: 20rpx; margin-top: 4rpx; }
  635. .report-status.status-resolved { color: #10B981; }
  636. .report-status.status-pending { color: #F59E0B; }
  637. .report-arrow { font-size: 28rpx; color: #ccc; }
  638. .empty-hint { text-align: center; padding: 30rpx 0; background: #fff; border-radius: 16rpx; }
  639. .empty-hint .empty-text { font-size: 26rpx; color: #999; display: block; }
  640. .empty-hint .empty-sub { font-size: 22rpx; color: #ccc; display: block; margin-top: 6rpx; }
  641. .section-plan { margin: 8rpx 24rpx 16rpx; }
  642. .plan-card { background: #fff; border-radius: 20rpx; padding: 24rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  643. .plan-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12rpx; }
  644. .plan-title { font-size: 28rpx; font-weight: bold; color: #333; }
  645. .plan-btn { background: linear-gradient(135deg, #F97316, #FB923C); color: #fff; font-size: 24rpx; border: none; border-radius: 20rpx; padding: 10rpx 28rpx; height: 56rpx; line-height: 36rpx; margin: 0; }
  646. .plan-goal { font-size: 24rpx; color: #666; line-height: 1.5; display: block; }
  647. .plan-hint { font-size: 22rpx; color: #999; display: block; }
  648. /* ===== 游客态样式 ===== */
  649. .brand-strap { margin: 0 24rpx 16rpx; background: linear-gradient(135deg, #FFF7ED, rgba(249,115,22,0.08)); border-radius: 16rpx; padding: 20rpx 24rpx; }
  650. .brand-strap-text { font-size: 26rpx; color: #F97316; font-weight: 600; }
  651. .pain-card { margin: 0 24rpx 16rpx; background: #fff; border-radius: 20rpx; padding: 28rpx; border-left: 6rpx solid #F97316; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  652. .pain-quote { font-size: 32rpx; font-weight: bold; color: #333; display: block; margin-bottom: 8rpx; }
  653. .pain-desc { font-size: 26rpx; color: #888; display: block; }
  654. .guest-features { display: flex; flex-wrap: wrap; justify-content: space-between; margin: 0 24rpx 16rpx; }
  655. .feat-card { width: 48.5%; box-sizing: border-box; background: #fff; border-radius: 20rpx; padding: 24rpx 20rpx; margin-bottom: 16rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  656. .feat-icon { font-size: 44rpx; display: block; margin-bottom: 10rpx; }
  657. .feat-title { font-size: 26rpx; font-weight: 600; color: #333; display: block; margin-bottom: 4rpx; }
  658. .feat-desc { font-size: 22rpx; color: #999; display: block; }
  659. .self-test-card { margin: 0 24rpx 16rpx; background: linear-gradient(135deg, #667eea, #764ba2); border-radius: 20rpx; padding: 24rpx 28rpx; }
  660. .self-test-head { display: flex; align-items: center; }
  661. .self-test-icon { font-size: 40rpx; margin-right: 16rpx; }
  662. .self-test-info { flex: 1; }
  663. .self-test-title { font-size: 28rpx; font-weight: bold; color: #fff; display: block; }
  664. .self-test-sub { font-size: 22rpx; color: rgba(255,255,255,0.8); display: block; margin-top: 4rpx; }
  665. .ai-q-entry { margin: 0 24rpx 16rpx; background: linear-gradient(135deg, #F97316, #F59E0B); border-radius: 20rpx; padding: 24rpx 28rpx; }
  666. .reminder-icon { font-size: 40rpx; margin-right: 16rpx; flex-shrink: 0; }
  667. .reminder-body { flex: 1; min-width: 0; }
  668. .reminder-text { font-size: 26rpx; font-weight: 600; color: #333; display: block; }
  669. .reminder-sub { font-size: 22rpx; color: #999; margin-top: 4rpx; display: block; line-height: 1.4; }
  670. .reminder-arrow { font-size: 28rpx; color: #F97316; flex-shrink: 0; }
  671. .ai-q-head { display: flex; align-items: center; }
  672. .ai-q-icon { font-size: 40rpx; margin-right: 16rpx; }
  673. .ai-q-info { flex: 1; }
  674. .q-title { font-size: 28rpx; font-weight: bold; color: #fff; display: block; }
  675. .ai-q-sub { font-size: 22rpx; color: rgba(255,255,255,0.85); display: block; margin-top: 4rpx; }
  676. .self-test-arrow { font-size: 36rpx; color: rgba(255,255,255,0.7); }
  677. .demo-section { margin: 0 24rpx 16rpx; }
  678. .demo-section-head { margin-bottom: 8rpx; }
  679. .demo-section-title { font-size: 30rpx; font-weight: bold; color: #333; display: block; }
  680. .demo-section-sub { font-size: 22rpx; color: #999; display: block; margin-top: 4rpx; }
  681. .demo-chart-title-row { display: flex; align-items: center; justify-content: space-between; margin: 8rpx 8rpx 0; padding: 0 8rpx; }
  682. .demo-chart-name { font-size: 26rpx; font-weight: 600; color: #333; }
  683. .demo-chart-tag { font-size: 20rpx; color: #F97316; background: rgba(249,115,22,0.1); border-radius: 8rpx; padding: 4rpx 12rpx; }
  684. .login-guide-section { margin: 0 24rpx 24rpx; }
  685. /* ===== 五维闭环体系样式 ===== */
  686. .wuxing-section { margin: 0 24rpx 16rpx; background: #fff; border-radius: 20rpx; padding: 24rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  687. .wuxing-title { font-size: 30rpx; font-weight: bold; color: #333; text-align: center; margin-bottom: 6rpx; }
  688. .wuxing-desc { font-size: 22rpx; color: #999; text-align: center; margin-bottom: 20rpx; }
  689. .wuxing-diagram { position: relative; height: 320rpx; margin: 0 auto 20rpx; }
  690. .wuxing-relations { margin-top: 8rpx; }
  691. .rel-group { margin-bottom: 16rpx; }
  692. .rel-title { font-size: 24rpx; font-weight: bold; color: #333; margin-bottom: 8rpx; display: block; }
  693. .rel-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4rpx; margin-bottom: 6rpx; }
  694. .rel-item { font-size: 22rpx; padding: 4rpx 10rpx; border-radius: 8rpx; background: #f7f7f7; color: #555; }
  695. .rel-arrow { font-size: 20rpx; color: #F97316; font-weight: bold; }
  696. .rel-dot { font-size: 20rpx; color: #ccc; }
  697. .rel-hint { font-size: 20rpx; color: #999; line-height: 1.5; display: block; }
  698. .wuxing-cards { display: flex; flex-direction: column; gap: 10rpx; margin-top: 16rpx; }
  699. .wc-card { display: flex; align-items: center; padding: 16rpx 20rpx; border-radius: 16rpx; border: 2rpx solid #f0f0f0; }
  700. .wc-card:active { opacity: 0.85; }
  701. .wc-icon { font-size: 36rpx; margin-right: 16rpx; flex-shrink: 0; }
  702. .wc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  703. .wc-name { font-size: 24rpx; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  704. .wc-text { font-size: 20rpx; color: #999; display: block; margin-top: 4rpx; white-space: normal; }
  705. .wc-body { border-color: rgba(255,140,66,0.3); background: rgba(255,140,66,0.04); border-left: 8rpx solid #FF8C42; }
  706. .wc-body .wc-name { color: #FF8C42; }
  707. .wc-wisdom { border-color: rgba(99,102,241,0.3); background: rgba(99,102,241,0.04); border-left: 8rpx solid #6366F1; }
  708. .wc-wisdom .wc-name { color: #6366F1; }
  709. .wc-wealth { border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.04); border-left: 8rpx solid #F59E0B; }
  710. .wc-wealth .wc-name { color: #F59E0B; }
  711. .wc-action { border-color: rgba(16,185,129,0.3); background: rgba(16,185,129,0.04); border-left: 8rpx solid #10B981; }
  712. .wc-action .wc-name { color: #10B981; }
  713. .wc-mind { border-color: rgba(255,107,157,0.3); background: rgba(255,107,157,0.04); border-left: 8rpx solid #FF6B9D; }
  714. .wc-mind .wc-name { color: #FF6B9D; }
  715. </style>