index.vue 3.3 KB

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