mockExamInfo.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. examUserExamMockDetail,
  58. } from '@/pages_safetyEducationExamination/api/index.js'
  59. import {
  60. parseTime
  61. } from '@/component/public.js'
  62. export default {
  63. data() {
  64. return {
  65. examData: {},
  66. newData: {}
  67. }
  68. },
  69. computed: {
  70. scoreGap() {
  71. return Math.max(0, (this.examData.passScore || 0) - (this.examData.maxScore || 0));
  72. }
  73. },
  74. onLoad(options) {
  75. if (options.examData) {
  76. try {
  77. this.newData = JSON.parse(decodeURIComponent(options.examData));
  78. } catch (e) {
  79. console.error('解析模拟考试数据失败', e);
  80. }
  81. }
  82. },
  83. onShow(){
  84. this.examUserExamMockDetail();
  85. },
  86. methods: {
  87. async examUserExamMockDetail() {
  88. try {
  89. const { data } = await examUserExamMockDetail({examId:this.newData.examId});
  90. if (data.code === 200 && data.data) {
  91. this.$set(this,'examData',data.data);
  92. this.formatExamData();
  93. }
  94. } catch (e) {
  95. console.error('获取考试详情失败', e);
  96. }
  97. },
  98. formatExamData() {
  99. if (this.examData.startTime) {
  100. this.examData.startTime = parseTime(this.examData.startTime, '{y}-{m}-{d} {h}:{i}');
  101. }
  102. if (this.examData.endTime) {
  103. this.examData.endTime = parseTime(this.examData.endTime, '{y}-{m}-{d} {h}:{i}');
  104. }
  105. },
  106. async startMockExam() {
  107. if (this.examData.needStudy || this.examData.examStudy) {
  108. goToExamPage(this.examData);
  109. return;
  110. }
  111. try {
  112. uni.showLoading({ title: '加载中...', mask: true });
  113. const { data } = await examUserExamStart({ examId: this.examData.examId, examScene: 2 });
  114. uni.hideLoading();
  115. if (data.code === 200 && data.data && data.data.attemptId) {
  116. uni.navigateTo({
  117. url: `/pages_safetyEducationExamination/views/exam/mockExamPlay?examId=${this.examData.examId}&attemptId=${data.data.attemptId}`
  118. });
  119. } else {
  120. uni.showToast({ title: data.message || '获取模拟试卷失败', icon: 'none' });
  121. }
  122. } catch (e) {
  123. uni.hideLoading();
  124. uni.showToast({ title: '获取模拟试卷失败', icon: 'none' });
  125. }
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="stylus" scoped>
  131. .mock-exam-info
  132. height 100%
  133. display flex
  134. flex-direction column
  135. background #f0f4fb
  136. .scroll-content
  137. flex 1
  138. overflow hidden
  139. padding-bottom 220rpx
  140. .card
  141. margin 24rpx
  142. padding 28rpx
  143. background #fff
  144. border 1rpx solid #dde3ed
  145. border-radius 20rpx
  146. .exam-name
  147. font-size 34rpx
  148. font-weight 700
  149. margin-bottom 16rpx
  150. .chip-row
  151. display flex
  152. gap 12rpx
  153. .tag
  154. padding 6rpx 16rpx
  155. border-radius 20rpx
  156. .tag-blue
  157. background #e6f4ff
  158. color #1677ff
  159. border 1rpx solid #91caff
  160. .tag-orange
  161. background #fff7e6
  162. color #d46b08
  163. border 1rpx solid #ffd591
  164. .info-grid
  165. display grid
  166. grid-template-columns 1fr 1fr
  167. gap 16rpx
  168. .info-item
  169. padding 20rpx
  170. border 1rpx solid #dde3ed
  171. border-radius 16rpx
  172. .score-summary
  173. padding 24rpx
  174. margin-bottom 28rpx
  175. background #f4f6fa
  176. border-radius 16rpx
  177. .notice
  178. padding 20rpx
  179. background #fff7e6
  180. border-radius 16rpx
  181. font-size 24rpx
  182. line-height 1.6
  183. color #d46b08
  184. .row-between
  185. display flex
  186. justify-content space-between
  187. align-items center
  188. .bottom-bar
  189. position fixed
  190. bottom 0
  191. left 0
  192. right 0
  193. padding 20rpx 24rpx
  194. padding-bottom calc(20rpx + env(safe-area-inset-bottom))
  195. background #fff
  196. border-top 1rpx solid #eee
  197. .btn-primary
  198. height 88rpx
  199. line-height 88rpx
  200. text-align center
  201. background #1857d4
  202. border-radius 16rpx
  203. color #fff
  204. font-size 32rpx
  205. font-weight 600
  206. .text-xs
  207. font-size 22rpx
  208. .text-sm
  209. font-size 24rpx
  210. .text-gray
  211. color #999
  212. .text-blue
  213. color #1857d4
  214. .text-orange
  215. color #d46b08
  216. .text-green
  217. color #52c41a
  218. .text-red
  219. color #ff4d4f
  220. .fw500
  221. font-weight 500
  222. .mb4
  223. margin-bottom 8rpx
  224. .mb8
  225. margin-bottom 16rpx
  226. .mb12
  227. margin-bottom 24rpx
  228. .mb14
  229. margin-bottom 28rpx
  230. </style>