|
@@ -4,10 +4,10 @@
|
|
|
<text class="page-title">实时积分榜</text>
|
|
<text class="page-title">实时积分榜</text>
|
|
|
<text class="page-desc" v-if="className">{{ className }}</text>
|
|
<text class="page-desc" v-if="className">{{ className }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <view v-if="board.length === 0" class="empty-state">
|
|
|
|
|
- <text class="empty-text">暂无积分数据</text>
|
|
|
|
|
- </view>
|
|
|
|
|
- <view class="rank-list">
|
|
|
|
|
|
|
+ <LoadingSkeleton v-if="loading" :rows="3" />
|
|
|
|
|
+ <ErrorState v-else-if="error" message="积分榜加载失败" @retry="loadData" />
|
|
|
|
|
+ <EmptyState v-else-if="board.length === 0" icon="🏆" title="暂无积分数据" desc="完成学习任务后积分会在此排行" />
|
|
|
|
|
+ <view v-else class="rank-list">
|
|
|
<view class="rank-item" v-for="(item, idx) in board" :key="idx" :class="rankClass(idx)">
|
|
<view class="rank-item" v-for="(item, idx) in board" :key="idx" :class="rankClass(idx)">
|
|
|
<view class="rank-num">
|
|
<view class="rank-num">
|
|
|
<text v-if="idx < 3" class="rank-medal">{{ ['🥇','🥈','🥉'][idx] }}</text>
|
|
<text v-if="idx < 3" class="rank-medal">{{ ['🥇','🥈','🥉'][idx] }}</text>
|
|
@@ -30,12 +30,18 @@
|
|
|
<script>
|
|
<script>
|
|
|
import { getScoreboard, getClassInfo } from '@/utils/api.js'
|
|
import { getScoreboard, getClassInfo } from '@/utils/api.js'
|
|
|
import { guardPage } from '@/utils/guard.js'
|
|
import { guardPage } from '@/utils/guard.js'
|
|
|
|
|
+import LoadingSkeleton from '@/components/loading-skeleton.vue'
|
|
|
|
|
+import ErrorState from '@/components/error-state.vue'
|
|
|
|
|
+import EmptyState from '@/components/empty-state.vue'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
|
|
+ components: { LoadingSkeleton, ErrorState, EmptyState },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
board: [],
|
|
board: [],
|
|
|
- className: ''
|
|
|
|
|
|
|
+ className: '',
|
|
|
|
|
+ loading: false,
|
|
|
|
|
+ error: false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
@@ -45,6 +51,8 @@ export default {
|
|
|
methods: {
|
|
methods: {
|
|
|
loadData() {
|
|
loadData() {
|
|
|
var self = this
|
|
var self = this
|
|
|
|
|
+ self.loading = true
|
|
|
|
|
+ self.error = false
|
|
|
var classId = self.$store.state.classId
|
|
var classId = self.$store.state.classId
|
|
|
var doLoad = function(cid) {
|
|
var doLoad = function(cid) {
|
|
|
return getScoreboard(cid).then(function(resp) {
|
|
return getScoreboard(cid).then(function(resp) {
|
|
@@ -52,7 +60,11 @@ export default {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
if (classId) {
|
|
if (classId) {
|
|
|
- doLoad(classId)
|
|
|
|
|
|
|
+ doLoad(classId).catch(function() {
|
|
|
|
|
+ self.error = true
|
|
|
|
|
+ }).finally(function() {
|
|
|
|
|
+ self.loading = false
|
|
|
|
|
+ })
|
|
|
getClassInfo().then(function(resp) {
|
|
getClassInfo().then(function(resp) {
|
|
|
if (resp.data) self.className = resp.data.name
|
|
if (resp.data) self.className = resp.data.name
|
|
|
}).catch(function() {})
|
|
}).catch(function() {})
|
|
@@ -61,9 +73,15 @@ export default {
|
|
|
if (resp.data) {
|
|
if (resp.data) {
|
|
|
self.className = resp.data.name
|
|
self.className = resp.data.name
|
|
|
self.$store.commit('setClassId', resp.data.id)
|
|
self.$store.commit('setClassId', resp.data.id)
|
|
|
- return doLoad(resp.data.id)
|
|
|
|
|
|
|
+ return doLoad(resp.data.id).catch(function() {
|
|
|
|
|
+ self.error = true
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- }).catch(function() {})
|
|
|
|
|
|
|
+ }).catch(function() {
|
|
|
|
|
+ self.error = true
|
|
|
|
|
+ }).finally(function() {
|
|
|
|
|
+ self.loading = false
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
rankClass(idx) {
|
|
rankClass(idx) {
|