index.vue 27 KB

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