| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073 |
- <template>
- <view class="body-container">
- <!-- Tabbar 切换过渡页 -->
- <tab-transition v-if="showTabTransition" dimCode="body" />
- <!-- 品牌头部 -->
- <PageBanner theme="body"
- tagline="科学管理全家健康"
- quote="身体健康是幸福的基础" />
- <!-- 游客专属区块 -->
- <template v-if="!isLoggedIn">
- <LoginGuideCard
- title="登录后查看全家健康数据"
- :items="[
- '查看全家身体能量数据和健康报告',
- '记录每日健康打卡,获取身体能量',
- '查看专属健康商品和活动价格'
- ]" />
- <HealthTips dimension="body" />
- </template>
- <!-- 登录后:五维能量条 -->
- <FamilyEnergyBar
- v-if="isLoggedIn"
- dimensionCode="body"
- :sandboxData="sandboxData"
- :dualDimension="dualDimension" />
- <!-- ===== 重要关系维护 ===== -->
- <FamilyRelationshipSection
- :contactList="contactList"
- :healthAlerts="healthAlerts"
- :milestones="milestones"
- :isLoggedIn="isLoggedIn"
- @contactClick="onContactClick"
- @refresh="loadContacts"
- @import="onShowImport"
- @interactionLog="goInteractionLog"
- @questionnaire="goRelationshipQuestionnaire" />
- <!-- 关系图谱(登录后可见) -->
- <FamilyRelationGraph
- v-if="isLoggedIn && familyMembersVisible.length > 0"
- dimensionCode="body"
- :selfId="activeChildId"
- :members="familyMembersVisible"
- :energyMap="energyMapForGraph"
- :intimacyMap="intimacyMapForGraph"
- @memberTap="goMemberDetail" />
- <!-- 登录后:用户快捷入口 -->
- <UserQuickEntry
- v-if="isLoggedIn"
- :userName="userName"
- roleName="家长"
- :currentChildName="activeChildName"
- :children="children"
- @childChanged="onChildChanged"
- @scrollTo="scrollToSection" />
- <!-- 雷达图 -->
- <view class="section" v-if="dimensionData">
- <view class="section-header" v-if="dimensionData.isAverage">
- <text class="section-title">七维健康图</text>
- <text class="avg-badge">同龄同性平均值 · 上传报告后显示个人数据</text>
- </view>
- <view class="section-header" v-else>
- <text class="section-title">七维健康图</text>
- </view>
- <RadarChart
- v-if="dimensionData && dimensionData.dimensions"
- :dimensions="dimensionData.dimensions.map(function(d) { return { label: d.label, key: d.dimension } })"
- :scores="dimensionData.dimensions.map(function(d) { return d.score })"
- fillColor="#FF8C42"
- gridColor="#FED7AA"
- labelColor="#9A3412"
- :width="580"
- :height="580"
- @dimensionClick="goDimensionDetail" />
- </view>
- <!-- 功能入口 -->
- <view class="func-section" v-if="sectionVisible('func_entries')">
- <view class="func-grid">
- <view class="func-item" v-for="item in funcList" :key="item.label" @click="onFuncClick(item)">
- <view class="func-icon-wrap">
- <text class="func-icon">{{ item.icon }}</text>
- </view>
- <text class="func-label">{{ item.label }}</text>
- </view>
- </view>
- </view>
- <!-- 健康报告摘要(登录后可见) -->
- <view class="section" v-if="sectionVisible('health_report') && isLoggedIn">
- <view class="section-header">
- <text class="section-title">健康报告</text>
- <text class="section-more" @click="goToHealthReport">查看详情 ›</text>
- </view>
- <view class="report-card" v-if="latestReport">
- <view class="report-type-tag">{{ reportTypeLabel }}</view>
- <view class="report-score-row">
- <view class="score-circle">
- <text class="score-value">{{ latestReport.overallScore || '--' }}</text>
- <text class="score-label">综合评分</text>
- </view>
- <view class="report-meta">
- <view class="meta-item" v-if="latestReport.gutHealthScore">
- <text class="meta-label">肠道健康</text>
- <text class="meta-value">{{ latestReport.gutHealthScore }}</text>
- </view>
- <view class="meta-item" v-if="latestReport.nutritionScore">
- <text class="meta-label">营养状况</text>
- <text class="meta-value">{{ latestReport.nutritionScore }}</text>
- </view>
- <view class="meta-item" v-if="latestReport.gutAge">
- <text class="meta-label">肠道年龄</text>
- <text class="meta-value">{{ latestReport.gutAge }}</text>
- </view>
- </view>
- </view>
- <text class="report-date">报告日期:{{ formatDate(latestReport.reportDate) }}</text>
- </view>
- <view class="report-empty" v-else>
- <text class="empty-tip">暂无健康报告</text>
- <text class="empty-sub">规划师录入后将自动显示</text>
- </view>
- </view>
- <!-- ===== 精准营养(上传报告+产品+文章) ===== -->
- <view class="section nutrition-section" v-if="isLoggedIn">
- <view class="section-header">
- <text class="section-title">🥗 精准营养</text>
- </view>
- <!-- 上传报告入口 -->
- <view class="nutrition-report-card" @click="goToUploadReport">
- <view class="nutrition-report-left">
- <text class="nutrition-icon-large">📋</text>
- </view>
- <view class="nutrition-report-right">
- <text class="nutrition-title">上传健康报告</text>
- <text class="nutrition-desc">上传体检报告或肠道检测报告,AI智能解读分析,获取个性化营养方案</text>
- <view class="nutrition-report-tags">
- <text class="tag">体检报告</text>
- <text class="tag">肠道检测</text>
- <text class="tag">AI解读</text>
- </view>
- </view>
- <text class="nutrition-arrow">›</text>
- </view>
- </view>
- <!-- 维度任务 -->
- <DimensionTasks
- v-if="isLoggedIn"
- dimensionCode="body"
- :tasks="dimensionTasks"
- @taskClick="onTaskClick"
- @moreTasks="goTasks" />
- <!-- 维度活动 -->
- <DimensionActivities
- dimensionCode="body"
- :activities="dimensionActivities"
- :isLoggedIn="isLoggedIn"
- @activityClick="goActivityDetail"
- @moreActivities="goMoreActivities" />
- <!-- 推荐阅读 -->
- <DimensionArticles
- dimensionCode="body"
- :articles="bodyArticles"
- :isLoggedIn="isLoggedIn"
- @articleClick="goArticleDetail"
- @moreArticles="goMoreArticles" />
- <!-- 健康小贴士 -->
- <view class="section" v-if="sectionVisible('health_tips')">
- <view class="section-header">
- <text class="section-title">健康小贴士</text>
- </view>
- <view class="tips-list">
- <view class="tip-card" v-for="item in healthTips" :key="item.id">
- <text class="tip-title">{{ item.title }}</text>
- <text class="tip-summary">{{ item.summary }}</text>
- </view>
- </view>
- </view>
- <!-- 快捷操作按钮 -->
- <view class="section quick-actions" v-if="isLoggedIn">
- <view class="action-btn" @click="goToHealthReport">
- <text class="action-icon">📋</text>
- <text class="action-text">报告详情</text>
- </view>
- <view class="action-btn" @click="goToCheckin">
- <text class="action-icon">🏃</text>
- <text class="action-text">健康打卡</text>
- </view>
- <view class="action-btn" @click="goToNutritionProfile">
- <text class="action-icon">🥗</text>
- <text class="action-text">营养档案</text>
- </view>
- </view>
- <!-- 底部占位 -->
- <view class="bottom-spacer"></view>
- <AIFloatingAvatar />
- </view>
- </template>
- <script>
- import TabTransition from '../../components/tab-transition.vue'
- import PageBanner from '../../components/PageBanner.vue'
- import LoginGuideCard from '../../components/LoginGuideCard.vue'
- import HealthTips from '../../components/HealthTips.vue'
- import FamilyEnergyBar from '../../components/FamilyEnergyBar.vue'
- import UserQuickEntry from '../../components/UserQuickEntry.vue'
- import DimensionTasks from '../../components/DimensionTasks.vue'
- import DimensionActivities from '../../components/DimensionActivities.vue'
- import DimensionProducts from '../../components/DimensionProducts.vue'
- import DimensionArticles from '../../components/DimensionArticles.vue'
- import FamilyRelationGraph from '../../components/FamilyRelationGraph.vue'
- import RadarChart from '../../components/RadarChart.vue'
- import AIFloatingAvatar from '../../components/AIFloatingAvatar.vue'
- import FamilyRelationshipSection from '../../components/FamilyRelationshipSection.vue'
- import { getVisibleSections, getEnergyOverview, getChildren, getTodayTasksByCategory, getActivityList, getProductsByDomain, getFamilyEnergySandbox, getVisibleFamilyMembers, getDimensionOverview, getFeaturedArticles, getContactList, getHealthAlerts, getMilestones } from '../../utils/api.js'
- import config from '../../config.js'
- var BASE_URL = config.api('')
- const healthRequest = function(url, data) {
- var token = uni.getStorageSync('token')
- return new Promise(function(resolve, reject) {
- uni.request({
- url: BASE_URL + url,
- method: 'POST',
- data: data,
- header: {
- 'Content-Type': 'application/json',
- 'Authorization': token ? 'Bearer ' + token : ''
- },
- success: function(res) {
- if (res.data.code === 200) {
- resolve(res.data)
- } else {
- reject(res.data)
- }
- },
- fail: function(err) {
- reject(err)
- }
- })
- })
- }
- export default {
- components: { TabTransition, PageBanner, LoginGuideCard, HealthTips, FamilyEnergyBar, UserQuickEntry, DimensionTasks, DimensionActivities, DimensionProducts, DimensionArticles, FamilyRelationGraph, RadarChart, AIFloatingAvatar, FamilyRelationshipSection },
- data() {
- return {
- isLoggedIn: false,
- role: null,
- showTabTransition: true,
- activeChildId: null,
- activeChildName: '',
- userName: '',
- children: [],
- familyMembersVisible: [],
- sandboxData: null,
- dualDimension: null,
- visibleSections: [],
- latestReport: null,
- dimensionTasks: [],
- dimensionActivities: [],
- dimensionProducts: [],
- bodyArticles: [],
- dimensionData: null,
- funcList: [
- { icon: '\u{1F3C3}', label: '运动', needLogin: true, page: '/pages/health/exercise-index' },
- { icon: '\u{1F957}', label: '饮食', needLogin: true, page: '/pages/health/diet-index' },
- { icon: '\u{1F634}', label: '作息', needLogin: true, page: '/pages/health/sleep-index' },
- { icon: '\u{1F9A0}', label: '菌群', needLogin: true, page: '/pages/health/gut-index' },
- { icon: '\u{1F9D8}', label: '冥想', needLogin: true, page: '/pages/health/meditation-index' },
- { icon: '\u{1F4CA}', label: '舌诊', needLogin: true, page: '/pages/health/tongue-index' }
- ],
- contactList: [],
- healthAlerts: [],
- milestones: [],
- healthTips: [
- { id: 1, title: '儿童每日运动指南', summary: '不同年龄段儿童每天需要多少运动量?科学运动助力健康成长。' },
- { id: 2, title: '五行饮食搭配法则', summary: '根据五行理论合理搭配膳食,均衡营养从每一餐开始。' },
- { id: 3, title: '优质睡眠从小养成', summary: '帮助孩子建立规律的作息习惯,提升睡眠质量。' },
- { id: 4, title: '肠道菌群与免疫力', summary: '了解益生菌对儿童健康的重要作用,从内部提升抵抗力。' }
- ]
- }
- },
- computed: {
- reportTypeLabel: function() {
- if (!this.latestReport) return ''
- return this.latestReport.reportType === 'gut_flora' ? '肠道检测报告' : '体检报告'
- },
- energyMapForGraph: function() {
- var map = {}
- if (this.sandboxData && this.sandboxData.members) {
- for (var i = 0; i < this.sandboxData.members.length; i++) {
- var m = this.sandboxData.members[i]
- map[m.memberId || m.id] = {
- bodyScore: m.bodyScore || 0,
- mindScore: m.mindScore || 0,
- actionScore: m.actionScore || 0
- }
- }
- }
- return map
- },
- intimacyMapForGraph: function() {
- return {}
- }
- },
- onShow() {
- // Tabbar 切换过渡动画(最少停留 1 秒)
- this.showTabTransition = true
- var self = this
- setTimeout(function() {
- self.showTabTransition = false
- }, 1800)
- var token = uni.getStorageSync('token')
- this.isLoggedIn = !!token
- if (this.isLoggedIn) {
- this.role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
- this.userName = uni.getStorageSync('nickname') || uni.getStorageSync('userName') || '家长'
- }
- this.loadSectionConfig()
- if (this.isLoggedIn) {
- this.loadChildren()
- this.loadFamilyMembersVisible()
- this.loadRelationshipHealth()
- }
- // 游客也能浏览活动和商品
- this.loadDimensionActivities()
- this.loadDimensionProducts()
- // 游客也能浏览文章
- this.loadFeaturedArticles()
- },
- methods: {
- loadSectionConfig: function() {
- var baseSections = ['func_entries']
- if (!uni.getStorageSync('token')) {
- this.visibleSections = baseSections
- return
- }
- var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
- var self = this
- getVisibleSections({ pageKey: 'body', role: role }).then(function(res) {
- if (res.code === 200 && res.data) {
- var keys = res.data.map(function(s) { return s.sectionKey })
- var merged = baseSections.slice()
- keys.forEach(function(k) { if (merged.indexOf(k) === -1) merged.push(k) })
- self.visibleSections = merged
- }
- }).catch(function(e) {
- self.visibleSections = ['func_entries']
- })
- },
- loadChildren: function() {
- var self = this
- getChildren().then(function(res) {
- if (res.code === 200 && res.data) {
- self.children = res.data
- var savedChildId = uni.getStorageSync('currentChildId')
- var found = false
- for (var i = 0; i < self.children.length; i++) {
- if (self.children[i].childId === savedChildId) {
- self.activeChildId = savedChildId
- self.activeChildName = self.children[i].name || self.children[i].nickname || '孩子'
- found = true
- break
- }
- }
- if (!found && self.children.length > 0) {
- self.activeChildId = self.children[0].childId
- self.activeChildName = self.children[0].name || self.children[0].nickname || '孩子'
- uni.setStorageSync('currentChildId', self.activeChildId)
- }
- if (self.activeChildId) {
- self.loadDashboardData()
- }
- self.loadContacts()
- }
- }).catch(function(e) {
- console.log('获取孩子列表失败', e)
- })
- },
- loadDashboardData: function() {
- if (!this.activeChildId) return
- this.loadHealthReport()
- this.loadEnergyData()
- this.loadDimensionTasks()
- this.loadDimensionActivities()
- this.loadDimensionProducts()
- this.loadSandboxData()
- this.loadHealthDimensions()
- },
- loadHealthDimensions: function() {
- var self = this
- getDimensionOverview({ memberId: this.activeChildId }).then(function(res) {
- if (res && res.data) {
- self.dimensionData = res.data
- }
- }).catch(function(e) {
- console.log('获取维度概览失败', e)
- })
- },
- loadSandboxData: function() {
- var self = this
- getFamilyEnergySandbox().then(function(res) {
- if (res && res.data) {
- self.sandboxData = res.data
- }
- }).catch(function(e) {
- console.log('获取沙盘数据失败', e)
- })
- },
- loadHealthReport: function() {
- var self = this
- healthRequest('/api/health/report/latest', { childId: this.activeChildId }).then(function(res) {
- if (res.data) {
- self.latestReport = res.data
- }
- }).catch(function(e) {
- console.log('获取健康报告失败', e)
- })
- },
- loadEnergyData: function() {
- var self = this
- getEnergyOverview(this.activeChildId).then(function(res) {
- if (res && res.data) {
- var dims = res.data.dimensions
- if (dims && dims.length > 0) {
- for (var i = 0; i < dims.length; i++) {
- if (dims[i].code === 'body') {
- self.dualDimension = dims[i]
- break
- }
- }
- }
- }
- }).catch(function(e) {
- console.log('获取能量概览失败', e)
- })
- },
- loadDimensionTasks: function() {
- var self = this
- if (!this.activeChildId) return
- getTodayTasksByCategory(this.activeChildId, 'body').then(function(res) {
- if (res && res.data) {
- self.dimensionTasks = Array.isArray(res.data) ? res.data.slice(0, 5) : []
- }
- }).catch(function() { self.dimensionTasks = [] })
- },
- loadDimensionActivities: function() {
- var self = this
- getActivityList({ dimensionCode: 'body', page: 1, size: 3 }).then(function(res) {
- if (res && res.data) {
- var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
- self.dimensionActivities = list.slice(0, 3)
- }
- }).catch(function() { self.dimensionActivities = [] })
- },
- loadDimensionProducts: function() {
- var self = this
- getProductsByDomain('body', 1, 4).then(function(res) {
- if (res && res.data) {
- var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
- self.dimensionProducts = list.slice(0, 4)
- }
- }).catch(function() { self.dimensionProducts = [] })
- },
- loadFeaturedArticles: function() {
- var self = this
- getFeaturedArticles({ size: 5 }).then(function(res) {
- if (res.code === 200 && res.data) {
- var gradientColors = [
- 'linear-gradient(135deg, #FF8C42, #FFB074)',
- 'linear-gradient(135deg, #FF6B9D, #FF9DBD)',
- 'linear-gradient(135deg, #6366F1, #818CF8)',
- 'linear-gradient(135deg, #10B981, #34D399)',
- 'linear-gradient(135deg, #F59E0B, #FBBF24)'
- ]
- var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
- self.bodyArticles = list.map(function(item, index) {
- return {
- id: item.id,
- category: item.categoryName || '身体健康',
- categoryColor: gradientColors[index % gradientColors.length],
- title: item.title || '',
- summary: item.summary || '',
- views: item.viewCount ? String(item.viewCount) : '0',
- date: item.publishedAt ? item.publishedAt.slice(0, 10) : ''
- }
- })
- }
- }.bind(this)).catch(function() {})
- },
- onChildChanged: function(child) {
- this.activeChildId = child.childId
- this.activeChildName = child.name || child.nickname || '孩子'
- this.loadDashboardData()
- },
- loadFamilyMembersVisible: function() {
- var self = this
- getVisibleFamilyMembers().then(function(res) {
- self.familyMembersVisible = res.data || []
- }).catch(function(e) {
- console.log('获取可见家庭成员失败', e)
- self.familyMembersVisible = []
- })
- },
- scrollToSection: function(section) {
- uni.pageScrollTo({ selector: '#' + section, duration: 300 })
- },
- onTaskClick: function(task) {
- uni.navigateTo({ url: '/pages/tasks/tasks' })
- },
- goActivityDetail: function(act) {
- uni.navigateTo({ url: '/pages/discover-detail/activity-detail/activity-detail?id=' + act.id })
- },
- goMoreActivities: function() {
- uni.navigateTo({ url: '/pages/activity/index' })
- },
- goProductDetail: function(prod) {
- uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + prod.id })
- },
- goMoreProducts: function() {
- uni.navigateTo({ url: '/pages/shop/index' })
- },
- goArticleDetail: function(article) {
- var id = article.id || article
- uni.navigateTo({ url: '/pages/mind-detail/article-detail?id=' + id })
- },
- goMoreArticles: function() {
- uni.navigateTo({ url: '/pages/mind-detail/articles' })
- },
- goTasks: function() { uni.switchTab({ url: '/pages/tasks/tasks' }) },
- goMemberDetail: function(member) {
- if (!member || !member.memberId) return
- uni.navigateTo({
- url: '/pages/body-detail/member-body-detail?childId=' + member.memberId
- })
- },
- sectionVisible: function(key) {
- return this.visibleSections.length === 0 || this.visibleSections.indexOf(key) !== -1
- },
- onFuncClick: function(item) {
- if (item.needLogin && !this.isLoggedIn) {
- uni.showModal({
- title: '提示',
- content: '请先登录后使用此功能',
- success: function(res) {
- if (res.confirm) uni.navigateTo({ url: '/pages/login/login' })
- }
- })
- return
- }
- if (item.page === 'health-dimensions') {
- if (!this.activeChildId) {
- uni.showToast({ title: '请先选择孩子', icon: 'none' })
- return
- }
- uni.navigateTo({ url: '/pages/body-detail/health-dimensions?childId=' + this.activeChildId })
- return
- }
- if (item.page) uni.navigateTo({ url: item.page })
- },
- goToHealthReport: function() {
- if (!this.activeChildId) {
- uni.showToast({ title: '请先选择孩子', icon: 'none' })
- return
- }
- uni.navigateTo({ url: '/pages/body-detail/health-report?childId=' + this.activeChildId })
- },
- goDimensionDetail: function(dimKey) {
- uni.navigateTo({ url: '/pages/body/dimension-detail?dimension=' + dimKey + '&childId=' + this.activeChildId })
- },
- goToCheckin: function() {
- if (!this.activeChildId) {
- uni.showToast({ title: '请先选择孩子', icon: 'none' })
- return
- }
- uni.navigateTo({ url: '/pages/body-detail/checkin?childId=' + this.activeChildId })
- },
- goToNutritionProfile: function() {
- if (!this.activeChildId) {
- uni.showToast({ title: '请先选择孩子', icon: 'none' })
- return
- }
- uni.navigateTo({ url: '/pages/health/nutrition-profile?childId=' + this.activeChildId })
- },
- goToUploadReport: function() {
- // 使用当前选中孩子;如果 loadChildren 异步未完成则尝试从 storage 读取
- var id = this.activeChildId || uni.getStorageSync('currentChildId') || ''
- uni.navigateTo({ url: '/pages/health/report-upload?childId=' + id + '&from=body' })
- },
- // ===== 重要关系 =====
- loadContacts: function() {
- var self = this
- getContactList({}).then(function(res) {
- if (res.code === 200 && res.data) {
- self.contactList = Array.isArray(res.data) ? res.data : []
- }
- }).catch(function(e) {
- console.log('获取联系人失败', e)
- })
- },
- loadRelationshipHealth: function() {
- var self = this
- getHealthAlerts({}).then(function(res) {
- if (res.code === 200 && res.data) {
- self.healthAlerts = Array.isArray(res.data) ? res.data : []
- }
- }).catch(function() {
- self.healthAlerts = []
- })
- getMilestones({}, 30).then(function(res) {
- if (res.code === 200 && res.data) {
- self.milestones = Array.isArray(res.data) ? res.data : []
- }
- }).catch(function() {
- self.milestones = []
- })
- },
- onContactClick: function(item) {
- uni.navigateTo({ url: '/pages/body-detail/contact-detail?id=' + item.id })
- },
- onShowImport: function() {
- uni.showToast({ title: '导入通讯录', icon: 'none' })
- },
- goInteractionLog: function(memberId) {
- if (memberId) {
- uni.navigateTo({ url: '/pages/body-detail/interaction-log?memberId=' + memberId })
- } else {
- uni.navigateTo({ url: '/pages/body-detail/interaction-log' })
- }
- },
- goRelationshipQuestionnaire: function() {
- uni.navigateTo({ url: '/pages/body-detail/relationship-questionnaire' })
- },
- formatDate: function(dateStr) {
- if (!dateStr) return '--'
- try {
- var d = new Date(dateStr)
- var y = d.getFullYear()
- var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
- var day = ('' + d.getDate()).padStart(2, '0')
- return y + '-' + m + '-' + day
- } catch (e) {
- return dateStr
- }
- }
- }
- }
- </script>
- <style scoped>
- .body-container {
- min-height: 100vh;
- background: #f5f7fa;
- padding-bottom: 120rpx;
- }
- /* ===== 功能入口 ===== */
- .func-section {
- margin: 20rpx 30rpx;
- }
- .func-grid {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx 16rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .func-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- flex: 1;
- }
- .func-icon-wrap {
- width: 80rpx;
- height: 80rpx;
- border-radius: 40rpx;
- background: linear-gradient(135deg, #D6EAF8, #EBF2FA);
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 10rpx;
- }
- .func-icon {
- font-size: 40rpx;
- }
- .func-label {
- font-size: 22rpx;
- color: #666;
- font-weight: 500;
- }
- /* ===== 通用区块 ===== */
- .section {
- margin: 20rpx 30rpx;
- }
- .section-header {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 16rpx;
- }
- .section-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- .avg-badge {
- font-size: 20rpx;
- color: #F97316;
- background: #FFF7ED;
- padding: 4rpx 12rpx;
- border-radius: 20rpx;
- margin-left: 12rpx;
- }
- .section-more {
- font-size: 24rpx;
- color: #5B9BD5;
- }
- /* ===== 健康报告 ===== */
- .report-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .report-type-tag {
- display: inline-block;
- background: #E8F5E9;
- color: #2E7D32;
- font-size: 22rpx;
- padding: 4rpx 16rpx;
- border-radius: 20rpx;
- margin-bottom: 16rpx;
- }
- .report-score-row {
- display: flex;
- flex-direction: row;
- align-items: center;
- }
- .score-circle {
- width: 140rpx;
- height: 140rpx;
- border-radius: 70rpx;
- background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- margin-right: 24rpx;
- }
- .score-value {
- font-size: 48rpx;
- font-weight: bold;
- color: #1565C0;
- }
- .score-label {
- font-size: 20rpx;
- color: #64B5F6;
- }
- .report-meta {
- flex: 1;
- }
- .meta-item {
- display: flex;
- flex-direction: row;
- align-items: center;
- margin-bottom: 12rpx;
- }
- .meta-label {
- font-size: 24rpx;
- color: #666;
- width: 140rpx;
- }
- .meta-value {
- font-size: 26rpx;
- color: #333;
- font-weight: 500;
- }
- .report-date {
- font-size: 22rpx;
- color: #bbb;
- margin-top: 16rpx;
- }
- .report-empty {
- background: #fff;
- border-radius: 20rpx;
- padding: 40rpx;
- text-align: center;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .empty-tip {
- font-size: 28rpx;
- color: #999;
- display: block;
- }
- .empty-sub {
- font-size: 24rpx;
- color: #ccc;
- display: block;
- margin-top: 8rpx;
- }
- /* ===== 健康小贴士 ===== */
- .tips-list {
- display: flex;
- flex-direction: column;
- }
- .tip-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx;
- margin-bottom: 16rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .tip-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- display: block;
- margin-bottom: 10rpx;
- }
- .tip-summary {
- font-size: 24rpx;
- color: #888;
- line-height: 1.5;
- display: block;
- }
- /* ===== 快捷操作 ===== */
- .quick-actions {
- display: flex;
- flex-direction: row;
- margin-top: 30rpx;
- }
- .action-btn {
- flex: 1;
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- margin-right: 20rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .action-btn:last-child {
- margin-right: 0;
- }
- .action-icon {
- font-size: 48rpx;
- margin-bottom: 8rpx;
- }
- .action-text {
- font-size: 26rpx;
- color: #666;
- }
- /* ===== 底部 ===== */
- .bottom-spacer {
- height: 120rpx;
- }
- .func-item:active, .action-btn:active {
- opacity: 0.7;
- }
- /* ===== 精准营养 ===== */
- .nutrition-section {
- margin-top: 20rpx;
- }
- .nutrition-report-card {
- display: flex;
- flex-direction: row;
- align-items: center;
- background: linear-gradient(135deg, #E8F5E9, #F1F8E9);
- border-radius: 20rpx;
- padding: 28rpx 24rpx;
- margin-bottom: 20rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .nutrition-report-left {
- width: 100rpx;
- height: 100rpx;
- background: rgba(255,255,255,0.7);
- border-radius: 20rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 20rpx;
- flex-shrink: 0;
- }
- .nutrition-icon-large {
- font-size: 52rpx;
- }
- .nutrition-report-right {
- flex: 1;
- }
- .nutrition-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #2E7D32;
- display: block;
- margin-bottom: 6rpx;
- }
- .nutrition-desc {
- font-size: 22rpx;
- color: #558B2F;
- line-height: 1.5;
- display: block;
- margin-bottom: 10rpx;
- }
- .nutrition-report-tags {
- display: flex;
- flex-direction: row;
- gap: 10rpx;
- }
- .nutrition-report-tags .tag {
- font-size: 20rpx;
- color: #33691E;
- background: rgba(255,255,255,0.6);
- padding: 4rpx 14rpx;
- border-radius: 20rpx;
- }
- .nutrition-arrow {
- font-size: 40rpx;
- color: #A5D6A7;
- margin-left: 12rpx;
- }
- .nutrition-links {
- margin-bottom: 20rpx;
- }
- .links-label {
- font-size: 26rpx;
- font-weight: bold;
- color: #333;
- display: block;
- margin-bottom: 12rpx;
- }
- .links-row {
- display: flex;
- flex-direction: row;
- gap: 16rpx;
- }
- .link-item {
- flex: 1;
- display: flex;
- flex-direction: row;
- align-items: center;
- background: #fff;
- border-radius: 16rpx;
- padding: 20rpx 18rpx;
- box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
- gap: 12rpx;
- }
- .link-item:active {
- opacity: 0.7;
- }
- .link-icon {
- font-size: 36rpx;
- flex-shrink: 0;
- }
- .link-texts {
- flex: 1;
- }
- .link-name {
- font-size: 24rpx;
- font-weight: 500;
- color: #333;
- display: block;
- margin-bottom: 4rpx;
- }
- .link-desc {
- font-size: 20rpx;
- color: #999;
- display: block;
- }
- .link-arrow {
- font-size: 32rpx;
- color: #CCC;
- flex-shrink: 0;
- }
- /* ===== 推荐阅读 ===== */
- .article-list {
- display: flex;
- flex-direction: column;
- gap: 16rpx;
- }
- .article-card {
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- }
- .article-card:active {
- opacity: 0.8;
- }
- .article-category {
- display: inline-block;
- padding: 4rpx 14rpx;
- border-radius: 8rpx;
- margin-bottom: 10rpx;
- }
- .article-category-text {
- font-size: 20rpx;
- color: #fff;
- }
- .article-title {
- display: block;
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 8rpx;
- line-height: 1.4;
- }
- .article-summary {
- display: block;
- font-size: 24rpx;
- color: #888;
- line-height: 1.5;
- margin-bottom: 12rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .article-meta {
- display: flex;
- align-items: center;
- gap: 16rpx;
- }
- .meta-item {
- display: flex;
- align-items: center;
- gap: 4rpx;
- }
- .meta-icon {
- font-size: 24rpx;
- }
- .meta-text {
- font-size: 22rpx;
- color: #999;
- }
- .article-date {
- font-size: 22rpx;
- color: #bbb;
- }
- </style>
|