You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

433 lines
17 KiB

1 week ago
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const common_assets = require("../../../common/assets.js");
  4. const config_api = require("../../../config/api.js");
  5. require("../../../uni_modules/uview-plus/index.js");
  6. const store_modules_car = require("../../../store/modules/car.js");
  7. const uni_modules_uviewPlus_libs_function_debounce = require("../../../uni_modules/uview-plus/libs/function/debounce.js");
  8. if (!Array) {
  9. const _easycom_up_count_down2 = common_vendor.resolveComponent("up-count-down");
  10. const _easycom_up_navbar2 = common_vendor.resolveComponent("up-navbar");
  11. const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
  12. const _easycom_up_popup2 = common_vendor.resolveComponent("up-popup");
  13. const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
  14. const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
  15. (_easycom_up_count_down2 + _easycom_up_navbar2 + _easycom_up_icon2 + _easycom_up_popup2 + _easycom_up_textarea2 + _easycom_up_button2)();
  16. }
  17. const _easycom_up_count_down = () => "../../../uni_modules/uview-plus/components/u-count-down/u-count-down.js";
  18. const _easycom_up_navbar = () => "../../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
  19. const _easycom_up_icon = () => "../../../uni_modules/uview-plus/components/u-icon/u-icon.js";
  20. const _easycom_up_popup = () => "../../../uni_modules/uview-plus/components/u-popup/u-popup.js";
  21. const _easycom_up_textarea = () => "../../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
  22. const _easycom_up_button = () => "../../../uni_modules/uview-plus/components/u-button/u-button.js";
  23. if (!Math) {
  24. (_easycom_up_count_down + _easycom_up_navbar + _easycom_up_icon + _easycom_up_popup + _easycom_up_textarea + _easycom_up_button)();
  25. }
  26. const _sfc_main = {
  27. __name: "examQuestions",
  28. setup(__props) {
  29. function speak(text) {
  30. const speech = new SpeechSynthesisUtterance(text);
  31. window.speechSynthesis.speak(speech);
  32. }
  33. const currentNav = common_vendor.ref("1");
  34. const types = common_vendor.ref([
  35. "单选题",
  36. "多选题",
  37. "判断题"
  38. ]);
  39. const yesNum = common_vendor.ref(0);
  40. const noNum = common_vendor.ref(0);
  41. let showCommit = common_vendor.ref(false);
  42. let usecarStore = store_modules_car.carStore();
  43. let totalExamTime = common_vendor.ref(45);
  44. let passScore = common_vendor.ref(90);
  45. common_vendor.onLoad((options) => {
  46. totalExamTime.value = options.totalExamTime;
  47. passScore.value = options.score;
  48. });
  49. const show = common_vendor.ref(false);
  50. function closePopup() {
  51. show.value = false;
  52. }
  53. function openPopup() {
  54. show.value = true;
  55. }
  56. let showCommt = common_vendor.ref(false);
  57. let contentStr = common_vendor.ref("");
  58. function showCommtClose() {
  59. showCommt.value = false;
  60. contentStr.value = "";
  61. }
  62. const questionBank = common_vendor.ref({});
  63. const questionBankList = common_vendor.ref([]);
  64. let examInfo = common_vendor.ref([]);
  65. let currentIndex = common_vendor.ref(0);
  66. async function startQuestionFn() {
  67. try {
  68. common_vendor.index.showLoading({
  69. title: "正在加载..."
  70. });
  71. let obj = {
  72. carType: usecarStore.carInfo.carType,
  73. stepType: usecarStore.carInfo.stepType,
  74. city: usecarStore.carInfo.city,
  75. examType: 1
  76. };
  77. const { data: res } = await config_api.startExam(obj);
  78. common_vendor.index.hideLoading();
  79. questionBank.value = res.questionBank[0];
  80. questionBankList.value = res.questionBank;
  81. initOptionArr();
  82. examInfo.value = res;
  83. } catch (e) {
  84. common_vendor.index.hideLoading();
  85. }
  86. }
  87. startQuestionFn();
  88. common_vendor.watch(() => questionBankList, (newVal, oldVal) => {
  89. yesNum.value = oldVal.value.filter((item) => item.yes).length;
  90. noNum.value = oldVal.value.filter((item) => item.yes == 0).length;
  91. }, { deep: true });
  92. function initOptionArr() {
  93. questionBank.value.optionArr = [];
  94. let abcd = [
  95. "a",
  96. "b",
  97. "c",
  98. "d",
  99. "e",
  100. "f"
  101. ];
  102. abcd.forEach((k, i) => {
  103. let option = "option" + k;
  104. if (questionBank.value[option]) {
  105. let obj = {
  106. key: k.toLocaleUpperCase(),
  107. text: questionBank.value[option],
  108. index: i + 1
  109. };
  110. questionBank.value.optionArr.push(obj);
  111. }
  112. });
  113. if (questionBank.value.types == 3) {
  114. questionBank.value.optionArr[0].key = "true";
  115. questionBank.value.optionArr[1].key = "false";
  116. }
  117. }
  118. async function nextQuestion(num) {
  119. if (questionBank.value.types == 2 && curOption.value.ans) {
  120. if (!curOption.value.answer) {
  121. curOption.value.answer = curOption.value.ans;
  122. }
  123. if (questionBank.value.answer != curOption.value.ans && curOption.value.isNext != "next") {
  124. curOption.value.isNext = "next";
  125. questionBank.value.yes = 0;
  126. return false;
  127. } else if (questionBank.value.answer == curOption.value.ans) {
  128. questionBank.value.yes = 1;
  129. }
  130. }
  131. curOption.value = {};
  132. currentIndex.value = currentIndex.value + num;
  133. getQuestionFn();
  134. }
  135. async function getQuestionFn() {
  136. console.log(currentIndex.value);
  137. questionBank.value = questionBankList.value[currentIndex.value];
  138. curOption.value = {};
  139. curOption.value.isNext = "";
  140. initOptionArr();
  141. }
  142. async function quesIdListClick(id, index) {
  143. curOption.value = {};
  144. currentIndex.value = index;
  145. getQuestionFn();
  146. show.value = false;
  147. }
  148. async function questionWrongColleFn() {
  149. let isAdd = questionBank.value.isCollect == 1 ? "0" : "1";
  150. const obj = {
  151. "carType": usecarStore.carInfo.carType,
  152. "isAdd": isAdd,
  153. "questionId": questionBank.value.id,
  154. "stepType": usecarStore.carInfo.stepType
  155. };
  156. await config_api.questionWrongColle(obj);
  157. questionBank.value.isCollect = isAdd;
  158. console.log(questionBank.value.isCollect);
  159. }
  160. const curOption = common_vendor.ref({});
  161. async function chooseOption(item) {
  162. console.log(item);
  163. if (curOption.value.answer)
  164. return;
  165. if (questionBank.value.types != 2) {
  166. if (questionBank.value.answer == item.key) {
  167. questionBank.value.yes = 1;
  168. currentIndex.value = currentIndex.value + 1;
  169. curOption.value = item;
  170. setTimeout(() => {
  171. getQuestionFn();
  172. }, 500);
  173. } else {
  174. item.answer = item.key;
  175. curOption.value = item;
  176. questionBank.value.yes = 0;
  177. }
  178. } else if (questionBank.value.types == 2) {
  179. if (!curOption.value.ans)
  180. curOption.value.ans = "";
  181. if (curOption.value.ans.includes(item.key)) {
  182. curOption.value.ans = curOption.value.ans.replace(item.key, "");
  183. return;
  184. }
  185. curOption.value.ans = (curOption.value.ans + item.key).split("").sort().join("");
  186. }
  187. }
  188. let remaining = common_vendor.ref(0);
  189. let countDownRef = common_vendor.ref(null);
  190. function handApaper() {
  191. let arr = questionBankList.value.filter((item) => item.yes == void 0);
  192. if (arr.length || passScore.value * 1 > yesNum.value) {
  193. remaining.value = arr.length;
  194. showCommit.value = true;
  195. if (countDownRef.value) {
  196. countDownRef.value.pause();
  197. }
  198. } else {
  199. submitBtnFn();
  200. }
  201. }
  202. function closeCommitPopup() {
  203. showCommit.value = false;
  204. if (countDownRef.value) {
  205. countDownRef.value.start();
  206. }
  207. }
  208. async function submitBtnFn() {
  209. let wrongArr = questionBankList.value.filter((item) => item.yes != 1);
  210. let worngId = wrongArr.map((item) => item.id).join(",");
  211. let obj = {
  212. "answer": null,
  213. "carType": usecarStore.carInfo.carType,
  214. "examId": examInfo.value.id,
  215. "examType": 1,
  216. "grade": questionBankList.value.length - wrongArr.length,
  217. "isEnd": 1,
  218. "pass": 1,
  219. "sort": examInfo.value.sort,
  220. "stepType": usecarStore.carInfo.stepType,
  221. "userId": examInfo.value.userId,
  222. "wrongQuestionIds": worngId
  223. };
  224. const res = await config_api.startExamDo(obj);
  225. console.log(res);
  226. common_vendor.index.$u.toast("已交卷");
  227. setTimeout(() => {
  228. common_vendor.index.navigateBack();
  229. }, 1500);
  230. }
  231. function finishFn() {
  232. common_vendor.index.$u.toast("考试时间已到,准备自动为您交卷");
  233. setTimeout(() => {
  234. submitBtnFn();
  235. }, 1500);
  236. }
  237. function goBack() {
  238. common_vendor.index.navigateBack();
  239. }
  240. return (_ctx, _cache) => {
  241. return common_vendor.e({
  242. a: common_vendor.sr(countDownRef, "7aaaebcc-1,7aaaebcc-0", {
  243. "k": "countDownRef"
  244. }),
  245. b: common_vendor.o(finishFn),
  246. c: common_vendor.p({
  247. time: common_vendor.unref(totalExamTime) * 60 * 1e3,
  248. format: "mm:ss"
  249. }),
  250. d: common_vendor.p({
  251. leftText: " ",
  252. title: "",
  253. safeAreaInsetTop: false,
  254. autoBack: true
  255. }),
  256. e: common_vendor.p({
  257. name: "checkmark-circle-fill",
  258. color: "#55ff7f",
  259. size: "20"
  260. }),
  261. f: common_vendor.t(yesNum.value),
  262. g: common_vendor.p({
  263. name: "close-circle-fill",
  264. color: "#ff0000",
  265. size: "20"
  266. }),
  267. h: common_vendor.t(noNum.value),
  268. i: common_vendor.t(common_vendor.unref(currentIndex) + 1),
  269. j: common_vendor.t(questionBankList.value.length),
  270. k: common_vendor.t(types.value[questionBank.value.types - 1]),
  271. l: questionBank.value.types == 2 ? 1 : "",
  272. m: questionBank.value.types == 3 ? 1 : "",
  273. n: common_vendor.t(questionBank.value.title),
  274. o: common_vendor.o(($event) => speak(questionBank.value.title)),
  275. p: questionBank.value.img
  276. }, questionBank.value.img ? {
  277. q: questionBank.value.img
  278. } : {}, {
  279. r: common_vendor.f(questionBank.value.optionArr, (item, index, i0) => {
  280. var _a, _b;
  281. return common_vendor.e(questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer) ? common_vendor.e({
  282. a: (_a = curOption.value.ans) == null ? void 0 : _a.includes(item.key)
  283. }, ((_b = curOption.value.ans) == null ? void 0 : _b.includes(item.key)) ? {
  284. b: "7aaaebcc-4-" + i0,
  285. c: common_vendor.p({
  286. name: "checkmark-circle-fill",
  287. color: "#55ff7f",
  288. size: "20"
  289. })
  290. } : {}, {
  291. d: common_vendor.t(item.key),
  292. e: common_vendor.t(item.text)
  293. }) : common_vendor.e({
  294. f: !curOption.value.key && questionBank.value.types != 2
  295. }, !curOption.value.key && questionBank.value.types != 2 ? {} : questionBank.value.answer.includes(item.key) ? {
  296. h: "7aaaebcc-5-" + i0,
  297. i: common_vendor.p({
  298. name: "checkmark-circle-fill",
  299. color: "#55ff7f",
  300. size: "20"
  301. })
  302. } : {
  303. j: "7aaaebcc-6-" + i0,
  304. k: common_vendor.p({
  305. name: "close-circle-fill",
  306. color: "#ff0000",
  307. size: "20"
  308. })
  309. }, {
  310. g: questionBank.value.answer.includes(item.key),
  311. l: questionBank.value.types != 3
  312. }, questionBank.value.types != 3 ? {
  313. m: common_vendor.t(item.key)
  314. } : {}, {
  315. n: common_vendor.t(item.text)
  316. }), {
  317. o: common_vendor.o(($event) => chooseOption(item))
  318. });
  319. }),
  320. s: questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer),
  321. t: curOption.value.answer && questionBank.value.answer != curOption.value.answer
  322. }, curOption.value.answer && questionBank.value.answer != curOption.value.answer ? common_vendor.e({
  323. v: questionBank.value.types == 3
  324. }, questionBank.value.types == 3 ? {
  325. w: common_vendor.t(questionBank.value.answer == "false" ? "错误" : "正确")
  326. } : {
  327. x: common_vendor.t(questionBank.value.answer)
  328. }, {
  329. y: questionBank.value.types == 3
  330. }, questionBank.value.types == 3 ? {
  331. z: common_vendor.t(curOption.value.answer == "false" ? "错误" : "正确")
  332. } : {
  333. A: common_vendor.t(curOption.value.answer)
  334. }) : {}, {
  335. B: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(-1), 500)),
  336. C: common_vendor.unref(currentIndex) == 0 ? 1 : "",
  337. D: common_vendor.unref(currentIndex) == 0,
  338. E: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(1), 500)),
  339. F: common_vendor.unref(currentIndex) >= questionBankList.value.length - 1 ? 1 : "",
  340. G: common_vendor.unref(currentIndex) >= questionBankList.value.length - 1,
  341. H: currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer
  342. }, currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer ? {
  343. I: common_vendor.t(questionBank.value.resolving)
  344. } : {}, {
  345. J: common_assets._imports_0$3,
  346. K: common_vendor.o(($event) => common_vendor.isRef(showCommt) ? showCommt.value = true : showCommt = true),
  347. L: common_assets._imports_1$1,
  348. M: common_vendor.o(openPopup),
  349. N: questionBank.value.isCollect == "1"
  350. }, questionBank.value.isCollect == "1" ? {
  351. O: common_assets._imports_2$1
  352. } : {
  353. P: common_assets._imports_3$1
  354. }, {
  355. Q: common_vendor.o(questionWrongColleFn),
  356. R: common_vendor.o(handApaper),
  357. S: common_vendor.t(yesNum.value),
  358. T: common_vendor.t(noNum.value),
  359. U: common_vendor.t(common_vendor.unref(currentIndex) + 1),
  360. V: common_vendor.t(questionBankList.value.length),
  361. W: common_vendor.f(questionBankList.value, (item, index, i0) => {
  362. return common_vendor.e({
  363. a: common_vendor.t(index + 1),
  364. b: index == common_vendor.unref(currentIndex)
  365. }, index == common_vendor.unref(currentIndex) ? {} : {}, {
  366. c: item.yes == 1 ? 1 : "",
  367. d: item.yes == 0 ? 1 : "",
  368. e: index,
  369. f: common_vendor.o(($event) => quesIdListClick(item, index), index)
  370. });
  371. }),
  372. X: common_vendor.o(closePopup),
  373. Y: common_vendor.o(openPopup),
  374. Z: common_vendor.p({
  375. show: show.value,
  376. mode: "bottom",
  377. round: "20",
  378. closeable: true
  379. }),
  380. aa: common_vendor.o(common_vendor.m(($event) => common_vendor.isRef(contentStr) ? contentStr.value = $event : contentStr = $event, {
  381. trim: true
  382. }, true)),
  383. ab: common_vendor.p({
  384. placeholder: "请输入反馈内容",
  385. maxlength: "300",
  386. modelValue: common_vendor.unref(contentStr)
  387. }),
  388. ac: common_vendor.o(_ctx.submitClick),
  389. ad: common_vendor.p({
  390. text: "提 交",
  391. type: "primary"
  392. }),
  393. ae: common_vendor.o(showCommtClose),
  394. af: common_vendor.p({
  395. show: common_vendor.unref(showCommt),
  396. mode: "bottom",
  397. round: "20rpx",
  398. closeable: true
  399. }),
  400. ag: common_vendor.unref(remaining)
  401. }, common_vendor.unref(remaining) ? {} : common_vendor.unref(passScore).value * 1 > yesNum.value.value ? {} : {}, {
  402. ah: common_vendor.unref(passScore).value * 1 > yesNum.value.value,
  403. ai: common_vendor.t(common_vendor.unref(remaining)),
  404. aj: common_vendor.t(questionBankList.value.length - common_vendor.unref(remaining)),
  405. ak: common_vendor.sr(countDownRef, "7aaaebcc-12,7aaaebcc-11", {
  406. "k": "countDownRef"
  407. }),
  408. al: common_vendor.p({
  409. time: common_vendor.unref(totalExamTime) * 60 * 60 * 1e3,
  410. format: "HH:mm"
  411. }),
  412. am: common_assets._imports_4$1,
  413. an: common_vendor.unref(remaining)
  414. }, common_vendor.unref(remaining) ? {
  415. ao: common_vendor.o(goBack),
  416. ap: common_vendor.o(closeCommitPopup)
  417. } : {
  418. aq: common_vendor.o(closeCommitPopup),
  419. ar: common_vendor.o(submitBtnFn)
  420. }, {
  421. as: common_vendor.o(closeCommitPopup),
  422. at: common_vendor.p({
  423. show: common_vendor.unref(showCommit),
  424. mode: "center",
  425. round: "20rpx",
  426. closeable: true
  427. })
  428. });
  429. };
  430. }
  431. };
  432. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7aaaebcc"]]);
  433. wx.createPage(MiniProgramPage);