|
|
@@ -1,5 +1,8 @@
|
|
|
<template>
|
|
|
<view class="wisdom-container">
|
|
|
+ <!-- Tabbar 切换过渡页 -->
|
|
|
+ <tab-transition v-if="showTabTransition" dimCode="wisdom" />
|
|
|
+
|
|
|
<!-- 1. 品牌头部 -->
|
|
|
<PageBanner theme="wisdom"
|
|
|
tagline="学以启智 · 慧及未来"
|
|
|
@@ -130,6 +133,33 @@
|
|
|
@productClick="goProductDetail"
|
|
|
@moreProducts="goMoreProducts" />
|
|
|
|
|
|
+ <!-- 推荐阅读 -->
|
|
|
+ <view class="section" v-if="sectionVisible('recommended_reading') && wisdomArticles.length > 0">
|
|
|
+ <view class="section-header">
|
|
|
+ <text class="section-title">推荐阅读</text>
|
|
|
+ </view>
|
|
|
+ <view class="article-list">
|
|
|
+ <view class="article-card" v-for="article in wisdomArticles" :key="article.id" @click="goArticleDetail(article.id)">
|
|
|
+ <view class="article-category" :style="{ background: article.categoryColor }">
|
|
|
+ <text class="article-category-text">{{ article.category }}</text>
|
|
|
+ </view>
|
|
|
+ <text class="article-title">{{ article.title }}</text>
|
|
|
+ <text class="article-summary">{{ article.summary }}</text>
|
|
|
+ <view class="article-meta">
|
|
|
+ <view class="meta-item">
|
|
|
+ <text class="meta-icon">📖</text>
|
|
|
+ <text class="meta-text">{{ article.views }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="meta-item">
|
|
|
+ <text class="meta-icon">👍</text>
|
|
|
+ <text class="meta-text">{{ article.likes }}</text>
|
|
|
+ </view>
|
|
|
+ <text class="article-date">{{ article.date }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
<!-- 13. 智慧小贴士 -->
|
|
|
<view class="section" v-if="sectionVisible('wisdom_tips')">
|
|
|
<view class="section-header">
|
|
|
@@ -165,6 +195,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import TabTransition from '../../components/tab-transition.vue'
|
|
|
import PageBanner from '../../components/PageBanner.vue'
|
|
|
import LoginGuideCard from '../../components/LoginGuideCard.vue'
|
|
|
import WisdomTips from '../../components/WisdomTips.vue'
|
|
|
@@ -174,14 +205,15 @@ import DimensionTasks from '../../components/DimensionTasks.vue'
|
|
|
import DimensionActivities from '../../components/DimensionActivities.vue'
|
|
|
import DimensionProducts from '../../components/DimensionProducts.vue'
|
|
|
import FamilyRelationGraph from '../../components/FamilyRelationGraph.vue'
|
|
|
-import { getVisibleSections, getChildren, getTodayTasksByCategory, getActivityList, getProductsByDomain, getFamilyEnergySandbox, getAssessmentLatestResult } from '../../utils/api.js'
|
|
|
+import { getVisibleSections, getChildren, getTodayTasksByCategory, getActivityList, getProductsByDomain, getFamilyEnergySandbox, getAssessmentLatestResult, getFeaturedArticles } from '../../utils/api.js'
|
|
|
|
|
|
export default {
|
|
|
- components: { PageBanner, LoginGuideCard, WisdomTips, FamilyEnergyBar, UserQuickEntry, DimensionTasks, DimensionActivities, DimensionProducts, FamilyRelationGraph },
|
|
|
+ components: { TabTransition, PageBanner, LoginGuideCard, WisdomTips, FamilyEnergyBar, UserQuickEntry, DimensionTasks, DimensionActivities, DimensionProducts, FamilyRelationGraph },
|
|
|
data() {
|
|
|
return {
|
|
|
isLoggedIn: false,
|
|
|
role: null,
|
|
|
+ showTabTransition: false,
|
|
|
activeChildId: null,
|
|
|
activeChildName: '',
|
|
|
userName: '',
|
|
|
@@ -195,6 +227,7 @@ export default {
|
|
|
dimensionTasks: [],
|
|
|
dimensionActivities: [],
|
|
|
dimensionProducts: [],
|
|
|
+ articles: [],
|
|
|
funcList: [
|
|
|
{ icon: '\u{1F4CA}', label: '认知报告', needLogin: true, page: '/pages/wisdom/cognitive-report' },
|
|
|
{ icon: '\u{270F}\uFE0F', label: '自己出题', needLogin: true, page: '/pages/wisdom/self-quiz' },
|
|
|
@@ -227,9 +260,28 @@ export default {
|
|
|
},
|
|
|
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)
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
+ // Tabbar 切换过渡动画(最少停留 1 秒)
|
|
|
+ this.showTabTransition = true
|
|
|
+ var self = this
|
|
|
+ setTimeout(function() {
|
|
|
+ self.showTabTransition = false
|
|
|
+ }, 1100)
|
|
|
+
|
|
|
var token = uni.getStorageSync('token')
|
|
|
this.isLoggedIn = !!token
|
|
|
if (this.isLoggedIn) {
|
|
|
@@ -244,6 +296,8 @@ export default {
|
|
|
}
|
|
|
this.loadDimensionActivities()
|
|
|
this.loadDimensionProducts()
|
|
|
+ // 游客也能浏览文章
|
|
|
+ this.loadFeaturedArticles()
|
|
|
},
|
|
|
methods: {
|
|
|
loadSectionConfig: function() {
|
|
|
@@ -420,7 +474,38 @@ export default {
|
|
|
uni.navigateTo({ url: '/pages/login/login?redirect=' + encodeURIComponent('/pages/wisdom/index') })
|
|
|
}
|
|
|
},
|
|
|
- goMoreProducts: function() {}
|
|
|
+ goMoreProducts: function() {},
|
|
|
+ loadFeaturedArticles: function() {
|
|
|
+ var self = this
|
|
|
+ getFeaturedArticles({ size: 5 }).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() {})
|
|
|
+ },
|
|
|
+ goArticleDetail: function(id) {
|
|
|
+ uni.navigateTo({ url: '/pages/wisdom/article-detail?id=' + id })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|