|
|
@@ -5,7 +5,10 @@
|
|
|
<view :class="['round-tab', round === 2 ? 'active' : '']" @click="switchRound(2)">第2轮 · 最想抄走</view>
|
|
|
</view>
|
|
|
|
|
|
- <view v-if="!voted" class="vote-section">
|
|
|
+ <LoadingSkeleton v-if="loading" :rows="3" />
|
|
|
+ <ErrorState v-else-if="error" message="投票数据加载失败" @retry="loadGroup" />
|
|
|
+ <EmptyState v-else-if="groups.length === 0" icon="🗳️" title="暂无可投票小组" desc="进班后小组信息会在此展示" />
|
|
|
+ <view v-else-if="!voted" class="vote-section">
|
|
|
<text class="vote-hint">{{ round === 1 ? '每人2票,不可投本组' : '每人1票,可投本组' }}</text>
|
|
|
<view class="group-list">
|
|
|
<view class="group-item" v-for="(g, idx) in groups" :key="idx"
|
|
|
@@ -39,8 +42,12 @@
|
|
|
<script>
|
|
|
import { castVote, getVoteResult, getVotedStatus, getMyGroup, getClassGroups } from '@/utils/api.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 {
|
|
|
+ components: { LoadingSkeleton, ErrorState, EmptyState },
|
|
|
data() {
|
|
|
return {
|
|
|
round: 1,
|
|
|
@@ -50,7 +57,9 @@ export default {
|
|
|
selectedGroups: [],
|
|
|
voted: false,
|
|
|
bars: [],
|
|
|
- voting: false
|
|
|
+ voting: false,
|
|
|
+ loading: false,
|
|
|
+ error: false
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
@@ -60,6 +69,8 @@ export default {
|
|
|
methods: {
|
|
|
loadGroup() {
|
|
|
var self = this
|
|
|
+ self.loading = true
|
|
|
+ self.error = false
|
|
|
getMyGroup().then(function(resp) {
|
|
|
if (resp.data) {
|
|
|
self.myGroupId = resp.data.id
|
|
|
@@ -72,7 +83,11 @@ export default {
|
|
|
}
|
|
|
self.checkVoted()
|
|
|
self.loadResult()
|
|
|
- }).catch(function() {})
|
|
|
+ }).catch(function() {
|
|
|
+ self.error = true
|
|
|
+ }).finally(function() {
|
|
|
+ self.loading = false
|
|
|
+ })
|
|
|
},
|
|
|
switchRound(r) {
|
|
|
this.round = r
|