From b2a6887c94cc7887b03ba1cce578e3fc59a62259 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期三, 27 三月 2024 16:12:28 +0800
Subject: [PATCH] 1

---
 packageBookService/pages/bookServices/examination/examination.js |   89 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 67 insertions(+), 22 deletions(-)

diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js
index e444433..9d544ed 100644
--- a/packageBookService/pages/bookServices/examination/examination.js
+++ b/packageBookService/pages/bookServices/examination/examination.js
@@ -41,7 +41,8 @@
       answer: []
     },
     saveTime: 20,
-    isNight: false
+    isNight: false,
+    sliderValue: 0, // 瀛椾綋婊戝潡
   },
 
   /**
@@ -169,7 +170,12 @@
       }
     });
   },
-
+  onChangeSlider(e) {
+    this.setData({
+      sliderValue: e.detail.value
+    })
+    console.log(e.detail.value);
+  },
   // 杩斿洖
   goBack() {
     console.log(this.data.submitStatus);
@@ -240,10 +246,11 @@
     this.setData({
       currentIndex: e.detail.index
     })
-    if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') {
-      let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0
-      let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer)
-      if (flag) this.handleQuestion(e.detail.index)
+    let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0
+    const item = this.data.questionDataList[index]
+    if ((this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
+      let flag = this.isHaveAnswer(item.userAnswer)
+      if (flag) this.handleQuestion(index)
     }
   },
   // 鐐瑰嚮绛旈鍗¤烦杞鐩�
@@ -263,21 +270,47 @@
     const id = e.detail.value.currentTarget.dataset.id
     const radioChecked = e.detail.value.detail.value
     const questionList = this.data.questionDataList
-    questionList.forEach(item => {
-      if (item.id == id) {
+    // 鎴戠殑閿欓鍜屾垜鐨勬敹钘忔ā寮忎笅锛屽崟閫夐閫夋嫨浜嗙洿鎺ユ壒鏀�
+    for (let index = 0; index < questionList.length; index++) {
+      const item = questionList[index];
+      if (item.id == id && !item.isComplete) {
         item.userAnswer = radioChecked
         item.isUserAnswer = this.isHaveAnswer(radioChecked)
+        if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
+          debugger
+          let index = this.data.currentIndex - 1 >= 0 ? this.data.currentIndex - 1 : 0
+          this.handleQuestion(index)
+        }
       }
-    })
+    }
+    // questionList.forEach(item => {
+    //   if (item.id == id && !item.isComplete) {
+    //     item.userAnswer = radioChecked
+    //     item.isUserAnswer = this.isHaveAnswer(radioChecked)
+    //     if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
+    //       this.handleQuestion(this.data.currentIndex)
+    //     }
+    //   }
+    // })
     const cardListUpdata = this.data.cardList
-    cardListUpdata.forEach(item => {
-      item.infoList.forEach(citem => {
-        if (citem.id == id) {
+    for (let index = 0; index < cardListUpdata.length; index++) {
+      const item = cardListUpdata[index];
+      for (let cindex = 0; cindex < item.infoList.length; cindex++) {
+        const citem = item.infoList[cindex];
+        if (citem.id == id && !citem.isComplete) {
           citem.userAnswer = radioChecked
           citem.isUserAnswer = this.isHaveAnswer(radioChecked)
         }
-      })
-    })
+      }
+    }
+    // cardListUpdata.forEach(item => {
+    //   item.infoList.forEach(citem => {
+    //     if (citem.id == id && !citem.isComplete) {
+    //       citem.userAnswer = radioChecked
+    //       citem.isUserAnswer = this.isHaveAnswer(radioChecked)
+    //     }
+    //   })
+    // })
     this.setData({
       questionDataList: questionList,
       cardList: cardListUpdata
@@ -356,10 +389,12 @@
   },
   // 鎻愪氦閫昏緫
   submitPaper() {
+
     // 鍏抽棴閫�鍑洪〉闈㈢洃鍚�
     wx.disableAlertBeforeUnload()
     this.setData({
-      submitStatus: true
+      submitStatus: true,
+      loading: true
     })
     const child = this.selectComponent('#question-options')
     if (this.data.answerType == 'option' || this.data.answerType == 'errorQuestion' || this.data.answerType == 'mock') {
@@ -367,7 +402,7 @@
       const qustionList = this.data.questionDataList
       for (let index = 0; index < qustionList.length; index++) {
         const item = qustionList[index];
-        if (!item.isComplete) this.handleQuestion(index + 1)
+        if (!item.isComplete) this.handleQuestion(index)
       }
     }
     if (this.data.answerType == 'option') {
@@ -417,7 +452,9 @@
       })
       child.openTestReportDialog()
     }
-
+    this.setData({
+      loading: false
+    })
   },
   // 鍒濆鍖栧嚱鏁�
   async init() {
@@ -429,17 +466,23 @@
     })
     if (this.data.answerType == 'option') {
       if (this.data)
-        this.startCountdown()
-      this.setData({
-        countdownTime: 2 * 60 * 60 * 1000
-      })
+        // this.startCountdown()
+        this.setData({
+          countdownTime: 2 * 60 * 60 * 1000
+        })
       // 娴嬭瘯绛旈
       await this.getCollectIdList() // 鑾峰彇鏀惰棌id鍒楄〃
       await this.getErrorList()   // 鑾峰彇閿欓id鍒楄〃
     } else if (this.data.answerType == 'collectQuestion') {
+      this.setData({
+        submitStatus: true
+      })
       // 鎴戠殑鏀惰棌
       await this.getcollectId() // 鑾峰彇鏀惰棌棰樼洰
     } else if (this.data.answerType == 'errorQuestion') {
+      this.setData({
+        submitStatus: true
+      })
       // 鎴戠殑閿欓
       // loadings.value = true
       await this.getErrorIdList()
@@ -776,6 +819,8 @@
         })
       })
     }
+    // 鏈夐鐩啀寮�濮嬪�掕鏃�
+    if (this.data.questionDataList.length) this.startCountdown()
     this.setData({
       loading: false
     })
@@ -783,7 +828,7 @@
   // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級
   handleQuestion(num) {
     const questionList = this.data.questionDataList
-    const index = num - 1 >= 0 ? num - 1 : 0
+    const index = num
     if (questionList[index].isComplete) {
       // 棰樼洰宸插畬鎴愶紝璺宠繃
       return true

--
Gitblit v1.9.1