countdown.vue 812 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <view class="time-box" @click="out()">
  3. 交易取消{{s}}{{!s?'':'s'}}
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data(){
  9. return{
  10. s:'',
  11. timeServer:'',
  12. }
  13. },
  14. mounted() {
  15. },
  16. methods:{
  17. out(){
  18. clearInterval(this.timeServer);
  19. uni.reLaunch({
  20. url:'/pages/index/index'
  21. })
  22. },
  23. timeFun(){
  24. this.s = 180
  25. this.timeServer = setInterval(() => {
  26. --this.s;
  27. if (this.s <= 0) {
  28. clearInterval(this.timeServer);
  29. uni.reLaunch({
  30. url:'/pages/index/index'
  31. })
  32. }
  33. }, 1000);
  34. },
  35. },
  36. }
  37. </script>
  38. <style scoped lang="scss">
  39. .time-box{
  40. width: 223rpx;
  41. height: 57rpx;
  42. line-height: 57rpx;
  43. text-align: center;
  44. border-radius: 104rpx;
  45. border: 2rpx solid #CCCCCC;
  46. font-size: 28rpx;
  47. color: #666;
  48. }
  49. </style>