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

"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_assets = require("../../../common/assets.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 store_modules_wrongQuestionBook = require("../../../store/modules/wrongQuestionBook.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: "brushQuestions",
setup(__props) {
function speak(text) {
const speech = new SpeechSynthesisUtterance(text);
window.speechSynthesis.speak(speech);
}
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();
let usequestionStore = store_modules_wrongQuestionBook.questionStore();
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;
}
}
common_vendor.onLoad((options) => {
if (options.wrong) {
findQuestionListFn(options.wrong);
} else {
startQuestionFn();
}
});
const questionBank = common_vendor.ref({});
let quesIdList = common_vendor.ref([]);
let currentIndex = common_vendor.ref(0);
async function findQuestionListFn(type) {
let obj = {
"carType": usecarStore.carInfo.carType,
"chapter": usecarStore.carInfo.chapter,
"isHigh": "",
"stepType": usecarStore.carInfo.stepType,
"type": type
};
await config_api.findQuestionList(obj);
}
async function startQuestionFn() {
try {
common_vendor.index.showLoading({
title: "正在加载..."
});
let obj = {
carType: usecarStore.carInfo.carType,
stepType: usecarStore.carInfo.stepType,
volume: usecarStore.carInfo.volume,
types: usecarStore.carInfo.types,
sift: usecarStore.carInfo.sift,
contentType: usecarStore.carInfo.contentType,
knowType: usecarStore.carInfo.knowType,
chapter: usecarStore.carInfo.chapter,
city: usecarStore.carInfo.city
};
const { data: res } = await config_api.startQuestionApi(obj);
common_vendor.index.hideLoading();
questionBank.value = res.questionBank;
initOptionArr();
quesIdList.value = res.quesIdList;
currentIndex.value = quesIdList.value.findIndex((item) => item == questionBank.value.id);
} catch (e) {
common_vendor.index.hideLoading();
}
}
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;
await submitAnswerResultFn();
}
if (questionBank.value.answer != curOption.value.ans && curOption.value.isNext != "next") {
curOption.value.isNext = "next";
return false;
}
}
curOption.value = {};
currentIndex.value = currentIndex.value + num;
questionBank.value = {};
getQuestionFn();
}
async function getQuestionFn() {
console.log(currentIndex.value);
let questionId = quesIdList.value[currentIndex.value];
let obj = {
"carType": usecarStore.carInfo.carType,
"questionId": questionId,
"sort": currentIndex.value,
"stepType": usecarStore.carInfo.stepType,
"tempId": questionBank.value.questionDoTemp.id
};
const { data: res } = await config_api.getQuestionApi(obj);
questionBank.value = res;
curOption.value.isNext = "";
initOptionArr();
}
async function quesIdListClick(id, index) {
curOption.value = {};
currentIndex.value = index;
questionBank.value = {};
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;
submitAnswerResultFn();
} 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 submitAnswerResultFn() {
let obj = {
answer: curOption.value.answer,
carType: usecarStore.carInfo.carType,
questionId: questionBank.value.id,
result: curOption.value.answer == questionBank.value.answer ? "0" : "1",
stepType: usecarStore.carInfo.stepType,
tempId: questionBank.value.questionDoTemp.id
};
await config_api.submitAnswerResultApi(obj);
if (curOption.value.answer == questionBank.value.answer) {
console.log("答对了");
curOption.value = {};
questionBank.value = {};
yesNum.value++;
usequestionStore.lookList(questionBank.value.id);
console.log(usequestionStore.wrongList);
nextQuestion(1);
} else {
noNum.value++;
usequestionStore.setList(questionBank.value.id);
console.log(usequestionStore.wrongList);
}
}
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: "d3f13873-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: "d3f13873-2-" + i0,
i: common_vendor.p({
name: "checkmark-circle-fill",
color: "#55ff7f",
size: "20"
})
} : {
j: "d3f13873-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.o(($event) => common_vendor.unref(uni_modules_uviewPlus_libs_function_debounce.debounce)(nextQuestion(1), 500)),
A: common_vendor.unref(currentIndex) >= common_vendor.unref(quesIdList).length - 1 ? 1 : "",
B: common_vendor.unref(currentIndex) >= common_vendor.unref(quesIdList).length - 1,
C: currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer
}, currentNav.value == 2 || curOption.value.answer && curOption.value.answer != questionBank.value.answer ? {
D: common_vendor.t(questionBank.value.resolving)
} : {}, {
E: common_vendor.t(yesNum.value),
F: common_vendor.t(noNum.value),
G: common_vendor.t(common_vendor.unref(currentIndex) + 1),
H: common_vendor.t(common_vendor.unref(quesIdList).length),
I: common_assets._imports_0$3,
J: common_vendor.o(($event) => common_vendor.isRef(showCommt) ? showCommt.value = true : showCommt = true),
K: common_assets._imports_1$1,
L: common_vendor.o(openPopup),
M: questionBank.value.isCollect == "1"
}, questionBank.value.isCollect == "1" ? {
N: common_assets._imports_2$1
} : {
O: common_assets._imports_3$1
}, {
P: common_vendor.o(questionWrongColleFn),
Q: common_vendor.t(yesNum.value),
R: common_vendor.t(noNum.value),
S: common_vendor.t(common_vendor.unref(currentIndex) + 1),
T: common_vendor.t(common_vendor.unref(quesIdList).length),
U: common_vendor.f(common_vendor.unref(quesIdList), (item, index, i0) => {
return {
a: common_vendor.t(index + 1),
b: index == common_vendor.unref(currentIndex) ? 1 : "",
c: index,
d: common_vendor.o(($event) => quesIdListClick(item, index), index)
};
}),
V: common_vendor.o(closePopup),
W: common_vendor.o(openPopup),
X: common_vendor.p({
show: show.value,
mode: "bottom",
round: "20",
closeable: true
}),
Y: common_vendor.o(common_vendor.m(($event) => common_vendor.isRef(contentStr) ? contentStr.value = $event : contentStr = $event, {
trim: true
}, true)),
Z: common_vendor.p({
placeholder: "请输入反馈内容",
maxlength: "300",
modelValue: common_vendor.unref(contentStr)
}),
aa: common_vendor.o(submitCommt),
ab: common_vendor.p({
text: "提 交",
type: "primary"
}),
ac: common_vendor.o(showCommtClose),
ad: 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-d3f13873"]]);
wx.createPage(MiniProgramPage);