index.vue 29 KB

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