| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675 |
- <template>
- <view class="wisdom-container">
- <!-- Tabbar 切换过渡页 -->
- <tab-transition v-if="showTabTransition" dimCode="wisdom" />
- <!-- 1. 品牌头部 -->
- <PageBanner theme="wisdom"
- tagline="学以启智 · 慧及未来"
- quote="知者不惑,仁者不忧" />
- <!-- 2. 游客专属区块 -->
- <template v-if="!isLoggedIn">
- <LoginGuideCard
- title="登录后查看全家智慧成长数据"
- :items="[
- '查看全家认知能量数据和测评报告',
- '记录每日成长,获取智慧能量',
- '参与认知训练,提升综合能力'
- ]" />
- </template>
- <!-- 3. 五维能量条(登录后) -->
- <FamilyEnergyBar
- v-if="isLoggedIn"
- dimensionCode="wisdom"
- :sandboxData="sandboxData"
- :dualDimension="dualDimension" />
- <!-- ===== 重要关系维护 ===== -->
- <FamilyRelationshipSection
- :contactList="contactList"
- :healthAlerts="healthAlerts"
- :milestones="milestones"
- :isLoggedIn="isLoggedIn"
- @contactClick="onContactClick"
- @refresh="loadContacts"
- @import="onShowImport"
- @interactionLog="goInteractionLog"
- @questionnaire="goRelationshipQuestionnaire" />
- <!-- 4. 认知雷达图(登录后) -->
- <view class="section" v-if="isLoggedIn && cognitiveReport">
- <view class="section-header">
- <text class="section-title">认知雷达</text>
- <text class="section-more" @click="goCognitiveReport">查看详情 ›</text>
- </view>
- <RadarChart
- :dimensions="cognitiveDimensions"
- :scores="cognitiveScores"
- :childName="activeChildName"
- fillColor="#6366F1"
- gridColor="#E0E7FF"
- labelColor="#3730A3" />
- </view>
- <!-- 5. 家庭成员关系图谱(登录后) -->
- <FamilyRelationGraph
- v-if="isLoggedIn && familyMembersVisible.length > 0"
- dimensionCode="wisdom"
- :selfId="activeChildId"
- :members="familyMembersVisible"
- :energyMap="energyMapForGraph"
- :intimacyMap="intimacyMapForGraph"
- @memberTap="goMemberDetail" />
- <!-- 6. 用户快捷入口 -->
- <UserQuickEntry
- v-if="isLoggedIn"
- :userName="userName"
- roleName="家长"
- :currentChildName="activeChildName"
- :children="children"
- @childChanged="onChildChanged"
- @scrollTo="scrollToSection" />
- <!-- 7. 功能入口 -->
- <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>
- <!-- 8. 维度任务 -->
- <DimensionTasks
- v-if="isLoggedIn"
- dimensionCode="wisdom"
- :tasks="dimensionTasks"
- @taskClick="onTaskClick"
- @moreTasks="goTasks" />
- <!-- 9. 维度活动 -->
- <DimensionActivities
- dimensionCode="wisdom"
- :activities="dimensionActivities"
- :isLoggedIn="isLoggedIn"
- @activityClick="goActivityDetail"
- @moreActivities="goMoreActivities" />
- <!-- 10. 维度商品 -->
- <DimensionProducts
- dimensionCode="wisdom"
- :products="dimensionProducts"
- @productClick="goProductDetail"
- @moreProducts="goMoreProducts" />
- <!-- 11. 推荐阅读 -->
- <DimensionArticles
- v-if="sectionVisible('recommended_reading')"
- dimensionCode="wisdom"
- :articles="wisdomArticles"
- :isLoggedIn="isLoggedIn"
- @articleClick="goArticleDetail"
- @moreArticles="goMoreArticles" />
- <!-- 12. 智慧小贴士 -->
- <view class="section" v-if="sectionVisible('wisdom_tips')">
- <view class="section-header">
- <text class="section-title">智慧小贴士</text>
- </view>
- <view class="tips-list">
- <view class="tip-card" v-for="item in wisdomTips" :key="item.id">
- <text class="tip-title">{{ item.title }}</text>
- <text class="tip-summary">{{ item.summary }}</text>
- </view>
- </view>
- </view>
- <!-- 13. 快捷操作按钮 -->
- <view class="section quick-actions" v-if="isLoggedIn">
- <view class="action-btn" @click="goCognitiveReport">
- <text class="action-icon">📊</text>
- <text class="action-text">认知报告</text>
- </view>
- <view class="action-btn" @click="goTrainingHub">
- <text class="action-icon">🧠</text>
- <text class="action-text">认知训练</text>
- </view>
- <view class="action-btn" @click="goAssessment">
- <text class="action-icon">📋</text>
- <text class="action-text">测评预约</text>
- </view>
- <view class="action-btn" @click="goHome">
- <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 RadarChart from '../../components/RadarChart.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 AIFloatingAvatar from '../../components/AIFloatingAvatar.vue'
- import FamilyRelationshipSection from '../../components/FamilyRelationshipSection.vue'
- import { getVisibleSections, getChildren, getTodayTasksByCategory, getActivityList, getProductsByDomain, getFamilyEnergySandbox, getAssessmentLatestResult, getFeaturedArticles, getContactList, getHealthAlerts, getMilestones } from '../../utils/api.js'
- export default {
- components: { TabTransition, PageBanner, LoginGuideCard, RadarChart, FamilyEnergyBar, UserQuickEntry, DimensionTasks, DimensionActivities, DimensionProducts, DimensionArticles, FamilyRelationGraph, AIFloatingAvatar, FamilyRelationshipSection },
- data() {
- return {
- isLoggedIn: false,
- role: null,
- showTabTransition: true,
- activeChildId: null,
- activeChildName: '',
- userName: '',
- children: [],
- familyMembersVisible: [],
- sandboxData: null,
- dualDimension: null,
- visibleSections: [],
- cognitiveReport: null,
- dimensionTasks: [],
- dimensionActivities: [],
- dimensionProducts: [],
- articles: [],
- wisdomTips: [],
- contactList: [],
- healthAlerts: [],
- milestones: [],
- funcList: [
- { icon: '\u{1F4CA}', label: '认知报告', needLogin: true, page: '/pages/wisdom-detail/cognitive-report' },
- { icon: '\u{270F}\uFE0F', label: '自己出题', needLogin: true, page: '/pages/wisdom-detail/self-quiz' },
- { icon: '\u{1F9E0}', label: '训练中心', needLogin: true, page: '/pages/wisdom-detail/training-hub' },
- { icon: '\u{1F3AF}', label: '测评预约', needLogin: false, page: '/pages/assessment/apply' },
- { icon: '\u{1F4D6}', label: '阅读天地', needLogin: false, page: '/pages/mind/articles' }
- ]
- }
- },
- computed: {
- 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,
- wisdomScore: m.wisdomScore || 0
- }
- }
- }
- return map
- },
- intimacyMapForGraph: function() {
- return {}
- },
- wisdomArticles: function() {
- if (!this.articles || this.articles.length === 0) return []
- var result = []
- for (var i = 0; i < this.articles.length; i++) {
- var a = this.articles[i]
- if (a.relatedDimensions && a.relatedDimensions.indexOf('wisdom') !== -1) {
- result.push(a)
- }
- }
- if (result.length === 0) return this.articles.slice(0, 5)
- return result.slice(0, 5)
- },
- cognitiveDimensions: function() {
- return [
- { label: '感知能力', key: 'perceptionScore' },
- { label: '专注力', key: 'focusScore' },
- { label: '记忆力', key: 'memoryScore' },
- { label: '逻辑思维', key: 'logicScore' },
- { label: '空间思维', key: 'spatialScore' },
- { label: '加工速度', key: 'processingSpeedScore' }
- ]
- },
- cognitiveScores: function() {
- if (!this.cognitiveReport) return []
- var dims = this.cognitiveDimensions
- var scores = []
- for (var i = 0; i < dims.length; i++) {
- scores.push(this.cognitiveReport[dims[i].key] || 0)
- }
- return scores
- }
- },
- 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.loadCognitiveReport()
- this.loadRelationshipHealth()
- }
- this.loadDimensionActivities()
- this.loadDimensionProducts()
- // 游客也能浏览文章
- this.loadFeaturedArticles()
- },
- methods: {
- loadSectionConfig: function() {
- var baseSections = ['func_entries', 'wisdom_tips']
- if (!uni.getStorageSync('token')) {
- this.visibleSections = baseSections
- return
- }
- var role = uni.getStorageSync('currentRole') || uni.getStorageSync('role') || null
- var self = this
- getVisibleSections({ pageKey: 'wisdom', 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', 'wisdom_tips']
- })
- },
- loadChildren: function() {
- var self = this
- getChildren().then(function(res) {
- if (res.code === 200 && res.data) {
- self.children = res.data
- if (self.children.length > 0) {
- var activeId = uni.getStorageSync('currentChildId')
- if (activeId) {
- for (var i = 0; i < self.children.length; i++) {
- if (self.children[i].id == activeId) {
- self.activeChildId = activeId
- self.activeChildName = self.children[i].nickname || self.children[i].name || ''
- break
- }
- }
- }
- if (!self.activeChildId) {
- self.activeChildId = self.children[0].id
- self.activeChildName = self.children[0].nickname || self.children[0].name || ''
- uni.setStorageSync('currentChildId', self.activeChildId)
- }
- }
- // Load cognitive report AFTER activeChildId is confirmed set
- self.loadCognitiveReport()
- }
- self.loadContacts()
- }).catch(function(e) {})
- },
- loadFamilyMembersVisible: function() {
- var self = this
- getFamilyEnergySandbox().then(function(res) {
- if (res && res.data) {
- self.sandboxData = res.data.sandboxData || null
- self.dualDimension = res.data.dualDimension || null
- if (res.data.members) {
- self.familyMembersVisible = res.data.members
- }
- }
- }).catch(function(e) {})
- },
- loadCognitiveReport: function() {
- var self = this
- var childId = this.activeChildId
- if (!childId) return
- getAssessmentLatestResult(childId).then(function(res) {
- if (res.code === 200 && res.data) {
- self.cognitiveReport = res.data
- }
- }).catch(function(e) {})
- },
- onChildChanged: function(childId) {
- this.activeChildId = childId
- uni.setStorageSync('currentChildId', childId)
- for (var i = 0; i < this.children.length; i++) {
- if (this.children[i].id == childId) {
- this.activeChildName = this.children[i].nickname || this.children[i].name || ''
- break
- }
- }
- this.loadFamilyMembersVisible()
- this.loadCognitiveReport()
- },
- loadDimensionTasks: function() {
- var self = this
- var childId = this.activeChildId
- if (!childId) return
- getTodayTasksByCategory(childId, 'wisdom').then(function(res) {
- if (res && res.data) {
- self.dimensionTasks = res.data.slice(0, 5)
- }
- }).catch(function(e) {})
- },
- loadDimensionActivities: function() {
- var self = this
- getActivityList({ dimensionCode: 'wisdom', page: 1, size: 5 }).then(function(res) {
- if (res && res.data) {
- self.dimensionActivities = res.data.records || res.data
- }
- }).catch(function(e) {})
- },
- loadDimensionProducts: function() {
- var self = this
- getProductsByDomain('wisdom', 1, 4).then(function(res) {
- if (res && res.data) {
- self.dimensionProducts = res.data.records || res.data
- }
- }).catch(function(e) {})
- },
- 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) {
- var nativeTabs = ['/pages/tasks/tasks', '/pages/index/index', '/pages/body/index', '/pages/mind/index', '/pages/action/index', '/pages/wisdom/index', '/pages/profile/profile']
- if (nativeTabs.indexOf(item.page) !== -1) {
- uni.switchTab({ url: item.page })
- } else {
- uni.navigateTo({ url: item.page })
- }
- }
- },
- scrollToSection: function(section) {},
- goMemberDetail: function(memberId) {
- uni.navigateTo({ url: '/pages/wisdom-detail/member-wisdom-detail?memberId=' + memberId })
- },
- goCognitiveReport: function() {
- uni.navigateTo({ url: '/pages/wisdom-detail/cognitive-report' })
- },
- goSelfQuiz: function() {
- uni.navigateTo({ url: '/pages/wisdom-detail/self-quiz' })
- },
- goTrainingHub: function() {
- uni.navigateTo({ url: '/pages/wisdom-detail/training-hub' })
- },
- goAssessment: function() {
- uni.navigateTo({ url: '/pages/assessment/apply' })
- },
- goHome: function() {
- uni.switchTab({ url: '/pages/index/index' })
- },
- onTaskClick: function(task) {},
- goTasks: function() { uni.switchTab({ url: '/pages/tasks/tasks' }) },
- goActivityDetail: function(id) {},
- goMoreActivities: function() {
- uni.navigateTo({ url: '/pages/activity/index' })
- },
- goActivityDetail: function(act) {
- if (act && act.id) uni.navigateTo({ url: '/pages/discover-detail/activity-detail/activity-detail?id=' + act.id })
- },
- goProductDetail: function(prod) {
- if (prod && prod.id) {
- var token = uni.getStorageSync('token')
- if (token) {
- uni.navigateTo({ url: '/pages/discover-detail/product-detail/product-detail?id=' + prod.id })
- } else {
- uni.navigateTo({ url: '/pages/login/login?redirect=' + encodeURIComponent('/pages/wisdom/index') })
- }
- }
- },
- goMoreProducts: function() {
- uni.navigateTo({ url: '/pages/shop/index' })
- },
- loadFeaturedArticles: function() {
- var self = this
- getFeaturedArticles({ size: 5, dimensionCode: 'wisdom' }).then(function(res) {
- if (res.code === 200 && res.data) {
- var gradientColors = [
- 'linear-gradient(135deg, #6366F1, #818CF8)',
- 'linear-gradient(135deg, #8B5CF6, #A78BFA)',
- 'linear-gradient(135deg, #5B9BD5, #8FC5E8)',
- 'linear-gradient(135deg, #10B981, #34D399)',
- 'linear-gradient(135deg, #F97316, #FB923C)'
- ]
- var list = Array.isArray(res.data) ? res.data : (res.data.records || [])
- self.articles = 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',
- likes: '0',
- date: item.publishedAt ? item.publishedAt.slice(0, 10) : '',
- relatedDimensions: item.relatedDimensions || []
- }
- })
- }
- }).catch(function() {})
- },
- goMoreArticles: function() {
- uni.navigateTo({ url: '/pages/mind/articles' })
- },
- goArticleDetail: function(article) {
- uni.navigateTo({ url: '/pages/mind-detail/article-detail?id=' + (article.id || article) })
- },
- // ===== 重要关系 =====
- 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/wisdom-detail/contact-detail?id=' + item.id })
- },
- onShowImport: function() {
- uni.showToast({ title: '导入通讯录', icon: 'none' })
- },
- goInteractionLog: function(memberId) {
- if (memberId) {
- uni.navigateTo({ url: '/pages/wisdom-detail/interaction-log?memberId=' + memberId })
- } else {
- uni.navigateTo({ url: '/pages/wisdom-detail/interaction-log' })
- }
- },
- goRelationshipQuestionnaire: function() {
- uni.navigateTo({ url: '/pages/wisdom-detail/relationship-questionnaire' })
- }
- }
- }
- </script>
- <style scoped>
- .wisdom-container {
- min-height: 100vh;
- background: #f5f7fa;
- padding-bottom: 120rpx;
- }
- .func-section {
- margin: -40rpx 20rpx 0;
- position: relative;
- z-index: 2;
- }
- .func-grid {
- background: #fff;
- border-radius: 24rpx;
- padding: 30rpx 16rpx;
- display: flex;
- box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
- }
- .func-item {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .func-item:active {
- opacity: 0.7;
- }
- .func-icon-wrap {
- width: 88rpx;
- height: 88rpx;
- border-radius: 50%;
- background: #FFF8E1;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 10rpx;
- }
- .func-icon {
- font-size: 40rpx;
- }
- .func-label {
- font-size: 24rpx;
- color: #333;
- font-weight: 500;
- }
- /* ===== Section ===== */
- .section {
- margin: 20rpx 20rpx;
- }
- .section-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .section-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- }
- .section-more {
- font-size: 24rpx;
- color: #999;
- }
- /* ===== 智慧小贴士 ===== */
- .tips-list {
- display: flex;
- flex-direction: column;
- }
- .tip-card {
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx 20rpx;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- margin-bottom: 16rpx;
- }
- .tip-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- display: block;
- margin-bottom: 8rpx;
- }
- .tip-summary {
- font-size: 24rpx;
- color: #888;
- line-height: 1.5;
- display: block;
- }
- /* ===== 快捷操作按钮 ===== */
- .quick-actions {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- justify-content: space-between;
- }
- .action-btn {
- width: 48%;
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx 0;
- box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
- display: flex;
- flex-direction: column;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .action-btn:active {
- opacity: 0.8;
- }
- .action-icon {
- font-size: 40rpx;
- margin-bottom: 10rpx;
- }
- .action-text {
- font-size: 26rpx;
- color: #333;
- font-weight: 500;
- }
- /* ===== 底部占位 ===== */
- .bottom-spacer {
- height: 120rpx;
- }
- </style>
|