index.vue 38 KB

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