From 9f916f98c6cc6827c84da18fbc9a5e2cacbefc0a Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期二, 02 四月 2024 16:20:08 +0800
Subject: [PATCH] Merge refs/remotes/origin/master into refs/heads/master

---
 packageBookService/pages/bookServices/examination/examination.js |   54 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/packageBookService/pages/bookServices/examination/examination.js b/packageBookService/pages/bookServices/examination/examination.js
index 83953d8..727756c 100644
--- a/packageBookService/pages/bookServices/examination/examination.js
+++ b/packageBookService/pages/bookServices/examination/examination.js
@@ -45,6 +45,8 @@
     saveTime: 20,
     isNight: false,
     sliderValue: 0, // 瀛椾綋婊戝潡
+    startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿
+    pauseTime: 0 //鏆傚仠鏃堕棿 
   },
 
   /**
@@ -110,6 +112,9 @@
         }
       }, 1000)
     }
+    this.setData({
+      startTime: Date.now()
+    })
   },
 
   /**
@@ -118,6 +123,13 @@
   onHide() {
     if (wx.timer) {
       clearInterval(wx.timer)
+    }
+    this.setData({
+      pauseTime: Date.now()
+    })
+    if (wx.getStorageSync(app.config.tokenKey)) {
+      let duration = this.data.pauseTime - this.data.startTime
+      this.count(duration)
     }
   },
 
@@ -131,6 +143,32 @@
     if (this.data.countdownInterval !== null) {
       clearInterval(this.data.countdownInterval)
     }
+    this.setData({
+      pauseTime: Date.now()
+    })
+    if (wx.getStorageSync(app.config.tokenKey)) {
+      let duration = this.data.pauseTime - this.data.startTime
+      this.count(duration)
+    }
+  },
+
+  count(timeStr) {
+    const data = {
+      appRefCode: app.config.appRefCode,
+      type: 'LearningTime', //缁熻绫诲瀷--闃呰鏃堕暱
+      data: timeStr + '', //缁熻鍐呭--鏃堕暱姣
+      event: 'LearningTime',
+      sysType: 'App'
+    }
+    //闃呰鍟嗗搧鐨刬d
+    if (this.data.bookId) {
+      data.productId = this.data.bookId
+    }
+    //闃呰璧勬簮鐨刬d
+    // if (product.cmsItemId) {
+    //   data.cmsItemId = product.cmsItemId
+    // }
+    app.MG.job.newJobWithApiNewEvent(data).then((res) => {})
   },
 
   /**
@@ -257,7 +295,9 @@
   viewParsing() {
     if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') {
       const item = this.data.questionDataList[this.data.currentIndex]
-      if (!item.isComplete) this.handleQuestion(this.data.currentIndex)
+      if (!item.isComplete) {
+        this.handleQuestion(this.data.currentIndex)
+      }
     }
   },
   // 鐐瑰嚮绛旈鍗¤烦杞鐩�
@@ -730,7 +770,7 @@
             questionObj.questionType == 'multipleChoice'
           ) {
             try {
-              questionObj.answer = JSON.parse(questionObj.answer)
+              questionObj.answer = JSON.parse(questionObj.answer).toString()
             } catch (error) {
               questionObj.answer = item.Embedded_QuestionBank_Answer
             }
@@ -1162,9 +1202,9 @@
             questionObj.questionType == 'multipleChoice'
           ) {
             try {
-              questionObj.answer = JSON.parse(questionObj.answer)
+              questionObj.answer = JSON.parse(questionObj.answer).toString()
             } catch (error) {
-              //
+              questionObj.answer = item.Embedded_QuestionBank_Answer
             }
           }
           // 濉┖棰樻敼閫�
@@ -1362,9 +1402,9 @@
           questionObj.questionType == 'multipleChoice'
         ) {
           try {
-            questionObj.answer = JSON.parse(questionObj.answer)
+            questionObj.answer = JSON.parse(questionObj.answer).toString()
           } catch (error) {
-            //
+            questionObj.answer = item.Embedded_QuestionBank_Answer
           }
         }
         // 濉┖棰樻敼閫�
@@ -1606,7 +1646,7 @@
             questionObj.questionType == 'multipleChoice'
           ) {
             try {
-              questionObj.answer = JSON.parse(questionObj.answer)
+              questionObj.answer = JSON.parse(questionObj.answer).toString()
             } catch (error) {
               questionObj.answer = item.Embedded_QuestionBank_Answer
             }

--
Gitblit v1.9.1