index.vue 28 KB

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