闫增涛
2024-04-02 9f916f98c6cc6827c84da18fbc9a5e2cacbefc0a
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'
    }
    //阅读商品的id
    if (this.data.bookId) {
      data.productId = this.data.bookId
    }
    //阅读资源的id
    // 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
            }