index.vue 26 KB

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