mockExamInfo.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <!-- 模拟考试详情 -->
  2. <template>
  3. <view class="mock-exam-info">
  4. <scroll-view scroll-y class="scroll-content">
  5. <view class="card">
  6. <view class="exam-name">{{ examData.examName }}</view>
  7. <view class="chip-row mb12">
  8. <text class="tag tag-blue text-xs">{{ examData.examTypeName }}</text>
  9. <text class="tag tag-orange text-xs">模拟卷</text>
  10. </view>
  11. <view class="info-grid mb14">
  12. <view class="info-item">
  13. <view class="text-xs text-gray mb4">题目总数</view>
  14. <view class="text-blue fw500">{{ examData.totalQuestionNum || 0 }} 题</view>
  15. </view>
  16. <view class="info-item">
  17. <view class="text-xs text-gray mb4">考试时长</view>
  18. <view class="fw500">{{ examData.answerDuration }} 分钟</view>
  19. </view>
  20. <view class="info-item">
  21. <view class="text-xs text-gray mb4">满分</view>
  22. <view class="fw500">{{ examData.totalScore }} 分</view>
  23. </view>
  24. <view class="info-item">
  25. <view class="text-xs text-gray mb4">及格分数</view>
  26. <view class="text-orange fw500">{{ examData.passScore }} 分</view>
  27. </view>
  28. </view>
  29. <view class="score-summary" v-for="(item,index) in examData.mockHistoryScores" :key="index">
  30. <view class="text-sm fw500 mb8">历次模拟成绩</view>
  31. <view class="row-between mb4">
  32. <text class="text-sm text-gray">第 {{ index+1 }} 次 {{ item.submitTime}}</text>
  33. <text class="text-sm fw500" :class="item.isPassed ? 'text-green' : 'text-red'">
  34. 最高 {{ item.score || 0 }} 分({{ item.isPassed ? '已通过' : '未通过' }})
  35. </text>
  36. </view>
  37. <view v-if="!item.isPassed" class="text-xs text-gray">
  38. 还需提高 {{ item.passScoreGap }} 分达到及格线
  39. </view>
  40. </view>
  41. <view class="notice">模拟考试需达到及格分数({{ examData.passScore }}分)方可参加正式在线考试。</view>
  42. </view>
  43. </scroll-view>
  44. <view class="bottom-bar" v-if="examData.needStudy||examData.examStudy||examData.mockExam">
  45. <view class="btn-primary" @click="startMockExam">
  46. {{examData.needStudy||examData.examStudy?'开始学习':(examData.mockExam?'开始模拟考试':'')}}
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. goToExamPage,
  54. } from '@/pages_safetyEducationExamination/utils/index.js'
  55. import {
  56. examUserExamStart,
  57. } from '@/pages_safetyEducationExamination/api/index.js'
  58. import {
  59. parseTime
  60. } from '@/component/public.js'
  61. export default {
  62. data() {
  63. return {
  64. examData: {}
  65. }
  66. },
  67. computed: {
  68. scoreGap() {
  69. return Math.max(0, (this.examData.passScore || 0) - (this.examData.maxScore || 0));
  70. }
  71. },
  72. onLoad(options) {
  73. if (options.examData) {
  74. try {
  75. this.examData = JSON.parse(decodeURIComponent(options.examData));
  76. this.formatExamData();
  77. } catch (e) {
  78. console.error('解析模拟考试数据失败', e);
  79. }
  80. }
  81. },
  82. methods: {
  83. formatExamData() {
  84. if (this.examData.startTime) {
  85. this.examData.startTime = parseTime(this.examData.startTime, '{y}-{m}-{d} {h}:{i}');
  86. }
  87. if (this.examData.endTime) {
  88. this.examData.endTime = parseTime(this.examData.endTime, '{y}-{m}-{d} {h}:{i}');
  89. }
  90. },
  91. async startMockExam() {
  92. if (this.examData.needStudy || this.examData.examStudy) {
  93. goToExamPage(this.examData);
  94. return;
  95. }
  96. try {
  97. uni.showLoading({ title: '加载中...', mask: true });
  98. const { data } = await examUserExamStart({ examId: this.examData.examId, examScene: 2 });
  99. uni.hideLoading();
  100. if (data.code === 200 && data.data && data.data.attemptId) {
  101. uni.navigateTo({
  102. url: `/pages_safetyEducationExamination/views/exam/mockExamPlay?examId=${this.examData.examId}&attemptId=${data.data.attemptId}`
  103. });
  104. } else {
  105. uni.showToast({ title: data.message || '获取模拟试卷失败', icon: 'none' });
  106. }
  107. } catch (e) {
  108. uni.hideLoading();
  109. uni.showToast({ title: '获取模拟试卷失败', icon: 'none' });
  110. }
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="stylus" scoped>
  116. .mock-exam-info
  117. height 100%
  118. display flex
  119. flex-direction column
  120. background #f0f4fb
  121. .scroll-content
  122. flex 1
  123. overflow hidden
  124. padding-bottom 220rpx
  125. .card
  126. margin 24rpx
  127. padding 28rpx
  128. background #fff
  129. border 1rpx solid #dde3ed
  130. border-radius 20rpx
  131. .exam-name
  132. font-size 34rpx
  133. font-weight 700
  134. margin-bottom 16rpx
  135. .chip-row
  136. display flex
  137. gap 12rpx
  138. .tag
  139. padding 6rpx 16rpx
  140. border-radius 20rpx
  141. .tag-blue
  142. background #e6f4ff
  143. color #1677ff
  144. border 1rpx solid #91caff
  145. .tag-orange
  146. background #fff7e6
  147. color #d46b08
  148. border 1rpx solid #ffd591
  149. .info-grid
  150. display grid
  151. grid-template-columns 1fr 1fr
  152. gap 16rpx
  153. .info-item
  154. padding 20rpx
  155. border 1rpx solid #dde3ed
  156. border-radius 16rpx
  157. .score-summary
  158. padding 24rpx
  159. margin-bottom 28rpx
  160. background #f4f6fa
  161. border-radius 16rpx
  162. .notice
  163. padding 20rpx
  164. background #fff7e6
  165. border-radius 16rpx
  166. font-size 24rpx
  167. line-height 1.6
  168. color #d46b08
  169. .row-between
  170. display flex
  171. justify-content space-between
  172. align-items center
  173. .bottom-bar
  174. position fixed
  175. bottom 0
  176. left 0
  177. right 0
  178. padding 20rpx 24rpx
  179. padding-bottom calc(20rpx + env(safe-area-inset-bottom))
  180. background #fff
  181. border-top 1rpx solid #eee
  182. .btn-primary
  183. height 88rpx
  184. line-height 88rpx
  185. text-align center
  186. background #1857d4
  187. border-radius 16rpx
  188. color #fff
  189. font-size 32rpx
  190. font-weight 600
  191. .text-xs
  192. font-size 22rpx
  193. .text-sm
  194. font-size 24rpx
  195. .text-gray
  196. color #999
  197. .text-blue
  198. color #1857d4
  199. .text-orange
  200. color #d46b08
  201. .text-green
  202. color #52c41a
  203. .text-red
  204. color #ff4d4f
  205. .fw500
  206. font-weight 500
  207. .mb4
  208. margin-bottom 8rpx
  209. .mb8
  210. margin-bottom 16rpx
  211. .mb12
  212. margin-bottom 24rpx
  213. .mb14
  214. margin-bottom 28rpx
  215. </style>