index.vue 3.7 KB

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