index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011
  1. <template>
  2. <view class="body-container">
  3. <!-- Tabbar 切换过渡页 -->
  4. <tab-transition v-if="showTabTransition" dimCode="body" />
  5. <!-- 品牌头部 -->
  6. <PageBanner theme="body"
  7. tagline="科学管理全家健康"
  8. quote="身体健康是幸福的基础" />
  9. <!-- 游客专属区块 -->
  10. <template v-if="!isLoggedIn">
  11. <LoginGuideCard
  12. title="登录后查看全家健康数据"
  13. :items="[
  14. '查看全家身体能量数据和健康报告',
  15. '记录每日健康打卡,获取身体能量',
  16. '查看专属健康商品和活动价格'
  17. ]" />
  18. <HealthTips dimension="body" />
  19. </template>
  20. <!-- 登录后:五维能量条 -->
  21. <FamilyEnergyBar
  22. v-if="isLoggedIn"
  23. dimensionCode="body"
  24. :sandboxData="sandboxData"
  25. :dualDimension="dualDimension" />
  26. <!-- 关系图谱(登录后可见) -->
  27. <FamilyRelationGraph
  28. v-if="isLoggedIn && familyMembersVisible.length > 0"
  29. dimensionCode="body"
  30. :selfId="activeChildId"
  31. :members="familyMembersVisible"
  32. :energyMap="energyMapForGraph"
  33. :intimacyMap="intimacyMapForGraph"
  34. @memberTap="goMemberDetail" />
  35. <!-- 登录后:用户快捷入口 -->
  36. <UserQuickEntry
  37. v-if="isLoggedIn"
  38. :userName="userName"
  39. roleName="家长"
  40. :currentChildName="activeChildName"
  41. :children="children"
  42. @childChanged="onChildChanged"
  43. @scrollTo="scrollToSection" />
  44. <!-- 雷达图 -->
  45. <view class="section" v-if="dimensionData">
  46. <view class="section-header" v-if="dimensionData.isAverage">
  47. <text class="section-title">七维健康图</text>
  48. <text class="avg-badge">同龄同性平均值 · 上传报告后显示个人数据</text>
  49. </view>
  50. <view class="section-header" v-else>
  51. <text class="section-title">七维健康图</text>
  52. </view>
  53. <RadarChart
  54. v-if="dimensionData && dimensionData.dimensions"
  55. :dimensions="dimensionData.dimensions.map(function(d) { return { label: d.label, key: d.dimension } })"
  56. :scores="dimensionData.dimensions.map(function(d) { return d.score })"
  57. :avg-scores="radarAvgScores"
  58. fillColor="#FF8C42"
  59. gridColor="#FED7AA"
  60. labelColor="#9A3412"
  61. :width="580"
  62. :height="580"
  63. @dimensionClick="goDimensionDetail" />
  64. </view>
  65. <!-- 七维健康全景(嵌入卡片) -->
  66. <HealthDimensionsSection
  67. v-if="isLoggedIn && dimensionData && dimensionData.dimensions"
  68. :healthData="dimensionData"
  69. :activeChildId="activeChildId" />
  70. <!-- 功能入口 -->
  71. <view class="func-section" v-if="sectionVisible('func_entries')">
  72. <view class="func-grid">
  73. <view class="func-item" v-for="item in funcList" :key="item.label" @click="onFuncClick(item)">
  74. <view class="func-icon-wrap">
  75. <text class="func-icon">{{ item.icon }}</text>
  76. </view>
  77. <text class="func-label">{{ item.label }}</text>
  78. </view>
  79. </view>
  80. </view>
  81. <!-- 健康报告摘要(登录后可见) -->
  82. <view class="section" v-if="sectionVisible('health_report') && isLoggedIn">
  83. <view class="section-header">
  84. <text class="section-title">健康报告</text>
  85. <text class="section-more" @click="goToHealthReport">查看详情 ›</text>
  86. </view>
  87. <view class="report-card" v-if="latestReport">
  88. <view class="report-type-tag">{{ reportTypeLabel }}</view>
  89. <view class="report-score-row">
  90. <view class="score-circle">
  91. <text class="score-value">{{ latestReport.overallScore || '--' }}</text>
  92. <text class="score-label">综合评分</text>
  93. </view>
  94. <view class="report-meta">
  95. <view class="meta-item" v-if="latestReport.gutHealthScore">
  96. <text class="meta-label">肠道健康</text>
  97. <text class="meta-value">{{ latestReport.gutHealthScore }}</text>
  98. </view>
  99. <view class="meta-item" v-if="latestReport.nutritionScore">
  100. <text class="meta-label">营养状况</text>
  101. <text class="meta-value">{{ latestReport.nutritionScore }}</text>
  102. </view>
  103. <view class="meta-item" v-if="latestReport.gutAge">
  104. <text class="meta-label">肠道年龄</text>
  105. <text class="meta-value">{{ latestReport.gutAge }}</text>
  106. </view>
  107. </view>
  108. </view>
  109. <text class="report-date">报告日期:{{ formatDate(latestReport.reportDate) }}</text>
  110. </view>
  111. <view class="report-empty" v-else>
  112. <text class="empty-tip">暂无健康报告</text>
  113. <text class="empty-sub">规划师录入后将自动显示</text>
  114. </view>
  115. </view>
  116. <!-- ===== 精准营养(上传报告+产品+文章) ===== -->
  117. <view class="section nutrition-section" v-if="isLoggedIn">
  118. <view class="section-header">
  119. <text class="section-title">🥗 精准营养</text>
  120. </view>
  121. <!-- 上传报告入口 -->
  122. <view class="nutrition-report-card" @click="goToUploadReport">
  123. <view class="nutrition-report-left">
  124. <text class="nutrition-icon-large">📋</text>
  125. </view>
  126. <view class="nutrition-report-right">
  127. <text class="nutrition-title">上传健康报告</text>
  128. <text class="nutrition-desc">上传体检报告或肠道检测报告,AI智能解读分析,获取个性化营养方案</text>
  129. <view class="nutrition-report-tags">
  130. <text class="tag">体检报告</text>
  131. <text class="tag">肠道检测</text>
  132. <text class="tag">AI解读</text>
  133. </view>
  134. </view>
  135. <text class="nutrition-arrow">›</text>
  136. </view>
  137. </view>
  138. <!-- 维度任务 -->
  139. <DimensionTasks
  140. v-if="isLoggedIn"
  141. dimensionCode="body"
  142. :tasks="dimensionTasks"
  143. @taskClick="onTaskClick"
  144. @moreTasks="goTasks" />
  145. <!-- 维度活动 -->
  146. <DimensionActivities
  147. dimensionCode="body"
  148. :activities="dimensionActivities"
  149. :isLoggedIn="isLoggedIn"
  150. @activityClick="goActivityDetail"
  151. @moreActivities="goMoreActivities" />
  152. <!-- 维度商品 -->
  153. <DimensionProducts
  154. dimensionCode="body"
  155. :products="dimensionProducts"
  156. @productClick="goProductDetail"
  157. @moreProducts="goMoreProducts" />
  158. <!-- 推荐阅读 -->
  159. <DimensionArticles
  160. dimensionCode="body"
  161. :articles="bodyArticles"
  162. :isLoggedIn="isLoggedIn"
  163. @articleClick="goArticleDetail"
  164. @moreArticles="goMoreArticles" />
  165. <!-- 快捷操作按钮 -->
  166. <view class="section quick-actions" v-if="isLoggedIn">
  167. <view class="action-btn" @click="goToHealthReport">
  168. <text class="action-icon">📋</text>
  169. <text class="action-text">报告详情</text>
  170. </view>
  171. <view class="action-btn" @click="goToCheckin">
  172. <text class="action-icon">🏃</text>
  173. <text class="action-text">健康打卡</text>
  174. </view>
  175. <view class="action-btn" @click="goToNutritionProfile">
  176. <text class="action-icon">🥗</text>
  177. <text class="action-text">营养档案</text>
  178. </view>
  179. </view>
  180. <!-- 底部占位 -->
  181. <view class="bottom-spacer"></view>
  182. <AIFloatingAvatar />
  183. </view>
  184. </template>
  185. <script>
  186. import TabTransition from '../../components/tab-transition.vue'
  187. import PageBanner from '../../components/PageBanner.vue'
  188. import LoginGuideCard from '../../components/LoginGuideCard.vue'
  189. import FamilyEnergyBar from '../../components/FamilyEnergyBar.vue'
  190. import UserQuickEntry from '../../components/UserQuickEntry.vue'
  191. import DimensionTasks from '../../components/DimensionTasks.vue'
  192. import DimensionActivities from '../../components/DimensionActivities.vue'
  193. import DimensionProducts from '../../components/DimensionProducts.vue'
  194. import DimensionArticles from '../../components/DimensionArticles.vue'
  195. import FamilyRelationGraph from '../../components/FamilyRelationGraph.vue'
  196. import RadarChart from '../../components/RadarChart.vue'
  197. import HealthDimensionsSection from '../../components/HealthDimensionsSection.vue'
  198. import AIFloatingAvatar from '../../components/AIFloatingAvatar.vue'
  199. import { getVisibleSections, getEnergyOverview, getChildren, getTodayTasksByCategory, getActivityList, getProductsByDomain, getFamilyEnergySandbox, getVisibleFamilyMembers, getDimensionOverview, getFeaturedArticles } from '../../utils/api.js'
  200. import config from '../../config.js'
  201. var BASE_URL = config.api('')
  202. const healthRequest = function(url, data) {
  203. var token = uni.getStorageSync('token')
  204. return new Promise(function(resolve, reject) {
  205. uni.request({
  206. url: BASE_URL + url,
  207. method: 'POST',
  208. data: data,
  209. header: {
  210. 'Content-Type': 'application/json',
  211. 'Authorization': token ? 'Bearer ' + token : ''
  212. },
  213. success: function(res) {
  214. if (res.data.code === 200) {
  215. resolve(res.data)
  216. } else {
  217. reject(res.data)
  218. }
  219. },
  220. fail: function(err) {
  221. reject(err)
  222. }
  223. })
  224. })
  225. }
  226. export default {
  227. components: { TabTransition, PageBanner, LoginGuideCard, FamilyEnergyBar, UserQuickEntry, DimensionTasks, DimensionActivities, DimensionProducts, DimensionArticles, FamilyRelationGraph, RadarChart, HealthDimensionsSection, AIFloatingAvatar },
  228. data() {
  229. return {
  230. isLoggedIn: false,
  231. role: null,
  232. showTabTransition: true,
  233. activeChildId: null,
  234. activeChildName: '',
  235. userName: '',
  236. children: [],
  237. familyMembersVisible: [],
  238. sandboxData: null,
  239. dualDimension: null,
  240. visibleSections: [],
  241. latestReport: null,
  242. dimensionTasks: [],
  243. dimensionActivities: [],
  244. dimensionProducts: [],
  245. bodyArticles: [],
  246. dimensionData: null,
  247. /** Mock 平均值(7维):生长发育/睡眠质量/视力健康/免疫力/营养均衡/肠胃健康/运动活力 */
  248. radarAvgScores: [72, 68, 75, 70, 73, 69, 71],
  249. funcList: [
  250. { icon: '\u{1F3C3}', label: '运动', needLogin: true, page: '/pages/body/exercise-record' },
  251. { icon: '\u{1F957}', label: '饮食', needLogin: true, page: '/pages/body/meal-record' },
  252. { icon: '\u{1F634}', label: '作息', needLogin: true, page: '/pages/body/sleep-record' },
  253. { icon: '\u{1F9D8}', label: '冥想', needLogin: true, page: '/pages/health/meditation-index' },
  254. { icon: '\u{1F4CA}', label: '舌诊', needLogin: true, page: '/pages/health/report-upload?reportType=tongue' }
  255. }
  256. },
  257. computed: {
  258. reportTypeLabel: function() {
  259. if (!this.latestReport) return ''
  260. return this.latestReport.reportType === 'gut_flora' ? '肠道检测报告' : '体检报告'
  261. },
  262. energyMapForGraph: function() {
  263. var map = {}
  264. if (this.sandboxData && this.sandboxData.members) {
  265. for (var i = 0; i < this.sandboxData.members.length; i++) {
  266. var m = this.sandboxData.members[i]
  267. map[m.memberId || m.id] = {
  268. bodyScore: m.bodyScore || 0,
  269. mindScore: m.mindScore || 0,
  270. actionScore: m.actionScore || 0
  271. }
  272. }
  273. }
  274. return map
  275. },
  276. intimacyMapForGraph: function() {
  277. return {}
  278. }
  279. },
  280. onShow() {
  281. this.showTabTransition = true
  282. var token = uni.getStorageSync('token')
  283. this.isLoggedIn = !!token
  284. if (this.isLoggedIn) {
  285. this.role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  286. this.userName = uni.getStorageSync('nickname') || uni.getStorageSync('userName') || '家长'
  287. }
  288. this.loadSectionConfig()
  289. if (this.isLoggedIn) {
  290. this.loadChildren()
  291. this.loadFamilyMembersVisible()
  292. }
  293. // 游客也能浏览活动和商品
  294. this.loadDimensionActivities()
  295. this.loadDimensionProducts()
  296. // 游客也能浏览文章
  297. this.loadFeaturedArticles()
  298. this._watchPageReady()
  299. },
  300. methods: {
  301. loadSectionConfig: function() {
  302. var baseSections = ['func_entries']
  303. if (!uni.getStorageSync('token')) {
  304. this.visibleSections = baseSections
  305. return
  306. }
  307. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  308. var self = this
  309. getVisibleSections({ pageKey: 'body', role: role }).then(function(res) {
  310. if (res.code === 200 && res.data) {
  311. var keys = res.data.map(function(s) { return s.sectionKey })
  312. var merged = baseSections.slice()
  313. keys.forEach(function(k) { if (merged.indexOf(k) === -1) merged.push(k) })
  314. self.visibleSections = merged
  315. }
  316. }).catch(function(e) {
  317. self.visibleSections = ['func_entries']
  318. })
  319. },
  320. loadChildren: function() {
  321. var self = this
  322. getChildren().then(function(res) {
  323. if (res.code === 200 && res.data) {
  324. self.children = res.data
  325. var savedChildId = uni.getStorageSync('currentChildId')
  326. var found = false
  327. for (var i = 0; i < self.children.length; i++) {
  328. if (self.children[i].childId === savedChildId) {
  329. self.activeChildId = savedChildId
  330. self.activeChildName = self.children[i].name || self.children[i].nickname || '孩子'
  331. found = true
  332. break
  333. }
  334. }
  335. if (!found && self.children.length > 0) {
  336. self.activeChildId = self.children[0].childId
  337. self.activeChildName = self.children[0].name || self.children[0].nickname || '孩子'
  338. uni.setStorageSync('currentChildId', self.activeChildId)
  339. }
  340. if (self.activeChildId) {
  341. self.loadDashboardData()
  342. }
  343. }
  344. }).catch(function(e) {
  345. console.log('获取孩子列表失败', e)
  346. })
  347. },
  348. loadDashboardData: function() {
  349. if (!this.activeChildId) return
  350. this.loadHealthReport()
  351. this.loadEnergyData()
  352. this.loadDimensionTasks()
  353. this.loadDimensionActivities()
  354. this.loadDimensionProducts()
  355. this.loadSandboxData()
  356. this.loadHealthDimensions()
  357. },
  358. loadHealthDimensions: function() {
  359. if (!this.activeChildId) {
  360. console.log('[body] loadHealthDimensions skipped: no activeChildId')
  361. return
  362. }
  363. var self = this
  364. getDimensionOverview({ memberId: this.activeChildId }).then(function(res) {
  365. if (res && res.data) {
  366. self.dimensionData = res.data
  367. console.log('[body] dimensionData loaded:', res.data.dimensions ? res.data.dimensions.length : 0, 'dimensions')
  368. } else if (res) {
  369. console.warn('[body] dimension API error:', res.message || res.code)
  370. }
  371. }).catch(function(e) {
  372. console.error('[body] loadHealthDimensions failed', e)
  373. })
  374. },
  375. loadSandboxData: function() {
  376. var self = this
  377. getFamilyEnergySandbox().then(function(res) {
  378. if (res && res.data) {
  379. self.sandboxData = res.data
  380. }
  381. }).catch(function(e) {
  382. console.log('获取沙盘数据失败', e)
  383. })
  384. },
  385. loadHealthReport: function() {
  386. var self = this
  387. healthRequest('/api/health/report/latest', { childId: this.activeChildId }).then(function(res) {
  388. if (res.data) {
  389. self.latestReport = res.data
  390. }
  391. }).catch(function(e) {
  392. console.log('获取健康报告失败', e)
  393. })
  394. },
  395. loadEnergyData: function() {
  396. var self = this
  397. getEnergyOverview(this.activeChildId).then(function(res) {
  398. if (res && res.data) {
  399. var dims = res.data.dimensions
  400. if (dims && dims.length > 0) {
  401. for (var i = 0; i < dims.length; i++) {
  402. if (dims[i].code === 'body') {
  403. self.dualDimension = dims[i]
  404. break
  405. }
  406. }
  407. }
  408. }
  409. }).catch(function(e) {
  410. console.log('获取能量概览失败', e)
  411. })
  412. },
  413. loadDimensionTasks: function() {
  414. var self = this
  415. if (!this.activeChildId) return
  416. getTodayTasksByCategory(this.activeChildId, 'body').then(function(res) {
  417. if (res && res.data) {
  418. self.dimensionTasks = Array.isArray(res.data) ? res.data.slice(0, 5) : []
  419. }
  420. }).catch(function() { self.dimensionTasks = [] })
  421. },
  422. loadDimensionActivities: function() {
  423. var self = this
  424. getActivityList({ dimensionCode: 'body', page: 1, size: 3 }).then(function(res) {
  425. if (res && res.data) {
  426. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  427. self.dimensionActivities = list.slice(0, 3)
  428. }
  429. }).catch(function() { self.dimensionActivities = [] })
  430. },
  431. loadDimensionProducts: function() {
  432. var self = this
  433. getProductsByDomain('body', 1, 4).then(function(res) {
  434. if (res && res.data) {
  435. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  436. self.dimensionProducts = list.slice(0, 4)
  437. }
  438. }).catch(function() { self.dimensionProducts = [] })
  439. },
  440. loadFeaturedArticles: function() {
  441. var self = this
  442. getFeaturedArticles({ size: 5 }).then(function(res) {
  443. if (res.code === 200 && res.data) {
  444. var gradientColors = [
  445. 'linear-gradient(135deg, #FF8C42, #FFB074)',
  446. 'linear-gradient(135deg, #FF6B9D, #FF9DBD)',
  447. 'linear-gradient(135deg, #6366F1, #818CF8)',
  448. 'linear-gradient(135deg, #10B981, #34D399)',
  449. 'linear-gradient(135deg, #F59E0B, #FBBF24)'
  450. ]
  451. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  452. self.bodyArticles = list.map(function(item, index) {
  453. return {
  454. id: item.id,
  455. category: item.categoryName || '身体健康',
  456. categoryColor: gradientColors[index % gradientColors.length],
  457. title: item.title || '',
  458. summary: item.summary || '',
  459. views: item.viewCount ? String(item.viewCount) : '0',
  460. date: item.publishedAt ? item.publishedAt.slice(0, 10) : ''
  461. }
  462. })
  463. }
  464. }.bind(this)).catch(function() {})
  465. },
  466. onChildChanged: function(child) {
  467. this.activeChildId = child.childId
  468. this.activeChildName = child.name || child.nickname || '孩子'
  469. this.loadDashboardData()
  470. },
  471. loadFamilyMembersVisible: function() {
  472. var self = this
  473. getVisibleFamilyMembers().then(function(res) {
  474. self.familyMembersVisible = res.data || []
  475. }).catch(function(e) {
  476. console.log('获取可见家庭成员失败', e)
  477. self.familyMembersVisible = []
  478. })
  479. },
  480. scrollToSection: function(section) {
  481. uni.pageScrollTo({ selector: '#' + section, duration: 300 })
  482. },
  483. onTaskClick: function(task) {
  484. uni.navigateTo({ url: '/pages/tasks/tasks' })
  485. },
  486. goActivityDetail: function(act) {
  487. if (!act || !act.id) return
  488. uni.navigateTo({ url: '/pages/discover-detail/activity-detail/activity-detail?id=' + act.id })
  489. },
  490. goMoreActivities: function() {
  491. uni.navigateTo({ url: '/pages/activity/index' })
  492. },
  493. goProductDetail: function(prod) {
  494. uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + prod.id })
  495. },
  496. goMoreProducts: function() {
  497. uni.navigateTo({ url: '/pages/shop/index' })
  498. },
  499. goArticleDetail: function(article) {
  500. var id = article.id || article
  501. uni.navigateTo({ url: '/pages/mind-detail/article-detail?id=' + id })
  502. },
  503. goMoreArticles: function() {
  504. uni.navigateTo({ url: '/pages/article-center/index?dimension=body' })
  505. },
  506. goTasks: function() { uni.switchTab({ url: '/pages/tasks/tasks' }) },
  507. goMemberDetail: function(member) {
  508. if (!member || !member.memberId) return
  509. uni.navigateTo({
  510. url: '/pages/member-detail/member-detail?memberId=' + member.memberId + '&memberType=' + (member.memberType || 'child') + '&entrySource=relation-graph&dimensionCode=body'
  511. })
  512. },
  513. goFamilyMembers: function() {
  514. uni.navigateTo({ url: '/pages/profile/family-members' })
  515. },
  516. sectionVisible: function(key) {
  517. return this.visibleSections.length === 0 || this.visibleSections.indexOf(key) !== -1
  518. },
  519. onFuncClick: function(item) {
  520. if (item.needLogin && !this.isLoggedIn) {
  521. uni.showModal({
  522. title: '提示',
  523. content: '请先登录后使用此功能',
  524. success: function(res) {
  525. if (res.confirm) uni.navigateTo({ url: '/pages/login/login' })
  526. }
  527. })
  528. return
  529. }
  530. if (item.page === 'health-dimensions') {
  531. if (!this.activeChildId) {
  532. uni.showToast({ title: '请先选择孩子', icon: 'none' })
  533. return
  534. }
  535. uni.navigateTo({ url: '/pages/body-detail/health-dimensions?childId=' + this.activeChildId })
  536. return
  537. }
  538. if (item.page) uni.navigateTo({ url: item.page })
  539. },
  540. goToHealthReport: function() {
  541. var id = this.activeChildId || uni.getStorageSync('currentChildId')
  542. if (!id) {
  543. uni.showToast({ title: '请先选择成员', icon: 'none' })
  544. return
  545. }
  546. uni.navigateTo({ url: '/pages/body-detail/health-report?childId=' + id })
  547. },
  548. goDimensionDetail: function(dimKey) {
  549. uni.navigateTo({ url: '/pages/body/dimension-detail?dimension=' + dimKey + '&childId=' + this.activeChildId })
  550. },
  551. goToCheckin: function() {
  552. var id = this.activeChildId || uni.getStorageSync('currentChildId')
  553. if (!id) {
  554. uni.showToast({ title: '请先选择成员', icon: 'none' })
  555. return
  556. }
  557. uni.navigateTo({ url: '/pages/body-detail/checkin?childId=' + id })
  558. },
  559. goToNutritionProfile: function() {
  560. var id = this.activeChildId || uni.getStorageSync('currentChildId')
  561. if (!id) {
  562. uni.showToast({ title: '请先选择成员', icon: 'none' })
  563. return
  564. }
  565. uni.navigateTo({ url: '/pages/health/nutrition-profile?childId=' + id })
  566. },
  567. goToUploadReport: function() {
  568. var id = this.activeChildId || uni.getStorageSync('currentChildId') || ''
  569. uni.navigateTo({ url: '/pages/health/report-upload?childId=' + id + '&from=body' })
  570. },
  571. formatDate: function(dateStr) {
  572. if (!dateStr) return '--'
  573. try {
  574. var d = new Date(dateStr)
  575. var y = d.getFullYear()
  576. var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
  577. var day = ('' + d.getDate()).padStart(2, '0')
  578. return y + '-' + m + '-' + day
  579. } catch (e) {
  580. return dateStr
  581. }
  582. },
  583. _watchPageReady() {
  584. var self = this
  585. var unwatch = this.$watch(function() {
  586. if (self.isLoggedIn) {
  587. return !!(self.dualDimension || self.sandboxData || (self.dimensionTasks && self.dimensionTasks.length > 0))
  588. }
  589. return !!(self.dimensionActivities && self.dimensionActivities.length > 0) ||
  590. !!(self.dimensionProducts && self.dimensionProducts.length > 0)
  591. }, function(val) {
  592. if (val) {
  593. if (unwatch) unwatch()
  594. self.showTabTransition = false
  595. }
  596. })
  597. setTimeout(function() {
  598. if (unwatch) unwatch()
  599. self.showTabTransition = false
  600. }, 5000)
  601. }
  602. }
  603. }
  604. </script>
  605. <style scoped>
  606. .body-container {
  607. min-height: 100vh;
  608. background: #f5f7fa;
  609. padding-bottom: 120rpx;
  610. }
  611. /* ===== 功能入口 ===== */
  612. .func-section {
  613. margin: 20rpx 30rpx;
  614. }
  615. .func-grid {
  616. display: flex;
  617. flex-direction: row;
  618. justify-content: space-between;
  619. background: #fff;
  620. border-radius: 20rpx;
  621. padding: 24rpx 16rpx;
  622. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  623. }
  624. .func-item {
  625. display: flex;
  626. flex-direction: column;
  627. align-items: center;
  628. flex: 1;
  629. }
  630. .func-icon-wrap {
  631. width: 80rpx;
  632. height: 80rpx;
  633. border-radius: 40rpx;
  634. background: linear-gradient(135deg, #D6EAF8, #EBF2FA);
  635. display: flex;
  636. align-items: center;
  637. justify-content: center;
  638. margin-bottom: 10rpx;
  639. }
  640. .func-icon {
  641. font-size: 40rpx;
  642. }
  643. .func-label {
  644. font-size: 22rpx;
  645. color: #666;
  646. font-weight: 500;
  647. }
  648. /* ===== 通用区块 ===== */
  649. .section {
  650. margin: 20rpx 30rpx;
  651. }
  652. .section-header {
  653. display: flex;
  654. flex-direction: row;
  655. align-items: center;
  656. justify-content: space-between;
  657. margin-bottom: 16rpx;
  658. }
  659. .section-title {
  660. font-size: 30rpx;
  661. font-weight: bold;
  662. color: #333;
  663. }
  664. .avg-badge {
  665. font-size: 20rpx;
  666. color: #F97316;
  667. background: #FFF7ED;
  668. padding: 4rpx 12rpx;
  669. border-radius: 20rpx;
  670. margin-left: 12rpx;
  671. }
  672. .section-more {
  673. font-size: 24rpx;
  674. color: #5B9BD5;
  675. }
  676. /* ===== 健康报告 ===== */
  677. .report-card {
  678. background: #fff;
  679. border-radius: 20rpx;
  680. padding: 24rpx;
  681. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  682. }
  683. .report-type-tag {
  684. display: inline-block;
  685. background: #E8F5E9;
  686. color: #2E7D32;
  687. font-size: 22rpx;
  688. padding: 4rpx 16rpx;
  689. border-radius: 20rpx;
  690. margin-bottom: 16rpx;
  691. }
  692. .report-score-row {
  693. display: flex;
  694. flex-direction: row;
  695. align-items: center;
  696. }
  697. .score-circle {
  698. width: 140rpx;
  699. height: 140rpx;
  700. border-radius: 70rpx;
  701. background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  702. display: flex;
  703. flex-direction: column;
  704. align-items: center;
  705. justify-content: center;
  706. margin-right: 24rpx;
  707. }
  708. .score-value {
  709. font-size: 48rpx;
  710. font-weight: bold;
  711. color: #1565C0;
  712. }
  713. .score-label {
  714. font-size: 20rpx;
  715. color: #64B5F6;
  716. }
  717. .report-meta {
  718. flex: 1;
  719. }
  720. .meta-item {
  721. display: flex;
  722. flex-direction: row;
  723. align-items: center;
  724. margin-bottom: 12rpx;
  725. }
  726. .meta-label {
  727. font-size: 24rpx;
  728. color: #666;
  729. width: 140rpx;
  730. }
  731. .meta-value {
  732. font-size: 26rpx;
  733. color: #333;
  734. font-weight: 500;
  735. }
  736. .report-date {
  737. font-size: 22rpx;
  738. color: #bbb;
  739. margin-top: 16rpx;
  740. }
  741. .report-empty {
  742. background: #fff;
  743. border-radius: 20rpx;
  744. padding: 40rpx;
  745. text-align: center;
  746. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  747. }
  748. .empty-tip {
  749. font-size: 28rpx;
  750. color: #999;
  751. display: block;
  752. }
  753. .empty-sub {
  754. font-size: 24rpx;
  755. color: #ccc;
  756. display: block;
  757. margin-top: 8rpx;
  758. }
  759. /* ===== 快捷操作 ===== */
  760. .quick-actions {
  761. display: flex;
  762. flex-direction: row;
  763. margin-top: 30rpx;
  764. }
  765. .action-btn {
  766. flex: 1;
  767. background: #fff;
  768. border-radius: 16rpx;
  769. padding: 24rpx;
  770. display: flex;
  771. flex-direction: column;
  772. align-items: center;
  773. margin-right: 20rpx;
  774. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  775. }
  776. .action-btn:last-child {
  777. margin-right: 0;
  778. }
  779. .action-icon {
  780. font-size: 48rpx;
  781. margin-bottom: 8rpx;
  782. }
  783. .action-text {
  784. font-size: 26rpx;
  785. color: #666;
  786. }
  787. /* ===== 底部 ===== */
  788. .bottom-spacer {
  789. height: 120rpx;
  790. }
  791. .func-item:active, .action-btn:active {
  792. opacity: 0.7;
  793. }
  794. /* ===== 精准营养 ===== */
  795. .nutrition-section {
  796. margin-top: 20rpx;
  797. }
  798. .nutrition-report-card {
  799. display: flex;
  800. flex-direction: row;
  801. align-items: center;
  802. background: linear-gradient(135deg, #E8F5E9, #F1F8E9);
  803. border-radius: 20rpx;
  804. padding: 28rpx 24rpx;
  805. margin-bottom: 20rpx;
  806. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  807. }
  808. .nutrition-report-left {
  809. width: 100rpx;
  810. height: 100rpx;
  811. background: rgba(255,255,255,0.7);
  812. border-radius: 20rpx;
  813. display: flex;
  814. align-items: center;
  815. justify-content: center;
  816. margin-right: 20rpx;
  817. flex-shrink: 0;
  818. }
  819. .nutrition-icon-large {
  820. font-size: 52rpx;
  821. }
  822. .nutrition-report-right {
  823. flex: 1;
  824. }
  825. .nutrition-title {
  826. font-size: 30rpx;
  827. font-weight: bold;
  828. color: #2E7D32;
  829. display: block;
  830. margin-bottom: 6rpx;
  831. }
  832. .nutrition-desc {
  833. font-size: 22rpx;
  834. color: #558B2F;
  835. line-height: 1.5;
  836. display: block;
  837. margin-bottom: 10rpx;
  838. }
  839. .nutrition-report-tags {
  840. display: flex;
  841. flex-direction: row;
  842. gap: 10rpx;
  843. }
  844. .nutrition-report-tags .tag {
  845. font-size: 20rpx;
  846. color: #33691E;
  847. background: rgba(255,255,255,0.6);
  848. padding: 4rpx 14rpx;
  849. border-radius: 20rpx;
  850. }
  851. .nutrition-arrow {
  852. font-size: 40rpx;
  853. color: #A5D6A7;
  854. margin-left: 12rpx;
  855. }
  856. .nutrition-links {
  857. margin-bottom: 20rpx;
  858. }
  859. .links-label {
  860. font-size: 26rpx;
  861. font-weight: bold;
  862. color: #333;
  863. display: block;
  864. margin-bottom: 12rpx;
  865. }
  866. .links-row {
  867. display: flex;
  868. flex-direction: row;
  869. gap: 16rpx;
  870. }
  871. .link-item {
  872. flex: 1;
  873. display: flex;
  874. flex-direction: row;
  875. align-items: center;
  876. background: #fff;
  877. border-radius: 16rpx;
  878. padding: 20rpx 18rpx;
  879. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  880. gap: 12rpx;
  881. }
  882. .link-item:active {
  883. opacity: 0.7;
  884. }
  885. .link-icon {
  886. font-size: 36rpx;
  887. flex-shrink: 0;
  888. }
  889. .link-texts {
  890. flex: 1;
  891. }
  892. .link-name {
  893. font-size: 24rpx;
  894. font-weight: 500;
  895. color: #333;
  896. display: block;
  897. margin-bottom: 4rpx;
  898. }
  899. .link-desc {
  900. font-size: 20rpx;
  901. color: #999;
  902. display: block;
  903. }
  904. .link-arrow {
  905. font-size: 32rpx;
  906. color: #CCC;
  907. flex-shrink: 0;
  908. }
  909. /* ===== 推荐阅读 ===== */
  910. .article-list {
  911. display: flex;
  912. flex-direction: column;
  913. gap: 16rpx;
  914. }
  915. .article-card {
  916. background: #fff;
  917. border-radius: 16rpx;
  918. padding: 24rpx;
  919. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  920. }
  921. .article-card:active {
  922. opacity: 0.8;
  923. }
  924. .article-category {
  925. display: inline-block;
  926. padding: 4rpx 14rpx;
  927. border-radius: 8rpx;
  928. margin-bottom: 10rpx;
  929. }
  930. .article-category-text {
  931. font-size: 20rpx;
  932. color: #fff;
  933. }
  934. .article-title {
  935. display: block;
  936. font-size: 28rpx;
  937. font-weight: bold;
  938. color: #333;
  939. margin-bottom: 8rpx;
  940. line-height: 1.4;
  941. }
  942. .article-summary {
  943. display: block;
  944. font-size: 24rpx;
  945. color: #888;
  946. line-height: 1.5;
  947. margin-bottom: 12rpx;
  948. overflow: hidden;
  949. text-overflow: ellipsis;
  950. display: -webkit-box;
  951. -webkit-line-clamp: 2;
  952. -webkit-box-orient: vertical;
  953. }
  954. .article-meta {
  955. display: flex;
  956. align-items: center;
  957. gap: 16rpx;
  958. }
  959. .meta-item {
  960. display: flex;
  961. align-items: center;
  962. gap: 4rpx;
  963. }
  964. .meta-icon {
  965. font-size: 24rpx;
  966. }
  967. .meta-text {
  968. font-size: 22rpx;
  969. color: #999;
  970. }
  971. .article-date {
  972. font-size: 22rpx;
  973. color: #bbb;
  974. }
  975. </style>