|
|
@@ -58,9 +58,13 @@
|
|
|
<text class="growth-guide-text">登录后查看我的成长档案</text>
|
|
|
</view>
|
|
|
|
|
|
+ <!-- 加载骨架 / 错误态(登录后数据区块) -->
|
|
|
+ <LoadingSkeleton v-if="isLoggedIn && homeLoading" :rows="3" />
|
|
|
+ <ErrorState v-else-if="isLoggedIn && homeError" message="首页数据加载失败" @retry="loadInfo" />
|
|
|
+
|
|
|
<!-- 平台动态 -->
|
|
|
<view class="section-title">平台动态</view>
|
|
|
- <view class="dynamic-list" v-if="dynamics.length">
|
|
|
+ <view class="dynamic-list" v-if="!homeLoading && !homeError && dynamics.length">
|
|
|
<view class="dynamic-item" v-for="(d, idx) in dynamics" :key="idx" @click="goDynamic(d)">
|
|
|
<text class="dynamic-tag" :class="d.tagClass">{{ d.tag }}</text>
|
|
|
<view class="dynamic-main">
|
|
|
@@ -88,7 +92,7 @@
|
|
|
|
|
|
<!-- 沙龙 -->
|
|
|
<view class="section-title">沙龙</view>
|
|
|
- <view class="course-mini-list">
|
|
|
+ <view class="course-mini-list" v-if="!homeLoading && !homeError">
|
|
|
<view class="course-mini-card" v-for="(s, idx) in salonNews" :key="idx" @click="goSalon(s)">
|
|
|
<view class="course-mini-head">
|
|
|
<text class="course-mini-level">{{ mapTheme(s.theme) }}</text>
|
|
|
@@ -105,7 +109,7 @@
|
|
|
|
|
|
<!-- 最近课程 -->
|
|
|
<view class="section-title">最近课程</view>
|
|
|
- <view class="course-mini-list">
|
|
|
+ <view class="course-mini-list" v-if="!homeLoading && !homeError">
|
|
|
<view class="course-mini-card" v-for="(c, idx) in recentCourses" :key="idx" @click="goToCourse(c)">
|
|
|
<view class="course-mini-head">
|
|
|
<text class="course-mini-level">{{ c.level || 'L' }}</text>
|
|
|
@@ -159,8 +163,11 @@ import { wechatLogin, wechatPhoneLogin, getCourseList, getMyEnrollments, getMyBa
|
|
|
import { formatDateTime } from '@/utils/format.js'
|
|
|
import { loadInviteCode, getInviteCode, buildSharePath } from '@/utils/share.js'
|
|
|
import { captureInviteCode } from '@/utils/invite.js'
|
|
|
+import LoadingSkeleton from '@/components/loading-skeleton.vue'
|
|
|
+import ErrorState from '@/components/error-state.vue'
|
|
|
|
|
|
export default {
|
|
|
+ components: { LoadingSkeleton, ErrorState },
|
|
|
data() {
|
|
|
return {
|
|
|
myClasses: [],
|
|
|
@@ -171,6 +178,9 @@ export default {
|
|
|
salonNews: [],
|
|
|
dynamics: [],
|
|
|
recentCourses: [],
|
|
|
+ homeLoading: false,
|
|
|
+ homePending: 0,
|
|
|
+ homeError: false,
|
|
|
aiTips: [
|
|
|
{ icon: '💡', text: '提示词三要素:角色 + 任务 + 要求,描述越具体,AI 越懂你。' },
|
|
|
{ icon: '🤖', text: '把 AI 当成一起上课的学伴,先问「怎么做」,再问「为什么」。' },
|
|
|
@@ -279,11 +289,18 @@ export default {
|
|
|
loadInfo() {
|
|
|
if (!this.isLoggedIn) return
|
|
|
var self = this
|
|
|
+ this.homeLoading = true
|
|
|
+ this.homeError = false
|
|
|
+ this.homePending = 2
|
|
|
this.loadClasses()
|
|
|
this.loadGrowth()
|
|
|
this.loadCourses()
|
|
|
this.loadSalons()
|
|
|
},
|
|
|
+ homeTick() {
|
|
|
+ this.homePending = this.homePending - 1
|
|
|
+ if (this.homePending <= 0) this.homeLoading = false
|
|
|
+ },
|
|
|
loadClasses() {
|
|
|
var self = this
|
|
|
getMyEnrollments().then(function(resp) {
|
|
|
@@ -329,14 +346,22 @@ export default {
|
|
|
})
|
|
|
self.recentCourses = sorted.slice(0, 3)
|
|
|
self.buildDynamics()
|
|
|
- }).catch(function() {})
|
|
|
+ }).catch(function() {
|
|
|
+ self.homeError = true
|
|
|
+ }).finally(function() {
|
|
|
+ self.homeTick()
|
|
|
+ })
|
|
|
},
|
|
|
loadSalons() {
|
|
|
var self = this
|
|
|
getSalonList().then(function(resp) {
|
|
|
self.salonNews = resp.data || []
|
|
|
self.buildDynamics()
|
|
|
- }).catch(function() {})
|
|
|
+ }).catch(function() {
|
|
|
+ self.homeError = true
|
|
|
+ }).finally(function() {
|
|
|
+ self.homeTick()
|
|
|
+ })
|
|
|
},
|
|
|
buildDynamics() {
|
|
|
// 平台动态 = 进行中/未开始课程(最多 3 条);沙龙已独立成区块,避免重复
|