index.vue 3.2 KB

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