exam.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. <template>
  2. <view class="phone-kaoshi-page">
  3. <!-- 导航区域 -->
  4. <view class="icon-title-bjcolor-navBar-box">
  5. <view @click="handleBack" class="nav-bar-icon"></view>
  6. <text class="nav-bar-title">{{data.ksName}}</text>
  7. </view>
  8. <!-- 第一行 -->
  9. <view class="kaoshi-page-title">
  10. <view v-if="activeSt" class="title-types">{{dlName}}</view>
  11. <!-- 倒计时 -->
  12. <view v-if="!!data.endSecond">
  13. <uni-countdown :show-day="false" :showHour="true" :showMinute="true" :second="data.endSecond"
  14. @timeup="onTimeUp" :start="startCountDown"></uni-countdown>
  15. </view>
  16. </view>
  17. <view class="kaoshi-shiti-content">
  18. <!-- 内容区域 -->
  19. <!-- 试题区域 -->
  20. <view v-if="activeSt">
  21. <template v-if="activeSt.stTypeId == 1">
  22. <!-- 单选 -->
  23. <danxuan :question="activeSt" :key="activeSt.stId"></danxuan>
  24. </template>
  25. <template v-if="activeSt.stTypeId == 2">
  26. <!-- 多选 -->
  27. <duoxuan :question="activeSt" :key="activeSt.stId"></duoxuan>
  28. </template>
  29. <template v-if="activeSt.stTypeId == 3">
  30. <!-- 判断 -->
  31. <panduan :question="activeSt" :key="activeSt.stId"></panduan>
  32. </template>
  33. <template v-if="activeSt.stTypeId == 4">
  34. <!-- 填空 -->
  35. <tiankong :question="activeSt" :key="activeSt.stId"></tiankong>
  36. </template>
  37. <template v-if="activeSt.stTypeId == 5">
  38. <!-- 简答 -->
  39. <jianda :question="activeSt" :key="activeSt.stId"></jianda>
  40. </template>
  41. <template v-if="activeSt.stTypeId == 6">
  42. <!-- 阅读 -->
  43. <yuedu :question="activeSt" :key="activeSt.stId"></yuedu>
  44. </template>
  45. </view>
  46. </view>
  47. <view class="kaoshi-bottom-box">
  48. <button class="phone-green-btn bj-btn" hover-class="none" type="default" size="mini"
  49. @click="handleBiaoji">{{activeSt && activeSt.marked ? '取标':'标记'}}</button>
  50. <view @click="showAnswerCard" class="shiti-num-box">
  51. <icon class="shiti-num-icon"></icon>
  52. <text
  53. class="active-num">{{activeSt ? activeSt.onlyNum: 0}}</text>/<text>{{data.StListForSearch.length}}</text>
  54. </view>
  55. <button class="phone-green-btn save-btn" hover-class="none" type="default" size="mini"
  56. @click="handleSave(true)">保存</button>
  57. </view>
  58. <template v-if="activeSt">
  59. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-prev"
  60. @click="handlePrev" v-if="!isFistStId">上一题</button>
  61. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-next"
  62. @click="handleNext" v-if="!isLastStId">下一题</button>
  63. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-next"
  64. @click="handleJiaojuan" v-if="isLastStId">交卷</button>
  65. </template>
  66. <!-- 答题卡 -->
  67. <uni-popup ref="popupRef" background-color="#fff" :animation="false" :is-mask-click="false" :mask-click="false">
  68. <view class="answer-card-popup">
  69. <view class="icon-title-bjcolor-navBar-box">
  70. <view @click="handlePopupBack" class="nav-bar-icon"> </view>
  71. <text class="nav-bar-title">答题卡</text>
  72. </view>
  73. <view class="card-content-box">
  74. <view class="answer-card-content" v-for="(paragraph,paragraphIndex) in questionData"
  75. :key="paragraphIndex">
  76. <view class="paragraph-title">
  77. {{paragraph.name}}
  78. </view>
  79. <view class="paragraph-qa" v-for="(qa,qaIndex) in paragraph.qas" :key="qaIndex"
  80. :class="getQaClass(qa)" @click="answerCardItemClick(qa)">{{qa.onlyNum}}
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </uni-popup>
  86. <!-- 摄像头确认 -->
  87. <!-- <zhuapaiConfirm ref="zhuapaiConfirmRef" @success="zpConfirmSuccess" @error="zpConfirmError"
  88. @cancel="zpConfirmCancel" key="1"></zhuapaiConfirm> -->
  89. <template v-if="data.zhuapai && data.zhuapai > 0">
  90. <!-- 抓拍 -->
  91. <!-- <zhuapaiVue ref="zhuapaiRef" @error="zpError" @success="zpSuccess" key="2" @progress="onProgress"></zhuapaiVue> -->
  92. </template>
  93. <!-- 切屏 -->
  94. <!-- <qiepingVue ref="qiepingRef" @zhuapai="qpZhuapai" @forceSubmit="forceSubmit" @qiepingToast="qiepingToast"
  95. key="3"></qiepingVue> -->
  96. <!-- 交卷确认 -->
  97. <answerQueren ref="answerQrRef" @confirm="handleQuerenConfirm"></answerQueren>
  98. <!-- 考试得分 -->
  99. <submitScoreVue ref="subScoreRef" @confirm="handleScoreConfirm" @close="handleScoreClose"></submitScoreVue>
  100. <!-- 切屏确认弹窗 -->
  101. <!-- <qiepingDlVue ref="qiepingDlRef" :content="messageContent" title="注意" okBtn="知道了"></qiepingDlVue> -->
  102. </view>
  103. </template>
  104. <script setup>
  105. import {
  106. ref,
  107. reactive,
  108. computed,
  109. watch,
  110. nextTick
  111. } from "vue";
  112. import zhuapaiVue from "@/components/zhuapaiConfirm/zhuapai.vue";
  113. import qiepingVue from "@/components/zhuapaiConfirm/qieping.vue";
  114. import zhuapaiConfirm from "@/components/zhuapaiConfirm/index.vue";
  115. import answerQueren from "@/components/zhuapaiConfirm/answerQueren.vue";
  116. import submitScoreVue from "@/components/zhuapaiConfirm/submitScore.vue";
  117. import {
  118. onLoad
  119. } from "@dcloudio/uni-app";
  120. import * as ksApi from "@/api/exam.js"
  121. import danxuan from "@/components/questions/danxuan.vue";
  122. import duoxuan from "@/components/questions/duoxuan.vue";
  123. import tiankong from "@/components/questions/tiankong.vue";
  124. import panduan from "@/components/questions/panduan.vue";
  125. import jianda from "@/components/questions/jianda.vue";
  126. import yuedu from "@/components/questions/yuedu.vue";
  127. import {
  128. useQuestionTools
  129. } from "@/components/questions/useQuestionTools.js";
  130. import {
  131. useKaoShiCache
  132. } from "./examTools"
  133. import qiepingDlVue from "@/components/dialog/qiepingDl.vue";
  134. const {
  135. checkDanxuanReply,
  136. checkDuoxuanReply,
  137. checkPanduanReply,
  138. checkTiankongReply,
  139. getLetterByIndex
  140. } = useQuestionTools();
  141. const {
  142. saveCacheKs,
  143. getCacheKs,
  144. removeCacheKs
  145. } = useKaoShiCache();
  146. onLoad((option) => {
  147. data.ksId = option.ksId;
  148. data.zhuapai = option.zhuapai;
  149. if (data.zhuapai && data.zhuapai != 0) {
  150. // 考试前确认摄像头
  151. nextTick(() => {
  152. // initBeforKaoshi();
  153. })
  154. } else {
  155. console.log('初始化')
  156. initKaoshi();
  157. }
  158. })
  159. const popupRef = ref(null)
  160. const zhuapaiRef = ref(null)
  161. const qiepingRef = ref(null)
  162. const zhuapaiConfirmRef = ref(null)
  163. const answerQrRef = ref(null);
  164. const startCountDown = ref(false);
  165. const subScoreRef = ref(null);
  166. const messageContent = ref('');
  167. const qiepingDlRef = ref(null);
  168. const timer1 = ref(null);
  169. const data = reactive({
  170. ksId: null,
  171. operId: null,
  172. ksName: '',
  173. stTotal: 0,
  174. stScore: 0,
  175. biaoji: {},
  176. endSecond: 0,
  177. pageSize: 0,
  178. toggleScreenFlag: 0,
  179. toggleScreenSecond: 0,
  180. zhuapai: 0,
  181. duanluo: [],
  182. StListForSearch: [],
  183. from: '',
  184. hisId: '',
  185. })
  186. const markDB = ref([]);
  187. const questionData = ref([]);
  188. const progress = reactive({
  189. dlIndex: 0,
  190. dtIndex: 0
  191. })
  192. const dlName = computed(() => {
  193. if (data.StListForSearch && activeSt.value) {
  194. return data.StListForSearch[activeSt.value.onlyNum - 1].paragraphName
  195. } else {
  196. return ''
  197. }
  198. })
  199. watch(() => data.duanluo, (newVal) => {
  200. // 计算已答试题数量
  201. }, {
  202. deep: true
  203. })
  204. const activeSt = computed(() => {
  205. if (questionData.value.length) {
  206. return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
  207. } else {
  208. return null
  209. }
  210. })
  211. const isFistStId = computed(() => {
  212. if (data.StListForSearch.length) {
  213. return data.StListForSearch[0].stId == activeSt.value.stId
  214. } else {
  215. return false
  216. }
  217. });
  218. const isLastStId = computed(() => {
  219. if (data.StListForSearch.length) {
  220. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  221. } else {
  222. return false
  223. }
  224. });
  225. function handleScoreClose() {
  226. handleBack()
  227. }
  228. // 考试得分相关 start
  229. function handleScoreConfirm() {
  230. uni.redirectTo({
  231. url: `/pages/client/Chengji/ksScoreShijuan?hisId=${data.hisId}&from=kaoshi`
  232. })
  233. }
  234. // 考试得分相关 end
  235. // 保存相关
  236. function handleSave(showToast) {
  237. if (timer1.value) {
  238. uni.showToast({
  239. title: '请勿连续保存',
  240. icon: 'none'
  241. })
  242. return
  243. }
  244. timer1.value = setTimeout(() => {
  245. clearTimeout(timer1.value);
  246. }, 10 * 1000);
  247. console.log(questionData.value)
  248. const result = []
  249. const option = {
  250. force: false,
  251. operId: data.operId,
  252. replyList: []
  253. }
  254. questionData.value.forEach(dl => {
  255. dl.qas.forEach(st => {
  256. const opt = {
  257. stId: st.stId,
  258. reply: st.reply,
  259. }
  260. result.push(opt)
  261. option.replyList.push(opt)
  262. })
  263. })
  264. // 保存试题答案
  265. saveCacheKs(data.operId, {
  266. replyList: result,
  267. position: {
  268. dlIndex: progress.dlIndex,
  269. dtIndex: progress.dtIndex
  270. }
  271. })
  272. // 保存答题进度
  273. ksApi.getClientKsSave(option).then(res => {
  274. if (res.data && showToast) {
  275. uni.showToast({
  276. title: '保存成功',
  277. })
  278. }
  279. })
  280. }
  281. // 交卷相关功能 start
  282. function checkJiaojuan() {
  283. const result = []
  284. let count = 0;
  285. let total = 0;
  286. questionData.value.forEach(dl => {
  287. dl.qas.forEach(st => {
  288. const opt = {
  289. stId: st.stId,
  290. reply: st.reply,
  291. stTypeId: st.stTypeId
  292. }
  293. result.push(opt)
  294. })
  295. })
  296. result.forEach(item => {
  297. total++;
  298. if (item.stTypeId == 1 && !checkDanxuanReply(item)) {
  299. count++;
  300. }
  301. if (item.stTypeId == 2 && !checkDuoxuanReply(item)) {
  302. count++;
  303. }
  304. if (item.stTypeId == 3 && !checkPanduanReply(item)) {
  305. count++;
  306. }
  307. if (item.stTypeId == 4 && !checkTiankongReply(item)) {
  308. count++;
  309. }
  310. })
  311. return {
  312. total,
  313. count,
  314. }
  315. }
  316. function handleJiaojuan() {
  317. const result = checkJiaojuan()
  318. console.log(result)
  319. if (result.count) {
  320. // 提示
  321. answerQrRef.value.showDialog({
  322. answercartsCount: result.total - result.count,
  323. answercartsTotal: result.total,
  324. })
  325. } else {
  326. handleSubmit()
  327. }
  328. }
  329. function handleQuerenConfirm() {
  330. handleSubmit()
  331. }
  332. function handleSubmit(force = false) {
  333. const result = {
  334. force,
  335. operId: data.operId,
  336. replyList: []
  337. };
  338. questionData.value.forEach(dl => {
  339. dl.qas.forEach(st => {
  340. const opt = {
  341. stId: st.stId,
  342. reply: st.reply
  343. }
  344. result.replyList.push(opt)
  345. })
  346. })
  347. ksApi.getClientKsSubmit(result).then(res => {
  348. if (res.code == 0) {
  349. subScoreRef.value.showDialog(res.data);
  350. data.hisId = res.data.hisId;
  351. // 清空缓存
  352. removeCacheKs(data.operId);
  353. }
  354. })
  355. }
  356. function onTimeUp() {
  357. handleSubmit();
  358. }
  359. // 交卷相关功能 end
  360. // 切屏功能 start
  361. function qiepingToast(count) {
  362. messageContent.value = `已离开${count}次。${data.toggleScreenFlag}次将自动交卷!`
  363. qiepingDlRef.value.handleShow()
  364. }
  365. function forceSubmit() {
  366. // 强制交卷
  367. console.log('强制交卷')
  368. handleSubmit(true)
  369. }
  370. function qpZhuapai() {
  371. // 重新开启抓拍
  372. zhuapaiRef.value && zhuapaiRef.value.showVideoBtn();
  373. }
  374. // 切屏功能 end
  375. // 摄像头抓拍相关功能 start
  376. function zpSuccess() {}
  377. function zpError() {
  378. uni.showToast({
  379. title: '抓拍图片异常',
  380. icon: 'none'
  381. })
  382. handleBack()
  383. }
  384. // 摄像头抓拍相关功能 end
  385. // 摄像头确认相关功能 start
  386. function onProgress() {
  387. uni.showToast({
  388. icon: 'none',
  389. title: '摄像头运行环境异常,请重新进入考试',
  390. duration: 8000
  391. })
  392. handleBack();
  393. }
  394. function zpConfirmSuccess() {
  395. console.log('zpConfirmSuccess')
  396. initKaoshi();
  397. }
  398. function zpConfirmError() {
  399. handleBack()
  400. }
  401. function zpConfirmCancel() {
  402. handleBack()
  403. }
  404. // 摄像头确认相关功能 end
  405. function getQaClass(qa) {
  406. if (qa.marked && qa.marked === true) {
  407. return 'paragraph-qa-block-mark';
  408. } else {
  409. if (qa.stTypeId == 1) {
  410. if (checkDanxuanReply(qa)) {
  411. return 'paragraph-qa-block-done';
  412. } else {
  413. return 'paragraph-qa-block-init';
  414. }
  415. } else if (qa.stTypeId == 2) {
  416. if (checkDuoxuanReply(qa)) {
  417. return 'paragraph-qa-block-done';
  418. } else {
  419. return 'paragraph-qa-block-init';
  420. }
  421. } else if (qa.stTypeId == 3) {
  422. if (checkPanduanReply(qa)) {
  423. return 'paragraph-qa-block-done';
  424. } else {
  425. return 'paragraph-qa-block-init';
  426. }
  427. } else if (qa.stTypeId == 4) {
  428. if (checkTiankongReply(qa)) {
  429. return 'paragraph-qa-block-done';
  430. } else {
  431. return 'paragraph-qa-block-init';
  432. }
  433. }
  434. }
  435. }
  436. function skipQuestion(dlIndex, dtIndex) {
  437. progress.dlIndex = dlIndex;
  438. progress.dtIndex = dtIndex;
  439. handlePopupBack()
  440. }
  441. function answerCardItemClick(qa) {
  442. const actQa = data.StListForSearch.find(item => item.stId == qa.stId);
  443. console.log('actQa', actQa)
  444. skipQuestion(actQa.dlIndex, actQa.dtIndex)
  445. }
  446. function handleBack() {
  447. const pages = getCurrentPages();
  448. if (pages.length > 1) {
  449. uni.navigateBack()
  450. } else {
  451. history.back();
  452. }
  453. }
  454. function showAnswerCard() {
  455. popupRef.value.open('top')
  456. }
  457. function handlePopupBack() {
  458. popupRef.value.close()
  459. }
  460. function handlePrev() {
  461. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  462. const index = qa.onlyNum - 1;
  463. if (index > 0) {
  464. const result = data.StListForSearch[index - 1];
  465. progress.dlIndex = result.dlIndex;
  466. progress.dtIndex = result.dtIndex
  467. }
  468. }
  469. function handleNext() {
  470. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  471. const index = qa.onlyNum - 1;
  472. if (index < data.StListForSearch.length) {
  473. const result = data.StListForSearch[index + 1];
  474. progress.dlIndex = result.dlIndex;
  475. progress.dtIndex = result.dtIndex
  476. }
  477. }
  478. function formatDuanluoList(dlData) {
  479. let uIndex = 0; // 试题onlyNum
  480. let iDuanluo = 0; // 段落onlyNum
  481. let result = [];
  482. for (const duanluo of data.duanluo) {
  483. let paragraph = {
  484. qas: [],
  485. };
  486. paragraph.name = duanluo.name;
  487. let iQa = 0; // 当前试题序号
  488. let order = 0; // 当前题型中第几题
  489. for (const iDanxuan of duanluo.danxuan) {
  490. iDanxuan.type = 'danxuan';
  491. iDanxuan.marked = data.biaoji[iDanxuan.stId] ? true : false;
  492. iDanxuan.onlyNum = uIndex + 1;
  493. iDanxuan.order = order;
  494. iDanxuan.iQa = iQa;
  495. paragraph.qas.push(iDanxuan);
  496. uIndex++;
  497. order++;
  498. iQa++;
  499. data.StListForSearch.push({
  500. stId: iDanxuan.stId,
  501. paragraphName: paragraph.name,
  502. dlIndex: iDuanluo,
  503. dtIndex: iDanxuan.iQa,
  504. onlyNum: iDanxuan.onlyNum
  505. })
  506. }
  507. order = 0;
  508. for (const iDuoxuan of duanluo.duoxuan) {
  509. iDuoxuan.type = 'duoxuan';
  510. iDuoxuan.marked = data.biaoji[iDuoxuan.stId] ? true : false;
  511. iDuoxuan.onlyNum = uIndex + 1;
  512. iDuoxuan.order = order;
  513. paragraph.qas.push(iDuoxuan);
  514. iDuoxuan.iQa = iQa;
  515. iDuoxuan.reply = [];
  516. uIndex++;
  517. order++;
  518. iQa++;
  519. data.StListForSearch.push({
  520. stId: iDuoxuan.stId,
  521. paragraphName: paragraph.name,
  522. dlIndex: iDuanluo,
  523. dtIndex: iDuoxuan.iQa,
  524. onlyNum: iDuoxuan.onlyNum
  525. })
  526. }
  527. order = 0;
  528. for (const iPanduan of duanluo.panduan) {
  529. iPanduan.type = 'panduan';
  530. iPanduan.marked = data.biaoji[iPanduan.stId] ? true : false;
  531. iPanduan.onlyNum = uIndex + 1;
  532. iPanduan.order = order;
  533. paragraph.qas.push(iPanduan);
  534. iPanduan.iQa = iQa;
  535. uIndex++;
  536. order++;
  537. iQa++;
  538. data.StListForSearch.push({
  539. stId: iPanduan.stId,
  540. paragraphName: paragraph.name,
  541. dlIndex: iDuanluo,
  542. dtIndex: iPanduan.iQa,
  543. onlyNum: iPanduan.onlyNum
  544. })
  545. }
  546. order = 0;
  547. for (const iTiankong of duanluo.tiankong) {
  548. iTiankong.type = 'tiankong';
  549. iTiankong.marked = data.biaoji[iTiankong.stId] ? true : false;
  550. iTiankong.onlyNum = uIndex + 1;
  551. iTiankong.order = order;
  552. paragraph.qas.push(iTiankong);
  553. iTiankong.iQa = iQa;
  554. iTiankong.reply = new Array(iTiankong.count).fill('');
  555. uIndex++;
  556. order++;
  557. iQa++;
  558. data.StListForSearch.push({
  559. stId: iTiankong.stId,
  560. paragraphName: paragraph.name,
  561. dlIndex: iDuanluo,
  562. dtIndex: iTiankong.iQa,
  563. onlyNum: iTiankong.onlyNum
  564. })
  565. }
  566. order = 0;
  567. for (const iJianda of duanluo.jianda) {
  568. iJianda.marked = data.biaoji[iJianda.stId] ? true : false;
  569. iJianda.type = 'jianda';
  570. iJianda.onlyNum = uIndex + 1;
  571. iJianda.order = order;
  572. iJianda.iQa = iQa;
  573. paragraph.qas.push(iJianda);
  574. iJianda.reply = '';
  575. uIndex++;
  576. order++;
  577. iQa++;
  578. data.StListForSearch.push({
  579. stId: iJianda.stId,
  580. paragraphName: paragraph.name,
  581. dlIndex: iDuanluo,
  582. dtIndex: iJianda.iQa,
  583. onlyNum: iJianda.onlyNum
  584. })
  585. }
  586. order = 0;
  587. for (const iYuedu of duanluo.yuedu) {
  588. iYuedu.marked = data.biaoji[iYuedu.stId] ? true : false;
  589. iYuedu.type = 'yuedu';
  590. iYuedu.onlyNum = uIndex + 1;
  591. iYuedu.order = order;
  592. iYuedu.iQa = iQa;
  593. if (iYuedu.duoxuan && iYuedu.duoxuan.length) {
  594. iYuedu.duoxuan.map((qIt) => {
  595. qIt.reply = qIt.reply || [];
  596. return qIt
  597. })
  598. }
  599. if (iYuedu.tiankong && iYuedu.tiankong.length) {
  600. iYuedu.tiankong.map((qIt) => {
  601. qIt.reply = new Array(qIt.count).fill('');
  602. return qIt;
  603. }) ;
  604. }
  605. paragraph.qas.push(iYuedu);
  606. iYuedu.reply = [];
  607. uIndex++;
  608. order++;
  609. iQa++;
  610. data.StListForSearch.push({
  611. stId: iYuedu.stId,
  612. paragraphName: paragraph.name,
  613. dlIndex: iDuanluo,
  614. dtIndex: iYuedu.iQa,
  615. onlyNum: iYuedu.onlyNum
  616. })
  617. }
  618. iDuanluo++;
  619. questionData.value.push(paragraph)
  620. }
  621. }
  622. function handleBiaoji() {
  623. activeSt.value.marked = !activeSt.value.marked;
  624. data.biaoji[activeSt.value.stId] = activeSt.value.marked
  625. ksApi.getClientKaoshiBiaoji({
  626. operId: data.operId,
  627. biaoji: JSON.stringify(data.biaoji)
  628. }).catch(err => {
  629. /* uni.redirectTo({
  630. url: '/pages/client/Kaoshi/list'
  631. }) */
  632. handleBack()
  633. })
  634. }
  635. function formatKaoshiData() {
  636. const historyData = getCacheKs(data.operId);
  637. if (historyData) {
  638. const {
  639. replyList,
  640. position
  641. } = historyData;
  642. if (replyList) {
  643. questionData.value.forEach(dl => {
  644. dl.qas.forEach(st => {
  645. st.reply = replyList.find(item => item.stId == st.stId).reply
  646. })
  647. })
  648. }
  649. if (position) {
  650. progress.dlIndex = position.dlIndex;
  651. progress.dtIndex = position.dtIndex;
  652. }
  653. }
  654. }
  655. // 摄像头确认初始化
  656. function initBeforKaoshi() {
  657. console.log(zhuapaiConfirmRef.value)
  658. zhuapaiConfirmRef.value.showDialog()
  659. }
  660. function initKaoshi() {
  661. ksApi.getClientKsStart({
  662. ksId: data.ksId,
  663. }).then(res => {
  664. const {
  665. ksId,
  666. operId,
  667. ksName,
  668. stTotal,
  669. stScore,
  670. biaoji,
  671. endSecond,
  672. pageSize,
  673. toggleScreenFlag,
  674. toggleScreenSecond,
  675. zhuapai,
  676. duanluoList
  677. } = res.data;
  678. data.ksId = ksId;
  679. data.operId = operId;
  680. data.ksName = ksName;
  681. data.stTotal = stTotal;
  682. data.stScore = stScore;
  683. data.biaoji = biaoji ? JSON.parse(biaoji) : {};
  684. data.endSecond = endSecond;
  685. data.pageSize = pageSize;
  686. data.toggleScreenFlag = toggleScreenFlag;
  687. data.toggleScreenSecond = toggleScreenSecond;
  688. data.zhuapai = zhuapai;
  689. data.duanluo = duanluoList;
  690. formatDuanluoList(data.duanluo);
  691. // 设置缓存
  692. formatKaoshiData();
  693. // 设置抓拍监听
  694. if (data.zhuapai && data.zhuapai > 0) {
  695. zhuapaiRef.value.init({
  696. zhuapai: zhuapai,
  697. operId: operId
  698. });
  699. }
  700. // 设置切屏监听
  701. // qiepingRef.value.init({
  702. // zhuapaiFlag: true,
  703. // toggleScreenFlag: toggleScreenFlag,
  704. // toggleScreenSecond: toggleScreenSecond,
  705. // ksId: data.ksId
  706. // })
  707. startCountDown.value = true;
  708. }).catch(err => {
  709. console.log('asdasd', err)
  710. // handleBack()
  711. })
  712. }
  713. </script>
  714. <style lang="scss">
  715. .phone-kaoshi-page {
  716. display: flex;
  717. flex-direction: column;
  718. background-color: #f4f6fa;
  719. position: relative;
  720. .kaoshi-page-title {
  721. height: 80rpx;
  722. line-height: 80rpx;
  723. background-color: #fff;
  724. margin-top: 20rpx;
  725. font-size: 26rpx;
  726. color: #333;
  727. display: flex;
  728. justify-content: space-between;
  729. padding: 0 24rpx;
  730. border-bottom: 1rpx solid #ebebeb;
  731. .title-types {
  732. font-size: 32rpx;
  733. color: #000;
  734. }
  735. }
  736. .kaoshi-shiti-content {
  737. padding: 24rpx 24rpx 0 24rpx;
  738. background-color: #fff;
  739. flex: 1;
  740. }
  741. .kaoshi-bottom-box {
  742. width: 100%;
  743. height: 100rpx;
  744. background-color: #f0f0f0;
  745. display: flex;
  746. align-items: center;
  747. justify-content: space-between;
  748. padding: 0 24rpx;
  749. box-sizing: border-box;
  750. position: fixed;
  751. bottom: var(--window-bottom);
  752. .bj-btn,
  753. .jx-btn,
  754. .save-btn {
  755. height: 60rpx;
  756. line-height: 58rpx;
  757. box-sizing: border-box;
  758. }
  759. .bj-btn {
  760. margin-left: unset;
  761. }
  762. .jx-btn,
  763. .save-btn {
  764. margin-right: unset;
  765. }
  766. .shiti-num-icon {
  767. width: 27px;
  768. height: 24px;
  769. vertical-align: middle;
  770. // background-image: url("@/static/images/exam/shiti-num-icon.png");
  771. @include ezy-no-repeat-cover();
  772. }
  773. .active-num {
  774. color: #30c190;
  775. }
  776. }
  777. .ks-btn-prev {
  778. position: fixed;
  779. bottom: 130rpx;
  780. left: 24rpx;
  781. }
  782. .ks-btn-next {
  783. position: fixed;
  784. bottom: 130rpx;
  785. right: 24rpx;
  786. }
  787. }
  788. </style>