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.

385 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 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 store_modules_wrongQuestionBook = require("../../../store/modules/wrongQuestionBook.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: "brushQuestions",
  27. setup(__props) {
  28. function speak(text) {
  29. const speech = new SpeechSynthesisUtterance(text);
  30. window.speechSynthesis.speak(speech);
  31. }
  32. const currentNav = common_vendor.ref("1");
  33. const types = common_vendor.ref([
  34. "单选题",
  35. "多选题",
  36. "判断题"
  37. ]);
  38. const yesNum = common_vendor.ref(0);
  39. const noNum = common_vendor.ref(0);
  40. let usecarStore = store_modules_car.carStore();
  41. let usequestionStore = store_modules_wrongQuestionBook.questionStore();
  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. common_vendor.onLoad((options) => {
  75. if (options.wrong) {
  76. findQuestionListFn(options.wrong);
  77. } else {
  78. startQuestionFn();
  79. }
  80. });
  81. const questionBank = common_vendor.ref({});
  82. let quesIdList = common_vendor.ref([]);
  83. let currentIndex = common_vendor.ref(0);
  84. async function findQuestionListFn(type) {
  85. let obj = {
  86. "carType": usecarStore.carInfo.carType,
  87. "chapter": usecarStore.carInfo.chapter,
  88. "isHigh": "",
  89. "stepType": usecarStore.carInfo.stepType,
  90. "type": type
  91. };
  92. await config_api.findQuestionList(obj);
  93. }
  94. async function startQuestionFn() {
  95. try {
  96. common_vendor.index.showLoading({
  97. title: "正在加载..."
  98. });
  99. let obj = {
  100. carType: usecarStore.carInfo.carType,
  101. stepType: usecarStore.carInfo.stepType,
  102. volume: usecarStore.carInfo.volume,
  103. types: usecarStore.carInfo.types,
  104. sift: usecarStore.carInfo.sift,
  105. contentType: usecarStore.carInfo.contentType,
  106. knowType: usecarStore.carInfo.knowType,
  107. chapter: usecarStore.carInfo.chapter,
  108. city: usecarStore.carInfo.city
  109. };
  110. const { data: res } = await config_api.startQuestionApi(obj);
  111. common_vendor.index.hideLoading();
  112. questionBank.value = res.questionBank;
  113. initOptionArr();
  114. quesIdList.value = res.quesIdList;
  115. currentIndex.value = quesIdList.value.findIndex((item) => item == questionBank.value.id);
  116. } catch (e) {
  117. common_vendor.index.hideLoading();
  118. }
  119. }
  120. function initOptionArr() {
  121. questionBank.value.optionArr = [];
  122. let abcd = [
  123. "a",
  124. "b",
  125. "c",
  126. "d",
  127. "e",
  128. "f"
  129. ];
  130. abcd.forEach((k, i) => {
  131. let option = "option" + k;
  132. if (questionBank.value[option]) {
  133. let obj = {
  134. key: k.toLocaleUpperCase(),
  135. text: questionBank.value[option],
  136. index: i + 1
  137. };
  138. questionBank.value.optionArr.push(obj);
  139. }
  140. });
  141. if (questionBank.value.types == 3) {
  142. questionBank.value.optionArr[0].key = "true";
  143. questionBank.value.optionArr[1].key = "false";
  144. }
  145. }
  146. async function nextQuestion(num) {
  147. if (questionBank.value.types == 2 && curOption.value.ans) {
  148. if (!curOption.value.answer) {
  149. curOption.value.answer = curOption.value.ans;
  150. await submitAnswerResultFn();
  151. }
  152. if (questionBank.value.answer != curOption.value.ans && curOption.value.isNext != "next") {
  153. curOption.value.isNext = "next";
  154. return false;
  155. }
  156. }
  157. curOption.value = {};
  158. currentIndex.value = currentIndex.value + num;
  159. questionBank.value = {};
  160. getQuestionFn();
  161. }
  162. async function getQuestionFn() {
  163. console.log(currentIndex.value);
  164. let questionId = quesIdList.value[currentIndex.value];
  165. let obj = {
  166. "carType": usecarStore.carInfo.carType,
  167. "questionId": questionId,
  168. "sort": currentIndex.value,
  169. "stepType": usecarStore.carInfo.stepType,
  170. "tempId": questionBank.value.questionDoTemp.id
  171. };
  172. const { data: res } = await config_api.getQuestionApi(obj);
  173. questionBank.value = res;
  174. curOption.value.isNext = "";
  175. initOptionArr();
  176. }
  177. async function quesIdListClick(id, index) {
  178. curOption.value = {};
  179. currentIndex.value = index;
  180. questionBank.value = {};
  181. getQuestionFn();
  182. show.value = false;
  183. }
  184. const curOption = common_vendor.ref({});
  185. async function chooseOption(item) {
  186. if (curOption.value.answer)
  187. return;
  188. if (questionBank.value.types != 2) {
  189. item.answer = item.key;
  190. curOption.value = item;
  191. submitAnswerResultFn();
  192. } else if (questionBank.value.types == 2) {
  193. if (!curOption.value.ans)
  194. curOption.value.ans = "";
  195. if (curOption.value.ans.includes(item.key)) {
  196. curOption.value.ans = curOption.value.ans.replace(item.key, "");
  197. return;
  198. }
  199. curOption.value.ans = (curOption.value.ans + item.key).split("").sort().join("");
  200. }
  201. }
  202. async function submitAnswerResultFn() {
  203. let obj = {
  204. answer: curOption.value.answer,
  205. carType: usecarStore.carInfo.carType,
  206. questionId: questionBank.value.id,
  207. result: curOption.value.answer == questionBank.value.answer ? "0" : "1",
  208. stepType: usecarStore.carInfo.stepType,
  209. tempId: questionBank.value.questionDoTemp.id
  210. };
  211. await config_api.submitAnswerResultApi(obj);
  212. if (curOption.value.answer == questionBank.value.answer) {
  213. console.log("答对了");
  214. curOption.value = {};
  215. questionBank.value = {};
  216. yesNum.value++;
  217. usequestionStore.lookList(questionBank.value.id);
  218. console.log(usequestionStore.wrongList);
  219. nextQuestion(1);
  220. } else {
  221. noNum.value++;
  222. usequestionStore.setList(questionBank.value.id);
  223. console.log(usequestionStore.wrongList);
  224. }
  225. }
  226. async function questionWrongColleFn() {
  227. let isAdd = questionBank.value.isCollect == 1 ? "0" : "1";
  228. const obj = {
  229. "carType": usecarStore.carInfo.carType,
  230. "isAdd": isAdd,
  231. "questionId": questionBank.value.id,
  232. "stepType": usecarStore.carInfo.stepType
  233. };
  234. await config_api.questionWrongColle(obj);
  235. questionBank.value.isCollect = isAdd;
  236. console.log(questionBank.value.isCollect);
  237. }
  238. return (_ctx, _cache) => {
  239. return common_vendor.e({
  240. a: common_vendor.o(($event) => changeNav(1)),
  241. b: currentNav.value == 1 ? 1 : "",
  242. c: common_vendor.o(($event) => changeNav(2)),
  243. d: currentNav.value == 2 ? 1 : "",
  244. e: common_vendor.p({
  245. leftText: " ",
  246. title: "",
  247. safeAreaInsetTop: false,
  248. autoBack: true
  249. }),
  250. f: common_vendor.t(types.value[questionBank.value.types - 1]),
  251. g: questionBank.value.types == 2 ? 1 : "",
  252. h: questionBank.value.types == 3 ? 1 : "",
  253. i: common_vendor.t(questionBank.value.title),
  254. j: common_vendor.o(($event) => speak(questionBank.value.title)),
  255. k: questionBank.value.img
  256. }, questionBank.value.img ? {
  257. l: questionBank.value.img
  258. } : {}, {
  259. m: common_vendor.f(questionBank.value.optionArr, (item, index, i0) => {
  260. var _a, _b;
  261. return common_vendor.e(questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer) ? common_vendor.e({
  262. a: (_a = curOption.value.ans) == null ? void 0 : _a.includes(item.key)
  263. }, ((_b = curOption.value.ans) == null ? void 0 : _b.includes(item.key)) ? {
  264. b: "d3f13873-1-" + i0,
  265. c: common_vendor.p({
  266. name: "checkmark-circle-fill",
  267. color: "#55ff7f",
  268. size: "20"
  269. })
  270. } : {}, {
  271. d: common_vendor.t(item.key),
  272. e: common_vendor.t(item.text)
  273. }) : common_vendor.e({
  274. f: !curOption.value.key && questionBank.value.types != 2
  275. }, !curOption.value.key && questionBank.value.types != 2 ? {} : questionBank.value.answer.includes(item.key) ? {
  276. h: "d3f13873-2-" + i0,
  277. i: common_vendor.p({
  278. name: "checkmark-circle-fill",
  279. color: "#55ff7f",
  280. size: "20"
  281. })
  282. } : {
  283. j: "d3f13873-3-" + i0,
  284. k: common_vendor.p({
  285. name: "close-circle-fill",
  286. color: "#ff0000",
  287. size: "20"
  288. })
  289. }, {
  290. g: questionBank.value.answer.includes(item.key),
  291. l: questionBank.value.types != 3
  292. }, questionBank.value.types != 3 ? {
  293. m: common_vendor.t(item.key)
  294. } : {}, {
  295. n: common_vendor.t(item.text)
  296. }), {
  297. o: common_vendor.o(($event) => chooseOption(item))
  298. });
  299. }),
  300. n: questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer),
  301. o: curOption.value.answer && questionBank.value.answer != curOption.value.answer
  302. }, curOption.value.answer && questionBank.value.answer != curOption.value.answer ? common_vendor.e({
  303. p: questionBank.value.types == 3
  304. }, questionBank.value.types == 3 ? {
  305. q: common_vendor.t(questionBank.value.answer == "false" ? "错误" : "正确")
  306. } : {
  307. r: common_vendor.t(questionBank.value.answer)
  308. }, {
  309. s: questionBank.value.types == 3
  310. }, questionBank.value.types == 3 ? {
  311. t: common_vendor.t(curOption.value.answer == "false" ? "错误" : "正确")
  312. } : {
  313. v: common_vendor.t(curOption.value.answer)
  314. }) : {}, {
  315. w: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(-1), 500)),
  316. x: common_vendor.unref(currentIndex) == 0 ? 1 : "",
  317. y: common_vendor.unref(currentIndex) == 0,
  318. z: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(1), 500)),
  319. A: common_vendor.unref(currentIndex) >= common_vendor.unref(quesIdList).length - 1 ? 1 : "",
  320. B: common_vendor.unref(currentIndex) >= common_vendor.unref(quesIdList).length - 1,
  321. C: currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer
  322. }, currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer ? {
  323. D: common_vendor.t(questionBank.value.resolving)
  324. } : {}, {
  325. E: common_vendor.t(yesNum.value),
  326. F: common_vendor.t(noNum.value),
  327. G: common_vendor.t(common_vendor.unref(currentIndex) + 1),
  328. H: common_vendor.t(common_vendor.unref(quesIdList).length),
  329. I: common_assets._imports_0$3,
  330. J: common_vendor.o(($event) => common_vendor.isRef(showCommt) ? showCommt.value = true : showCommt = true),
  331. K: common_assets._imports_1$1,
  332. L: common_vendor.o(openPopup),
  333. M: questionBank.value.isCollect == "1"
  334. }, questionBank.value.isCollect == "1" ? {
  335. N: common_assets._imports_2$1
  336. } : {
  337. O: common_assets._imports_3$1
  338. }, {
  339. P: common_vendor.o(questionWrongColleFn),
  340. Q: common_vendor.t(yesNum.value),
  341. R: common_vendor.t(noNum.value),
  342. S: common_vendor.t(common_vendor.unref(currentIndex) + 1),
  343. T: common_vendor.t(common_vendor.unref(quesIdList).length),
  344. U: common_vendor.f(common_vendor.unref(quesIdList), (item, index, i0) => {
  345. return {
  346. a: common_vendor.t(index + 1),
  347. b: index == common_vendor.unref(currentIndex) ? 1 : "",
  348. c: index,
  349. d: common_vendor.o(($event) => quesIdListClick(item, index), index)
  350. };
  351. }),
  352. V: common_vendor.o(closePopup),
  353. W: common_vendor.o(openPopup),
  354. X: common_vendor.p({
  355. show: show.value,
  356. mode: "bottom",
  357. round: "20",
  358. closeable: true
  359. }),
  360. Y: common_vendor.o(common_vendor.m(($event) => common_vendor.isRef(contentStr) ? contentStr.value = $event : contentStr = $event, {
  361. trim: true
  362. }, true)),
  363. Z: common_vendor.p({
  364. placeholder: "请输入反馈内容",
  365. maxlength: "300",
  366. modelValue: common_vendor.unref(contentStr)
  367. }),
  368. aa: common_vendor.o(submitCommt),
  369. ab: common_vendor.p({
  370. text: "提 交",
  371. type: "primary"
  372. }),
  373. ac: common_vendor.o(showCommtClose),
  374. ad: common_vendor.p({
  375. show: common_vendor.unref(showCommt),
  376. mode: "bottom",
  377. round: "20rpx",
  378. closeable: true
  379. })
  380. });
  381. };
  382. }
  383. };
  384. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d3f13873"]]);
  385. wx.createPage(MiniProgramPage);