index.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942
  1. <template>
  2. <view class="body-container">
  3. <!-- Tabbar 切换过渡页 -->
  4. <tab-transition v-if="showTabTransition" dimCode="body" ref="tabTransition" @close="showTabTransition = false" />
  5. <!-- 品牌头部 -->
  6. <PageBanner theme="body"
  7. tagline="科学管理全家健康"
  8. quote="身体健康是幸福的基础" />
  9. <!-- 品牌定位语(登录前显示) -->
  10. <view class="brand-strap" v-if="!isLoggedIn">
  11. <text class="brand-strap-text">科学管理全家健康数据</text>
  12. </view>
  13. <!-- 雷达图(始终显示,无用户数据时仅显示人群平均值) -->
  14. <view class="section">
  15. <view class="section-header">
  16. <text class="section-title">健康指标</text>
  17. <text class="section-sub">身体健康各项指标,分数越高代表越健康</text>
  18. <text class="avg-badge" v-if="!dimensionData">同龄同性平均值 · 上传健康报告后显示个人数据</text>
  19. </view>
  20. <RadarChart
  21. v-if="radarDimensions && radarDimensions.length >= 3"
  22. :dimensions="radarDimensions"
  23. :scores="radarScores"
  24. :avg-scores="radarFamilyScores"
  25. :population-scores="radarPopulationScores"
  26. fillColor="#FF8C42"
  27. gridColor="#FED7AA"
  28. labelColor="#9A3412"
  29. :width="580"
  30. :height="580"
  31. @dimensionClick="goDimensionDetail" />
  32. </view>
  33. <!-- 身体指标卡片 -->
  34. <view class="indicator-cards-section" v-if="isLoggedIn && (bodyIndicators.length > 0 || gutFloraIndicators.length > 0)">
  35. <view class="section-header">
  36. <text class="section-title">📊 身体指标</text>
  37. <text class="section-more" @click="goToBodyDetail">更多 ›</text>
  38. </view>
  39. <view class="indicator-cards">
  40. <view
  41. v-for="(ind, i) in bodyIndicators"
  42. :key="ind.code"
  43. class="indicator-card"
  44. :class="{ 'no-data': !ind.value }"
  45. @click="goIndicatorDetail(ind)"
  46. >
  47. <view class="indicator-header">
  48. <text class="indicator-name">{{ ind.name }}</text>
  49. <text class="indicator-unit" v-if="ind.unit">{{ ind.unit }}</text>
  50. </view>
  51. <view class="indicator-body">
  52. <text class="indicator-value" v-if="ind.value || ind.numericValue !== null">
  53. {{ ind.value || formatNumeric(ind.numericValue) }}
  54. </text>
  55. <text class="indicator-placeholder" v-else>暂无数据</text>
  56. </view>
  57. <view class="indicator-footer">
  58. <text class="indicator-range" v-if="ind.refRange">参考: {{ ind.refRange }}</text>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 肠道菌群卡片(有菌群报告时显示) -->
  64. <view class="gut-section" v-if="isLoggedIn">
  65. <view class="section-header">
  66. <text class="section-title">🦠 肠道菌群</text>
  67. <text class="section-more" @click="goToBodyDetail">更多 ›</text>
  68. </view>
  69. <view class="gut-summary" v-if="gutSummary && gutFloraIndicators.length > 0">
  70. <text class="gut-summary-text">{{ gutSummary }}</text>
  71. </view>
  72. <view class="gut-groups" v-if="gutFloraIndicators.length > 0">
  73. <view class="gut-group" v-for="group in gutGrouped" :key="group.category">
  74. <text class="gut-group-title">{{ group.title }}</text>
  75. <view class="gut-items">
  76. <view
  77. v-for="(ind, i) in group.items"
  78. :key="i"
  79. class="gut-item"
  80. :class="{ 'gut-abnormal': ind.status === 'high' || ind.status === 'low' }"
  81. >
  82. <text class="gut-item-name">{{ ind.name }}</text>
  83. <view class="gut-item-right">
  84. <text class="gut-item-value" v-if="ind.value">{{ ind.value }}</text>
  85. <text class="gut-item-status" :class="'status-' + (ind.status || 'normal')">{{ ind.status === 'high' ? '偏高' : ind.status === 'low' ? '偏低' : (ind.status || '正常') }}</text>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="gut-empty-hint" v-if="!hasGutReport">
  92. <text>上传菌群检测报告,查看肠道健康指标</text>
  93. <text class="gut-upload-link" @click="goToUploadReport">去上传 →</text>
  94. </view>
  95. </view>
  96. <!-- 疾病风险卡片(有报告且有风险项时显示) -->
  97. <view class="risk-section" v-if="isLoggedIn && diseaseRisks.length > 0">
  98. <view class="section-header">
  99. <text class="section-title">⚠️ 疾病风险</text>
  100. <text class="section-more" @click="goToBodyDetail">更多 ›</text>
  101. </view>
  102. <view class="risk-list">
  103. <view
  104. v-for="(risk, i) in diseaseRisks"
  105. :key="i"
  106. class="risk-item"
  107. :class="'risk-' + (risk.level || 'normal')"
  108. >
  109. <text class="risk-name">{{ risk.name }}</text>
  110. <view class="risk-right">
  111. <text class="risk-value" v-if="risk.value">{{ risk.value }}</text>
  112. <text class="risk-level">{{ risk.level === 'severe' ? '高风险' : risk.level === 'attention' ? '需注意' : (risk.level || '未知') }}</text>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 家庭成员选择条 -->
  118. <FamilyMemberStrip
  119. v-if="currentView === 'self' && isLoggedIn"
  120. :members="familyMembersVisible"
  121. :selectedMemberId="selectedMemberId"
  122. @select="onFamilyMemberSelect"
  123. @removed="loadFamilyMembersVisible" />
  124. <!-- 游客引导语(每月更换) -->
  125. <view class="monthly-guidance" v-if="!isLoggedIn">
  126. <text class="guidance-icon">🌿</text>
  127. <text class="guidance-text">{{ monthlyGuidance }}</text>
  128. </view>
  129. <!-- 登录后:五维能量条 -->
  130. <FamilyEnergyBar
  131. v-if="isLoggedIn"
  132. dimensionCode="body"
  133. :sandboxData="sandboxData"
  134. :dualDimension="dualDimension" />
  135. <!-- 身体指标卡片 -->
  136. <view class="func-section" v-if="sectionVisible('func_entries')">
  137. <view class="func-grid">
  138. <view class="func-item" v-for="item in funcList" :key="item.label" @click="onFuncClick(item)">
  139. <view class="func-icon-wrap">
  140. <text class="func-icon">{{ item.icon }}</text>
  141. </view>
  142. <text class="func-label">{{ item.label }}</text>
  143. </view>
  144. </view>
  145. </view>
  146. <!-- 身维度介绍卡片(登录后显示) -->
  147. <DimensionIntroCard dimCode="body" v-if="isLoggedIn" learn-more-url="/pages/body-detail/dimension-intro" />
  148. <!-- 底部占位 -->
  149. <view class="bottom-spacer"></view>
  150. <FloatingAvatar />
  151. </view>
  152. </template>
  153. <script>
  154. import TabTransition from '../../components/tab-transition.vue'
  155. import PageBanner from '../../components/PageBanner.vue'
  156. import FamilyEnergyBar from '../../components/FamilyEnergyBar.vue'
  157. import RadarChart from '../../components/RadarChart.vue'
  158. import FloatingAvatar from '../../components/AIFloatingAvatar.vue'
  159. import DimensionIntroCard from '../../components/DimensionIntroCard.vue'
  160. import FamilyMemberStrip from '../../components/FamilyMemberStrip.vue'
  161. import { getVisibleSections, getEnergyOverview, getChildren, getFamilyEnergySandbox, getEnergySandbox, getFamilyMemberList, getDimensionOverview, getRadarData, getGutFloraIndicators, getBodyAbnormalIndicators } from '../../utils/api.js'
  162. export default {
  163. components: { TabTransition, PageBanner, FamilyEnergyBar, RadarChart, FloatingAvatar, FamilyMemberStrip, DimensionIntroCard },
  164. data() {
  165. return {
  166. isLoggedIn: false,
  167. role: null,
  168. showTabTransition: true,
  169. activeChildId: null,
  170. selectedMemberId: null,
  171. activeChildName: '',
  172. userName: '',
  173. children: [],
  174. familyMembersVisible: [],
  175. // 接口数据是否已检查(避免"暂无数据"闪烁)
  176. childrenChecked: false,
  177. membersChecked: false,
  178. healthSubDims: [],
  179. bodyIndicators: [],
  180. gutFloraIndicators: [],
  181. hasGutReport: false,
  182. diseaseRisks: [],
  183. sandboxData: null,
  184. currentView: 'self', // 'self' | 'family'
  185. dualDimension: null,
  186. visibleSections: [],
  187. dimensionData: null,
  188. /** 雷达图家庭平均分(来自接口) */
  189. radarFamilyScores: [],
  190. /** 雷达图人群位置分(来自接口) */
  191. radarPopulationScores: [],
  192. funcList: [
  193. { icon: '\u{1F3C3}', label: '运动', needLogin: true, page: '/pages/body/exercise-record' },
  194. { icon: '\u{1F957}', label: '饮食', needLogin: true, page: '/pages/diet/index' },
  195. { icon: '\u{1F634}', label: '作息', needLogin: true, page: '/pages/body/sleep-record' },
  196. { icon: '\u{1F9D8}', label: '冥想', needLogin: true, page: '/pages/health/meditation-index' },
  197. { icon: '\u{1F4CA}', label: '舌诊', needLogin: true, page: '/pages/health/report-upload?reportType=tongue' },
  198. // 问答功能已屏蔽: { icon: '\u{1F3E5}', label: '健康管家', needLogin: true, page: '/pages/ai/chat?mode=butler&fromPage=pages/body/index' },
  199. { icon: '\u{1F9EC}', label: '健康维度', needLogin: true, page: 'health-dimensions' }
  200. ]
  201. }
  202. },
  203. computed: {
  204. /** 七维雷达图:维度标签(API无数据时使用默认标签) */
  205. radarDimensions: function() {
  206. var dims = this.dimensionData && this.dimensionData.dimensions
  207. if (dims && dims.length > 0) {
  208. var result = []
  209. for (var i = 0; i < dims.length; i++) {
  210. var d = dims[i]
  211. if (!d) continue
  212. result.push({ label: d.label || '', key: d.dimension || '' })
  213. }
  214. return result
  215. }
  216. // 无数据时使用默认七维标签
  217. return [
  218. { label: '生长发育', key: 'growth' },
  219. { label: '睡眠质量', key: 'sleep' },
  220. { label: '视力健康', key: 'vision' },
  221. { label: '免疫力', key: 'immunity' },
  222. { label: '营养均衡', key: 'nutrition' },
  223. { label: '肠胃健康', key: 'gut' },
  224. { label: '运动活力', key: 'exercise' }
  225. ]
  226. },
  227. /** 七维雷达图:分值(无数据时返回空数组,仅显示平均值) */
  228. radarScores: function() {
  229. var dims = this.dimensionData && this.dimensionData.dimensions
  230. if (!dims) return []
  231. var result = []
  232. for (var i = 0; i < dims.length; i++) {
  233. var d = dims[i]
  234. if (!d) { result.push(0); continue }
  235. var s = d.score
  236. if (typeof s !== 'number' || isNaN(s) || s === null) s = 0
  237. result.push(s)
  238. }
  239. return result
  240. },
  241. gutGrouped: function() {
  242. var groups = {}
  243. var order = ['core', 'probiotic', 'harmful', 'other']
  244. var titles = { core: '核心菌属', probiotic: '益生菌', harmful: '有害菌', other: '其他重要菌属' }
  245. for (var i = 0; i < this.gutFloraIndicators.length; i++) {
  246. var ind = this.gutFloraIndicators[i]
  247. var cat = ind.category || 'other'
  248. if (!groups[cat]) groups[cat] = { category: cat, title: titles[cat] || cat, items: [] }
  249. groups[cat].items.push(ind)
  250. }
  251. var result = []
  252. for (var j = 0; j < order.length; j++) {
  253. if (groups[order[j]]) result.push(groups[order[j]])
  254. }
  255. return result
  256. },
  257. gutSummary: function() {
  258. if (!this.gutFloraIndicators.length) return ''
  259. var abnormal = this.gutFloraIndicators.filter(function(i) { return i.status === 'high' || i.status === 'low' }).length
  260. if (abnormal === 0) return '菌群整体平衡良好'
  261. if (abnormal <= 2) return '部分菌群指标略有波动'
  262. return '多项菌群指标异常,建议咨询专业营养师'
  263. },
  264. /** 每月引导语 */
  265. monthlyGuidance: function() {
  266. var month = new Date().getMonth()
  267. var messages = [
  268. '一月:新年新健康,从一次体检开始',
  269. '二月:春暖花开,适合调整作息',
  270. '三月:植树节到,守护呼吸健康',
  271. '四月:踏青正当时,关注视力保护',
  272. '五月:劳动节后,重视营养均衡',
  273. '六月:夏日来临,关注肠胃健康',
  274. '七月:暑期到来,规律运动不可少',
  275. '八月:秋前调养,提升免疫力',
  276. '九月:开学季,关注孩子生长发育',
  277. '十月:国庆长假,注意饮食控制',
  278. '十一月:秋冬交替,保暖防寒',
  279. '十二月:年终总结,规划来年健康'
  280. ]
  281. return messages[month] || messages[0]
  282. }
  283. },
  284. onShow() {
  285. this.showTabTransition = true
  286. var token = uni.getStorageSync('token')
  287. this.isLoggedIn = !!token
  288. if (this.isLoggedIn) {
  289. this.role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  290. this.userName = uni.getStorageSync('nickname') || uni.getStorageSync('userName') || '家长'
  291. }
  292. this.loadSectionConfig()
  293. if (this.isLoggedIn) {
  294. this.loadChildren()
  295. this.loadFamilyMembersVisible()
  296. }
  297. // 游客也能浏览活动和商品
  298. // 游客也能浏览文章
  299. this._watchPageReady()
  300. },
  301. methods: {
  302. loadSectionConfig: function() {
  303. var baseSections = ['func_entries']
  304. if (!uni.getStorageSync('token')) {
  305. this.visibleSections = baseSections
  306. return
  307. }
  308. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  309. var self = this
  310. getVisibleSections({ pageKey: 'body', role: role }).then(function(res) {
  311. if (res.code === 200 && res.data) {
  312. var keys = res.data.map(function(s) { return s.sectionKey })
  313. var merged = baseSections.slice()
  314. keys.forEach(function(k) { if (merged.indexOf(k) === -1) merged.push(k) })
  315. self.visibleSections = merged
  316. }
  317. }).catch(function(e) {
  318. self.visibleSections = ['func_entries']
  319. })
  320. },
  321. loadChildren: function() {
  322. var self = this
  323. getChildren().then(function(res) {
  324. if (res.code === 200 && res.data) {
  325. self.children = res.data
  326. var savedChildId = uni.getStorageSync('currentChildId')
  327. var found = false
  328. for (var i = 0; i < self.children.length; i++) {
  329. if (self.children[i].memberId === savedChildId) {
  330. self.activeChildId = savedChildId
  331. self.activeChildName = self.children[i].name || self.children[i].nickname || '孩子'
  332. found = true
  333. break
  334. }
  335. }
  336. if (!found && self.children.length > 0) {
  337. self.activeChildId = self.children[0].memberId
  338. self.activeChildName = self.children[0].name || self.children[0].nickname || '孩子'
  339. uni.setStorageSync('currentChildId', self.activeChildId)
  340. }
  341. if (self.activeChildId) {
  342. self.loadDashboardData()
  343. }
  344. }
  345. self.childrenChecked = true
  346. }).catch(function(e) {
  347. console.log('获取孩子列表失败', e)
  348. self.childrenChecked = true
  349. })
  350. },
  351. loadDashboardData: function() {
  352. if (!this.activeChildId) return
  353. this.loadEnergyData()
  354. this.loadSandboxData()
  355. this.loadHealthDimensions()
  356. },
  357. loadHealthDimensions: function() {
  358. var memberId = this.activeChildId || (this.userInfo && this.userInfo.userId)
  359. if (!memberId) {
  360. console.log('[body] loadHealthDimensions skipped: no memberId')
  361. return
  362. }
  363. var self = this
  364. getDimensionOverview({ memberId: memberId }).then(function(res) {
  365. if (res && res.data) {
  366. self.dimensionData = res.data
  367. self.healthSubDims = (self.dimensionData.dimensions || []).map(function(d) { return {label: d.label || d.dimension, score: d.score || 0, desc: d.description || ''}; });
  368. console.log('[body] dimensionData loaded:', res.data.dimensions ? res.data.dimensions.length : 0, 'dimensions')
  369. } else if (res) {
  370. console.warn('[body] dimension API error:', res.message || res.code)
  371. }
  372. }).catch(function(e) {
  373. console.error('[body] loadHealthDimensions failed', e)
  374. })
  375. // 加载雷达图三层数据(实际值/人群位置/家庭占比)
  376. getRadarData({ memberId: memberId, dimensions: ['growth','sleep','vision','immunity','nutrition','gut','exercise'] }).then(function(res) {
  377. if (res && res.data) {
  378. self.radarFamilyScores = res.data.familyScores || []
  379. self.radarPopulationScores = res.data.populationScores || []
  380. }
  381. }).catch(function(e) {
  382. console.warn('[body] radar-data failed', e)
  383. })
  384. // 加载身体指标列表
  385. self.loadBodyIndicators(memberId)
  386. // 加载菌群指标
  387. self.loadGutFlora(memberId)
  388. // 加载疾病风险
  389. self.loadDiseaseRisks(memberId)
  390. },
  391. loadBodyIndicators: function(memberId) {
  392. var self = this
  393. getLatestIndicators({ memberId: memberId, domain: 'body' }).then(function(res) {
  394. if (res.code === 200) {
  395. self.bodyIndicators = res.data || []
  396. }
  397. }).catch(function(e) {
  398. console.log('[body] loadBodyIndicators failed', e)
  399. })
  400. },
  401. loadGutFlora: function(memberId) {
  402. var self = this
  403. getGutFloraIndicators({ memberId: memberId }).then(function(res) {
  404. if (res.code === 200) { self.gutFloraIndicators = res.data || []; self.hasGutReport = (res.data && res.data.length > 0) }
  405. }).catch(function(e) { console.log('[body] loadGutFlora failed', e) })
  406. },
  407. loadSandboxData: function() {
  408. var self = this
  409. getFamilyEnergySandbox().then(function(res) {
  410. if (res && res.data) {
  411. self.sandboxData = res.data
  412. }
  413. }).catch(function(e) {
  414. console.log('获取沙盘数据失败', e)
  415. })
  416. },
  417. switchView: function(view) {
  418. this.currentView = view
  419. if (view === 'family') {
  420. this.selectedMemberId = null
  421. var self = this
  422. getEnergySandbox('family').then(function(res) {
  423. if (res && res.data && !res.data.locked) {
  424. self.sandboxData = res.data.familyData || res.data
  425. }
  426. }).catch(function(e) { console.log('获取家庭数据失败', e) })
  427. } else {
  428. this.loadSandboxData()
  429. }
  430. },
  431. loadEnergyData: function() {
  432. var self = this
  433. getEnergyOverview(this.activeChildId).then(function(res) {
  434. if (res && res.data) {
  435. var dims = res.data.dimensions
  436. if (dims && dims.length > 0) {
  437. for (var i = 0; i < dims.length; i++) {
  438. if (dims[i].code === 'body') {
  439. self.dualDimension = dims[i]
  440. break
  441. }
  442. }
  443. }
  444. }
  445. }).catch(function(e) {
  446. console.log('获取能量概览失败', e)
  447. })
  448. },
  449. onFamilyMemberSelect: function(member) {
  450. this.selectedMemberId = member.id
  451. },
  452. onChildChanged: function(child) {
  453. this.activeChildId = child.memberId
  454. this.activeChildName = child.name || child.nickname || '孩子'
  455. this.loadDashboardData()
  456. },
  457. loadFamilyMembersVisible: function() {
  458. var self = this
  459. getFamilyMemberList({ visibleOnly: true }).then(function(res) {
  460. self.familyMembersVisible = res.data || []
  461. self.membersChecked = true
  462. }).catch(function(e) {
  463. console.log('获取可见家庭成员失败', e)
  464. self.familyMembersVisible = []
  465. self.membersChecked = true
  466. })
  467. },
  468. scrollToSection: function(section) {
  469. uni.pageScrollTo({ selector: '#' + section, duration: 300 })
  470. },
  471. sectionVisible: function(key) {
  472. return this.visibleSections.length === 0 || this.visibleSections.indexOf(key) !== -1
  473. },
  474. onFuncClick: function(item) {
  475. if (item.needLogin && !this.isLoggedIn) {
  476. uni.showModal({
  477. title: '提示',
  478. content: '请先登录后使用此功能',
  479. success: function(res) {
  480. if (res.confirm) uni.navigateTo({ url: '/pages/login/login' })
  481. }
  482. })
  483. return
  484. }
  485. if (item.page === 'health-dimensions') {
  486. if (!this.activeChildId) {
  487. uni.showToast({ title: '请先选择孩子', icon: 'none' })
  488. return
  489. }
  490. uni.navigateTo({ url: '/pages/body-detail/health-dimensions?memberId=' + this.activeChildId })
  491. return
  492. }
  493. if (item.page) uni.navigateTo({ url: item.page })
  494. },
  495. goDimensionDetail: function(dimKey) {
  496. uni.navigateTo({ url: '/pages/body-detail/dimension-detail?dimension=' + dimKey + '&memberId=' + this.activeChildId })
  497. },
  498. goToCheckin: function() {
  499. var id = this.activeChildId || uni.getStorageSync('currentChildId')
  500. if (!id) {
  501. uni.showToast({ title: '请先选择成员', icon: 'none' })
  502. return
  503. }
  504. uni.navigateTo({ url: '/pages/body-detail/checkin?memberId=' + id })
  505. },
  506. goToNutritionProfile: function() {
  507. var id = this.activeChildId || uni.getStorageSync('currentChildId')
  508. if (!id) {
  509. uni.showToast({ title: '请先选择成员', icon: 'none' })
  510. return
  511. }
  512. uni.navigateTo({ url: '/pages/health/nutrition-profile?memberId=' + id })
  513. },
  514. loadDiseaseRisks: function(memberId) {
  515. var self = this
  516. getBodyAbnormalIndicators(memberId).then(function(res) {
  517. if (res.code === 200 && res.data && res.data.diseaseRisks) {
  518. self.diseaseRisks = res.data.diseaseRisks
  519. }
  520. }).catch(function(e) { console.log('[body] loadDiseaseRisks failed', e) })
  521. },
  522. goToBodyDetail: function() {
  523. var id = this.activeChildId || uni.getStorageSync('currentChildId')
  524. if (!id) return
  525. uni.navigateTo({ url: '/pages/body-detail/member-body-detail?memberId=' + id })
  526. },
  527. goIndicatorDetail: function(ind) {
  528. var id = this.activeChildId || uni.getStorageSync('currentChildId')
  529. if (!id) return
  530. uni.navigateTo({ url: '/pages/body-detail/dimension-detail?dimension=' + ind.code + '&memberId=' + id })
  531. },
  532. formatNumeric: function(v) {
  533. if (v === null || v === undefined) return ''
  534. var n = parseFloat(v)
  535. if (isNaN(n)) return String(v)
  536. return n % 1 === 0 ? String(n) : n.toFixed(1)
  537. },
  538. goToUploadReport: function() {
  539. var id = this.activeChildId || uni.getStorageSync('currentChildId') || ''
  540. uni.navigateTo({ url: '/pages/health/report-upload?memberId=' + id + '&from=body' })
  541. },
  542. _watchPageReady() {
  543. var self = this
  544. var unwatch = this.$watch(function() {
  545. if (self.isLoggedIn) {
  546. return !!(self.dualDimension || self.sandboxData)
  547. }
  548. }, function(val) {
  549. if (val) {
  550. if (unwatch) unwatch()
  551. if (self.$refs.tabTransition) self.$refs.tabTransition.markReady()
  552. }
  553. })
  554. }
  555. }
  556. }
  557. </script>
  558. <style scoped>
  559. .body-container {
  560. min-height: 100vh;
  561. background: #f5f7fa;
  562. padding-bottom: 120rpx;
  563. }
  564. /* ===== 功能入口 ===== */
  565. .func-section {
  566. margin: 20rpx 30rpx;
  567. }
  568. .func-grid {
  569. display: flex;
  570. flex-direction: row;
  571. justify-content: space-between;
  572. background: #fff;
  573. border-radius: 20rpx;
  574. padding: 24rpx 16rpx;
  575. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  576. }
  577. .func-item {
  578. display: flex;
  579. flex-direction: column;
  580. align-items: center;
  581. flex: 1;
  582. }
  583. .func-icon-wrap {
  584. width: 80rpx;
  585. height: 80rpx;
  586. border-radius: 40rpx;
  587. background: linear-gradient(135deg, #D6EAF8, #EBF2FA);
  588. display: flex;
  589. align-items: center;
  590. justify-content: center;
  591. margin-bottom: 10rpx;
  592. }
  593. .func-icon {
  594. font-size: 40rpx;
  595. }
  596. .func-label {
  597. font-size: 22rpx;
  598. color: #666;
  599. font-weight: 500;
  600. }
  601. /* ===== 通用区块 ===== */
  602. .section {
  603. margin: 20rpx 30rpx;
  604. }
  605. .section-header {
  606. display: flex;
  607. flex-direction: row;
  608. align-items: center;
  609. justify-content: space-between;
  610. margin-bottom: 16rpx;
  611. }
  612. .section-title {
  613. font-size: 30rpx;
  614. font-weight: bold;
  615. color: #333;
  616. }
  617. .avg-badge {
  618. font-size: 20rpx;
  619. color: #F97316;
  620. background: #FFF7ED;
  621. padding: 4rpx 12rpx;
  622. border-radius: 20rpx;
  623. margin-left: 12rpx;
  624. }
  625. /* ===== 快捷操作 ===== */
  626. .quick-actions {
  627. display: flex;
  628. flex-direction: row;
  629. margin-top: 30rpx;
  630. }
  631. .action-btn {
  632. flex: 1;
  633. background: #fff;
  634. border-radius: 16rpx;
  635. padding: 24rpx;
  636. display: flex;
  637. flex-direction: column;
  638. align-items: center;
  639. margin-right: 20rpx;
  640. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  641. }
  642. .action-btn:last-child {
  643. margin-right: 0;
  644. }
  645. .action-icon {
  646. font-size: 48rpx;
  647. margin-bottom: 8rpx;
  648. }
  649. .action-text {
  650. font-size: 26rpx;
  651. color: #666;
  652. }
  653. /* ===== 底部 ===== */
  654. /* ===== 肠道菌群 ===== */
  655. .gut-section { margin: 20rpx 30rpx; }
  656. .gut-summary { background: #F0F9FF; border-radius: 16rpx; padding: 16rpx 20rpx; margin-bottom: 16rpx; }
  657. .gut-summary-text { font-size: 26rpx; color: #0369A1; }
  658. .gut-group { background: #fff; border-radius: 16rpx; padding: 20rpx 24rpx; margin-bottom: 16rpx; }
  659. .gut-group-title { font-size: 28rpx; font-weight: bold; color: #333; margin-bottom: 12rpx; display: block; }
  660. .gut-item { display: flex; align-items: center; justify-content: space-between; padding: 12rpx 0; border-bottom: 1rpx solid #F3F4F6; }
  661. .gut-item:last-child { border-bottom: none; }
  662. .gut-item.gut-abnormal .gut-item-name { color: #EF4444; }
  663. .gut-item-name { font-size: 26rpx; color: #333; flex: 1; }
  664. .gut-item-right { display: flex; align-items: center; gap: 12rpx; }
  665. .gut-item-value { font-size: 26rpx; color: #666; }
  666. .gut-item-status { font-size: 22rpx; padding: 4rpx 12rpx; border-radius: 20rpx; }
  667. .gut-item-status.status-high { background: #FEE2E2; color: #DC2626; }
  668. .gut-item-status.status-low { background: #FEF3C7; color: #D97706; }
  669. .gut-item-status.status-normal { background: #D1FAE5; color: #059669; }
  670. .gut-empty-hint { text-align: center; padding: 30rpx; color: #999; font-size: 26rpx; background: #fff; border-radius: 16rpx; margin-bottom: 16rpx; }
  671. .gut-upload-link { color: #3B82F6; margin-left: 8rpx; }
  672. /* ===== 疾病风险 ===== */
  673. .risk-section { margin: 20rpx 30rpx; }
  674. .risk-list { background: #fff; border-radius: 16rpx; padding: 8rpx 0; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  675. .risk-item { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; border-bottom: 1rpx solid #F3F4F6; }
  676. .risk-item:last-child { border-bottom: none; }
  677. .risk-item.risk-severe { background: #FEF2F2; }
  678. .risk-item.risk-attention { background: #FFFBEB; }
  679. .risk-name { font-size: 28rpx; font-weight: 500; color: #333; flex: 1; }
  680. .risk-right { display: flex; align-items: center; gap: 12rpx; }
  681. .risk-value { font-size: 24rpx; color: #666; }
  682. .risk-level { font-size: 22rpx; padding: 4rpx 12rpx; border-radius: 20rpx; }
  683. .risk-level.risk-severe { background: #FEE2E2; color: #DC2626; }
  684. .risk-level.risk-attention { background: #FEF3C7; color: #D97706; }
  685. .bottom-spacer {
  686. height: 120rpx;
  687. }
  688. .indicator-cards-section { margin: 20rpx 30rpx; }
  689. .indicator-cards { display: flex; flex-direction: row; flex-wrap: wrap; gap: 16rpx; }
  690. .indicator-card { width: calc(50% - 8rpx); background: #fff; border-radius: 20rpx; padding: 24rpx 20rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06); }
  691. .indicator-card.no-data { opacity: 0.5; }
  692. .indicator-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12rpx; }
  693. .indicator-name { font-size: 26rpx; color: #666; font-weight: 500; }
  694. .indicator-unit { font-size: 22rpx; color: #999; }
  695. .indicator-body { margin-bottom: 8rpx; }
  696. .indicator-value { font-size: 40rpx; font-weight: bold; color: #FF8C42; }
  697. .indicator-placeholder { font-size: 26rpx; color: #ccc; }
  698. .indicator-range { font-size: 20rpx; color: #bbb; }
  699. .func-item:active, .action-btn:active {
  700. opacity: 0.7;
  701. }
  702. /* ===== 精准营养 ===== */
  703. .nutrition-section {
  704. margin-top: 20rpx;
  705. }
  706. .nutrition-report-card {
  707. display: flex;
  708. flex-direction: row;
  709. align-items: center;
  710. background: linear-gradient(135deg, #E8F5E9, #F1F8E9);
  711. border-radius: 20rpx;
  712. padding: 28rpx 24rpx;
  713. margin-bottom: 20rpx;
  714. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  715. }
  716. .nutrition-report-left {
  717. width: 100rpx;
  718. height: 100rpx;
  719. background: rgba(255,255,255,0.7);
  720. border-radius: 20rpx;
  721. display: flex;
  722. align-items: center;
  723. justify-content: center;
  724. margin-right: 20rpx;
  725. flex-shrink: 0;
  726. }
  727. .nutrition-icon-large {
  728. font-size: 52rpx;
  729. }
  730. .nutrition-report-right {
  731. flex: 1;
  732. }
  733. .nutrition-title {
  734. font-size: 30rpx;
  735. font-weight: bold;
  736. color: #2E7D32;
  737. display: block;
  738. margin-bottom: 6rpx;
  739. }
  740. .nutrition-desc {
  741. font-size: 22rpx;
  742. color: #558B2F;
  743. line-height: 1.5;
  744. display: block;
  745. margin-bottom: 10rpx;
  746. }
  747. .nutrition-report-tags {
  748. display: flex;
  749. flex-direction: row;
  750. gap: 10rpx;
  751. }
  752. .nutrition-report-tags .tag {
  753. font-size: 20rpx;
  754. color: #33691E;
  755. background: rgba(255,255,255,0.6);
  756. padding: 4rpx 14rpx;
  757. border-radius: 20rpx;
  758. }
  759. .nutrition-arrow {
  760. font-size: 40rpx;
  761. color: #A5D6A7;
  762. margin-left: 12rpx;
  763. }
  764. .nutrition-links {
  765. margin-bottom: 20rpx;
  766. }
  767. .links-label {
  768. font-size: 26rpx;
  769. font-weight: bold;
  770. color: #333;
  771. display: block;
  772. margin-bottom: 12rpx;
  773. }
  774. .links-row {
  775. display: flex;
  776. flex-direction: row;
  777. gap: 16rpx;
  778. }
  779. .link-item {
  780. flex: 1;
  781. display: flex;
  782. flex-direction: row;
  783. align-items: center;
  784. background: #fff;
  785. border-radius: 16rpx;
  786. padding: 20rpx 18rpx;
  787. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  788. gap: 12rpx;
  789. }
  790. .link-item:active {
  791. opacity: 0.7;
  792. }
  793. .link-icon {
  794. font-size: 36rpx;
  795. flex-shrink: 0;
  796. }
  797. .link-texts {
  798. flex: 1;
  799. }
  800. .link-name {
  801. font-size: 24rpx;
  802. font-weight: 500;
  803. color: #333;
  804. display: block;
  805. margin-bottom: 4rpx;
  806. }
  807. .link-desc {
  808. font-size: 20rpx;
  809. color: #999;
  810. display: block;
  811. }
  812. .link-arrow {
  813. font-size: 32rpx;
  814. color: #CCC;
  815. flex-shrink: 0;
  816. }
  817. /* ===== 推荐阅读 ===== */
  818. .article-list {
  819. display: flex;
  820. flex-direction: column;
  821. gap: 16rpx;
  822. }
  823. .article-card {
  824. background: #fff;
  825. border-radius: 16rpx;
  826. padding: 24rpx;
  827. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  828. }
  829. .article-card:active {
  830. opacity: 0.8;
  831. }
  832. .article-category {
  833. display: inline-block;
  834. padding: 4rpx 14rpx;
  835. border-radius: 8rpx;
  836. margin-bottom: 10rpx;
  837. }
  838. .article-category-text {
  839. font-size: 20rpx;
  840. color: #fff;
  841. }
  842. .article-title {
  843. display: block;
  844. font-size: 28rpx;
  845. font-weight: bold;
  846. color: #333;
  847. margin-bottom: 8rpx;
  848. line-height: 1.4;
  849. }
  850. .article-summary {
  851. display: block;
  852. font-size: 24rpx;
  853. color: #888;
  854. line-height: 1.5;
  855. margin-bottom: 12rpx;
  856. overflow: hidden;
  857. text-overflow: ellipsis;
  858. display: -webkit-box;
  859. -webkit-line-clamp: 2;
  860. -webkit-box-orient: vertical;
  861. }
  862. .article-meta {
  863. display: flex;
  864. align-items: center;
  865. gap: 16rpx;
  866. }
  867. .meta-item {
  868. display: flex;
  869. align-items: center;
  870. gap: 4rpx;
  871. }
  872. .meta-icon {
  873. font-size: 24rpx;
  874. }
  875. .meta-text {
  876. font-size: 22rpx;
  877. color: #999;
  878. }
  879. .article-date {
  880. font-size: 22rpx;
  881. color: #bbb;
  882. }
  883. /* 品牌定位语 */
  884. .brand-strap {
  885. margin: 16rpx 30rpx 0;
  886. padding: 20rpx 28rpx;
  887. background: linear-gradient(135deg, #FFF7ED, rgba(255,140,66,0.12));
  888. border-radius: 16rpx;
  889. border-left: 4rpx solid #FF8C42;
  890. }
  891. .brand-strap-text {
  892. font-size: 26rpx;
  893. color: #9A3412;
  894. font-weight: 500;
  895. }
  896. /* 每月引导语 */
  897. .monthly-guidance {
  898. margin: 16rpx 30rpx 0;
  899. padding: 20rpx 28rpx;
  900. background: linear-gradient(135deg, #FFF7ED, rgba(255,140,66,0.08));
  901. border-radius: 16rpx;
  902. border-left: 4rpx solid #FF8C42;
  903. display: flex;
  904. align-items: center;
  905. gap: 12rpx;
  906. }
  907. .guidance-icon {
  908. font-size: 32rpx;
  909. }
  910. .guidance-text {
  911. font-size: 26rpx;
  912. color: #9A3412;
  913. font-weight: 500;
  914. }
  915. </style>