index.vue 4.8 KB

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