onlineExamInfo.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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. await confirmCommitmentAndStart(this.preData, () => {
  159. this.$refs.preExamDialog.close();
  160. startFormalExam(this.itemData);
  161. });
  162. },
  163. // 获取任务列表
  164. async loadTaskList() {
  165. try {
  166. const { data } = await examUserExamStudyTaskList({ page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false });
  167. if (data.code === 200) {
  168. this.$set(this, 'onlineExamList', data.data.records);
  169. }
  170. } catch (e) { console.error('获取考试任务失败', e); }
  171. },
  172. },
  173. }
  174. </script>
  175. <style lang="stylus" scoped>
  176. .exam-detail-page {
  177. height: 100%;
  178. display: flex;
  179. flex-direction: column;
  180. background-color: #f0f4fb;
  181. }
  182. .scroll-content {
  183. flex: 1;
  184. overflow: hidden;
  185. padding-bottom: 160rpx;
  186. }
  187. .card {
  188. background: #fff;
  189. border-radius: 20rpx;
  190. padding: 28rpx;
  191. margin: 24rpx 24rpx 0;
  192. border: 1px solid #dde3ed;
  193. }
  194. .chip-row {
  195. display: flex;
  196. gap: 12rpx;
  197. }
  198. .tag {
  199. display: inline-block;
  200. padding: 6rpx 16rpx;
  201. border-radius: 20rpx;
  202. font-size: 20rpx;
  203. }
  204. .tag-orange {
  205. background: #fff7e6;
  206. color: #d46b08;
  207. }
  208. .text-xs {
  209. font-size: 22rpx;
  210. }
  211. .mb8 {
  212. margin-bottom: 16rpx;
  213. }
  214. .mb4 {
  215. margin-bottom: 8rpx;
  216. }
  217. .mb12 {
  218. margin-bottom: 24rpx;
  219. }
  220. .mb14 {
  221. margin-bottom: 28rpx;
  222. }
  223. .exam-title {
  224. font-size: 34rpx;
  225. font-weight: 700;
  226. margin-bottom: 24rpx;
  227. }
  228. .info-grid {
  229. display: grid;
  230. grid-template-columns: 1fr 1fr;
  231. gap: 16rpx;
  232. }
  233. .info-item {
  234. border: 1px solid #dde3ed;
  235. border-radius: 16rpx;
  236. padding: 20rpx;
  237. }
  238. .text-gray {
  239. color: #999;
  240. }
  241. .text-333 {
  242. color: #333;
  243. }
  244. .text-blue {
  245. color: #1857d4;
  246. }
  247. .text-green {
  248. color: #52c41a;
  249. }
  250. .text-red {
  251. color: #ff4d4f;
  252. }
  253. .fw500 {
  254. font-weight: 500;
  255. }
  256. .time-row {
  257. font-size: 24rpx;
  258. }
  259. .card-title {
  260. font-size: 28rpx;
  261. font-weight: 600;
  262. }
  263. .condition-row {
  264. display: flex;
  265. align-items: center;
  266. padding: 16rpx 0;
  267. border-bottom: 1rpx solid #f0f0f0;
  268. &:last-child {
  269. border-bottom: none;
  270. }
  271. }
  272. .condition-icon {
  273. font-size: 32rpx;
  274. margin-right: 16rpx;
  275. }
  276. .condition-text {
  277. flex: 1;
  278. font-size: 26rpx;
  279. }
  280. .exam-desc-box{
  281. padding:28rpx;
  282. border-radius:10rpx;
  283. }
  284. .exam-desc {
  285. font-size: 26rpx;
  286. line-height: 1.8;
  287. color: #666;
  288. }
  289. .exam-type-max-box{
  290. margin-bottom:30rpx;
  291. .exam-title-p{
  292. font-size:24rpx;
  293. line-height:70rpx;
  294. }
  295. .exam-type-box{
  296. border:1px solid #dde3ed;
  297. border-radius:20rpx;
  298. .exam-min-box:nth-child(1){
  299. border-top:none;
  300. }
  301. .exam-min-box{
  302. display:flex;
  303. border-top:1px solid #dde3ed;
  304. padding:30rpx 28rpx;
  305. view{
  306. height:30rpx;
  307. line-height:30rpx;
  308. font-size:24rpx;
  309. }
  310. view:nth-child(1){
  311. flex:1;
  312. }
  313. view:nth-child(2){
  314. color:#e67e22;
  315. }
  316. }
  317. }
  318. }
  319. .bottom-bar {
  320. position: fixed;
  321. bottom: 0;
  322. left: 0;
  323. right: 0;
  324. background: #fff;
  325. padding: 20rpx 24rpx;
  326. border-top: 1rpx solid #eee;
  327. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  328. }
  329. .btn-primary {
  330. height: 88rpx;
  331. line-height: 88rpx;
  332. text-align: center;
  333. background: #1857d4;
  334. color: #fff;
  335. border-radius: 16rpx;
  336. font-size: 32rpx;
  337. font-weight: 600;
  338. }
  339. // 承诺书弹窗样式
  340. .pre-exam-dialog {
  341. width: 600rpx;
  342. max-height: 80vh;
  343. background: #fff;
  344. border-radius: 20rpx;
  345. overflow: hidden;
  346. }
  347. .dialog-header {
  348. padding: 32rpx;
  349. border-bottom: 1rpx solid #eee;
  350. .dialog-title {
  351. font-size: 32rpx;
  352. font-weight: 600;
  353. color: #333;
  354. }
  355. }
  356. .dialog-body {
  357. height: 800rpx;
  358. overflow: hidden;
  359. .content-scroll {
  360. height: 100%;
  361. }
  362. }
  363. .dialog-footer {
  364. display: flex;
  365. gap: 20rpx;
  366. padding: 24rpx 32rpx;
  367. border-top: 1rpx solid #eee;
  368. .btn {
  369. flex: 1;
  370. height: 72rpx;
  371. line-height: 72rpx;
  372. text-align: center;
  373. font-size: 28rpx;
  374. border-radius: 12rpx;
  375. }
  376. .btn-border {
  377. background: #fff;
  378. color: #1857d4;
  379. border: 1rpx solid #1857d4;
  380. }
  381. .btn-primary {
  382. background: #1857d4;
  383. color: #fff;
  384. }
  385. }
  386. </style>