detail.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="content" v-if="checkData">
  3. <uni-card :title="checkData.title">
  4. <view v-if="checkData.content">{{checkData.content}}</view>
  5. <view style="color: #666;">
  6. <view>考试时长:{{checkData.totalTime}}分钟</view>
  7. <view>试卷总分:{{checkData.totalScore}}</view>
  8. <view>及格分数:{{checkData.qualifyScore}}</view>
  9. <view>关联培训:
  10. <text v-if="checkData.associate === 1" style="color: rgb(24, 144, 255)" @click="funJumpCourse">是</text>
  11. <text v-if="checkData.associate !== 1">否</text>
  12. </view>
  13. </view>
  14. </uni-card>
  15. <view v-if="checkData.answerDevice === 1" class="empty">
  16. 当前考试只能使用电脑端答题!
  17. <view>
  18. <button type="primary" @tap="backList">返回</button>
  19. </view>
  20. </view>
  21. <view v-else>
  22. <view v-if="checkData.late" class="empty">
  23. <view>您已经迟到超过{{checkData.lateMax}}分钟,不允许进入考试!</view>
  24. <view>
  25. <button type="primary" @tap="backList">返回</button>
  26. </view>
  27. </view>
  28. <view v-else-if="checkData.overTime" class="empty">
  29. <view>考试未开始或已结束!</view>
  30. <button type="primary" @tap="backList">返回</button>
  31. </view>
  32. <view v-else-if="checkData.chance>0 && checkData.examCount>=checkData.chance" class="empty">
  33. <view>开始次数超限,总共有{{checkData.chance}}次考试机会!</view>
  34. <button type="primary" @tap="backList">返回</button>
  35. </view>
  36. <view v-else>
  37. <uni-card title="考试密码" v-if="checkData.openType ===9 ">
  38. <uni-easyinput v-model="password" placeholder="请输入密码" type="password" />
  39. </uni-card>
  40. <view style="padding: 20px;">
  41. <button type="primary" @tap="startExam">开始考试</button>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. checkInfo,
  50. createPaper,
  51. checkProcess
  52. } from '@/api/exam.js'
  53. import {
  54. quickReg
  55. } from '@/api/user.js'
  56. export default {
  57. data() {
  58. return {
  59. examId: '',
  60. password: '',
  61. checkData: {}
  62. }
  63. },
  64. onLoad: function(option) {
  65. this.examId = option.id;
  66. this.fetchExamDetail();
  67. // 支付成功刷新页面
  68. uni.$on('paySuccess', () => {
  69. this.fetchExamDetail()
  70. });
  71. },
  72. methods: {
  73. // 加载考试列表
  74. fetchExamDetail() {
  75. uni.showLoading({
  76. title: '加载中...'
  77. });
  78. checkInfo(this.examId).then(data => {
  79. this.checkData = data
  80. uni.hideLoading();
  81. })
  82. },
  83. startExam() {
  84. let that = this
  85. // 如果要人脸识别
  86. if (this.checkData.faceOn) {
  87. //打印请求返回的数据
  88. uni.navigateTo({
  89. url: '/pages/exam/face?examId=' + this.examId + '&password=' + this.password
  90. });
  91. return;
  92. }
  93. uni.showLoading({
  94. title: '创建试卷...'
  95. });
  96. const data = {
  97. examId: this.examId,
  98. password: this.password,
  99. }
  100. createPaper(data).then(data => {
  101. // 关闭加载
  102. uni.hideLoading();
  103. //打印请求返回的数据
  104. uni.navigateTo({
  105. url: '/pages/exam/exam?id=' + data.id
  106. });
  107. }).catch(err => {
  108. // 有正在进行的考试
  109. if (err && err.code === 20010002) {
  110. uni.showModal({
  111. title: '提示信息',
  112. content: '您有其它正在进行的考试,是否继续进入该考试?',
  113. success: function(res) {
  114. if (res.confirm) {
  115. that.backExam()
  116. }
  117. }
  118. });
  119. }
  120. })
  121. },
  122. backList() {
  123. uni.navigateBack()
  124. },
  125. backExam() {
  126. checkProcess().then(data => {
  127. if (data && data.id) {
  128. this.continueExam(data.id)
  129. }
  130. })
  131. },
  132. funJumpCourse(){
  133. uni.navigateTo({
  134. url:'/pages/course/detail?id='+ this.checkData.courseId
  135. })
  136. },
  137. // 继续考试
  138. continueExam(id) {
  139. uni.redirectTo({
  140. url: '/pages/exam/exam?id=' + id
  141. });
  142. },
  143. },
  144. onUnload() {
  145. uni.$off('paySuccess');
  146. }
  147. }
  148. </script>
  149. <style scoped>
  150. </style>