From 8aeddcf766df9f7e3061d4d098b57afdf53db896 Mon Sep 17 00:00:00 2001
From: zhongshujie <2862698242@qq.com>
Date: 星期四, 19 十二月 2024 15:28:07 +0800
Subject: [PATCH] 骨架屏及选择选中后自动跳转

---
 packageBookService/pages/psychologyAnswer/psychologyAnswer.js |   51 +++++++++++++++++++++++----------------------------
 1 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/packageBookService/pages/psychologyAnswer/psychologyAnswer.js b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js
index 0b381f3..dc16d9a 100644
--- a/packageBookService/pages/psychologyAnswer/psychologyAnswer.js
+++ b/packageBookService/pages/psychologyAnswer/psychologyAnswer.js
@@ -282,22 +282,14 @@
   },
   // 鍒囨崲棰樼洰
   changeSwiper(e) {
-    let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0;
-    const item = this.data.questionDataList[index];
-    const lastItem = this.data.questionDataList[index + 1];
+    let index = e.detail.index;
+    const lastItem = this.data.questionDataList[index];
     this.setData({
       currentIndex: e.detail.index,
       showId: lastItem.id
     });
-    if (
-      (this.data.answerType == "collectQuestion" ||
-        this.data.answerType == "errorQuestion") &&
-      !item.isComplete
-    ) {
-      let flag = this.isHaveAnswer(item.userAnswer);
-      if (flag) this.handleQuestion(index);
-    }
   },
+
   // 鎴戠殑閿欓锛屾敹钘忔煡鐪嬭В鏋愭寜閽�
   viewParsing() {
     if (
@@ -396,6 +388,12 @@
         radioChange(citem)
       }
     }
+    const listLength = this.data.questionDataList.length - 1
+    if (this.data.currentIndex < listLength) {
+      this.setData({
+        currentIndex: this.data.currentIndex + 1
+      })
+    }
   },
   // 杈撳叆妗嗚Е鍙�
   onChangeInput(e) {
@@ -471,10 +469,6 @@
     // 鍏堥亶鍘嗘墍鏈夐鐩紝灏嗘湭鎵规敼鐨勯鐩壒鏀�
     const qustionList = this.data.questionDataList;
     if (qustionList.length) this.handleQuestion();
-    this.setData({
-      isShowDialog: true,
-      submitStatus: true,
-    })
     // 璁板綍鐢ㄦ埛绛旈鏁版嵁
     let saveData = [];
     for (let index = 0; index < this.data.questionDataList.length; index++) {
@@ -497,13 +491,15 @@
     });
     this.setData({
       loading: false,
-      showDialog: false,
+      isShowDialog: true,
+      submitStatus: true,
     });
   },
   // 鍒濆鍖栧嚱鏁�
   async init(isReset) {
     this.setData({
-      loading: false,
+      isShowDialog: false,
+      loading: true,
     });
     const questuionName = this.data.questuionName
     const questuionList = pastData.postData.list
@@ -552,7 +548,6 @@
     const questionList = this.data.questionDataList;
     const optionList = this.data.questionDataOptions;
     const scoreData = this.data.scoreDataList;
-    debugger
     for (let index = 0; index < questionList.length; index++) {
       const item = questionList[index];
       if (item.questionType == 'judge' && item.userAnswer) {
@@ -661,6 +656,7 @@
   },
   async restart() {
     this.setData({
+      isShowDialog: false,
       currentIndex: 0,
       submitStatus: false,
     });
@@ -724,25 +720,24 @@
           this.setData({
             questionDataList: newArr,
             scoreDataList: scoreArr,
+            loading: false,
           })
         } catch (error) {
           this.setData({
             questionDataList: newArr,
-            scoreDataList: scoreArr
+            scoreDataList: scoreArr,
+            loading: false,
           })
           console.log(error);
         }
+        const e = {
+          detail: {
+            index: 0
+          }
+        };
+        this.changeSwiper(e)
       });
   },
-
-
-
-
-
-
-
-
-
 
   // 璁板綍妯¤�冪瓟棰樻暟鎹�
   saveMockData() {

--
Gitblit v1.9.1