onlineExamInfo.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <!-- 考试详情 -->
  2. <template>
  3. <view class="exam-detail-page">
  4. <scroll-view scroll-y class="scroll-content">
  5. <view class="card">
  6. <view class="chip-row mb8">
  7. <text class="tag tag-orange text-xs">{{ examData.examTypeName }}</text>
  8. <text class="tag tag-orange text-xs">{{ examData.examStatus == 2?'进行中':(examData.examStatus==1?'未开始':'') }}</text>
  9. </view>
  10. <view class="exam-title">{{ examData.examName }}</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="text-333 fw500">{{ examData.answerDuration }} 分钟</view>
  19. </view>
  20. <view class="info-item">
  21. <view class="text-xs text-gray mb4">总分/及格</view>
  22. <view class="text-333 fw500">{{ examData.totalScore }} / {{ examData.passScore }} 分</view>
  23. </view>
  24. <view class="info-item">
  25. <view class="text-xs text-gray mb4">考试次数</view>
  26. <view class="text-333 fw500">{{ examData.attemptLimit === 0 ? '不限' : examData.attemptLimit+' 次' }}</view>
  27. </view>
  28. </view>
  29. <!-- 考前任务要求 -->
  30. <view class="exam-type-max-box" v-if="examData.needStudy||examData.examStudy||examData.mockExam">
  31. <view class="exam-title-p">考前任务状态</view>
  32. <view class="exam-type-box">
  33. <view class="exam-min-box" v-if="examData.needStudy">
  34. <view>学时要求</view>
  35. <view>{{ examData.completedStudyHours }}/{{ examData.studyHoursRequirement }}</view>
  36. </view>
  37. <view class="exam-min-box" v-if="examData.examStudy">
  38. <view>学习任务</view>
  39. <view>待完成</view>
  40. </view>
  41. <view class="exam-min-box" v-if="examData.mockExam">
  42. <view>模拟考试</view>
  43. <view>待完成</view>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 考试说明 -->
  48. <view v-if="examData.unavailableDesc" class="exam-desc-box" style="background-color:#f4f6fa;">
  49. <view class="exam-desc">{{ examData.unavailableDesc }}</view>
  50. </view>
  51. </view>
  52. </scroll-view>
  53. <!-- 底部按钮 -->
  54. <view class="bottom-bar">
  55. <view class="btn-primary" @click="startExam">
  56. {{examData.needStudy||examData.examStudy?'开始学习':(examData.mockExam?'开始模拟考试':'开始考试')}}
  57. </view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import {
  63. parseTime
  64. } from '@/component/public.js'
  65. import {
  66. examUserExamStart
  67. } from '@/pages_safetyEducationExamination/api/index.js'
  68. export default {
  69. data() {
  70. return {
  71. examData: {},
  72. }
  73. },
  74. computed: {
  75. showConditions() {
  76. return this.examData.needStudy || this.examData.examStudy || this.examData.mockExam;
  77. }
  78. },
  79. onLoad(options) {
  80. // 接收从上个页面传递的考试数据
  81. if (options.examData) {
  82. try {
  83. this.examData = JSON.parse(decodeURIComponent(options.examData));
  84. this.formatExamData();
  85. } catch (e) {
  86. console.error('解析考试数据失败', e);
  87. }
  88. }
  89. },
  90. methods: {
  91. formatExamData() {
  92. // 格式化时间
  93. if (this.examData.startTime) {
  94. this.examData.startTime = parseTime(this.examData.startTime, '{y}-{m}-{d} {h}:{i}');
  95. }
  96. if (this.examData.endTime) {
  97. this.examData.endTime = parseTime(this.examData.endTime, '{y}-{m}-{d} {h}:{i}');
  98. }
  99. },
  100. goToStudyHour() {
  101. // 跳转到学时任务页面
  102. if (this.examData.knowledgePointIds && this.examData.knowledgePointIds.length > 0) {
  103. uni.navigateTo({
  104. url: `/pages_safetyEducationExamination/views/studyHourTask/index?knowledgePointId=${this.examData.knowledgePointIds.join(',')}`
  105. });
  106. } else {
  107. uni.navigateTo({
  108. url: '/pages_safetyEducationExamination/views/study/index'
  109. });
  110. }
  111. },
  112. goToCourse() {
  113. // 跳转到课程学习页面
  114. uni.showToast({
  115. title: '跳转到课程学习',
  116. icon: 'none'
  117. });
  118. },
  119. goToMockExam() {
  120. // 跳转到模拟考试页面
  121. uni.showToast({
  122. title: '跳转到模拟考试',
  123. icon: 'none'
  124. });
  125. },
  126. async startExam() {
  127. if (!this.examData.available) {
  128. uni.showToast({
  129. title: this.examData.unavailableDesc || '暂不可考试',
  130. icon: 'none'
  131. });
  132. return;
  133. }
  134. let attemptId = this.examData.attemptId;
  135. if (!attemptId) {
  136. try {
  137. const { data } = await examUserExamStart({
  138. examId: this.examData.examId,
  139. examScene: 1
  140. });
  141. if (data.code !== 200 || !data.data || !data.data.attemptId) {
  142. uni.showToast({
  143. title: data.message || '开始考试失败',
  144. icon: 'none'
  145. });
  146. return;
  147. }
  148. attemptId = data.data.attemptId;
  149. } catch (e) {
  150. console.error('开始考试失败', e);
  151. uni.showToast({ title: '开始考试失败', icon: 'none' });
  152. return;
  153. }
  154. }
  155. uni.navigateTo({
  156. url: `/pages_safetyEducationExamination/views/exam/onlineExamPlay?examId=${encodeURIComponent(this.examData.examId)}&attemptId=${encodeURIComponent(attemptId)}&examKind=${encodeURIComponent(this.examData.examKind || '')}`
  157. });
  158. },
  159. },
  160. }
  161. </script>
  162. <style lang="stylus" scoped>
  163. .exam-detail-page {
  164. height: 100%;
  165. display: flex;
  166. flex-direction: column;
  167. background-color: #f0f4fb;
  168. }
  169. .scroll-content {
  170. flex: 1;
  171. overflow: hidden;
  172. padding-bottom: 160rpx;
  173. }
  174. .card {
  175. background: #fff;
  176. border-radius: 20rpx;
  177. padding: 28rpx;
  178. margin: 24rpx 24rpx 0;
  179. border: 1px solid #dde3ed;
  180. }
  181. .chip-row {
  182. display: flex;
  183. gap: 12rpx;
  184. }
  185. .tag {
  186. display: inline-block;
  187. padding: 6rpx 16rpx;
  188. border-radius: 20rpx;
  189. font-size: 20rpx;
  190. }
  191. .tag-orange {
  192. background: #fff7e6;
  193. color: #d46b08;
  194. }
  195. .text-xs {
  196. font-size: 22rpx;
  197. }
  198. .mb8 {
  199. margin-bottom: 16rpx;
  200. }
  201. .mb4 {
  202. margin-bottom: 8rpx;
  203. }
  204. .mb12 {
  205. margin-bottom: 24rpx;
  206. }
  207. .mb14 {
  208. margin-bottom: 28rpx;
  209. }
  210. .exam-title {
  211. font-size: 34rpx;
  212. font-weight: 700;
  213. margin-bottom: 24rpx;
  214. }
  215. .info-grid {
  216. display: grid;
  217. grid-template-columns: 1fr 1fr;
  218. gap: 16rpx;
  219. }
  220. .info-item {
  221. border: 1px solid #dde3ed;
  222. border-radius: 16rpx;
  223. padding: 20rpx;
  224. }
  225. .text-gray {
  226. color: #999;
  227. }
  228. .text-333 {
  229. color: #333;
  230. }
  231. .text-blue {
  232. color: #1857d4;
  233. }
  234. .text-green {
  235. color: #52c41a;
  236. }
  237. .text-red {
  238. color: #ff4d4f;
  239. }
  240. .fw500 {
  241. font-weight: 500;
  242. }
  243. .time-row {
  244. font-size: 24rpx;
  245. }
  246. .card-title {
  247. font-size: 28rpx;
  248. font-weight: 600;
  249. }
  250. .condition-row {
  251. display: flex;
  252. align-items: center;
  253. padding: 16rpx 0;
  254. border-bottom: 1rpx solid #f0f0f0;
  255. &:last-child {
  256. border-bottom: none;
  257. }
  258. }
  259. .condition-icon {
  260. font-size: 32rpx;
  261. margin-right: 16rpx;
  262. }
  263. .condition-text {
  264. flex: 1;
  265. font-size: 26rpx;
  266. }
  267. .exam-desc-box{
  268. padding:28rpx;
  269. border-radius:10rpx;
  270. }
  271. .exam-desc {
  272. font-size: 26rpx;
  273. line-height: 1.8;
  274. color: #666;
  275. }
  276. .exam-type-max-box{
  277. margin-bottom:30rpx;
  278. .exam-title-p{
  279. font-size:24rpx;
  280. line-height:70rpx;
  281. }
  282. .exam-type-box{
  283. border:1px solid #dde3ed;
  284. border-radius:20rpx;
  285. .exam-min-box:nth-child(1){
  286. border-top:none;
  287. }
  288. .exam-min-box{
  289. display:flex;
  290. border-top:1px solid #dde3ed;
  291. padding:30rpx 28rpx;
  292. view{
  293. height:30rpx;
  294. line-height:30rpx;
  295. font-size:24rpx;
  296. }
  297. view:nth-child(1){
  298. flex:1;
  299. }
  300. view:nth-child(2){
  301. color:#e67e22;
  302. }
  303. }
  304. }
  305. }
  306. .bottom-bar {
  307. position: fixed;
  308. bottom: 0;
  309. left: 0;
  310. right: 0;
  311. background: #fff;
  312. padding: 20rpx 24rpx;
  313. border-top: 1rpx solid #eee;
  314. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  315. }
  316. .btn-primary {
  317. height: 88rpx;
  318. line-height: 88rpx;
  319. text-align: center;
  320. background: #1857d4;
  321. color: #fff;
  322. border-radius: 16rpx;
  323. font-size: 32rpx;
  324. font-weight: 600;
  325. }
  326. </style>