onlineExamPlay.vue 26 KB

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