onlineExamPlay.vue 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. <!-- 在线考试答题页 -->
  2. <template>
  3. <view class="exam-screen">
  4. <!-- 顶部栏 -->
  5. <view class="topbar">
  6. <view class="topbar-left" @click="requestSubmit(false)">‹ 交卷</view>
  7. <view class="topbar-title">{{ examInfo.examName || '考试中' }}</view>
  8. <view class="topbar-right" @click="toggleQuestionNav">题号</view>
  9. </view>
  10. <!-- 剩余时间条 -->
  11. <view class="time-bar">
  12. <view class="time-bar-left">
  13. <text class="time-label">剩余时间</text>
  14. <text class="time-value">{{ formattedTime }}</text>
  15. </view>
  16. <text class="time-tip">请合理安排答题时间</text>
  17. </view>
  18. <!-- 答题统计 -->
  19. <view class="stat-row">
  20. <view class="stat-item">
  21. <text class="stat-num stat-answered">{{ answeredCount }}</text>
  22. <text class="stat-label">已答</text>
  23. </view>
  24. <view class="stat-divider"></view>
  25. <view class="stat-item">
  26. <text class="stat-num">{{ unansweredCount }}</text>
  27. <text class="stat-label">未答</text>
  28. </view>
  29. <view class="stat-divider"></view>
  30. <view class="stat-item">
  31. <text class="stat-num">{{ totalCount }}</text>
  32. <text class="stat-label">总题</text>
  33. </view>
  34. </view>
  35. <!-- 题号导航面板 -->
  36. <view v-if="showQuestionNav" class="q-nav-panel">
  37. <view class="q-nav-scroll-wrapper">
  38. <view class="q-nav-header">
  39. <text class="q-nav-title">题目列表</text>
  40. <text class="q-nav-close" @click="toggleQuestionNav">✕</text>
  41. </view>
  42. <scroll-view scroll-y class="q-nav-scroll">
  43. <view v-for="(group, gi) in questionTypeGroups" :key="gi" class="q-group">
  44. <view class="q-group-title">{{ group.questionTypeName }}({{ group.questionCount }}题 {{ group.totalScore }}分)</view>
  45. <view class="q-num-row">
  46. <view
  47. v-for="(q, qi) in group.questions"
  48. :key="qi"
  49. class="q-num"
  50. :class="gi === groupIndex && qi === questionIndex ? 'current' : (q.answered === 1 ? 'answered' : '')"
  51. @click="selectQuestion(gi, qi)"
  52. >{{ q.questionNo }}</view>
  53. </view>
  54. </view>
  55. </scroll-view>
  56. </view>
  57. </view>
  58. <!-- 题目内容 -->
  59. <scroll-view scroll-y class="q-scroll-content">
  60. <view v-if="currentQuestion.snapshotQuestionId" class="q-card">
  61. <view class="q-header">
  62. <view class="q-header-left">
  63. <text class="q-type-badge">{{ currentQuestion.questionTypeName }}</text>
  64. <text class="q-num-text">第 {{ currentQuestion.questionNo }} 题</text>
  65. <text class="q-score-text">({{ currentQuestion.questionScore }}分)</text>
  66. </view>
  67. <text v-if="currentQuestion.difficulty" class="q-difficulty">{{ getDifficultyText(currentQuestion.difficulty) }}</text>
  68. </view>
  69. <view class="q-content">
  70. <rich-text :nodes="currentQuestion.questionContent || ''"></rich-text>
  71. </view>
  72. <view class="q-options">
  73. <view
  74. v-for="(opt, oi) in (currentQuestion.options || [])"
  75. :key="oi"
  76. class="q-option"
  77. :class="{ selected: isSelected(opt.optionLabel) }"
  78. @click="selectAnswer(oi)"
  79. >
  80. <view class="q-option-label">{{ opt.optionLabel }}</view>
  81. <view class="q-option-content">
  82. <rich-text :nodes="opt.optionContent || opt.optionLabel"></rich-text>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <view v-else-if="pageLoading" class="empty-tip">加载中...</view>
  88. <view v-else class="empty-tip">暂无题目</view>
  89. <view class="scroll-bottom-space"></view>
  90. </scroll-view>
  91. <!-- 上一题/下一题 -->
  92. <view class="q-nav">
  93. <view class="q-nav-btn" :class="{ disabled: isFirstQuestion }" @click="prevQuestion">上一题</view>
  94. <view class="q-nav-btn q-nav-btn-next" :class="{ disabled: isLastQuestion }" @click="nextQuestion">下一题</view>
  95. </view>
  96. <!-- 底部提交 -->
  97. <view class="exam-bottom">
  98. <view class="btn-primary" @click="requestSubmit(false)">提交试卷</view>
  99. </view>
  100. <!-- 交卷结果遮罩 -->
  101. <view v-if="showResult" class="result-shade">
  102. <view class="result-card">
  103. <view class="result-score-wrap">
  104. <text class="result-score-num">{{ resultData.score }}</text>
  105. <text class="result-score-unit">分</text>
  106. </view>
  107. <view class="result-score-label">本次考试成绩</view>
  108. <view class="result-pass-pill" :class="resultData.isPass ? 'is-pass' : 'is-fail'">
  109. <text class="result-pass-text">{{ resultData.isPass ? '考试通过' : '考试未通过' }}</text>
  110. </view>
  111. <view class="result-grid">
  112. <view class="result-grid-item">
  113. <view class="result-grid-label">满分</view>
  114. <view class="result-grid-value">{{ resultData.totalScore }}</view>
  115. </view>
  116. <view class="result-grid-item">
  117. <view class="result-grid-label">及格分</view>
  118. <view class="result-grid-value text-orange">{{ resultData.passScore }}</view>
  119. </view>
  120. <view class="result-grid-item">
  121. <view class="result-grid-label">用时</view>
  122. <view class="result-grid-value">{{ resultData.usedTime }}</view>
  123. </view>
  124. </view>
  125. <view class="result-stats">
  126. <view class="result-stats-row">
  127. <text class="result-stats-label">正确题数</text>
  128. <text class="result-stats-value text-green">{{ resultData.correctCount }}</text>
  129. </view>
  130. <view class="result-stats-row">
  131. <text class="result-stats-label">错误题数</text>
  132. <text class="result-stats-value text-red">{{ resultData.wrongCount }}</text>
  133. </view>
  134. <view class="result-stats-row">
  135. <text class="result-stats-label">正确率</text>
  136. <text class="result-stats-value text-blue">{{ resultData.accuracy }}</text>
  137. </view>
  138. </view>
  139. <view class="result-btns">
  140. <view v-if="!resultData.isPass" class="result-btn result-btn-outline" @click="reviewMistakes">查看错题</view>
  141. <view v-if="resultData.canRetake" class="result-btn result-btn-primary" @click="retakeExam">重新考试</view>
  142. <view v-else class="result-btn result-btn-primary" @click="closeResult">返回工作台</view>
  143. </view>
  144. <view class="result-cert">
  145. <text class="result-cert-icon">🏆</text>
  146. <view class="result-cert-info">
  147. <view class="result-cert-title">您已获得证书!</view>
  148. <view class="result-cert-name">{{ resultData.certName }}</view>
  149. <view class="result-cert-btn" @click="goCertificate(resultData.certUrl)">查看证书</view>
  150. </view>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. </template>
  156. <script>
  157. import {
  158. examElExamAttemptReviewSidebar,
  159. examElExamAttemptReviewQuestion,
  160. examUserExamGetExamSurplusTime,
  161. examUserExamAnswerSave,
  162. examUserExamSubmit,
  163. examUserExamStart,
  164. } from '@/pages_safetyEducationExamination/api/index.js'
  165. export default {
  166. data() {
  167. return {
  168. examId: '',
  169. attemptId: '',
  170. examKind: '',
  171. examInfo: {},
  172. questionTypeGroups: [],
  173. currentQuestion: {},
  174. groupIndex: 0,
  175. questionIndex: 0,
  176. remainingSeconds: 0,
  177. initialSeconds: 0,
  178. timer: null,
  179. hasWarnedTime: false,
  180. showQuestionNav: false,
  181. pageLoading: false,
  182. isSaving: false,
  183. isSubmitting: false,
  184. hasSubmitted: false,
  185. showResult: false,
  186. resultData: {},
  187. }
  188. },
  189. computed: {
  190. isFirstQuestion() {
  191. return this.groupIndex === 0 && this.questionIndex === 0;
  192. },
  193. isLastQuestion() {
  194. const lastGi = this.questionTypeGroups.length - 1;
  195. if (lastGi < 0) return true;
  196. const lastGroup = this.questionTypeGroups[lastGi];
  197. return this.groupIndex === lastGi && this.questionIndex === (lastGroup.questions.length - 1);
  198. },
  199. totalCount() {
  200. return this.questionTypeGroups.reduce((s, g) => s + (g.questions ? g.questions.length : 0), 0);
  201. },
  202. answeredCount() {
  203. return this.questionTypeGroups.reduce((s, g) => {
  204. return s + (g.questions || []).filter(q => q.answered === 1).length;
  205. }, 0);
  206. },
  207. unansweredCount() {
  208. return this.totalCount - this.answeredCount;
  209. },
  210. formattedTime() {
  211. const s = Math.max(0, Math.floor(this.remainingSeconds));
  212. const m = Math.floor(s / 60);
  213. const sec = s % 60;
  214. return m + '分' + (sec < 10 ? '0' : '') + sec + '秒';
  215. },
  216. },
  217. onLoad(options) {
  218. this.examId = options.examId || '';
  219. this.attemptId = options.attemptId || '';
  220. this.examKind = options.examKind || '';
  221. if (!this.attemptId) {
  222. uni.showToast({ title: '考试信息无效', icon: 'none' });
  223. setTimeout(() => uni.navigateBack(), 1500);
  224. return;
  225. }
  226. this.pageLoading = true;
  227. this.loadSidebar();
  228. },
  229. onShow() {
  230. if (this.hasSubmitted || !this.attemptId) return;
  231. if (this.questionTypeGroups.length > 0) {
  232. this.syncRemainingTime();
  233. }
  234. },
  235. onHide() {
  236. this.clearTimer();
  237. if (!this.hasSubmitted) this.saveCurrentAnswer();
  238. },
  239. onUnload() {
  240. this.clearTimer();
  241. if (!this.hasSubmitted) this.saveCurrentAnswer();
  242. },
  243. methods: {
  244. async loadSidebar() {
  245. try {
  246. const { data } = await examElExamAttemptReviewSidebar({
  247. attemptId: this.attemptId,
  248. examKind: this.examKind,
  249. });
  250. if (data.code === 200 && data.data) {
  251. this.examInfo = {
  252. examTypeName: data.data.examTypeName || '',
  253. examName: data.data.examName || '',
  254. questionCount: data.data.questionCount || 0,
  255. totalScore: data.data.totalScore || 0,
  256. passScore: data.data.passScore || 0,
  257. };
  258. this.$set(this, 'questionTypeGroups', data.data.questionTypeGroups || []);
  259. this.groupIndex = 0;
  260. this.questionIndex = 0;
  261. const firstGroup = this.questionTypeGroups[0];
  262. if (firstGroup && firstGroup.questions && firstGroup.questions.length > 0) {
  263. await this.loadQuestion(firstGroup.questions[0].snapshotQuestionId);
  264. this.syncRemainingTime();
  265. }
  266. } else {
  267. uni.showToast({ title: data.message || '加载失败', icon: 'none' });
  268. }
  269. } catch (e) {
  270. console.error('加载题号导航失败', e);
  271. } finally {
  272. this.pageLoading = false;
  273. }
  274. },
  275. async loadQuestion(snapshotQuestionId) {
  276. try {
  277. const { data } = await examElExamAttemptReviewQuestion({
  278. attemptId: this.attemptId,
  279. snapshotQuestionId: snapshotQuestionId,
  280. examScene: 1,
  281. });
  282. if (data.code === 200 && data.data) {
  283. this.$set(this, 'currentQuestion', data.data);
  284. }
  285. } catch (e) {
  286. console.error('加载题目失败', e);
  287. }
  288. },
  289. async syncRemainingTime() {
  290. try {
  291. const { data } = await examUserExamGetExamSurplusTime({ attemptId: this.attemptId });
  292. if (data.code === 200) {
  293. this.remainingSeconds = Number(data.data) || 0;
  294. if (!this.initialSeconds) this.initialSeconds = this.remainingSeconds;
  295. this.clearTimer();
  296. this.startTimer();
  297. }
  298. } catch (e) {
  299. console.error('获取剩余时间失败', e);
  300. }
  301. },
  302. startTimer() {
  303. if (this.timer) return;
  304. this.timer = setInterval(() => {
  305. if (this.remainingSeconds <= 0) {
  306. this.clearTimer();
  307. this.autoSubmit();
  308. return;
  309. }
  310. this.remainingSeconds--;
  311. if (this.remainingSeconds === 60 && !this.hasWarnedTime) {
  312. this.hasWarnedTime = true;
  313. uni.showToast({ title: '请注意剩余时间', icon: 'none', duration: 2000 });
  314. }
  315. }, 1000);
  316. },
  317. clearTimer() {
  318. if (this.timer) {
  319. clearInterval(this.timer);
  320. this.timer = null;
  321. }
  322. },
  323. selectAnswer(optIndex) {
  324. const opt = (this.currentQuestion.options || [])[optIndex];
  325. if (!opt || !this.currentQuestion.snapshotQuestionId) return;
  326. let tags = Array.isArray(this.currentQuestion.answerTags) ? [...this.currentQuestion.answerTags] : [];
  327. if (this.currentQuestion.questionType === 2) {
  328. const idx = tags.indexOf(opt.optionLabel);
  329. if (idx === -1) {
  330. tags.push(opt.optionLabel);
  331. } else {
  332. tags.splice(idx, 1);
  333. }
  334. } else {
  335. tags = [opt.optionLabel];
  336. }
  337. this.$set(this.currentQuestion, 'answerTags', tags);
  338. },
  339. isSelected(label) {
  340. const tags = this.currentQuestion.answerTags;
  341. return Array.isArray(tags) && tags.indexOf(label) !== -1;
  342. },
  343. saveCurrentAnswer() {
  344. const q = this.currentQuestion;
  345. if (!q || !q.snapshotQuestionId) return Promise.resolve();
  346. const tags = Array.isArray(q.answerTags) ? q.answerTags.filter(Boolean) : [];
  347. if (tags.length === 0) return Promise.resolve();
  348. return examUserExamAnswerSave({
  349. attemptId: this.attemptId,
  350. snapshotQuestionId: q.snapshotQuestionId,
  351. userAnswer: tags.join(','),
  352. }).then(res => {
  353. if (res.data && res.data.code === 200) {
  354. const groups = this.questionTypeGroups;
  355. if (groups[this.groupIndex] && groups[this.groupIndex].questions[this.questionIndex]) {
  356. this.$set(groups[this.groupIndex].questions[this.questionIndex], 'answered', 1);
  357. }
  358. }
  359. }).catch(e => {
  360. console.error('保存答案失败', e);
  361. });
  362. },
  363. async changeQuestion(targetGi, targetQi) {
  364. if (this.isSaving) return;
  365. if (targetGi === this.groupIndex && targetQi === this.questionIndex) return;
  366. const group = this.questionTypeGroups[targetGi];
  367. if (!group || !group.questions || !group.questions[targetQi]) return;
  368. this.isSaving = true;
  369. await this.saveCurrentAnswer();
  370. this.isSaving = false;
  371. this.groupIndex = targetGi;
  372. this.questionIndex = targetQi;
  373. await this.loadQuestion(group.questions[targetQi].snapshotQuestionId);
  374. },
  375. selectQuestion(gi, qi) {
  376. this.changeQuestion(gi, qi);
  377. this.showQuestionNav = false;
  378. },
  379. prevQuestion() {
  380. if (this.isFirstQuestion || this.isSaving) return;
  381. if (this.questionIndex > 0) {
  382. this.changeQuestion(this.groupIndex, this.questionIndex - 1);
  383. } else {
  384. const prevGi = this.groupIndex - 1;
  385. const prevGroup = this.questionTypeGroups[prevGi];
  386. if (prevGroup) {
  387. this.changeQuestion(prevGi, prevGroup.questions.length - 1);
  388. }
  389. }
  390. },
  391. nextQuestion() {
  392. if (this.isLastQuestion || this.isSaving) return;
  393. const currentGroup = this.questionTypeGroups[this.groupIndex];
  394. if (this.questionIndex < currentGroup.questions.length - 1) {
  395. this.changeQuestion(this.groupIndex, this.questionIndex + 1);
  396. } else {
  397. this.changeQuestion(this.groupIndex + 1, 0);
  398. }
  399. },
  400. toggleQuestionNav() {
  401. this.showQuestionNav = !this.showQuestionNav;
  402. },
  403. getNumClass(gi, qi, q) {
  404. if (gi === this.groupIndex && qi === this.questionIndex) return 'current';
  405. if (q.answered === 1) return 'answered';
  406. return '';
  407. },
  408. getDifficultyText(d) {
  409. return { 1: '简单', 2: '一般', 3: '较难', 4: '很难' }[d] || '';
  410. },
  411. async requestSubmit(isAuto) {
  412. if (this.isSubmitting || this.hasSubmitted) return;
  413. this.isSubmitting = true;
  414. await this.saveCurrentAnswer();
  415. const unanswered = this.unansweredCount;
  416. if (isAuto) {
  417. await this.doSubmit();
  418. this.isSubmitting = false;
  419. return;
  420. }
  421. const content = unanswered > 0 ? `还有${unanswered}题未答,确认要交卷吗?` : '确认要交卷吗?';
  422. uni.showModal({
  423. title: '提示',
  424. content: content,
  425. success: async (res) => {
  426. if (res.confirm) {
  427. await this.doSubmit();
  428. }
  429. this.isSubmitting = false;
  430. },
  431. fail: () => { this.isSubmitting = false; }
  432. });
  433. },
  434. async autoSubmit() {
  435. if (this.isSubmitting || this.hasSubmitted) return;
  436. this.isSubmitting = true;
  437. await this.saveCurrentAnswer();
  438. uni.showToast({ title: '考试时间结束,正在提交…', icon: 'none' });
  439. await this.doSubmit();
  440. this.isSubmitting = false;
  441. },
  442. async doSubmit() {
  443. try {
  444. const { data } = await examUserExamSubmit({ attemptId: this.attemptId });
  445. if (data.code === 200 && data.data) {
  446. this.hasSubmitted = true;
  447. this.clearTimer();
  448. this.buildResult(data.data);
  449. this.showResult = true;
  450. } else {
  451. uni.showToast({ title: data.message || '交卷失败', icon: 'none' });
  452. }
  453. } catch (e) {
  454. console.error('交卷失败', e);
  455. uni.showToast({ title: '交卷失败', icon: 'none' });
  456. }
  457. },
  458. buildResult(resp) {
  459. const score = resp.totalScore || 0;
  460. const passScore = this.examInfo.passScore || 0;
  461. const pass = score >= passScore;
  462. const correct = this.pickNumber(resp.correctCount, resp.correctNum);
  463. const wrong = this.pickNumber(resp.wrongCount, resp.wrongNum);
  464. const total = this.pickNumber(resp.totalQuestionNum, this.totalCount);
  465. this.resultData = {
  466. score: score,
  467. isPass: pass,
  468. totalScore: this.examInfo.totalScore || 0,
  469. passScore: passScore,
  470. usedTime: this.buildUsedTime(),
  471. correctCount: correct == null ? '-' : `${correct} 题`,
  472. wrongCount: wrong == null ? '-' : `${wrong} 题`,
  473. accuracy: (correct == null || !total) ? '-' : `${Math.round((correct / total) * 100)}%`,
  474. canRetake: !pass && resp.canContinueExam === 1,
  475. certName: resp.certName || '',
  476. certUrl: resp.certUrl || '',
  477. };
  478. },
  479. pickNumber(...vals) {
  480. for (const v of vals) {
  481. if (v !== undefined && v !== null && v !== '') return Number(v);
  482. }
  483. return null;
  484. },
  485. buildUsedTime() {
  486. if (!this.initialSeconds) return '-';
  487. const used = Math.max(0, this.initialSeconds - Math.floor(this.remainingSeconds));
  488. const m = Math.floor(used / 60);
  489. const s = used % 60;
  490. return `${m}'${s < 10 ? '0' : ''}${s}"`;
  491. },
  492. async retakeExam() {
  493. try {
  494. const { data } = await examUserExamStart({ examId: this.examId, examScene: 1 });
  495. if (data.code === 200 && data.data && data.data.attemptId) {
  496. this.attemptId = data.data.attemptId;
  497. this.showResult = false;
  498. this.hasSubmitted = false;
  499. this.isSubmitting = false;
  500. this.hasWarnedTime = false;
  501. this.$set(this, 'questionTypeGroups', []);
  502. this.$set(this, 'currentQuestion', {});
  503. this.groupIndex = 0;
  504. this.questionIndex = 0;
  505. this.remainingSeconds = 0;
  506. this.initialSeconds = 0;
  507. this.pageLoading = true;
  508. this.loadSidebar();
  509. } else {
  510. uni.showToast({ title: data.message || '重新考试失败', icon: 'none' });
  511. }
  512. } catch (e) {
  513. console.error('重新考试失败', e);
  514. uni.showToast({ title: '重新考试失败', icon: 'none' });
  515. }
  516. },
  517. closeResult() {
  518. this.showResult = false;
  519. uni.navigateBack();
  520. },
  521. reviewMistakes() {
  522. uni.showToast({ title: '错题查看功能开发中', icon: 'none' });
  523. },
  524. goCertificate(url) {
  525. if (!url) {
  526. uni.showToast({ title: '暂无证书', icon: 'none' });
  527. return;
  528. }
  529. uni.showLoading({ title: '加载中...', mask: true });
  530. uni.downloadFile({
  531. url: url,
  532. success: (res) => {
  533. if (res.statusCode === 200) {
  534. uni.openDocument({
  535. filePath: res.tempFilePath,
  536. fileType: 'pdf',
  537. showMenu: true,
  538. fail: () => {
  539. uni.showToast({ title: '打开证书失败', icon: 'none' });
  540. },
  541. complete: () => {
  542. uni.hideLoading();
  543. }
  544. });
  545. } else {
  546. uni.hideLoading();
  547. uni.showToast({ title: '证书加载失败', icon: 'none' });
  548. }
  549. },
  550. fail: () => {
  551. uni.hideLoading();
  552. uni.showToast({ title: '证书加载失败', icon: 'none' });
  553. }
  554. });
  555. },
  556. }
  557. }
  558. </script>
  559. <style lang="stylus" scoped>
  560. .exam-screen
  561. height 100%
  562. display flex
  563. flex-direction column
  564. background #f5f7fa
  565. position relative
  566. .topbar
  567. display flex
  568. align-items center
  569. justify-content space-between
  570. height 88rpx
  571. padding 0 28rpx
  572. background #fff
  573. border-bottom 1rpx solid #e8edf3
  574. flex-shrink 0
  575. .topbar-left
  576. font-size 28rpx
  577. color #1677ff
  578. min-width 80rpx
  579. .topbar-title
  580. font-size 28rpx
  581. font-weight 600
  582. color #222
  583. flex 1
  584. text-align center
  585. .topbar-right
  586. font-size 28rpx
  587. color #1677ff
  588. min-width 80rpx
  589. text-align right
  590. .time-bar
  591. display flex
  592. align-items center
  593. justify-content space-between
  594. padding 20rpx 28rpx
  595. background linear-gradient(90deg, #1677ff 0%, #0958d9 100%)
  596. flex-shrink 0
  597. .time-bar-left
  598. display flex
  599. align-items baseline
  600. .time-label
  601. font-size 24rpx
  602. color rgba(255,255,255,0.85)
  603. margin-right 16rpx
  604. .time-value
  605. font-size 44rpx
  606. font-weight 700
  607. color #fff
  608. .time-tip
  609. font-size 22rpx
  610. color rgba(255,255,255,0.75)
  611. .stat-row
  612. display flex
  613. align-items center
  614. background #fff
  615. padding 20rpx 0
  616. flex-shrink 0
  617. border-bottom 1rpx solid #e8edf3
  618. .stat-item
  619. flex 1
  620. display flex
  621. flex-direction column
  622. align-items center
  623. .stat-divider
  624. width 1rpx
  625. height 40rpx
  626. background #eee
  627. .stat-num
  628. font-size 36rpx
  629. font-weight 700
  630. color #333
  631. line-height 1
  632. .stat-answered
  633. color #1677ff
  634. .stat-label
  635. font-size 22rpx
  636. color #999
  637. margin-top 6rpx
  638. .q-nav-panel
  639. position absolute
  640. top 0
  641. left 0
  642. right 0
  643. bottom 0
  644. background rgba(0,0,0,0.45)
  645. z-index 100
  646. display flex
  647. flex-direction column
  648. justify-content flex-end
  649. .q-nav-scroll-wrapper
  650. background #fff
  651. border-radius 32rpx 32rpx 0 0
  652. max-height 70vh
  653. display flex
  654. flex-direction column
  655. .q-nav-header
  656. display flex
  657. align-items center
  658. justify-content space-between
  659. padding 28rpx 28rpx 16rpx
  660. flex-shrink 0
  661. .q-nav-title
  662. font-size 30rpx
  663. font-weight 600
  664. color #222
  665. .q-nav-close
  666. font-size 32rpx
  667. color #999
  668. padding 10rpx
  669. .q-nav-scroll
  670. flex 1
  671. overflow hidden
  672. padding-bottom 40rpx
  673. .q-group
  674. padding 0 28rpx 16rpx
  675. .q-group-title
  676. font-size 24rpx
  677. color #666
  678. line-height 60rpx
  679. .q-num-row
  680. display flex
  681. flex-wrap wrap
  682. .q-num
  683. width 72rpx
  684. height 72rpx
  685. line-height 72rpx
  686. text-align center
  687. font-size 24rpx
  688. border-radius 12rpx
  689. margin 8rpx
  690. background #f4f6fa
  691. color #333
  692. border 1rpx solid transparent
  693. .q-num.answered
  694. background #e6f4ff
  695. color #1677ff
  696. border-color #91caff
  697. .q-num.current
  698. background #1677ff
  699. color #fff
  700. .q-scroll-content
  701. flex 1
  702. overflow hidden
  703. .q-card
  704. margin 24rpx
  705. padding 28rpx
  706. background #fff
  707. border-radius 20rpx
  708. border 1rpx solid #dde3ed
  709. .q-header
  710. display flex
  711. align-items center
  712. justify-content space-between
  713. margin-bottom 20rpx
  714. .q-header-left
  715. display flex
  716. align-items center
  717. .q-type-badge
  718. font-size 20rpx
  719. padding 4rpx 14rpx
  720. background #e6f4ff
  721. color #1677ff
  722. border 1rpx solid #91caff
  723. border-radius 8rpx
  724. margin-right 12rpx
  725. .q-num-text
  726. font-size 26rpx
  727. color #333
  728. .q-score-text
  729. font-size 22rpx
  730. color #999
  731. .q-difficulty
  732. font-size 22rpx
  733. color #fa8c16
  734. background #fff7e6
  735. padding 4rpx 12rpx
  736. border-radius 8rpx
  737. .q-content
  738. font-size 28rpx
  739. line-height 1.8
  740. color #222
  741. margin-bottom 24rpx
  742. .q-options
  743. display flex
  744. flex-direction column
  745. .q-option
  746. display flex
  747. align-items center
  748. padding 22rpx 20rpx
  749. margin-bottom 16rpx
  750. border 2rpx solid #dde3ed
  751. border-radius 16rpx
  752. background #fff
  753. .q-option.selected
  754. border-color #1677ff
  755. background #e6f4ff
  756. .q-option-label
  757. width 48rpx
  758. height 48rpx
  759. line-height 48rpx
  760. text-align center
  761. border-radius 50%
  762. background #f4f6fa
  763. color #333
  764. font-size 24rpx
  765. font-weight 600
  766. margin-right 20rpx
  767. flex-shrink 0
  768. .q-option.selected .q-option-label
  769. background #1677ff
  770. color #fff
  771. .q-option-content
  772. flex 1
  773. font-size 26rpx
  774. color #333
  775. line-height 1.6
  776. .scroll-bottom-space
  777. height 200rpx
  778. .q-nav
  779. display flex
  780. background #fff
  781. border-top 1rpx solid #e8edf3
  782. flex-shrink 0
  783. .q-nav-btn
  784. flex 1
  785. height 88rpx
  786. line-height 88rpx
  787. text-align center
  788. font-size 28rpx
  789. color #1677ff
  790. .q-nav-btn.q-nav-btn-next
  791. border-left 1rpx solid #e8edf3
  792. .q-nav-btn.disabled
  793. color #ccc
  794. .exam-bottom
  795. padding 20rpx 24rpx
  796. padding-bottom calc(20rpx + env(safe-area-inset-bottom))
  797. background #fff
  798. border-top 1rpx solid #e8edf3
  799. flex-shrink 0
  800. .btn-primary
  801. background #1677ff
  802. color #fff
  803. border-radius 16rpx
  804. font-size 30rpx
  805. font-weight 600
  806. height 88rpx
  807. line-height 88rpx
  808. text-align center
  809. .result-shade
  810. position fixed
  811. top 0
  812. left 0
  813. right 0
  814. bottom 0
  815. background rgba(0,0,0,0.55)
  816. z-index 200
  817. display flex
  818. align-items center
  819. justify-content center
  820. .result-card
  821. width 580rpx
  822. background #fff
  823. border-radius 24rpx
  824. padding 40rpx 32rpx 32rpx
  825. display flex
  826. flex-direction column
  827. align-items center
  828. .result-score-wrap
  829. display flex
  830. align-items baseline
  831. line-height 1
  832. .result-score-num
  833. font-size 112rpx
  834. font-weight 900
  835. color #1857d4
  836. .result-score-unit
  837. font-size 30rpx
  838. font-weight 700
  839. color #1857d4
  840. margin-left 6rpx
  841. .result-score-label
  842. font-size 24rpx
  843. color #8896a7
  844. margin-top 4rpx
  845. margin-bottom 20rpx
  846. .result-pass-pill
  847. display inline-flex
  848. align-items center
  849. justify-content center
  850. border-radius 40rpx
  851. padding 8rpx 40rpx
  852. margin-bottom 28rpx
  853. .result-pass-pill.is-pass
  854. background #f6ffed
  855. .result-pass-pill.is-fail
  856. background #fff5f5
  857. .result-pass-text
  858. font-size 30rpx
  859. font-weight 700
  860. .result-pass-pill.is-pass .result-pass-text
  861. color #10a37f
  862. .result-pass-pill.is-fail .result-pass-text
  863. color #e53e3e
  864. .result-grid
  865. display flex
  866. width 100%
  867. gap 16rpx
  868. margin-bottom 24rpx
  869. .result-grid-item
  870. flex 1
  871. background #f4f6fa
  872. border-radius 16rpx
  873. padding 18rpx 12rpx
  874. text-align center
  875. .result-grid-label
  876. font-size 22rpx
  877. color #8896a7
  878. margin-bottom 8rpx
  879. .result-grid-value
  880. font-size 28rpx
  881. font-weight 500
  882. color #1a2233
  883. .result-stats
  884. width 100%
  885. background #f4f6fa
  886. border-radius 16rpx
  887. padding 22rpx 24rpx
  888. margin-bottom 28rpx
  889. box-sizing border-box
  890. .result-stats-row
  891. display flex
  892. justify-content space-between
  893. align-items center
  894. font-size 26rpx
  895. color #4a5568
  896. .result-stats-row + .result-stats-row
  897. margin-top 16rpx
  898. .result-stats-value
  899. font-weight 500
  900. .result-btns
  901. display flex
  902. width 100%
  903. gap 16rpx
  904. .result-btn
  905. flex 1
  906. height 80rpx
  907. line-height 80rpx
  908. text-align center
  909. border-radius 14rpx
  910. font-size 28rpx
  911. .result-btn-outline
  912. border 1rpx solid #1857d4
  913. color #1857d4
  914. .result-btn-primary
  915. background #1857d4
  916. color #fff
  917. .result-cert
  918. display flex
  919. align-items center
  920. width 100%
  921. margin-top 24rpx
  922. padding 24rpx 20rpx
  923. background #f4f6fa
  924. border-radius 16rpx
  925. box-sizing border-box
  926. .result-cert-icon
  927. font-size 56rpx
  928. margin-right 20rpx
  929. .result-cert-info
  930. flex 1
  931. .result-cert-title
  932. font-size 28rpx
  933. font-weight 500
  934. color #1a2233
  935. margin-bottom 8rpx
  936. .result-cert-name
  937. font-size 24rpx
  938. color #8896a7
  939. .result-cert-btn
  940. display inline-block
  941. margin-top 12rpx
  942. padding 0 24rpx
  943. height 56rpx
  944. line-height 56rpx
  945. background #1857d4
  946. color #fff
  947. font-size 24rpx
  948. border-radius 10rpx
  949. .text-orange
  950. color #e67e22
  951. .text-green
  952. color #10a37f
  953. .text-red
  954. color #e53e3e
  955. .text-blue
  956. color #1857d4
  957. .empty-tip
  958. text-align center
  959. padding 80rpx 0
  960. color #aaa
  961. font-size 26rpx
  962. </style>