From 6a734d758720185f538e672c879121adb6732274 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期二, 02 四月 2024 09:20:45 +0800
Subject: [PATCH] 代码合并,问题修改,学习

---
 packageDomain/pages/resourceDetails/myVideo/index.js |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/packageDomain/pages/resourceDetails/myVideo/index.js b/packageDomain/pages/resourceDetails/myVideo/index.js
index 04b67c6..421bf0d 100644
--- a/packageDomain/pages/resourceDetails/myVideo/index.js
+++ b/packageDomain/pages/resourceDetails/myVideo/index.js
@@ -35,7 +35,9 @@
     submitType: "new", //  鏂板缓 or 缂栬緫
     noteId: '',
 
-    videoChange: true
+    videoChange: true,
+    startTime: "", //杩涘叆椤甸潰褰撳墠鏃堕棿
+    pauseTime: 0 //鏆傚仠鏃堕棿
   },
   // 鏍煎紡鍖栫瑪璁版椂闂�
   convertTimestamp(timestamp) {
@@ -86,6 +88,9 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
   onShow() {
+    this.setData({
+      startTime: Date.now()
+    })
 
   },
 
@@ -93,16 +98,45 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
    */
   onHide() {
-
+    this.setData({
+      pauseTime: Date.now()
+    })
+    if (wx.getStorageSync(app.config.tokenKey)) {
+      let duration = this.data.pauseTime - this.data.startTime
+      this.count(duration)
+    }
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
    */
   onUnload() {
-
+    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 (this.data.cmsId) {
+      data.cmsItemId = this.data.cmsId
+    }
+    app.MG.job.newJobWithApiNewEvent(data).then((res) => {})
+  },
   /**
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */

--
Gitblit v1.9.1