index.vue 27 KB

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