|
|
@@ -161,27 +161,31 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 成长历史记录(按日期分组 · 预览压缩:最多 3 组 × 3 条) -->
|
|
|
- <view class="section history-group-section">
|
|
|
+ <!-- 能量沙盘(2026-12-05 廖总:原首页沙盘迁入本页) -->
|
|
|
+ <view class="section">
|
|
|
<view class="section-header">
|
|
|
<view class="section-header-title">
|
|
|
- <view class="gi-calendar"></view>
|
|
|
- <text class="section-title">成长历史记录</text>
|
|
|
- </view>
|
|
|
- <text class="section-more" @click="goMoreHistory" v-if="dateGroups.length > 0">查看全部 ›</text>
|
|
|
- </view>
|
|
|
- <BaseEmpty v-if="dateGroups.length === 0" compact title="暂无记录,去记录第一笔成长吧" />
|
|
|
- <view v-else class="history-group-list">
|
|
|
- <view class="history-group" v-for="group in dateGroups" :key="group.date">
|
|
|
- <view class="history-group-title">
|
|
|
- <text class="history-group-date">{{ group.date }}</text>
|
|
|
- <text class="history-group-count">{{ group.records.length }} 条</text>
|
|
|
- </view>
|
|
|
- <view class="history-group-item" v-for="(rec, idx) in group.records" :key="getHistoryItemKey(group.date, idx)">
|
|
|
- <text class="history-group-item-title">{{ getHistoryItemTitle(rec) }}</text>
|
|
|
- </view>
|
|
|
+ <view class="gi-chart"></view>
|
|
|
+ <text class="section-title">能量沙盘</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
+ <GateLock v-if="sandboxLocked && sandboxLockGate" :gate="sandboxLockGate" />
|
|
|
+ <WuxingSandbox
|
|
|
+ v-else-if="sandboxData"
|
|
|
+ mode="live"
|
|
|
+ :scores="familySandboxScores"
|
|
|
+ :overallScore="familySandboxOverall"
|
|
|
+ :members="familySandboxMembers"
|
|
|
+ :personalData="sandboxPersonalData"
|
|
|
+ :dimensions="energyDimensions"
|
|
|
+ :totalEnergy="totalEnergy"
|
|
|
+ :totalHealthIndex="totalHealthIndex"
|
|
|
+ :currentView="currentSandboxView"
|
|
|
+ :familyUnlocked="familyUnlocked"
|
|
|
+ :memberCount="1"
|
|
|
+ @view-change="onSandboxViewChange"
|
|
|
+ showDimensionBar
|
|
|
+ starHeight="340rpx" />
|
|
|
</view>
|
|
|
|
|
|
<!-- 推荐阅读(2 条预览) -->
|
|
|
@@ -203,23 +207,50 @@
|
|
|
|
|
|
<script>
|
|
|
import LoginGuideCard from '../../components/LoginGuideCard.vue'
|
|
|
-import BaseEmpty from '../../components/BaseEmpty.vue'
|
|
|
import ArticleFeed from '../../components/ArticleFeed.vue'
|
|
|
-import { healthCheckinList, getHealthMealList, getGrowthRecommendations, getExerciseRecords, getSleepRecords, getEmotionCheckinList, getCheckinList, getTodayTasks, reportAppEnter, getGrowthRecordList } from '../../utils/api.js'
|
|
|
-import { parseDate, recordDateOf } from '../../utils/format.js'
|
|
|
+import WuxingSandbox from '../../components/wuxing-sandbox.vue'
|
|
|
+import GateLock from '../../components/gate-lock.vue'
|
|
|
+import { healthCheckinList, getHealthMealList, getGrowthRecommendations, getExerciseRecords, getSleepRecords, getEmotionCheckinList, getCheckinList, getTodayTasks, reportAppEnter, getEnergySandbox, getEnergyOverview } from '../../utils/api.js'
|
|
|
+import { recordDateOf } from '../../utils/format.js'
|
|
|
import fontScaleMixin from '@/mixins/font-scale.js'
|
|
|
import shareMixin from '../../components/share-mixin.js'
|
|
|
export default {
|
|
|
mixins: [fontScaleMixin, shareMixin],
|
|
|
- components: { LoginGuideCard, BaseEmpty, ArticleFeed },
|
|
|
+ components: { LoginGuideCard, ArticleFeed, WuxingSandbox, GateLock },
|
|
|
data() { return { memberId: '', todayDate: '', hasIncomplete: false, incompleteCount: 0, progressItems: [], todayTaskList: [], streakDays: 0,
|
|
|
healthArticles: [],
|
|
|
growthArticles: [],
|
|
|
- dateGroups: [],
|
|
|
+ // 五维能量沙盘(2026-12-05 由首页迁入)
|
|
|
+ sandboxData: null,
|
|
|
+ sandboxPersonalData: null,
|
|
|
+ sandboxFamilyData: null,
|
|
|
+ sandboxLocked: false,
|
|
|
+ sandboxLockGate: null,
|
|
|
+ currentSandboxView: 'personal',
|
|
|
+ familyUnlocked: false,
|
|
|
+ energyDimensions: [],
|
|
|
+ totalEnergy: 0,
|
|
|
+ totalHealthIndex: 0,
|
|
|
isLoggedIn: false } },
|
|
|
computed: {
|
|
|
doneCount: function() { var c = 0; for (var i = 0; i < this.progressItems.length; i++) if (this.progressItems[i] && this.progressItems[i].done) c++; return c },
|
|
|
totalCount: function() { return this.progressItems.length },
|
|
|
+ familySandboxScores: function() {
|
|
|
+ var d = this.sandboxFamilyData || {}
|
|
|
+ return {
|
|
|
+ body: d.bodyScore || 0,
|
|
|
+ mind: d.mindScore || 0,
|
|
|
+ wisdom: d.wisdomScore || 0,
|
|
|
+ action: d.actionScore || 0,
|
|
|
+ wealth: d.wealthScore || 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ familySandboxOverall: function() {
|
|
|
+ return this.sandboxFamilyData ? (this.sandboxFamilyData.overallScore || 0) : 0
|
|
|
+ },
|
|
|
+ familySandboxMembers: function() {
|
|
|
+ return this.sandboxFamilyData ? (this.sandboxFamilyData.members || []) : []
|
|
|
+ },
|
|
|
recommendArticles: function() {
|
|
|
var arr = []
|
|
|
if (this.healthArticles && this.healthArticles.length > 0) arr = arr.concat(this.healthArticles)
|
|
|
@@ -286,7 +317,6 @@ export default {
|
|
|
goToGames: function() { uni.navigateTo({ url: '/pages/games/list' }) },
|
|
|
goToArticle: function(article) { var id = article && article.id ? article.id : article; if (!id) return; uni.navigateTo({ url: '/pages/article-center/article-detail?id=' + id }) },
|
|
|
goMoreArticles: function() { uni.navigateTo({ url: '/pages/article-center/index?dimension=action' }) },
|
|
|
- goMoreHistory: function() { uni.navigateTo({ url: '/pages/growth/history' }) },
|
|
|
// 登录成功:刷新登录态数据(镜像 onShow 已登录分支)
|
|
|
onLoginSuccess: function() {
|
|
|
this.isLoggedIn = true
|
|
|
@@ -295,86 +325,56 @@ export default {
|
|
|
this.todayDate = now.getFullYear() + '-' + this.pad(now.getMonth() + 1) + '-' + this.pad(now.getDate())
|
|
|
this.loadAllData()
|
|
|
},
|
|
|
- /** 按日期分组(变更B):把打卡/档案记录流按业务日期 recordDate>startTime>sleepTime>checkinDate>createdAt
|
|
|
- * 分组合并——同日合并、分组键 yyyy-MM-dd、多日倒序(新在前)、无有效日期的记录平稳跳过 */
|
|
|
- groupByDate: function(records) {
|
|
|
- var list = Array.isArray(records) ? records : []
|
|
|
- var map = {}
|
|
|
- var order = []
|
|
|
- for (var i = 0; i < list.length; i++) {
|
|
|
- var r = list[i]
|
|
|
- if (!r) continue
|
|
|
- var key = this.recordDateKeyOf(r)
|
|
|
- if (!key) continue
|
|
|
- if (!map[key]) {
|
|
|
- map[key] = { date: key, records: [] }
|
|
|
- order.push(key)
|
|
|
- }
|
|
|
- map[key].records.push(r)
|
|
|
- }
|
|
|
- order.sort(function(a, b) { return a < b ? 1 : -1 })
|
|
|
- var groups = []
|
|
|
- for (var j = 0; j < order.length; j++) {
|
|
|
- groups.push(map[order[j]])
|
|
|
- }
|
|
|
- return groups
|
|
|
- },
|
|
|
- getHistoryItemKey: function(dateKey, idx) { return dateKey + '-' + idx },
|
|
|
- getHistoryItemTitle: function(rec) {
|
|
|
- if (!rec) return ''
|
|
|
- var t = rec.recordTitle || rec.name || rec.note || rec.mood || rec.content || ''
|
|
|
- if (t) return t
|
|
|
- if (rec.type) return rec.type
|
|
|
- return '记录'
|
|
|
- },
|
|
|
- /** 单条记录的业务日期键(分组口径):recordDate>startTime>sleepTime>checkinDate,
|
|
|
- * 无效业务日期(空串/无法解析,如手填 'not-a-date')视为无日期记录予以跳过;不取 createdAt 兜底 */
|
|
|
- recordDateKeyOf: function(rec) {
|
|
|
- if (!rec) return ''
|
|
|
- var fields = ['recordDate', 'startTime', 'sleepTime', 'checkinDate']
|
|
|
- for (var i = 0; i < fields.length; i++) {
|
|
|
- var key = fields[i]
|
|
|
- var v = rec[key]
|
|
|
- if (v === null || v === undefined || v === '') continue
|
|
|
- var d = parseDate(v)
|
|
|
- if (!d) continue
|
|
|
- return d.getFullYear() + '-' + this.pad(d.getMonth() + 1) + '-' + this.pad(d.getDate())
|
|
|
- }
|
|
|
- return ''
|
|
|
- },
|
|
|
- /** 成长历史记录加载:档案列表与全部打卡记录汇成一条记录流,按日期分组存入 dateGroups。
|
|
|
- * 极致简单:本页只取预览(最多 3 个日期分组 × 每组 3 条),完整记录走 /pages/growth/history */
|
|
|
- async loadGrowthHistoryGroups() {
|
|
|
- var self = this
|
|
|
- var streams = []
|
|
|
- try {
|
|
|
- var gRes = await getGrowthRecordList()
|
|
|
- if (gRes && gRes.code === 200 && Array.isArray(gRes.data)) streams = streams.concat(gRes.data)
|
|
|
- } catch(e) {}
|
|
|
- var checkinStreams = [
|
|
|
- getHealthMealList(self.memberId ? { memberId: self.memberId } : {}),
|
|
|
- getExerciseRecords(self.memberId ? { memberId: self.memberId } : {}),
|
|
|
- getSleepRecords(self.memberId ? { memberId: self.memberId } : {}),
|
|
|
- getEmotionCheckinList({ page: 1, size: 50, memberId: self.memberId || undefined }),
|
|
|
- getCheckinList(self.memberId ? { memberId: self.memberId } : {})
|
|
|
- ]
|
|
|
- var results = await Promise.all(checkinStreams.map(function(p) { return p.catch(function() { return null }) }))
|
|
|
- for (var i = 0; i < results.length; i++) {
|
|
|
- var res = results[i]
|
|
|
- if (res && res.code === 200 && Array.isArray(res.data)) streams = streams.concat(res.data)
|
|
|
- }
|
|
|
- var groups = self.groupByDate(streams)
|
|
|
- // 预览上限:最多 3 个日期分组,每组最多 3 条(完整记录走历史页)
|
|
|
- self.dateGroups = groups.slice(0, 3).map(function(g) {
|
|
|
- return { date: g.date, records: g.records.slice(0, 3) }
|
|
|
- })
|
|
|
- },
|
|
|
async loadAllData() {
|
|
|
var self = this
|
|
|
try { await self.loadProgressItems() } catch(e) {}
|
|
|
try { await self.loadGrowthRecommendations() } catch(e) {}
|
|
|
try { await self.loadMilestones() } catch(e) {}
|
|
|
- try { await self.loadGrowthHistoryGroups() } catch(e) {}
|
|
|
+ try { await self.loadEnergyOverview() } catch(e) {}
|
|
|
+ try { await self.loadSandboxData() } catch(e) {}
|
|
|
+ },
|
|
|
+ /** 能量概览:供沙盘右上角总能量/健康指数展示 */
|
|
|
+ async loadEnergyOverview() {
|
|
|
+ var memberId = this.memberId || uni.getStorageSync('currentChildId') || uni.getStorageSync('currentMemberId')
|
|
|
+ if (!memberId) return
|
|
|
+ var self = this
|
|
|
+ getEnergyOverview(memberId).then(function(res) {
|
|
|
+ if (res && res.data) {
|
|
|
+ self.energyDimensions = res.data.dimensions || []
|
|
|
+ self.totalEnergy = res.data.totalEnergy || 0
|
|
|
+ self.totalHealthIndex = res.data.totalHealthIndex || 0
|
|
|
+ }
|
|
|
+ }).catch(function(e) { console.log('获取能量概览失败', e) })
|
|
|
+ },
|
|
|
+ /** 五维能量沙盘:个人/全家视角(未解锁时后端回 gate,交由 GateLock 渲染自检引导) */
|
|
|
+ loadSandboxData: function() {
|
|
|
+ var self = this
|
|
|
+ var memberId = this.memberId || uni.getStorageSync('currentChildId') || uni.getStorageSync('currentMemberId') || null
|
|
|
+ getEnergySandbox(this.currentSandboxView, memberId).then(function(res) {
|
|
|
+ if (res && res.data) {
|
|
|
+ var d = res.data
|
|
|
+ if (d.locked) {
|
|
|
+ self.sandboxLocked = true
|
|
|
+ self.sandboxLockGate = d.gate || null
|
|
|
+ self.sandboxData = null
|
|
|
+ self.sandboxPersonalData = null
|
|
|
+ self.sandboxFamilyData = null
|
|
|
+ } else {
|
|
|
+ self.sandboxLocked = false
|
|
|
+ self.sandboxLockGate = null
|
|
|
+ self.sandboxPersonalData = d.personalData || null
|
|
|
+ self.sandboxFamilyData = d.familyData || null
|
|
|
+ self.sandboxData = self.currentSandboxView === 'family' ? (d.familyData || null) : (d.personalData || null)
|
|
|
+ self.familyUnlocked = d.familyUnlocked || false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch(function() {})
|
|
|
+ },
|
|
|
+ /** 切换沙盘个人/全家视角(本地切换,不重新请求) */
|
|
|
+ onSandboxViewChange: function(view) {
|
|
|
+ if (view === this.currentSandboxView) return
|
|
|
+ this.currentSandboxView = view
|
|
|
+ this.sandboxData = view === 'family' ? (this.sandboxFamilyData || null) : (this.sandboxPersonalData || null)
|
|
|
},
|
|
|
async loadProgressItems() {
|
|
|
var self = this
|
|
|
@@ -801,59 +801,6 @@ $gg-tint-soft: $tint-warm-soft; // 暖白浅底 #FFF1E6
|
|
|
margin-left: 12rpx;
|
|
|
}
|
|
|
|
|
|
-// ---- 成长历史记录(日期分组预览 · 修复:模板已引用 .history-group-* 但无样式定义,未套用;现按卡片规范补齐) ----
|
|
|
-.history-group-section { margin-top: 20rpx; }
|
|
|
-.history-group-list {
|
|
|
- background: $app-surface;
|
|
|
- border-radius: 24rpx;
|
|
|
- padding: 8rpx 24rpx;
|
|
|
- box-shadow: 0 2rpx 16rpx rgba(0,0,0,0.05);
|
|
|
-}
|
|
|
-.history-group { padding: 18rpx 0; }
|
|
|
-.history-group + .history-group { border-top: 1rpx solid $app-border-subtle; }
|
|
|
-.history-group-title {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: space-between;
|
|
|
- margin-bottom: 8rpx;
|
|
|
-}
|
|
|
-.history-group-date {
|
|
|
- font-size: calc(24rpx * var(--font-scale, 1));
|
|
|
- font-weight: 700;
|
|
|
- color: $facade-text-strong;
|
|
|
-}
|
|
|
-.history-group-count {
|
|
|
- font-size: calc(20rpx * var(--font-scale, 1));
|
|
|
- color: $facade-text-body;
|
|
|
- background: $facade-fill-2;
|
|
|
- border-radius: 999rpx;
|
|
|
- padding: 2rpx 14rpx;
|
|
|
- font-weight: 500;
|
|
|
-}
|
|
|
-.history-group-item {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- padding: 8rpx 0;
|
|
|
-}
|
|
|
-.history-group-item::before {
|
|
|
- content: '';
|
|
|
- width: 10rpx;
|
|
|
- height: 10rpx;
|
|
|
- border-radius: 50%;
|
|
|
- background: $brand-primary;
|
|
|
- flex-shrink: 0;
|
|
|
- margin-right: 14rpx;
|
|
|
-}
|
|
|
-.history-group-item-title {
|
|
|
- flex: 1;
|
|
|
- min-width: 0;
|
|
|
- font-size: calc(24rpx * var(--font-scale, 1));
|
|
|
- color: $facade-text-body;
|
|
|
- overflow: hidden;
|
|
|
- white-space: nowrap;
|
|
|
- text-overflow: ellipsis;
|
|
|
-}
|
|
|
-
|
|
|
// ---- 通用 section-header ----
|
|
|
.section-header {
|
|
|
display: flex;
|