onlineExamInfo.vue 9.8 KB

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