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.

381 lines
15 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 store_modules_wrongQuestionBook = require("../../../store/modules/wrongQuestionBook.js");
  5. const config_api = require("../../../config/api.js");
  6. require("../../../uni_modules/uview-plus/index.js");
  7. const store_modules_car = require("../../../store/modules/car.js");
  8. const uni_modules_uviewPlus_libs_function_debounce = require("../../../uni_modules/uview-plus/libs/function/debounce.js");
  9. if (!Array) {
  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_navbar2 + _easycom_up_icon2 + _easycom_up_popup2 + _easycom_up_textarea2 + _easycom_up_button2)();
  16. }
  17. const _easycom_up_navbar = () => "../../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
  18. const _easycom_up_icon = () => "../../../uni_modules/uview-plus/components/u-icon/u-icon.js";
  19. const _easycom_up_popup = () => "../../../uni_modules/uview-plus/components/u-popup/u-popup.js";
  20. const _easycom_up_textarea = () => "../../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
  21. const _easycom_up_button = () => "../../../uni_modules/uview-plus/components/u-button/u-button.js";
  22. if (!Math) {
  23. (_easycom_up_navbar + _easycom_up_icon + _easycom_up_popup + _easycom_up_textarea + _easycom_up_button)();
  24. }
  25. const _sfc_main = {
  26. __name: "wrongQuestions",
  27. setup(__props) {
  28. function speak(text) {
  29. const speech = new SpeechSynthesisUtterance(text);
  30. window.speechSynthesis.speak(speech);
  31. }
  32. let usewrongQuestion = store_modules_wrongQuestionBook.questionStore();
  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 usecarStore = store_modules_car.carStore();
  42. function changeNav(val) {
  43. console.log(window);
  44. if (currentNav.value == val)
  45. return;
  46. currentNav.value = val;
  47. }
  48. const show = common_vendor.ref(false);
  49. function closePopup() {
  50. show.value = false;
  51. }
  52. function openPopup() {
  53. show.value = true;
  54. }
  55. let showCommt = common_vendor.ref(false);
  56. let contentStr = common_vendor.ref("");
  57. function showCommtClose() {
  58. showCommt.value = false;
  59. contentStr.value = "";
  60. }
  61. async function submitCommt() {
  62. if (!contentStr.value)
  63. return common_vendor.index.$u.toast("请输入内容");
  64. let obj = {
  65. content: contentStr.value,
  66. questionId: questionBank.value.id
  67. };
  68. const res = await config_api.questionCommentAdd(obj);
  69. if (res.errorcode == 0) {
  70. common_vendor.index.$u.toast("提交成功,感谢您的反馈");
  71. showCommt.value = false;
  72. }
  73. }
  74. let questionType = common_vendor.ref(1);
  75. common_vendor.onLoad((options) => {
  76. let isHigh = options.isHigh ? options.isHigh : "";
  77. if (options.wrong) {
  78. questionType.value = options.wrong;
  79. findQuestionListFn(options.wrong, isHigh);
  80. }
  81. });
  82. const questionBank = common_vendor.ref({});
  83. let questionBankList = common_vendor.ref([]);
  84. let currentIndex = common_vendor.ref(0);
  85. async function findQuestionListFn(type, isHigh) {
  86. let obj = {
  87. "carType": usecarStore.carInfo.carType,
  88. "chapter": usecarStore.carInfo.chapter,
  89. "isHigh": isHigh,
  90. "stepType": usecarStore.carInfo.stepType,
  91. "type": type
  92. };
  93. const { data: res } = await config_api.findQuestionList(obj);
  94. if (!res.length) {
  95. common_vendor.index.$u.toast("暂无错题");
  96. setTimeout(() => {
  97. return common_vendor.index.navigateBack();
  98. }, 1500);
  99. return;
  100. }
  101. questionBank.value = res[0];
  102. questionBankList.value = res;
  103. initOptionArr();
  104. }
  105. function initOptionArr() {
  106. questionBank.value.optionArr = [];
  107. let abcd = [
  108. "a",
  109. "b",
  110. "c",
  111. "d",
  112. "e",
  113. "f"
  114. ];
  115. abcd.forEach((k, i) => {
  116. let option = "option" + k;
  117. if (questionBank.value[option]) {
  118. let obj = {
  119. key: k.toLocaleUpperCase(),
  120. text: questionBank.value[option],
  121. index: i + 1
  122. };
  123. questionBank.value.optionArr.push(obj);
  124. }
  125. });
  126. if (questionBank.value.types == 3) {
  127. questionBank.value.optionArr[0].key = "true";
  128. questionBank.value.optionArr[1].key = "false";
  129. }
  130. }
  131. async function nextQuestion(num) {
  132. if (questionBank.value.types == 2 && curOption.value.ans) {
  133. if (!curOption.value.answer) {
  134. curOption.value.answer = curOption.value.ans;
  135. }
  136. if (questionBank.value.answer != curOption.value.ans && curOption.value.isNext != "next") {
  137. curOption.value.isNext = "next";
  138. noNum.value++;
  139. return false;
  140. }
  141. if (curOption.value.answer == questionBank.value.answer) {
  142. yesNum.value++;
  143. if (questionType.value == 1) {
  144. usewrongQuestion.deleteWrongOrColFn(questionBank.value.id).then(() => {
  145. questionBankList.value.splice(currentIndex.value, 1);
  146. if (currentIndex.value >= questionBankList.value.length - 1) {
  147. currentIndex.value = 0;
  148. }
  149. if (num == 0)
  150. return;
  151. getQuestionFn();
  152. common_vendor.index.$u.toast("题目已删除");
  153. return;
  154. });
  155. }
  156. if (num == 0)
  157. return;
  158. }
  159. }
  160. curOption.value = {};
  161. currentIndex.value = currentIndex.value + num;
  162. getQuestionFn();
  163. }
  164. async function getQuestionFn() {
  165. if (!questionBankList.value.length) {
  166. common_vendor.index.$u.toast("已全部刷完");
  167. setTimeout(() => {
  168. common_vendor.index.navigateBack();
  169. }, 1500);
  170. return;
  171. }
  172. questionBank.value = questionBankList.value[currentIndex.value];
  173. curOption.value = {};
  174. curOption.value.isNext = "";
  175. initOptionArr();
  176. }
  177. async function questionBankListClick(id, index) {
  178. curOption.value = {};
  179. currentIndex.value = index;
  180. getQuestionFn();
  181. show.value = false;
  182. }
  183. const curOption = common_vendor.ref({});
  184. async function chooseOption(item) {
  185. if (curOption.value.answer)
  186. return;
  187. if (questionBank.value.types != 2) {
  188. item.answer = item.key;
  189. curOption.value = item;
  190. if (curOption.value.answer == questionBank.value.answer) {
  191. yesNum.value++;
  192. if (questionType.value == 1) {
  193. usewrongQuestion.deleteWrongOrColFn(questionBank.value.id).then(() => {
  194. questionBankList.value.splice(currentIndex.value, 1);
  195. if (currentIndex.value >= questionBankList.value.length - 1) {
  196. currentIndex.value = 0;
  197. }
  198. getQuestionFn();
  199. common_vendor.index.$u.toast("题目已删除");
  200. });
  201. }
  202. } else {
  203. noNum.value++;
  204. }
  205. } else if (questionBank.value.types == 2) {
  206. if (!curOption.value.ans)
  207. curOption.value.ans = "";
  208. if (curOption.value.ans.includes(item.key)) {
  209. curOption.value.ans = curOption.value.ans.replace(item.key, "");
  210. return;
  211. }
  212. curOption.value.ans = (curOption.value.ans + item.key).split("").sort().join("");
  213. }
  214. }
  215. async function questionWrongColleFn() {
  216. let isAdd = questionBank.value.isCollect == 1 ? "0" : "1";
  217. const obj = {
  218. "carType": usecarStore.carInfo.carType,
  219. "isAdd": isAdd,
  220. "questionId": questionBank.value.id,
  221. "stepType": usecarStore.carInfo.stepType
  222. };
  223. await config_api.questionWrongColle(obj);
  224. questionBank.value.isCollect = isAdd;
  225. console.log(questionBank.value.isCollect);
  226. }
  227. return (_ctx, _cache) => {
  228. return common_vendor.e({
  229. a: common_vendor.o(($event) => changeNav(1)),
  230. b: currentNav.value == 1 ? 1 : "",
  231. c: common_vendor.o(($event) => changeNav(2)),
  232. d: currentNav.value == 2 ? 1 : "",
  233. e: common_vendor.p({
  234. leftText: " ",
  235. title: "",
  236. safeAreaInsetTop: false,
  237. autoBack: true
  238. }),
  239. f: common_vendor.t(types.value[questionBank.value.types - 1]),
  240. g: questionBank.value.types == 2 ? 1 : "",
  241. h: questionBank.value.types == 3 ? 1 : "",
  242. i: common_vendor.t(questionBank.value.title),
  243. j: common_vendor.o(($event) => speak(questionBank.value.title)),
  244. k: questionBank.value.img
  245. }, questionBank.value.img ? {
  246. l: questionBank.value.img
  247. } : {}, {
  248. m: common_vendor.f(questionBank.value.optionArr, (item, index, i0) => {
  249. var _a, _b;
  250. return common_vendor.e(questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer) ? common_vendor.e({
  251. a: (_a = curOption.value.ans) == null ? void 0 : _a.includes(item.key)
  252. }, ((_b = curOption.value.ans) == null ? void 0 : _b.includes(item.key)) ? {
  253. b: "4320d38d-1-" + i0,
  254. c: common_vendor.p({
  255. name: "checkmark-circle-fill",
  256. color: "#55ff7f",
  257. size: "20"
  258. })
  259. } : {}, {
  260. d: common_vendor.t(item.key),
  261. e: common_vendor.t(item.text)
  262. }) : common_vendor.e({
  263. f: !curOption.value.key && questionBank.value.types != 2
  264. }, !curOption.value.key && questionBank.value.types != 2 ? {} : questionBank.value.answer.includes(item.key) ? {
  265. h: "4320d38d-2-" + i0,
  266. i: common_vendor.p({
  267. name: "checkmark-circle-fill",
  268. color: "#55ff7f",
  269. size: "20"
  270. })
  271. } : {
  272. j: "4320d38d-3-" + i0,
  273. k: common_vendor.p({
  274. name: "close-circle-fill",
  275. color: "#ff0000",
  276. size: "20"
  277. })
  278. }, {
  279. g: questionBank.value.answer.includes(item.key),
  280. l: questionBank.value.types != 3
  281. }, questionBank.value.types != 3 ? {
  282. m: common_vendor.t(item.key)
  283. } : {}, {
  284. n: common_vendor.t(item.text)
  285. }), {
  286. o: common_vendor.o(($event) => chooseOption(item))
  287. });
  288. }),
  289. n: questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer),
  290. o: curOption.value.answer && questionBank.value.answer != curOption.value.answer
  291. }, curOption.value.answer && questionBank.value.answer != curOption.value.answer ? common_vendor.e({
  292. p: questionBank.value.types == 3
  293. }, questionBank.value.types == 3 ? {
  294. q: common_vendor.t(questionBank.value.answer == "false" ? "错误" : "正确")
  295. } : {
  296. r: common_vendor.t(questionBank.value.answer)
  297. }, {
  298. s: questionBank.value.types == 3
  299. }, questionBank.value.types == 3 ? {
  300. t: common_vendor.t(curOption.value.answer == "false" ? "错误" : "正确")
  301. } : {
  302. v: common_vendor.t(curOption.value.answer)
  303. }) : {}, {
  304. w: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(-1), 500)),
  305. x: common_vendor.unref(currentIndex) == 0 ? 1 : "",
  306. y: common_vendor.unref(currentIndex) == 0,
  307. z: common_vendor.unref(currentIndex) == common_vendor.unref(questionBankList).length - 1
  308. }, common_vendor.unref(currentIndex) == common_vendor.unref(questionBankList).length - 1 ? {
  309. A: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(0), 500)),
  310. B: curOption.value.answer ? 1 : "",
  311. C: curOption.value.answer
  312. } : {
  313. D: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(1), 500)),
  314. E: common_vendor.unref(currentIndex) >= common_vendor.unref(questionBankList).length - 1 ? 1 : "",
  315. F: common_vendor.unref(currentIndex) >= common_vendor.unref(questionBankList).length - 1
  316. }, {
  317. G: currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer
  318. }, currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer ? {
  319. H: common_vendor.t(questionBank.value.resolving)
  320. } : {}, {
  321. I: common_vendor.t(yesNum.value),
  322. J: common_vendor.t(noNum.value),
  323. K: common_vendor.t(common_vendor.unref(currentIndex) + 1),
  324. L: common_vendor.t(common_vendor.unref(questionBankList).length),
  325. M: common_assets._imports_0$3,
  326. N: common_vendor.o(($event) => common_vendor.isRef(showCommt) ? showCommt.value = true : showCommt = true),
  327. O: common_assets._imports_1$1,
  328. P: common_vendor.o(openPopup),
  329. Q: questionBank.value.isCollect == "1"
  330. }, questionBank.value.isCollect == "1" ? {
  331. R: common_assets._imports_2$1
  332. } : {
  333. S: common_assets._imports_3$1
  334. }, {
  335. T: common_vendor.o(questionWrongColleFn),
  336. U: common_vendor.t(yesNum.value),
  337. V: common_vendor.t(noNum.value),
  338. W: common_vendor.t(common_vendor.unref(currentIndex) + 1),
  339. X: common_vendor.t(common_vendor.unref(questionBankList).length),
  340. Y: common_vendor.f(common_vendor.unref(questionBankList), (item, index, i0) => {
  341. return {
  342. a: common_vendor.t(index + 1),
  343. b: index == common_vendor.unref(currentIndex) ? 1 : "",
  344. c: index,
  345. d: common_vendor.o(($event) => questionBankListClick(item, index), index)
  346. };
  347. }),
  348. Z: common_vendor.o(closePopup),
  349. aa: common_vendor.o(openPopup),
  350. ab: common_vendor.p({
  351. show: show.value,
  352. mode: "bottom",
  353. round: "20",
  354. closeable: true
  355. }),
  356. ac: common_vendor.o(common_vendor.m(($event) => common_vendor.isRef(contentStr) ? contentStr.value = $event : contentStr = $event, {
  357. trim: true
  358. }, true)),
  359. ad: common_vendor.p({
  360. placeholder: "请输入反馈内容",
  361. maxlength: "300",
  362. modelValue: common_vendor.unref(contentStr)
  363. }),
  364. ae: common_vendor.o(submitCommt),
  365. af: common_vendor.p({
  366. text: "提 交",
  367. type: "primary"
  368. }),
  369. ag: common_vendor.o(showCommtClose),
  370. ah: common_vendor.p({
  371. show: common_vendor.unref(showCommt),
  372. mode: "bottom",
  373. round: "20rpx",
  374. closeable: true
  375. })
  376. });
  377. };
  378. }
  379. };
  380. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4320d38d"]]);
  381. wx.createPage(MiniProgramPage);