litian
2024-04-02 6a734d758720185f538e672c879121adb6732274
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) => {})
  },
  /**