index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="safeArea">
  3. <nav-bar title="模拟考试-一级建造师-管理"></nav-bar>
  4. <view class="examWrap">
  5. <view class="title">距离管理开考还有</view>
  6. <view class="circle">
  7. <u-circle-progress class="img" width="448" bg-color="rgba(0,0,0,0)" type="primary" :percent="percent"></u-circle-progress>
  8. <view class="time">{{timeText}}</view>
  9. </view>
  10. <view class="btn" @click="examBank()" :class="{disabled:!((nowTime > start) && (nowTime < end ))}">开始考试</view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import { mapGetters } from 'vuex';
  16. export default {
  17. components: {
  18. },
  19. data() {
  20. return {
  21. mockName:'',
  22. state:1,
  23. start:0,
  24. timer:null,
  25. timeText:'',
  26. nowTime:0,
  27. timeLimit:0,
  28. examId:0,
  29. eachExamId:0,
  30. subscribeId:0,
  31. end:0,
  32. percent:0,
  33. };
  34. },
  35. onLoad(option){
  36. this.mockName = option.mockName || ''
  37. this.subscribeId = option.subscribeId
  38. this.eachExamId = option.eachExamId
  39. this.examId = option.examId
  40. this.timeLimit = +option.limit || 0
  41. this.start = +option.start;
  42. this.end = (this.timeLimit* 60) + this.start ;
  43. this.timer = setInterval(() => {
  44. this.timeText = this.getDuring()
  45. },1000)
  46. },
  47. onShow() {
  48. clearInterval(this.timer)
  49. this.timer = setInterval(() => {
  50. this.timeText = this.getDuring()
  51. },1000)
  52. },
  53. onUnload() {
  54. clearInterval(this.timer)
  55. },
  56. methods: {
  57. getDuring() {
  58. this.nowTime = +this.$method.timest();
  59. let during = this.start - this.nowTime;
  60. this.percent = during <= 0 ? 100 : during >= 600 ? 0 : (600 - during) / 600 * 100;
  61. if(during <= 0) {
  62. return '00:00'
  63. }
  64. let minutes = parseInt(during/60) >= 10 ? '0'+ parseInt(during/60) : parseInt(during/60);
  65. let seconds = during % 60 >= 10 ? during % 60 :'0'+ during % 60;
  66. return minutes+':'+seconds
  67. },
  68. canTest() {
  69. },
  70. examBank() {
  71. if(((this.nowTime > this.start) && (this.nowTime < this.end ))) {
  72. uni.redirectTo({
  73. url:'../examBank/index?examId='+this.examId+'&eachExamId='+this.eachExamId+'&subscribeId='+this.subscribeId
  74. })
  75. } else {
  76. uni.showToast({
  77. icon:'none',
  78. title:'不在考试时间'
  79. })
  80. }
  81. }
  82. },
  83. onReachBottom() {},
  84. computed: { ...mapGetters(['userInfo']) }
  85. };
  86. </script>
  87. <style >
  88. page {
  89. background: #EAEEF1;
  90. }
  91. </style>
  92. <style scoped lang="scss">
  93. .examWrap{
  94. padding: 16rpx;
  95. .title {
  96. margin-top:70rpx;
  97. font-size: 32rpx;
  98. color: #666666;
  99. line-height: 48rpx;
  100. text-align: center;
  101. }
  102. .circle {
  103. margin:60rpx auto 0;
  104. width:480rpx;
  105. height:480rpx;
  106. position:relative;
  107. background: #fff;
  108. border-radius:50%;
  109. .img {
  110. position:absolute;
  111. left:50%;
  112. top:50%;
  113. transform: translate3D(-50%,-50%,0);
  114. }
  115. .time {
  116. width:100%;
  117. height:100%;
  118. display: flex;
  119. align-items: center;
  120. justify-content: center;
  121. position:relative;
  122. z-index: 999;
  123. font-size: 80rpx;
  124. text-align: center;
  125. font-weight: bold;
  126. color: #333333;
  127. }
  128. }
  129. .btn {
  130. margin:330rpx auto 0;
  131. width: 528rpx;
  132. height: 80rpx;
  133. background: #007AFF;
  134. border-radius: 40rpx;
  135. text-align: center;
  136. line-height: 80rpx;
  137. color:#fff;
  138. &.disabled {
  139. background:#ccc;
  140. }
  141. }
  142. }
  143. </style>