onlineExamInfo.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. <!-- 考试承诺书弹窗 -->
  60. <uni-popup ref="preExamDialog" type="center" :mask-click="false">
  61. <view class="pre-exam-dialog">
  62. <view class="dialog-header">
  63. <text class="dialog-title">考试承诺书</text>
  64. </view>
  65. <view class="dialog-body">
  66. <scroll-view scroll-y class="content-scroll">
  67. <richTextPdf ref="richTextPdf" :content="richTextHtml" />
  68. </scroll-view>
  69. </view>
  70. <view class="dialog-footer">
  71. <view v-if="preButtonType" class="btn btn-border" @click="downloadCommitment">下载</view>
  72. <view class="btn btn-primary" @click="confirmCommitment">确认</view>
  73. </view>
  74. </view>
  75. </uni-popup>
  76. </view>
  77. </template>
  78. <script>
  79. import {
  80. parseTime
  81. } from '@/component/public.js'
  82. import {
  83. examUserExamDetail,
  84. } from '@/pages_safetyEducationExamination/api/index.js'
  85. import {
  86. goToExamPage,
  87. confirmCommitmentAndStart,
  88. startFormalExam,
  89. } from '@/pages_safetyEducationExamination/utils/index.js'
  90. import richTextPdf from '@/pages_safetyEducationExamination/component/richTextPdf.vue'
  91. export default {
  92. components: {
  93. richTextPdf
  94. },
  95. data() {
  96. return {
  97. examData: {},
  98. newData:{},
  99. // 承诺书相关
  100. preButtonType: false,
  101. richTextHtml: '',
  102. preData: null,
  103. itemData:{},
  104. }
  105. },
  106. computed: {
  107. showConditions() {
  108. return this.examData.needStudy || this.examData.examStudy || this.examData.mockExam;
  109. }
  110. },
  111. onLoad(options) {
  112. // 接收从上个页面传递的考试数据
  113. if (options.examData) {
  114. try {
  115. this.newData = JSON.parse(decodeURIComponent(options.examData));
  116. // this.examUserExamDetail();
  117. } catch (e) {
  118. console.error('解析考试数据失败', e);
  119. }
  120. }
  121. },
  122. onShow(){
  123. this.examUserExamDetail();
  124. },
  125. methods: {
  126. async examUserExamDetail() {
  127. try {
  128. const { data } = await examUserExamDetail({examId:this.newData.examId});
  129. if (data.code === 200 && data.data) {
  130. this.$set(this,'examData',data.data);
  131. this.formatExamData();
  132. }
  133. } catch (e) {
  134. console.error('获取考试详情失败', e);
  135. }
  136. },
  137. formatExamData() {
  138. // 格式化时间
  139. if (this.examData.startTime) {
  140. this.examData.startTime = parseTime(this.examData.startTime, '{y}-{m}-{d} {h}:{i}');
  141. }
  142. if (this.examData.endTime) {
  143. this.examData.endTime = parseTime(this.examData.endTime, '{y}-{m}-{d} {h}:{i}');
  144. }
  145. },
  146. goToStudyHour() {
  147. // 跳转到学时任务页面
  148. if (this.examData.knowledgePointIds && this.examData.knowledgePointIds.length > 0) {
  149. uni.navigateTo({
  150. url: `/pages_safetyEducationExamination/views/studyHourTask/index?knowledgePointId=${this.examData.knowledgePointIds.join(',')}`
  151. });
  152. } else {
  153. uni.navigateTo({
  154. url: '/pages_safetyEducationExamination/views/study/index'
  155. });
  156. }
  157. },
  158. async startExam() {
  159. this.$set(this,'itemData',this.examData);
  160. goToExamPage(this.examData, {
  161. openCommitmentDialog: (examItem) => {
  162. this.preButtonType = examItem.commitmentPrintEnabled == 1;
  163. this.richTextHtml = examItem.commitmentContent;
  164. this.preData = examItem;
  165. this.$refs.preExamDialog.open();
  166. },
  167. });
  168. },
  169. // 下载承诺书
  170. downloadCommitment() {
  171. uni.showToast({ title: '正在下载,请耐心等候', icon: 'none' });
  172. this.$refs.richTextPdf.downloadPDF();
  173. },
  174. // 确认承诺书
  175. async confirmCommitment() {
  176. let self = this;
  177. await confirmCommitmentAndStart(this.preData, () => {
  178. this.$refs.preExamDialog.close();
  179. setTimeout(function(){
  180. startFormalExam(self.itemData);
  181. },500);
  182. });
  183. },
  184. // 获取任务列表
  185. async loadTaskList() {
  186. try {
  187. const { data } = await examUserExamStudyTaskList({ page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false });
  188. if (data.code === 200) {
  189. this.$set(this, 'onlineExamList', data.data.records);
  190. }
  191. } catch (e) { console.error('获取考试任务失败', e); }
  192. },
  193. },
  194. }
  195. </script>
  196. <style lang="stylus" scoped>
  197. .exam-detail-page {
  198. height: 100%;
  199. display: flex;
  200. flex-direction: column;
  201. background-color: #f0f4fb;
  202. }
  203. .scroll-content {
  204. flex: 1;
  205. overflow: hidden;
  206. padding-bottom: 160rpx;
  207. }
  208. .card {
  209. background: #fff;
  210. border-radius: 20rpx;
  211. padding: 28rpx;
  212. margin: 24rpx 24rpx 0;
  213. border: 1px solid #dde3ed;
  214. }
  215. .chip-row {
  216. display: flex;
  217. gap: 12rpx;
  218. }
  219. .tag {
  220. display: inline-block;
  221. padding: 6rpx 16rpx;
  222. border-radius: 20rpx;
  223. font-size: 20rpx;
  224. }
  225. .tag-orange {
  226. background: #fff7e6;
  227. color: #d46b08;
  228. }
  229. .text-xs {
  230. font-size: 22rpx;
  231. }
  232. .mb8 {
  233. margin-bottom: 16rpx;
  234. }
  235. .mb4 {
  236. margin-bottom: 8rpx;
  237. }
  238. .mb12 {
  239. margin-bottom: 24rpx;
  240. }
  241. .mb14 {
  242. margin-bottom: 28rpx;
  243. }
  244. .exam-title {
  245. font-size: 34rpx;
  246. font-weight: 700;
  247. margin-bottom: 24rpx;
  248. }
  249. .info-grid {
  250. display: grid;
  251. grid-template-columns: 1fr 1fr;
  252. gap: 16rpx;
  253. }
  254. .info-item {
  255. border: 1px solid #dde3ed;
  256. border-radius: 16rpx;
  257. padding: 20rpx;
  258. }
  259. .text-gray {
  260. color: #999;
  261. }
  262. .text-333 {
  263. color: #333;
  264. }
  265. .text-blue {
  266. color: #1857d4;
  267. }
  268. .text-green {
  269. color: #52c41a;
  270. }
  271. .text-red {
  272. color: #ff4d4f;
  273. }
  274. .fw500 {
  275. font-weight: 500;
  276. }
  277. .time-row {
  278. font-size: 24rpx;
  279. }
  280. .card-title {
  281. font-size: 28rpx;
  282. font-weight: 600;
  283. }
  284. .condition-row {
  285. display: flex;
  286. align-items: center;
  287. padding: 16rpx 0;
  288. border-bottom: 1rpx solid #f0f0f0;
  289. &:last-child {
  290. border-bottom: none;
  291. }
  292. }
  293. .condition-icon {
  294. font-size: 32rpx;
  295. margin-right: 16rpx;
  296. }
  297. .condition-text {
  298. flex: 1;
  299. font-size: 26rpx;
  300. }
  301. .exam-desc-box{
  302. padding:28rpx;
  303. border-radius:10rpx;
  304. }
  305. .exam-desc {
  306. font-size: 26rpx;
  307. line-height: 1.8;
  308. color: #666;
  309. }
  310. .exam-type-max-box{
  311. margin-bottom:30rpx;
  312. .exam-title-p{
  313. font-size:24rpx;
  314. line-height:70rpx;
  315. }
  316. .exam-type-box{
  317. border:1px solid #dde3ed;
  318. border-radius:20rpx;
  319. .exam-min-box:nth-child(1){
  320. border-top:none;
  321. }
  322. .exam-min-box{
  323. display:flex;
  324. border-top:1px solid #dde3ed;
  325. padding:30rpx 28rpx;
  326. view{
  327. height:30rpx;
  328. line-height:30rpx;
  329. font-size:24rpx;
  330. }
  331. view:nth-child(1){
  332. flex:1;
  333. }
  334. view:nth-child(2){
  335. color:#e67e22;
  336. }
  337. }
  338. }
  339. }
  340. .bottom-bar {
  341. position: fixed;
  342. bottom: 0;
  343. left: 0;
  344. right: 0;
  345. background: #fff;
  346. padding: 20rpx 24rpx;
  347. border-top: 1rpx solid #eee;
  348. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  349. }
  350. .btn-primary {
  351. height: 88rpx;
  352. line-height: 88rpx;
  353. text-align: center;
  354. background: #1857d4;
  355. color: #fff;
  356. border-radius: 16rpx;
  357. font-size: 32rpx;
  358. font-weight: 600;
  359. }
  360. // 承诺书弹窗样式
  361. .pre-exam-dialog {
  362. width: 600rpx;
  363. max-height: 80vh;
  364. background: #fff;
  365. border-radius: 20rpx;
  366. overflow: hidden;
  367. }
  368. .dialog-header {
  369. padding: 32rpx;
  370. border-bottom: 1rpx solid #eee;
  371. .dialog-title {
  372. font-size: 32rpx;
  373. font-weight: 600;
  374. color: #333;
  375. }
  376. }
  377. .dialog-body {
  378. height: 800rpx;
  379. overflow: hidden;
  380. .content-scroll {
  381. height: 100%;
  382. }
  383. }
  384. .dialog-footer {
  385. display: flex;
  386. gap: 20rpx;
  387. padding: 24rpx 32rpx;
  388. border-top: 1rpx solid #eee;
  389. .btn {
  390. flex: 1;
  391. height: 72rpx;
  392. line-height: 72rpx;
  393. text-align: center;
  394. font-size: 28rpx;
  395. border-radius: 12rpx;
  396. }
  397. .btn-border {
  398. background: #fff;
  399. color: #1857d4;
  400. border: 1rpx solid #1857d4;
  401. }
  402. .btn-primary {
  403. background: #1857d4;
  404. color: #fff;
  405. }
  406. }
  407. </style>