Explorar el Código

修复选择学校参数bug

shmily1213 hace 1 semana
padre
commit
0a9009a01a

+ 34 - 21
src/composables/useExam.ts

@@ -287,6 +287,12 @@ export const useExam = () => {
     if (!nextEnable.value) {
       return;
     }
+    // if (currentIndex.value < questionList.value.length - 1) {
+    //   currentIndex.value++;
+    //   setTimeout(() => {
+    //     subQuestionIndex.value = 0;
+    //   }, 300);
+    // }
     if (currentQuestion.value.subQuestions && currentQuestion.value.subQuestions.length > 0) {
       if (subQuestionIndex.value < currentQuestion.value.subQuestions.length - 1) {
         subQuestionIndex.value++;
@@ -295,9 +301,7 @@ export const useExam = () => {
         subQuestionIndex.value = 0;
       }
     } else {
-      if (currentIndex.value < questionList.value.length - 1) {
-        currentIndex.value++;
-      }
+      currentIndex.value++;
     }
   }
   // 上一题
@@ -305,26 +309,32 @@ export const useExam = () => {
     if (!prevEnable.value) {
       return;
     }
-    if (currentQuestion.value.subQuestions && currentQuestion.value.subQuestions.length > 0) {
-      if (subQuestionIndex.value > 0) {
-        subQuestionIndex.value--;
-      } else {
-        currentIndex.value--;
-      }
-    } else {
-      if (currentIndex.value > 0) {
-        currentIndex.value--;
-        // 如果上一个题是子题,那么,默认选中最后一个子题
-        const prevQuestion = questionList.value[currentIndex.value - 1];
-        if (prevQuestion.subQuestions && prevQuestion.subQuestions.length > 0) {
-          subQuestionIndex.value = prevQuestion.subQuestions.length - 1;
-        }
-      }
+    if (currentIndex.value > 0) {
+      currentIndex.value--;
+      setTimeout(() => {
+        subQuestionIndex.value = 0;
+      }, 300);
     }
+    // if (currentQuestion.value.subQuestions && currentQuestion.value.subQuestions.length > 0) {
+    //   if (subQuestionIndex.value > 0) {
+    //     subQuestionIndex.value--;
+    //   } else {
+    //     currentIndex.value--;
+    //   }
+    // } else {
+    //   if (currentIndex.value > 0) {
+    //     currentIndex.value--;
+    //     // 如果上一个题是子题,那么,默认选中最后一个子题
+    //     const prevQuestion = questionList.value[currentIndex.value - 1];
+    //     if (prevQuestion.subQuestions && prevQuestion.subQuestions.length > 0) {
+    //       subQuestionIndex.value = prevQuestion.subQuestions.length - 1;
+    //     }
+    //   }
+    // }
   }
   // 快速下一题
   const nextQuestionQuickly = () => {
-    if (currentIndex.value >= questionList.value.length - 1) {
+    if (!nextEnable.value) {
       return;
     }
     swiperDuration.value = 0;
@@ -337,7 +347,7 @@ export const useExam = () => {
   }
   // 快速上一题
   const prevQuestionQuickly = () => {
-    if (currentIndex.value <= 0) {
+    if (!prevEnable.value) {
       return;
     }
     swiperDuration.value = 0;
@@ -349,10 +359,13 @@ export const useExam = () => {
     }, 0);
   }
   // 通过下标切换题目
-  const changeIndex = (index: number) => {
+  const changeIndex = (index: number, subIndex?: number) => {
     swiperDuration.value = 0;
     setTimeout(() => {
       currentIndex.value = index;
+      if (!subIndex !== undefined) {
+        subQuestionIndex.value = subIndex || 0;
+      }
       setTimeout(() => {
         swiperDuration.value = 300;
       }, 0);

+ 1 - 4
src/pagesStudy/pages/exam-start/components/exam-stats-card.vue

@@ -134,10 +134,7 @@ const handleSubmit = () => {
 }
 const hanadleNavigate = (question: Study.Question, index: number) => {
   if (question.isSubQuestion) {
-    changeIndex(question.parentIndex || 0);
-    setTimeout(() => {
-      setSubQuestionIndex(question.subIndex || 0);
-    });
+    changeIndex(question.parentIndex || 0, question.subIndex || 0);
   } else {
     changeIndex(index);
   }

+ 0 - 7
src/pagesStudy/pages/exam-start/components/exam-swiper.vue

@@ -71,13 +71,6 @@ const emit = defineEmits<{
   (e: 'changeQuestion', question: Study.Question): void;
   (e: 'submit'): void;
 }>();
-const handleChangeSubQuestion = (index: number) => {
-  emit('changeSubQuestion', index);
-}
-
-const handleChangeQuestion = (question: Study.Question) => {
-  emit('changeQuestion', question);
-}
 
 const handleSwiperChange = (e: any) => {
   changeIndex(e.detail.current);

+ 3 - 1
src/pagesSystem/pages/bind-profile/bind-profile.vue

@@ -159,7 +159,9 @@ const handleSchoolSelect = () => {
   //   return;
   // }
   transferTo('/pagesSystem/pages/school-select/school-select', {
-    data: form.value
+    data: {
+      examType: form.value.examType || examTypeForm.value.examType,
+    }
   }).then(res => {
     const school = res as SchoolItem;
     form.value.schoolId = school.id;