index.vue 30 KB

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