onlineExamPlay.vue 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  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 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. const examName = encodeURIComponent(this.examInfo.examName || '');
  523. uni.redirectTo({
  524. url: `/pages_safetyEducationExamination/views/exam/incorrectQuestionsList?attemptId=${this.attemptId}&examName=${examName}`
  525. });
  526. },
  527. goCertificate(url) {
  528. if (!url) {
  529. uni.showToast({ title: '暂无证书', icon: 'none' });
  530. return;
  531. }
  532. uni.showLoading({ title: '加载中...', mask: true });
  533. uni.downloadFile({
  534. url: url,
  535. success: (res) => {
  536. if (res.statusCode === 200) {
  537. uni.openDocument({
  538. filePath: res.tempFilePath,
  539. fileType: 'pdf',
  540. showMenu: true,
  541. fail: () => {
  542. uni.showToast({ title: '打开证书失败', icon: 'none' });
  543. },
  544. complete: () => {
  545. uni.hideLoading();
  546. }
  547. });
  548. } else {
  549. uni.hideLoading();
  550. uni.showToast({ title: '证书加载失败', icon: 'none' });
  551. }
  552. },
  553. fail: () => {
  554. uni.hideLoading();
  555. uni.showToast({ title: '证书加载失败', icon: 'none' });
  556. }
  557. });
  558. },
  559. }
  560. }
  561. </script>
  562. <style lang="stylus" scoped>
  563. .exam-screen
  564. height 100%
  565. display flex
  566. flex-direction column
  567. background #f5f7fa
  568. position relative
  569. .topbar
  570. display flex
  571. align-items center
  572. justify-content space-between
  573. height 88rpx
  574. padding 0 28rpx
  575. background #fff
  576. border-bottom 1rpx solid #e8edf3
  577. flex-shrink 0
  578. .topbar-left
  579. font-size 28rpx
  580. color #1677ff
  581. min-width 80rpx
  582. .topbar-title
  583. font-size 28rpx
  584. font-weight 600
  585. color #222
  586. flex 1
  587. text-align center
  588. .topbar-right
  589. font-size 28rpx
  590. color #1677ff
  591. min-width 80rpx
  592. text-align right
  593. .time-bar
  594. display flex
  595. align-items center
  596. justify-content space-between
  597. padding 20rpx 28rpx
  598. background linear-gradient(90deg, #1677ff 0%, #0958d9 100%)
  599. flex-shrink 0
  600. .time-bar-left
  601. display flex
  602. align-items baseline
  603. .time-label
  604. font-size 24rpx
  605. color rgba(255,255,255,0.85)
  606. margin-right 16rpx
  607. .time-value
  608. font-size 44rpx
  609. font-weight 700
  610. color #fff
  611. .time-tip
  612. font-size 22rpx
  613. color rgba(255,255,255,0.75)
  614. .stat-row
  615. display flex
  616. align-items center
  617. background #fff
  618. padding 20rpx 0
  619. flex-shrink 0
  620. border-bottom 1rpx solid #e8edf3
  621. .stat-item
  622. flex 1
  623. display flex
  624. flex-direction column
  625. align-items center
  626. .stat-divider
  627. width 1rpx
  628. height 40rpx
  629. background #eee
  630. .stat-num
  631. font-size 36rpx
  632. font-weight 700
  633. color #333
  634. line-height 1
  635. .stat-answered
  636. color #1677ff
  637. .stat-label
  638. font-size 22rpx
  639. color #999
  640. margin-top 6rpx
  641. .q-nav-panel
  642. position absolute
  643. top 0
  644. left 0
  645. right 0
  646. bottom 0
  647. background rgba(0,0,0,0.45)
  648. z-index 100
  649. display flex
  650. flex-direction column
  651. justify-content flex-end
  652. .q-nav-scroll-wrapper
  653. background #fff
  654. border-radius 32rpx 32rpx 0 0
  655. max-height 70vh
  656. display flex
  657. flex-direction column
  658. .q-nav-header
  659. display flex
  660. align-items center
  661. justify-content space-between
  662. padding 28rpx 28rpx 16rpx
  663. flex-shrink 0
  664. .q-nav-title
  665. font-size 30rpx
  666. font-weight 600
  667. color #222
  668. .q-nav-close
  669. font-size 32rpx
  670. color #999
  671. padding 10rpx
  672. .q-nav-scroll
  673. flex 1
  674. overflow hidden
  675. padding-bottom 40rpx
  676. .q-group
  677. padding 0 28rpx 16rpx
  678. .q-group-title
  679. font-size 24rpx
  680. color #666
  681. line-height 60rpx
  682. .q-num-row
  683. display flex
  684. flex-wrap wrap
  685. .q-num
  686. width 72rpx
  687. height 72rpx
  688. line-height 72rpx
  689. text-align center
  690. font-size 24rpx
  691. border-radius 12rpx
  692. margin 8rpx
  693. background #f4f6fa
  694. color #333
  695. border 1rpx solid transparent
  696. .q-num.answered
  697. background #e6f4ff
  698. color #1677ff
  699. border-color #91caff
  700. .q-num.current
  701. background #1677ff
  702. color #fff
  703. .q-scroll-content
  704. flex 1
  705. overflow hidden
  706. .q-card
  707. margin 24rpx
  708. padding 28rpx
  709. background #fff
  710. border-radius 20rpx
  711. border 1rpx solid #dde3ed
  712. .q-header
  713. display flex
  714. align-items center
  715. justify-content space-between
  716. margin-bottom 20rpx
  717. .q-header-left
  718. display flex
  719. align-items center
  720. .q-type-badge
  721. font-size 20rpx
  722. padding 4rpx 14rpx
  723. background #e6f4ff
  724. color #1677ff
  725. border 1rpx solid #91caff
  726. border-radius 8rpx
  727. margin-right 12rpx
  728. .q-num-text
  729. font-size 26rpx
  730. color #333
  731. .q-score-text
  732. font-size 22rpx
  733. color #999
  734. .q-difficulty
  735. font-size 22rpx
  736. color #fa8c16
  737. background #fff7e6
  738. padding 4rpx 12rpx
  739. border-radius 8rpx
  740. .q-content
  741. font-size 28rpx
  742. line-height 1.8
  743. color #222
  744. margin-bottom 24rpx
  745. .q-options
  746. display flex
  747. flex-direction column
  748. .q-option
  749. display flex
  750. align-items center
  751. padding 22rpx 20rpx
  752. margin-bottom 16rpx
  753. border 2rpx solid #dde3ed
  754. border-radius 16rpx
  755. background #fff
  756. .q-option.selected
  757. border-color #1677ff
  758. background #e6f4ff
  759. .q-option-label
  760. width 48rpx
  761. height 48rpx
  762. line-height 48rpx
  763. text-align center
  764. border-radius 50%
  765. background #f4f6fa
  766. color #333
  767. font-size 24rpx
  768. font-weight 600
  769. margin-right 20rpx
  770. flex-shrink 0
  771. .q-option.selected .q-option-label
  772. background #1677ff
  773. color #fff
  774. .q-option-content
  775. flex 1
  776. font-size 26rpx
  777. color #333
  778. line-height 1.6
  779. .scroll-bottom-space
  780. height 200rpx
  781. .q-nav
  782. display flex
  783. background #fff
  784. border-top 1rpx solid #e8edf3
  785. flex-shrink 0
  786. .q-nav-btn
  787. flex 1
  788. height 88rpx
  789. line-height 88rpx
  790. text-align center
  791. font-size 28rpx
  792. color #1677ff
  793. .q-nav-btn.q-nav-btn-next
  794. border-left 1rpx solid #e8edf3
  795. .q-nav-btn.disabled
  796. color #ccc
  797. .exam-bottom
  798. padding 20rpx 24rpx
  799. padding-bottom calc(20rpx + env(safe-area-inset-bottom))
  800. background #fff
  801. border-top 1rpx solid #e8edf3
  802. flex-shrink 0
  803. .btn-primary
  804. background #1677ff
  805. color #fff
  806. border-radius 16rpx
  807. font-size 30rpx
  808. font-weight 600
  809. height 88rpx
  810. line-height 88rpx
  811. text-align center
  812. .result-shade
  813. position fixed
  814. top 0
  815. left 0
  816. right 0
  817. bottom 0
  818. background rgba(0,0,0,0.55)
  819. z-index 200
  820. display flex
  821. align-items center
  822. justify-content center
  823. .result-card
  824. width 580rpx
  825. background #fff
  826. border-radius 24rpx
  827. padding 40rpx 32rpx 32rpx
  828. display flex
  829. flex-direction column
  830. align-items center
  831. .result-score-wrap
  832. display flex
  833. align-items baseline
  834. line-height 1
  835. .result-score-num
  836. font-size 112rpx
  837. font-weight 900
  838. color #1857d4
  839. .result-score-unit
  840. font-size 30rpx
  841. font-weight 700
  842. color #1857d4
  843. margin-left 6rpx
  844. .result-score-label
  845. font-size 24rpx
  846. color #8896a7
  847. margin-top 4rpx
  848. margin-bottom 20rpx
  849. .result-pass-pill
  850. display inline-flex
  851. align-items center
  852. justify-content center
  853. border-radius 40rpx
  854. padding 8rpx 40rpx
  855. margin-bottom 28rpx
  856. .result-pass-pill.is-pass
  857. background #f6ffed
  858. .result-pass-pill.is-fail
  859. background #fff5f5
  860. .result-pass-text
  861. font-size 30rpx
  862. font-weight 700
  863. .result-pass-pill.is-pass .result-pass-text
  864. color #10a37f
  865. .result-pass-pill.is-fail .result-pass-text
  866. color #e53e3e
  867. .result-grid
  868. display flex
  869. width 100%
  870. gap 16rpx
  871. margin-bottom 24rpx
  872. .result-grid-item
  873. flex 1
  874. background #f4f6fa
  875. border-radius 16rpx
  876. padding 18rpx 12rpx
  877. text-align center
  878. .result-grid-label
  879. font-size 22rpx
  880. color #8896a7
  881. margin-bottom 8rpx
  882. .result-grid-value
  883. font-size 28rpx
  884. font-weight 500
  885. color #1a2233
  886. .result-stats
  887. width 100%
  888. background #f4f6fa
  889. border-radius 16rpx
  890. padding 22rpx 24rpx
  891. margin-bottom 28rpx
  892. box-sizing border-box
  893. .result-stats-row
  894. display flex
  895. justify-content space-between
  896. align-items center
  897. font-size 26rpx
  898. color #4a5568
  899. .result-stats-row + .result-stats-row
  900. margin-top 16rpx
  901. .result-stats-value
  902. font-weight 500
  903. .result-btns
  904. display flex
  905. width 100%
  906. gap 16rpx
  907. .result-btn
  908. flex 1
  909. height 80rpx
  910. line-height 80rpx
  911. text-align center
  912. border-radius 14rpx
  913. font-size 28rpx
  914. .result-btn-outline
  915. border 1rpx solid #1857d4
  916. color #1857d4
  917. .result-btn-primary
  918. border 1rpx solid #1857d4
  919. background #1857d4
  920. color #fff
  921. .result-cert
  922. display flex
  923. align-items center
  924. width 100%
  925. margin-top 24rpx
  926. padding 24rpx 20rpx
  927. background #f4f6fa
  928. border-radius 16rpx
  929. box-sizing border-box
  930. .result-cert-icon
  931. font-size 56rpx
  932. margin-right 20rpx
  933. .result-cert-info
  934. flex 1
  935. .result-cert-title
  936. font-size 28rpx
  937. font-weight 500
  938. color #1a2233
  939. margin-bottom 8rpx
  940. .result-cert-name
  941. font-size 24rpx
  942. color #8896a7
  943. .result-cert-btn
  944. display inline-block
  945. margin-top 12rpx
  946. padding 0 24rpx
  947. height 56rpx
  948. line-height 56rpx
  949. background #1857d4
  950. color #fff
  951. font-size 24rpx
  952. border-radius 10rpx
  953. .text-orange
  954. color #e67e22
  955. .text-green
  956. color #10a37f
  957. .text-red
  958. color #e53e3e
  959. .text-blue
  960. color #1857d4
  961. .empty-tip
  962. text-align center
  963. padding 80rpx 0
  964. color #aaa
  965. font-size 26rpx
  966. </style>