onlineExamInfo.vue 9.2 KB

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