index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  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. ]
  196. }
  197. },
  198. computed: {
  199. energyMapForGraph: function() {
  200. var map = {}
  201. if (this.sandboxData && this.sandboxData.members) {
  202. for (var i = 0; i < this.sandboxData.members.length; i++) {
  203. var m = this.sandboxData.members[i]
  204. map[m.memberId || m.id] = {
  205. bodyScore: m.bodyScore || 0,
  206. mindScore: m.mindScore || 0,
  207. actionScore: m.actionScore || 0
  208. }
  209. }
  210. }
  211. return map
  212. },
  213. intimacyMapForGraph: function() {
  214. return {}
  215. },
  216. /** 七维雷达图:维度标签(遵守 AGENTS.md 禁止模板内方法调用,使用 computed 缓存) */
  217. radarDimensions: function() {
  218. var dims = this.dimensionData && this.dimensionData.dimensions
  219. if (!dims) return []
  220. var result = []
  221. for (var i = 0; i < dims.length; i++) {
  222. var d = dims[i]
  223. if (!d) continue
  224. result.push({ label: d.label || '', key: d.dimension || '' })
  225. }
  226. return result
  227. },
  228. /** 七维雷达图:分值(对 null/NaN 做归一化,避免 Canvas 计算 NaN 静默失败) */
  229. radarScores: function() {
  230. var dims = this.dimensionData && this.dimensionData.dimensions
  231. if (!dims) return []
  232. var result = []
  233. for (var i = 0; i < dims.length; i++) {
  234. var d = dims[i]
  235. if (!d) { result.push(0); continue }
  236. var s = d.score
  237. if (typeof s !== 'number' || isNaN(s) || s === null) s = 0
  238. result.push(s)
  239. }
  240. return result
  241. }
  242. },
  243. onShow() {
  244. this.showTabTransition = true
  245. var token = uni.getStorageSync('token')
  246. this.isLoggedIn = !!token
  247. if (this.isLoggedIn) {
  248. this.role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  249. this.userName = uni.getStorageSync('nickname') || uni.getStorageSync('userName') || '家长'
  250. }
  251. this.loadSectionConfig()
  252. if (this.isLoggedIn) {
  253. this.loadChildren()
  254. this.loadFamilyMembersVisible()
  255. this.loadChallenges()
  256. }
  257. // 游客也能浏览活动和商品
  258. this.loadDimensionActivities()
  259. this.loadDimensionProducts()
  260. // 游客也能浏览文章
  261. this.loadFeaturedArticles()
  262. this._watchPageReady()
  263. },
  264. methods: {
  265. loadSectionConfig: function() {
  266. var baseSections = ['func_entries']
  267. if (!uni.getStorageSync('token')) {
  268. this.visibleSections = baseSections
  269. return
  270. }
  271. var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
  272. var self = this
  273. getVisibleSections({ pageKey: 'body', role: role }).then(function(res) {
  274. if (res.code === 200 && res.data) {
  275. var keys = res.data.map(function(s) { return s.sectionKey })
  276. var merged = baseSections.slice()
  277. keys.forEach(function(k) { if (merged.indexOf(k) === -1) merged.push(k) })
  278. self.visibleSections = merged
  279. }
  280. }).catch(function(e) {
  281. self.visibleSections = ['func_entries']
  282. })
  283. },
  284. loadChildren: function() {
  285. var self = this
  286. getChildren().then(function(res) {
  287. if (res.code === 200 && res.data) {
  288. self.children = res.data
  289. var savedChildId = uni.getStorageSync('currentChildId')
  290. var found = false
  291. for (var i = 0; i < self.children.length; i++) {
  292. if (self.children[i].childId === savedChildId) {
  293. self.activeChildId = savedChildId
  294. self.activeChildName = self.children[i].name || self.children[i].nickname || '孩子'
  295. found = true
  296. break
  297. }
  298. }
  299. if (!found && self.children.length > 0) {
  300. self.activeChildId = self.children[0].childId
  301. self.activeChildName = self.children[0].name || self.children[0].nickname || '孩子'
  302. uni.setStorageSync('currentChildId', self.activeChildId)
  303. }
  304. if (self.activeChildId) {
  305. self.loadDashboardData()
  306. }
  307. }
  308. }).catch(function(e) {
  309. console.log('获取孩子列表失败', e)
  310. })
  311. },
  312. loadDashboardData: function() {
  313. if (!this.activeChildId) return
  314. this.loadEnergyData()
  315. this.loadDimensionTasks()
  316. this.loadDimensionActivities()
  317. this.loadDimensionProducts()
  318. this.loadSandboxData()
  319. this.loadHealthDimensions()
  320. },
  321. loadHealthDimensions: function() {
  322. var memberId = this.activeChildId || (this.userInfo && this.userInfo.userId)
  323. if (!memberId) {
  324. console.log('[body] loadHealthDimensions skipped: no memberId')
  325. return
  326. }
  327. var self = this
  328. getDimensionOverview({ memberId: memberId }).then(function(res) {
  329. if (res && res.data) {
  330. self.dimensionData = res.data
  331. console.log('[body] dimensionData loaded:', res.data.dimensions ? res.data.dimensions.length : 0, 'dimensions')
  332. } else if (res) {
  333. console.warn('[body] dimension API error:', res.message || res.code)
  334. }
  335. }).catch(function(e) {
  336. console.error('[body] loadHealthDimensions failed', e)
  337. })
  338. },
  339. loadSandboxData: function() {
  340. var self = this
  341. getFamilyEnergySandbox().then(function(res) {
  342. if (res && res.data) {
  343. self.sandboxData = res.data
  344. }
  345. }).catch(function(e) {
  346. console.log('获取沙盘数据失败', e)
  347. })
  348. },
  349. loadEnergyData: function() {
  350. var self = this
  351. getEnergyOverview(this.activeChildId).then(function(res) {
  352. if (res && res.data) {
  353. var dims = res.data.dimensions
  354. if (dims && dims.length > 0) {
  355. for (var i = 0; i < dims.length; i++) {
  356. if (dims[i].code === 'body') {
  357. self.dualDimension = dims[i]
  358. break
  359. }
  360. }
  361. }
  362. }
  363. }).catch(function(e) {
  364. console.log('获取能量概览失败', e)
  365. })
  366. },
  367. loadDimensionTasks: function() {
  368. var self = this
  369. if (!this.activeChildId) return
  370. getTodayTasksByCategory(this.activeChildId, 'body').then(function(res) {
  371. if (res && res.data) {
  372. self.dimensionTasks = Array.isArray(res.data) ? res.data.slice(0, 5) : []
  373. }
  374. }).catch(function() { self.dimensionTasks = [] })
  375. },
  376. loadDimensionActivities: function() {
  377. var self = this
  378. getActivityList({ dimensionCode: 'body', page: 1, size: 3 }).then(function(res) {
  379. if (res && res.data) {
  380. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  381. self.dimensionActivities = list.slice(0, 3)
  382. }
  383. }).catch(function() { self.dimensionActivities = [] })
  384. },
  385. loadDimensionProducts: function() {
  386. var self = this
  387. getProductsByDomain('body', 1, 4).then(function(res) {
  388. if (res && res.data) {
  389. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  390. self.dimensionProducts = list.slice(0, 4)
  391. }
  392. }).catch(function() { self.dimensionProducts = [] })
  393. },
  394. loadFeaturedArticles: function() {
  395. var self = this
  396. getFeaturedArticles({ size: 5 }).then(function(res) {
  397. if (res.code === 200 && res.data) {
  398. var gradientColors = [
  399. 'linear-gradient(135deg, #FF8C42, #FFB074)',
  400. 'linear-gradient(135deg, #FF6B9D, #FF9DBD)',
  401. 'linear-gradient(135deg, #6366F1, #818CF8)',
  402. 'linear-gradient(135deg, #10B981, #34D399)',
  403. 'linear-gradient(135deg, #F59E0B, #FBBF24)'
  404. ]
  405. var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
  406. self.bodyArticles = list.map(function(item, index) {
  407. return {
  408. id: item.id,
  409. category: item.categoryName || '身体健康',
  410. categoryColor: gradientColors[index % gradientColors.length],
  411. title: item.title || '',
  412. summary: item.summary || '',
  413. views: item.viewCount ? String(item.viewCount) : '0',
  414. date: item.publishedAt ? item.publishedAt.slice(0, 10) : ''
  415. }
  416. })
  417. }
  418. }.bind(this)).catch(function() {})
  419. },
  420. onFamilyMemberSelect: function(member) {
  421. this.selectedMemberId = member.id
  422. },
  423. onChildChanged: function(child) {
  424. this.activeChildId = child.childId
  425. this.activeChildName = child.name || child.nickname || '孩子'
  426. this.loadDashboardData()
  427. },
  428. loadFamilyMembersVisible: function() {
  429. var self = this
  430. getVisibleFamilyMembers().then(function(res) {
  431. self.familyMembersVisible = res.data || []
  432. }).catch(function(e) {
  433. console.log('获取可见家庭成员失败', e)
  434. self.familyMembersVisible = []
  435. })
  436. },
  437. loadChallenges: function() {
  438. var familyId = uni.getStorageSync('familyId')
  439. if (!familyId) return
  440. var self = this
  441. getChallengeList({ familyId: familyId }).then(function(res) {
  442. if (res.code === 200 && Array.isArray(res.data)) {
  443. self.activeChallenges = res.data
  444. }
  445. }).catch(function() {
  446. self.activeChallenges = []
  447. })
  448. },
  449. scrollToSection: function(section) {
  450. uni.pageScrollTo({ selector: '#' + section, duration: 300 })
  451. },
  452. onTaskClick: function(task) {
  453. uni.navigateTo({ url: '/pages/tasks/tasks' })
  454. },
  455. goActivityDetail: function(act) {
  456. if (!act || !act.id) return
  457. uni.navigateTo({ url: '/pages/discover-detail/activity-detail/activity-detail?id=' + act.id })
  458. },
  459. goMoreActivities: function() {
  460. uni.navigateTo({ url: '/pages/activity/index' })
  461. },
  462. goProductDetail: function(prod) {
  463. uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + prod.id })
  464. },
  465. goMoreProducts: function() {
  466. uni.navigateTo({ url: '/pages/shop/index' })
  467. },
  468. goArticleDetail: function(article) {
  469. var id = article.id || article
  470. uni.navigateTo({ url: '/pages/mind-detail/article-detail?id=' + id })
  471. },
  472. goMoreArticles: function() {
  473. uni.navigateTo({ url: '/pages/article-center/index?dimension=body' })
  474. },
  475. goTasks: function() { uni.switchTab({ url: '/pages/tasks/tasks' }) },
  476. goMemberDetail: function(member) {
  477. if (!member || !member.memberId) return
  478. uni.navigateTo({
  479. url: '/pages/member-detail/member-detail?memberId=' + member.memberId + '&memberType=' + (member.memberType || 'child') + '&entrySource=relation-graph&dimensionCode=body'
  480. })
  481. },
  482. goFamilyMembers: function() {
  483. uni.navigateTo({ url: '/pages/profile/family-members' })
  484. },
  485. sectionVisible: function(key) {
  486. return this.visibleSections.length === 0 || this.visibleSections.indexOf(key) !== -1
  487. },
  488. onFuncClick: function(item) {
  489. if (item.needLogin && !this.isLoggedIn) {
  490. uni.showModal({
  491. title: '提示',
  492. content: '请先登录后使用此功能',
  493. success: function(res) {
  494. if (res.confirm) uni.navigateTo({ url: '/pages/login/login' })
  495. }
  496. })
  497. return
  498. }
  499. if (item.page === 'health-dimensions') {
  500. if (!this.activeChildId) {
  501. uni.showToast({ title: '请先选择孩子', icon: 'none' })
  502. return
  503. }
  504. uni.navigateTo({ url: '/pages/body-detail/health-dimensions?childId=' + this.activeChildId })
  505. return
  506. }
  507. if (item.page) uni.navigateTo({ url: item.page })
  508. },
  509. goDimensionDetail: function(dimKey) {
  510. uni.navigateTo({ url: '/pages/body-detail/dimension-detail?dimension=' + dimKey + '&childId=' + this.activeChildId })
  511. },
  512. goToCheckin: function() {
  513. var id = this.activeChildId || uni.getStorageSync('currentChildId')
  514. if (!id) {
  515. uni.showToast({ title: '请先选择成员', icon: 'none' })
  516. return
  517. }
  518. uni.navigateTo({ url: '/pages/body-detail/checkin?childId=' + id })
  519. },
  520. goToNutritionProfile: function() {
  521. var id = this.activeChildId || uni.getStorageSync('currentChildId')
  522. if (!id) {
  523. uni.showToast({ title: '请先选择成员', icon: 'none' })
  524. return
  525. }
  526. uni.navigateTo({ url: '/pages/health/nutrition-profile?childId=' + id })
  527. },
  528. goToUploadReport: function() {
  529. var id = this.activeChildId || uni.getStorageSync('currentChildId') || ''
  530. uni.navigateTo({ url: '/pages/health/report-upload?childId=' + id + '&from=body' })
  531. },
  532. _watchPageReady() {
  533. var self = this
  534. var unwatch = this.$watch(function() {
  535. if (self.isLoggedIn) {
  536. return !!(self.dualDimension || self.sandboxData || (self.dimensionTasks && self.dimensionTasks.length > 0))
  537. }
  538. return !!(self.dimensionActivities && self.dimensionActivities.length > 0) ||
  539. !!(self.dimensionProducts && self.dimensionProducts.length > 0)
  540. }, function(val) {
  541. if (val) {
  542. if (unwatch) unwatch()
  543. self.showTabTransition = false
  544. }
  545. })
  546. setTimeout(function() {
  547. if (unwatch) unwatch()
  548. self.showTabTransition = false
  549. }, 5000)
  550. }
  551. }
  552. }
  553. </script>
  554. <style scoped>
  555. .body-container {
  556. min-height: 100vh;
  557. background: #f5f7fa;
  558. padding-bottom: 120rpx;
  559. }
  560. /* ===== 功能入口 ===== */
  561. .func-section {
  562. margin: 20rpx 30rpx;
  563. }
  564. .func-grid {
  565. display: flex;
  566. flex-direction: row;
  567. justify-content: space-between;
  568. background: #fff;
  569. border-radius: 20rpx;
  570. padding: 24rpx 16rpx;
  571. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  572. }
  573. .func-item {
  574. display: flex;
  575. flex-direction: column;
  576. align-items: center;
  577. flex: 1;
  578. }
  579. .func-icon-wrap {
  580. width: 80rpx;
  581. height: 80rpx;
  582. border-radius: 40rpx;
  583. background: linear-gradient(135deg, #D6EAF8, #EBF2FA);
  584. display: flex;
  585. align-items: center;
  586. justify-content: center;
  587. margin-bottom: 10rpx;
  588. }
  589. .func-icon {
  590. font-size: 40rpx;
  591. }
  592. .func-label {
  593. font-size: 22rpx;
  594. color: #666;
  595. font-weight: 500;
  596. }
  597. /* ===== 通用区块 ===== */
  598. .section {
  599. margin: 20rpx 30rpx;
  600. }
  601. .section-header {
  602. display: flex;
  603. flex-direction: row;
  604. align-items: center;
  605. justify-content: space-between;
  606. margin-bottom: 16rpx;
  607. }
  608. .section-title {
  609. font-size: 30rpx;
  610. font-weight: bold;
  611. color: #333;
  612. }
  613. .avg-badge {
  614. font-size: 20rpx;
  615. color: #F97316;
  616. background: #FFF7ED;
  617. padding: 4rpx 12rpx;
  618. border-radius: 20rpx;
  619. margin-left: 12rpx;
  620. }
  621. /* ===== 快捷操作 ===== */
  622. .quick-actions {
  623. display: flex;
  624. flex-direction: row;
  625. margin-top: 30rpx;
  626. }
  627. .action-btn {
  628. flex: 1;
  629. background: #fff;
  630. border-radius: 16rpx;
  631. padding: 24rpx;
  632. display: flex;
  633. flex-direction: column;
  634. align-items: center;
  635. margin-right: 20rpx;
  636. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  637. }
  638. .action-btn:last-child {
  639. margin-right: 0;
  640. }
  641. .action-icon {
  642. font-size: 48rpx;
  643. margin-bottom: 8rpx;
  644. }
  645. .action-text {
  646. font-size: 26rpx;
  647. color: #666;
  648. }
  649. /* ===== 底部 ===== */
  650. .bottom-spacer {
  651. height: 120rpx;
  652. }
  653. .func-item:active, .action-btn:active {
  654. opacity: 0.7;
  655. }
  656. /* ===== 精准营养 ===== */
  657. .nutrition-section {
  658. margin-top: 20rpx;
  659. }
  660. .nutrition-report-card {
  661. display: flex;
  662. flex-direction: row;
  663. align-items: center;
  664. background: linear-gradient(135deg, #E8F5E9, #F1F8E9);
  665. border-radius: 20rpx;
  666. padding: 28rpx 24rpx;
  667. margin-bottom: 20rpx;
  668. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  669. }
  670. .nutrition-report-left {
  671. width: 100rpx;
  672. height: 100rpx;
  673. background: rgba(255,255,255,0.7);
  674. border-radius: 20rpx;
  675. display: flex;
  676. align-items: center;
  677. justify-content: center;
  678. margin-right: 20rpx;
  679. flex-shrink: 0;
  680. }
  681. .nutrition-icon-large {
  682. font-size: 52rpx;
  683. }
  684. .nutrition-report-right {
  685. flex: 1;
  686. }
  687. .nutrition-title {
  688. font-size: 30rpx;
  689. font-weight: bold;
  690. color: #2E7D32;
  691. display: block;
  692. margin-bottom: 6rpx;
  693. }
  694. .nutrition-desc {
  695. font-size: 22rpx;
  696. color: #558B2F;
  697. line-height: 1.5;
  698. display: block;
  699. margin-bottom: 10rpx;
  700. }
  701. .nutrition-report-tags {
  702. display: flex;
  703. flex-direction: row;
  704. gap: 10rpx;
  705. }
  706. .nutrition-report-tags .tag {
  707. font-size: 20rpx;
  708. color: #33691E;
  709. background: rgba(255,255,255,0.6);
  710. padding: 4rpx 14rpx;
  711. border-radius: 20rpx;
  712. }
  713. .nutrition-arrow {
  714. font-size: 40rpx;
  715. color: #A5D6A7;
  716. margin-left: 12rpx;
  717. }
  718. .nutrition-links {
  719. margin-bottom: 20rpx;
  720. }
  721. .links-label {
  722. font-size: 26rpx;
  723. font-weight: bold;
  724. color: #333;
  725. display: block;
  726. margin-bottom: 12rpx;
  727. }
  728. .links-row {
  729. display: flex;
  730. flex-direction: row;
  731. gap: 16rpx;
  732. }
  733. .link-item {
  734. flex: 1;
  735. display: flex;
  736. flex-direction: row;
  737. align-items: center;
  738. background: #fff;
  739. border-radius: 16rpx;
  740. padding: 20rpx 18rpx;
  741. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  742. gap: 12rpx;
  743. }
  744. .link-item:active {
  745. opacity: 0.7;
  746. }
  747. .link-icon {
  748. font-size: 36rpx;
  749. flex-shrink: 0;
  750. }
  751. .link-texts {
  752. flex: 1;
  753. }
  754. .link-name {
  755. font-size: 24rpx;
  756. font-weight: 500;
  757. color: #333;
  758. display: block;
  759. margin-bottom: 4rpx;
  760. }
  761. .link-desc {
  762. font-size: 20rpx;
  763. color: #999;
  764. display: block;
  765. }
  766. .link-arrow {
  767. font-size: 32rpx;
  768. color: #CCC;
  769. flex-shrink: 0;
  770. }
  771. /* ===== 推荐阅读 ===== */
  772. .article-list {
  773. display: flex;
  774. flex-direction: column;
  775. gap: 16rpx;
  776. }
  777. .article-card {
  778. background: #fff;
  779. border-radius: 16rpx;
  780. padding: 24rpx;
  781. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  782. }
  783. .article-card:active {
  784. opacity: 0.8;
  785. }
  786. .article-category {
  787. display: inline-block;
  788. padding: 4rpx 14rpx;
  789. border-radius: 8rpx;
  790. margin-bottom: 10rpx;
  791. }
  792. .article-category-text {
  793. font-size: 20rpx;
  794. color: #fff;
  795. }
  796. .article-title {
  797. display: block;
  798. font-size: 28rpx;
  799. font-weight: bold;
  800. color: #333;
  801. margin-bottom: 8rpx;
  802. line-height: 1.4;
  803. }
  804. .article-summary {
  805. display: block;
  806. font-size: 24rpx;
  807. color: #888;
  808. line-height: 1.5;
  809. margin-bottom: 12rpx;
  810. overflow: hidden;
  811. text-overflow: ellipsis;
  812. display: -webkit-box;
  813. -webkit-line-clamp: 2;
  814. -webkit-box-orient: vertical;
  815. }
  816. .article-meta {
  817. display: flex;
  818. align-items: center;
  819. gap: 16rpx;
  820. }
  821. .meta-item {
  822. display: flex;
  823. align-items: center;
  824. gap: 4rpx;
  825. }
  826. .meta-icon {
  827. font-size: 24rpx;
  828. }
  829. .meta-text {
  830. font-size: 22rpx;
  831. color: #999;
  832. }
  833. .article-date {
  834. font-size: 22rpx;
  835. color: #bbb;
  836. }
  837. </style>