From 1cad6ba03f8cb848352c6739c54395128e73485f Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 26 三月 2024 16:00:53 +0800
Subject: [PATCH] 资源购买页布局调整

---
 packageBookService/pages/bookServices/examination/examination.js |   94 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 71 insertions(+), 23 deletions(-)

diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js
index 3bec06c..44262d4 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, // 瀛椾綋婊戝潡
   },
 
   /**
@@ -90,6 +91,11 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
+    if (this.data.answerType != 'mock') {
+      if (wx.timer) {
+        clearInterval(wx.timer)
+      }
+    }
     if (this.data.answerType == 'mock') {
       if (wx.timer) {
         clearInterval(wx.timer)
@@ -109,12 +115,18 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */
   onHide() {
+    if (wx.timer) {
+      clearInterval(wx.timer)
+    }
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
    */
   onUnload(e) {
+    if (wx.timer) {
+      clearInterval(wx.timer)
+    }
     if (this.data.countdownInterval !== null) {
       clearInterval(this.data.countdownInterval)
     }
@@ -158,7 +170,12 @@
       }
     });
   },
-
+  onChangeSlider(e) {
+    this.setData({
+      sliderValue: e.detail.value
+    })
+    console.log(e.detail.value);
+  },
   // 杩斿洖
   goBack() {
     console.log(this.data.submitStatus);
@@ -258,8 +275,18 @@
         item.isUserAnswer = this.isHaveAnswer(radioChecked)
       }
     })
+    const cardListUpdata = this.data.cardList
+    cardListUpdata.forEach(item => {
+      item.infoList.forEach(citem => {
+        if (citem.id == id) {
+          citem.userAnswer = radioChecked
+          citem.isUserAnswer = this.isHaveAnswer(radioChecked)
+        }
+      })
+    })
     this.setData({
-      questionDataList: questionList
+      questionDataList: questionList,
+      cardList: cardListUpdata
     })
     if (this.data.answerType == 'mock') {
       this.setData({
@@ -271,16 +298,27 @@
   onChangeInput(e) {
     const inputData = e.detail.value.detail.value
     const id = e.detail.value.currentTarget.dataset.id
-    const index = e.detail.value.currentTarget.dataset.index
+    const index = Number(e.detail.value.currentTarget.dataset.index)
+    console.log(index);
     const questionList = this.data.questionDataList
     questionList.forEach(item => {
       if (item.id == id) {
-        item.userAnswer[index] = inputData,
-          item.isUserAnswer = this.isHaveAnswer(item.userAnswer)
+        item.userAnswer[index] = inputData
+        return item.isUserAnswer = this.isHaveAnswer(inputData)
       }
     })
+    const cardListUpdata = this.data.cardList
+    cardListUpdata.forEach(item => {
+      item.infoList.forEach(citem => {
+        if (citem.id == id) {
+          citem.userAnswer[index] = inputData
+          return citem.isUserAnswer = this.isHaveAnswer(inputData)
+        }
+      })
+    })
     this.setData({
-      questionDataList: questionList
+      questionDataList: questionList,
+      cardList: cardListUpdata,
     })
     if (this.data.answerType == 'mock') {
       this.setData({
@@ -324,10 +362,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') {
@@ -385,7 +425,9 @@
       })
       child.openTestReportDialog()
     }
-
+    this.setData({
+      loading: false
+    })
   },
   // 鍒濆鍖栧嚱鏁�
   async init() {
@@ -405,9 +447,15 @@
       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()
@@ -437,18 +485,19 @@
             let oldQuestionList = []
             oldQuestionList = await this.getMockQuestionList()
             const userAnswerList = await this.getMockAnswer()
-            await this.getMockDataList(oldQuestionList, userAnswerList)
             this.setData({
               'mockData.sumTime': oldMockData.time,
               cardList: oldQuestionList
             })
+            await this.getMockDataList(oldQuestionList, userAnswerList)
           }
           if (oldMockData.state == '0' || oldMockData.state == '1' || oldMockData.state == '2') {
             this.startCountdown()
           }
           if (oldMockData.state == '3') {
             this.setData({
-              submitStatus: true
+              submitStatus: true,
+              subjectiveNum: oldMockData.report.userScore
             })
           }
         }
@@ -563,19 +612,19 @@
             errorList: JSON.parse(res[0].value)
           })
         } catch (error) {
-
         }
       })
   },
   // 鑾峰彇棰樺簱棰樼洰
-  getQuestionList(oldData) {
+  async getQuestionList(oldData) {
     // 娓呯┖姝g‘棰樻暟璁板綍
     this.setData({
       cardList: [],
       correctNum: 0,
     })
     let flag = 0
-    this.data.idPathList.forEach((pathitem) => {
+    for (let index = 0; index < this.data.idPathList.length; index++) {
+      const pathitem = this.data.idPathList[index];
       const pathList = this.data.cardList
       pathList.push({
         path: pathitem.productLinkPath,
@@ -608,7 +657,7 @@
           size: 999
         }
       }
-      app.MG.store.getProductDetail(query).then((res) => {
+      await app.MG.store.getProductDetail(query).then((res) => {
         this.setData({
           total: res.datas.cmsDatas[0].datas.length
         })
@@ -738,13 +787,13 @@
           })
           this.setData({
             questionDataList: questionList,
-            cardList: cardUpdatedList
+            cardList: cardUpdatedList,
           })
         })
       })
-    })
+    }
     this.setData({
-      loading: false,
+      loading: false
     })
   },
   // 鎵规敼棰樼洰 锛堢粌涔狅紝鎴戠殑閿欓锛屾垜鐨勬敹钘�,锛岀粍鍗凤級
@@ -1368,7 +1417,8 @@
   // 鑾峰彇缁勫嵎棰樼洰鍒楄〃
   async getMockDataList(questionList, oldList) {
     const questionDataList = this.data.questionDataList
-    questionList.forEach(async (pathitem, pathindex) => {
+    for (let pathindex = 0; pathindex < questionList.length; pathindex++) {
+      const pathitem = questionList[pathindex];
       let itemIds = []
       pathitem.infoList.forEach(item => {
         itemIds.push(item.id + '')
@@ -1427,7 +1477,7 @@
             isUserAnswer: oldObj ? this.isHaveAnswer(oldObj.userAnswer) : false,
             isRight: oldObj ? oldObj.isRight : null,
             // isComplete: oldObj ? oldObj.isComplete : false,
-            isComplete: this.data.mockData.state == '3' ? true : oldObj ? this.isHaveAnswer(oldObj.answer) : false,
+            isComplete: this.data.mockData.state == '3' ? true : false,
             isCollect: this.data.collectList.indexOf(item.id) > -1 ? true : false,
             isUnfold: '' // 鎺у埗瑙f瀽鐨勬姌鍙犻潰鏉挎槸鍚﹀睍寮�
           }
@@ -1495,12 +1545,10 @@
             questionDataList: questionList,
             cardList: cardUpdatedList
           })
-          console.log('缁勫嵎棰樼洰鍒楄〃', this.data.questionDataList);
         })
       })
-    })
+    }
     this.setData({
-      // questionDataList: questionDataList,
       loading: false
     })
   },

--
Gitblit v1.9.1