index.vue 40 KB

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