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

"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_assets = require("../../../common/assets.js");
const store_modules_wrongQuestionBook = require("../../../store/modules/wrongQuestionBook.js");
const config_api = require("../../../config/api.js");
require("../../../uni_modules/uview-plus/index.js");
const store_modules_car = require("../../../store/modules/car.js");
const uni_modules_uviewPlus_libs_function_debounce = require("../../../uni_modules/uview-plus/libs/function/debounce.js");
if (!Array) {
const _easycom_up_navbar2 = common_vendor.resolveComponent("up-navbar");
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
const _easycom_up_popup2 = common_vendor.resolveComponent("up-popup");
const _easycom_up_textarea2 = common_vendor.resolveComponent("up-textarea");
const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
(_easycom_up_navbar2 + _easycom_up_icon2 + _easycom_up_popup2 + _easycom_up_textarea2 + _easycom_up_button2)();
}
const _easycom_up_navbar = () => "../../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
const _easycom_up_icon = () => "../../../uni_modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_up_popup = () => "../../../uni_modules/uview-plus/components/u-popup/u-popup.js";
const _easycom_up_textarea = () => "../../../uni_modules/uview-plus/components/u-textarea/u-textarea.js";
const _easycom_up_button = () => "../../../uni_modules/uview-plus/components/u-button/u-button.js";
if (!Math) {
(_easycom_up_navbar + _easycom_up_icon + _easycom_up_popup + _easycom_up_textarea + _easycom_up_button)();
}
const _sfc_main = {
__name: "wrongQuestions",
setup(__props) {
function speak(text) {
const speech = new SpeechSynthesisUtterance(text);
window.speechSynthesis.speak(speech);
}
let usewrongQuestion = store_modules_wrongQuestionBook.questionStore();
const currentNav = common_vendor.ref("1");
const types = common_vendor.ref([
"单选题",
"多选题",
"判断题"
]);
const yesNum = common_vendor.ref(0);
const noNum = common_vendor.ref(0);
let usecarStore = store_modules_car.carStore();
function changeNav(val) {
console.log(window);
if (currentNav.value == val)
return;
currentNav.value = val;
}
const show = common_vendor.ref(false);
function closePopup() {
show.value = false;
}
function openPopup() {
show.value = true;
}
let showCommt = common_vendor.ref(false);
let contentStr = common_vendor.ref("");
function showCommtClose() {
showCommt.value = false;
contentStr.value = "";
}
async function submitCommt() {
if (!contentStr.value)
return common_vendor.index.$u.toast("请输入内容");
let obj = {
content: contentStr.value,
questionId: questionBank.value.id
};
const res = await config_api.questionCommentAdd(obj);
if (res.errorcode == 0) {
common_vendor.index.$u.toast("提交成功,感谢您的反馈");
showCommt.value = false;
}
}
let questionType = common_vendor.ref(1);
common_vendor.onLoad((options) => {
let isHigh = options.isHigh ? options.isHigh : "";
if (options.wrong) {
questionType.value = options.wrong;
findQuestionListFn(options.wrong, isHigh);
}
});
const questionBank = common_vendor.ref({});
let questionBankList = common_vendor.ref([]);
let currentIndex = common_vendor.ref(0);
async function findQuestionListFn(type, isHigh) {
let obj = {
"carType": usecarStore.carInfo.carType,
"chapter": usecarStore.carInfo.chapter,
"isHigh": isHigh,
"stepType": usecarStore.carInfo.stepType,
"type": type
};
const { data: res } = await config_api.findQuestionList(obj);
if (!res.length) {
common_vendor.index.$u.toast("暂无错题");
setTimeout(() => {
return common_vendor.index.navigateBack();
}, 1500);
return;
}
questionBank.value = res[0];
questionBankList.value = res;
initOptionArr();
}
function initOptionArr() {
questionBank.value.optionArr = [];
let abcd = [
"a",
"b",
"c",
"d",
"e",
"f"
];
abcd.forEach((k, i) => {
let option = "option" + k;
if (questionBank.value[option]) {
let obj = {
key: k.toLocaleUpperCase(),
text: questionBank.value[option],
index: i + 1
};
questionBank.value.optionArr.push(obj);
}
});
if (questionBank.value.types == 3) {
questionBank.value.optionArr[0].key = "true";
questionBank.value.optionArr[1].key = "false";
}
}
async function nextQuestion(num) {
if (questionBank.value.types == 2 && curOption.value.ans) {
if (!curOption.value.answer) {
curOption.value.answer = curOption.value.ans;
}
if (questionBank.value.answer != curOption.value.ans && curOption.value.isNext != "next") {
curOption.value.isNext = "next";
noNum.value++;
return false;
}
if (curOption.value.answer == questionBank.value.answer) {
yesNum.value++;
if (questionType.value == 1) {
usewrongQuestion.deleteWrongOrColFn(questionBank.value.id).then(() => {
questionBankList.value.splice(currentIndex.value, 1);
if (currentIndex.value >= questionBankList.value.length - 1) {
currentIndex.value = 0;
}
if (num == 0)
return;
getQuestionFn();
common_vendor.index.$u.toast("题目已删除");
return;
});
}
if (num == 0)
return;
}
}
curOption.value = {};
currentIndex.value = currentIndex.value + num;
getQuestionFn();
}
async function getQuestionFn() {
if (!questionBankList.value.length) {
common_vendor.index.$u.toast("已全部刷完");
setTimeout(() => {
common_vendor.index.navigateBack();
}, 1500);
return;
}
questionBank.value = questionBankList.value[currentIndex.value];
curOption.value = {};
curOption.value.isNext = "";
initOptionArr();
}
async function questionBankListClick(id, index) {
curOption.value = {};
currentIndex.value = index;
getQuestionFn();
show.value = false;
}
const curOption = common_vendor.ref({});
async function chooseOption(item) {
if (curOption.value.answer)
return;
if (questionBank.value.types != 2) {
item.answer = item.key;
curOption.value = item;
if (curOption.value.answer == questionBank.value.answer) {
yesNum.value++;
if (questionType.value == 1) {
usewrongQuestion.deleteWrongOrColFn(questionBank.value.id).then(() => {
questionBankList.value.splice(currentIndex.value, 1);
if (currentIndex.value >= questionBankList.value.length - 1) {
currentIndex.value = 0;
}
getQuestionFn();
common_vendor.index.$u.toast("题目已删除");
});
}
} else {
noNum.value++;
}
} else if (questionBank.value.types == 2) {
if (!curOption.value.ans)
curOption.value.ans = "";
if (curOption.value.ans.includes(item.key)) {
curOption.value.ans = curOption.value.ans.replace(item.key, "");
return;
}
curOption.value.ans = (curOption.value.ans + item.key).split("").sort().join("");
}
}
async function questionWrongColleFn() {
let isAdd = questionBank.value.isCollect == 1 ? "0" : "1";
const obj = {
"carType": usecarStore.carInfo.carType,
"isAdd": isAdd,
"questionId": questionBank.value.id,
"stepType": usecarStore.carInfo.stepType
};
await config_api.questionWrongColle(obj);
questionBank.value.isCollect = isAdd;
console.log(questionBank.value.isCollect);
}
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.o(($event) => changeNav(1)),
b: currentNav.value == 1 ? 1 : "",
c: common_vendor.o(($event) => changeNav(2)),
d: currentNav.value == 2 ? 1 : "",
e: common_vendor.p({
leftText: " ",
title: "",
safeAreaInsetTop: false,
autoBack: true
}),
f: common_vendor.t(types.value[questionBank.value.types - 1]),
g: questionBank.value.types == 2 ? 1 : "",
h: questionBank.value.types == 3 ? 1 : "",
i: common_vendor.t(questionBank.value.title),
j: common_vendor.o(($event) => speak(questionBank.value.title)),
k: questionBank.value.img
}, questionBank.value.img ? {
l: questionBank.value.img
} : {}, {
m: common_vendor.f(questionBank.value.optionArr, (item, index, i0) => {
var _a, _b;
return common_vendor.e(questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer) ? common_vendor.e({
a: (_a = curOption.value.ans) == null ? void 0 : _a.includes(item.key)
}, ((_b = curOption.value.ans) == null ? void 0 : _b.includes(item.key)) ? {
b: "4320d38d-1-" + i0,
c: common_vendor.p({
name: "checkmark-circle-fill",
color: "#55ff7f",
size: "20"
})
} : {}, {
d: common_vendor.t(item.key),
e: common_vendor.t(item.text)
}) : common_vendor.e({
f: !curOption.value.key && questionBank.value.types != 2
}, !curOption.value.key && questionBank.value.types != 2 ? {} : questionBank.value.answer.includes(item.key) ? {
h: "4320d38d-2-" + i0,
i: common_vendor.p({
name: "checkmark-circle-fill",
color: "#55ff7f",
size: "20"
})
} : {
j: "4320d38d-3-" + i0,
k: common_vendor.p({
name: "close-circle-fill",
color: "#ff0000",
size: "20"
})
}, {
g: questionBank.value.answer.includes(item.key),
l: questionBank.value.types != 3
}, questionBank.value.types != 3 ? {
m: common_vendor.t(item.key)
} : {}, {
n: common_vendor.t(item.text)
}), {
o: common_vendor.o(($event) => chooseOption(item))
});
}),
n: questionBank.value.types == 2 && (!curOption.value.answer || curOption.value.answer == questionBank.value.answer),
o: curOption.value.answer && questionBank.value.answer != curOption.value.answer
}, curOption.value.answer && questionBank.value.answer != curOption.value.answer ? common_vendor.e({
p: questionBank.value.types == 3
}, questionBank.value.types == 3 ? {
q: common_vendor.t(questionBank.value.answer == "false" ? "错误" : "正确")
} : {
r: common_vendor.t(questionBank.value.answer)
}, {
s: questionBank.value.types == 3
}, questionBank.value.types == 3 ? {
t: common_vendor.t(curOption.value.answer == "false" ? "错误" : "正确")
} : {
v: common_vendor.t(curOption.value.answer)
}) : {}, {
w: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(-1), 500)),
x: common_vendor.unref(currentIndex) == 0 ? 1 : "",
y: common_vendor.unref(currentIndex) == 0,
z: common_vendor.unref(currentIndex) == common_vendor.unref(questionBankList).length - 1
}, common_vendor.unref(currentIndex) == common_vendor.unref(questionBankList).length - 1 ? {
A: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(0), 500)),
B: curOption.value.answer ? 1 : "",
C: curOption.value.answer
} : {
D: common_vendor.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(1), 500)),
E: common_vendor.unref(currentIndex) >= common_vendor.unref(questionBankList).length - 1 ? 1 : "",
F: common_vendor.unref(currentIndex) >= common_vendor.unref(questionBankList).length - 1
}, {
G: currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer
}, currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer ? {
H: common_vendor.t(questionBank.value.resolving)
} : {}, {
I: common_vendor.t(yesNum.value),
J: common_vendor.t(noNum.value),
K: common_vendor.t(common_vendor.unref(currentIndex) + 1),
L: common_vendor.t(common_vendor.unref(questionBankList).length),
M: common_assets._imports_0$3,
N: common_vendor.o(($event) => common_vendor.isRef(showCommt) ? showCommt.value = true : showCommt = true),
O: common_assets._imports_1$1,
P: common_vendor.o(openPopup),
Q: questionBank.value.isCollect == "1"
}, questionBank.value.isCollect == "1" ? {
R: common_assets._imports_2$1
} : {
S: common_assets._imports_3$1
}, {
T: common_vendor.o(questionWrongColleFn),
U: common_vendor.t(yesNum.value),
V: common_vendor.t(noNum.value),
W: common_vendor.t(common_vendor.unref(currentIndex) + 1),
X: common_vendor.t(common_vendor.unref(questionBankList).length),
Y: common_vendor.f(common_vendor.unref(questionBankList), (item, index, i0) => {
return {
a: common_vendor.t(index + 1),
b: index == common_vendor.unref(currentIndex) ? 1 : "",
c: index,
d: common_vendor.o(($event) => questionBankListClick(item, index), index)
};
}),
Z: common_vendor.o(closePopup),
aa: common_vendor.o(openPopup),
ab: common_vendor.p({
show: show.value,
mode: "bottom",
round: "20",
closeable: true
}),
ac: common_vendor.o(common_vendor.m(($event) => common_vendor.isRef(contentStr) ? contentStr.value = $event : contentStr = $event, {
trim: true
}, true)),
ad: common_vendor.p({
placeholder: "请输入反馈内容",
maxlength: "300",
modelValue: common_vendor.unref(contentStr)
}),
ae: common_vendor.o(submitCommt),
af: common_vendor.p({
text: "提 交",
type: "primary"
}),
ag: common_vendor.o(showCommtClose),
ah: common_vendor.p({
show: common_vendor.unref(showCommt),
mode: "bottom",
round: "20rpx",
closeable: true
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4320d38d"]]);
wx.createPage(MiniProgramPage);