|
@@ -45,14 +45,13 @@ export function useExam() {
|
|
|
list: [], // 试题列表
|
|
|
jieId: null, // 节Id
|
|
|
zhangId: null,
|
|
|
- nextZhangId: null,
|
|
|
nianji: null,
|
|
|
xueqi: null,
|
|
|
})
|
|
|
|
|
|
onLoad((options) => {
|
|
|
const {
|
|
|
- jieId,zhangId,nextZhangId,nianji,xueqi
|
|
|
+ jieId,zhangId,nianji,xueqi
|
|
|
} = options;
|
|
|
data.jieId = jieId; // 需要路由参数 节Id
|
|
|
data.zhangId = zhangId;// 需要路由参数 章Id
|
|
@@ -64,35 +63,12 @@ export function useExam() {
|
|
|
initPage();
|
|
|
})
|
|
|
|
|
|
- // 当前试题
|
|
|
- const activeQa = computed(() => data.list.length ? data.list[data.current] : null);
|
|
|
- // 第一题
|
|
|
- const isFirst = computed(() => {
|
|
|
- if (!activeQa.value) return false;
|
|
|
- return activeQa.value.id === data.list[0].id;
|
|
|
- })
|
|
|
- // 最后一题
|
|
|
- const isLast = computed(() => {
|
|
|
- if (!activeQa.value) return false;
|
|
|
- const clength = data.list.length;
|
|
|
- return activeQa.value.id === data.list[clength - 1].id;
|
|
|
- })
|
|
|
watch(() => data.list, (val) => {
|
|
|
const list = data.list.filter(item => item.reply!==null);
|
|
|
data.count = list.length;
|
|
|
},{deep: true})
|
|
|
|
|
|
|
|
|
- // 下一题
|
|
|
- function nextQuestion() {
|
|
|
- data.current = data.current + 1;
|
|
|
- }
|
|
|
-
|
|
|
- // 前一题
|
|
|
- function prevQuestion() {
|
|
|
- data.current = data.current - 1;
|
|
|
- }
|
|
|
-
|
|
|
// 初始化页面数据
|
|
|
async function initPage() {
|
|
|
const [err, cdata] = await catchError(httpUnit.getExamData({
|
|
@@ -142,15 +118,10 @@ export function useExam() {
|
|
|
|
|
|
return {
|
|
|
...toRefs(data),
|
|
|
- activeQa,
|
|
|
- isFirst,
|
|
|
- isLast,
|
|
|
rightAnswer,
|
|
|
wrongAnswer,
|
|
|
jifen,
|
|
|
|
|
|
- nextQuestion,
|
|
|
- prevQuestion,
|
|
|
handleSubmit,
|
|
|
initPage
|
|
|
}
|