提交 0d406289 authored 作者: 王鹏飞's avatar 王鹏飞

增加倒计时

上级 9547b08e
...@@ -6,21 +6,21 @@ ...@@ -6,21 +6,21 @@
<div class="vote-box" style="margin-top: 0.2rem"> <div class="vote-box" style="margin-top: 0.2rem">
<p>{{ announce }}</p> <p>{{ announce }}</p>
</div> </div>
<div class="vote-button" @click="toHome">回到首页</div> <div class="vote-button" @click="goHome">回到首页</div>
</template> </template>
<!-- 已投票 --> <!-- 已投票 -->
<template v-else-if="hasVote"> <template v-else-if="hasVote">
<div class="vote-banner"><img src="../../assets/img/vote_banner.png" /></div> <div class="vote-banner"><img src="../../assets/img/vote_banner.png" /></div>
<h1 class="vote-tips">您已投票成功</h1> <h1 class="vote-tips">您已投票成功</h1>
<div class="vote-button" @click="toHome">回到首页</div> <div class="vote-button" @click="goHome">回到首页</div>
</template> </template>
<!-- 投票结束 --> <!-- 投票结束 -->
<template v-else-if="status === 0"> <template v-else-if="status === 0">
<div class="vote-banner"><img src="../../assets/img/vote_banner.png" /></div> <div class="vote-banner"><img src="../../assets/img/vote_banner.png" /></div>
<h1 class="vote-tips">投票已截止,请等待公示</h1> <h1 class="vote-tips">投票已截止,请等待公示</h1>
<div class="vote-button" @click="toHome">回到首页</div> <div class="vote-button" @click="goHome">回到首页</div>
</template> </template>
<!-- 投票中 --> <!-- 投票中 -->
...@@ -61,7 +61,7 @@ export default { ...@@ -61,7 +61,7 @@ export default {
this.hasVote = response.flag this.hasVote = response.flag
}) })
}, },
toHome() { goHome() {
this.$router.replace('/') this.$router.replace('/')
} }
}, },
......
...@@ -14,7 +14,12 @@ ...@@ -14,7 +14,12 @@
<div class="vote-button" @click="handSubmit">确认投票</div> <div class="vote-button" @click="handSubmit">确认投票</div>
<van-dialog v-model="show" title="您已投票成功" :showConfirmButton="false"> <van-dialog v-model="show" title="您已投票成功" :showConfirmButton="false">
<img src="../../assets/img/vote_success.png" class="vote-success-icon" /> <img src="../../assets/img/vote_success.png" class="vote-success-icon" />
<div class="vote-button-success" @click="goHome">回到首页</div> <div class="vote-button-success" @click="goHome">
回到首页
<van-count-down ref="countDown" :time="3000" :auto-start="false" @finish="finish">
<template #default="timeData"> ({{ timeData.seconds }}) </template>
</van-count-down>
</div>
</van-dialog> </van-dialog>
</div> </div>
</template> </template>
...@@ -50,9 +55,15 @@ export default { ...@@ -50,9 +55,15 @@ export default {
api.addVote(ids).then(response => { api.addVote(ids).then(response => {
if (response.success) { if (response.success) {
this.show = true this.show = true
this.$nextTick(() => {
this.$refs.countDown.start()
})
} }
}) })
}, },
finish() {
this.goHome()
},
goHome() { goHome() {
this.$router.replace('/') this.$router.replace('/')
} }
...@@ -96,4 +107,8 @@ export default { ...@@ -96,4 +107,8 @@ export default {
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
} }
::v-deep .van-count-down {
display: inline;
color: #fff;
}
</style> </style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论