|
|
@@ -144,14 +144,15 @@
|
|
|
<view class="section">
|
|
|
<view class="progress-card">
|
|
|
<view class="progress-header">
|
|
|
- <text class="progress-title">今日干预进度</text>
|
|
|
+ <text class="progress-title">今日成长</text>
|
|
|
<text class="progress-date">{{ todayDate }}</text>
|
|
|
</view>
|
|
|
- <view class="progress-item" v-for="(item, idx) in progressItems" :key="getProgressKey(item)">
|
|
|
- <text class="progress-icon">{{ item.icon }}</text>
|
|
|
- <text class="progress-label">{{ item.label }}</text>
|
|
|
- <text class="progress-status" :class="item.done ? 'status-done' : 'status-pending'">{{ item.done ? '✔ 已完成' : '' }}</text>
|
|
|
- <text class="progress-btn" v-if="!item.done" @click="handleProgressClick(item)">{{ item.actionText || '补录' }}</text>
|
|
|
+ <view class="progress-grid" v-if="progressItems.length > 0">
|
|
|
+ <view class="progress-grid-item" v-for="(item, idx) in progressItems" :key="getProgressKey(item)" @click="handleProgressClick(item)">
|
|
|
+ <text class="progress-grid-icon">{{ item.icon }}</text>
|
|
|
+ <text class="progress-grid-label">{{ item.label }}</text>
|
|
|
+ <text class="progress-grid-status" :class="item.done ? 'status-done' : 'status-pending'">{{ item.done ? '✔' : (item.actionText || '去记录') }}</text>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
<view class="progress-footer">
|
|
|
<text class="footer-text">今日完成 {{ doneCount }}/{{ totalCount }}</text>
|
|
|
@@ -169,16 +170,6 @@
|
|
|
<text class="action-arrow">›</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="section">
|
|
|
- <view class="action-card" @click="goToFoods">
|
|
|
- <text class="action-icon">🍽️</text>
|
|
|
- <view class="action-info">
|
|
|
- <text class="action-title">饮食推荐</text>
|
|
|
- <text class="action-desc">基于菌群报告的个性化食材建议</text>
|
|
|
- </view>
|
|
|
- <text class="action-arrow">›</text>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
|
|
|
<!-- 推荐文章 -->
|
|
|
<view class="section" v-if="healthArticles.length > 0 || growthArticles.length > 0">
|
|
|
@@ -289,7 +280,7 @@
|
|
|
import PageBanner from '../../components/PageBanner.vue'
|
|
|
import LoginGuideCard from '../../components/LoginGuideCard.vue'
|
|
|
import DimensionActivities from '../../components/DimensionActivities.vue'
|
|
|
-import { healthCheckinList, getDietDailyRecords, getSurveyStatus, getSurveyHistory, getFoodCautionList, getGrowthRecommendations, getExerciseRecords, getSleepRecords, getEmotionCheckinList } from '../../utils/api.js'
|
|
|
+import { healthCheckinList, getHealthMealList, getSurveyStatus, getSurveyHistory, getFoodCautionList, getGrowthRecommendations, getExerciseRecords, getSleepRecords, getEmotionCheckinList, productList } from '../../utils/api.js'
|
|
|
import { parseDate } from '../../utils/format.js'
|
|
|
export default {
|
|
|
components: { PageBanner, LoginGuideCard, DimensionActivities },
|
|
|
@@ -365,32 +356,39 @@ export default {
|
|
|
try { await self.loadProgressItems() } catch(e) {}
|
|
|
try { await self.loadCautionData() } catch(e) {}
|
|
|
try { await self.loadGrowthRecommendations() } catch(e) {}
|
|
|
+ try { await self.loadRecommendedProducts() } catch(e) {}
|
|
|
try { await self.loadSurveyData() } catch(e) {}
|
|
|
try { await self.loadMilestones() } catch(e) {}
|
|
|
},
|
|
|
- async loadProgressItems() {
|
|
|
+ async loadRecommendedProducts() {
|
|
|
var self = this
|
|
|
- var items = []
|
|
|
- var checkinDone = false
|
|
|
try {
|
|
|
- var ciRes = await healthCheckinList({ yearMonth: self.todayDate.substring(0, 7) })
|
|
|
- if (ciRes.code === 200 && ciRes.data) {
|
|
|
- for (var ci = 0; ci < ciRes.data.length; ci++) { if (ciRes.data[ci] && self.formatDateKey(ciRes.data[ci].checkinDate) === self.todayDate) { checkinDone = true; break } }
|
|
|
+ var res = await productList({ page: 1, size: 6 })
|
|
|
+ if (res && res.code === 200 && res.data) {
|
|
|
+ var list = (res.data.list || res.data.records || res.data).slice(0, 6)
|
|
|
+ self.healthProducts = list
|
|
|
+ self.growthProducts = []
|
|
|
}
|
|
|
} catch(e) {}
|
|
|
- items.push({ key: 'checkin', icon: '✅', label: '今日打卡', done: checkinDone, actionText: '打卡' })
|
|
|
- // 饮食记录:daily 接口返回 {date, records, ...},records 才是数组
|
|
|
+ },
|
|
|
+ async loadProgressItems() {
|
|
|
+ var self = this
|
|
|
+ var items = []
|
|
|
+ // 饮食记录:health/meal/list 返回当日记录数组
|
|
|
var dietDone = false
|
|
|
try {
|
|
|
- var dRes = await getDietDailyRecords({ date: self.todayDate })
|
|
|
- var dRecords = (dRes.code === 200 && dRes.data && dRes.data.records) ? dRes.data.records : []
|
|
|
- if (dRecords.length > 0) dietDone = true
|
|
|
+ var dParams = self.memberId ? { memberId: self.memberId } : {}
|
|
|
+ var dRes = await getHealthMealList(dParams)
|
|
|
+ var dList = (dRes.code === 200 && dRes.data) ? dRes.data : []
|
|
|
self.trackingData.diet = []
|
|
|
- for (var di = 0; di < dRecords.length; di++) {
|
|
|
- var dr = dRecords[di]
|
|
|
+ for (var di = 0; di < dList.length; di++) {
|
|
|
+ var dr = dList[di]
|
|
|
if (!dr) continue
|
|
|
- var foods = dr.userConfirmedFoods || dr.aiRecognizedFoods || dr.notes || ''
|
|
|
- self.trackingData.diet.push({ _id: dr.id, _date: self.mealTypeLabel(dr.mealType), _content: foods || '已记录' })
|
|
|
+ if (self.formatDateKey(dr.createdAt || dr.recordDate) === self.todayDate) dietDone = true
|
|
|
+ if (di < 5) {
|
|
|
+ var foods = dr.foodNames || dr.mealContent || dr.notes || ''
|
|
|
+ self.trackingData.diet.push({ _id: dr.id, _date: self.mealTypeLabel(dr.mealType), _content: foods || '已记录' })
|
|
|
+ }
|
|
|
}
|
|
|
} catch(e) {}
|
|
|
items.push({ key: 'diet', icon: '🍽️', label: '饮食记录', done: dietDone, actionText: '补录' })
|
|
|
@@ -447,7 +445,6 @@ export default {
|
|
|
}
|
|
|
} catch(e) {}
|
|
|
items.push({ key: 'emotion', icon: '😊', label: '心情记录', done: emotionDone, actionText: '记录' })
|
|
|
- items.push({ key: 'survey', icon: '📋', label: '本周调研', done: self.allDone, actionText: self.allDone ? '' : '开始' })
|
|
|
self.progressItems = items.filter(function(it) { return it && it.key })
|
|
|
self.incompleteCount = 0
|
|
|
for (var pi = 0; pi < items.length; pi++) if (items[pi] && !items[pi].done) self.incompleteCount++
|
|
|
@@ -567,6 +564,13 @@ export default {
|
|
|
.progress-icon{font-size:28rpx;margin-right:12rpx;flex-shrink:0}
|
|
|
.progress-label{font-size:26rpx;color:#333;flex:1}
|
|
|
.progress-status{font-size:22rpx;margin-right:8rpx;flex-shrink:0}
|
|
|
+.progress-grid{display:flex;justify-content:space-between}
|
|
|
+.progress-grid-item{flex:1;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:20rpx 8rpx;background:#FFF7ED;border-radius:16rpx;margin-right:12rpx}
|
|
|
+.progress-grid-item:last-child{margin-right:0}
|
|
|
+.progress-grid-item:active{opacity:0.85;background:#FFEDD5}
|
|
|
+.progress-grid-icon{font-size:40rpx;margin-bottom:8rpx}
|
|
|
+.progress-grid-label{font-size:24rpx;color:#333;margin-bottom:8rpx;text-align:center}
|
|
|
+.progress-grid-status{font-size:20rpx;flex-shrink:0}
|
|
|
.status-done{color:#10B981}
|
|
|
.status-pending{color:#ccc}
|
|
|
.progress-btn{font-size:22rpx;color:#F97316;padding:4rpx 16rpx;border:1rpx solid #F97316;border-radius:20rpx;flex-shrink:0}
|