Quellcode durchsuchen

feat 合集埋点

erekook vor 11 Monaten
Ursprung
Commit
cef18ca0f3
1 geänderte Dateien mit 58 neuen und 4 gelöschten Zeilen
  1. 58 4
      pages/collect-video/video.js

+ 58 - 4
pages/collect-video/video.js

@@ -32,7 +32,8 @@ Page({
       templateError: false,
     },
 
-    collectId: "",
+    collectId: "", // 合集id
+    tagId: "", // 合集标签id
     eps: [], // 合集视频列表
     playingEp: 0, // 正在播放集
     videoDetail: null,
@@ -141,6 +142,7 @@ Page({
             });
           this.setData({
             eps: res.video,
+            tagId: res.tagId,
             playingEp: 0,
             videoDetail: res.video[0],
           });
@@ -218,6 +220,11 @@ Page({
       playingEp: idx,
       videoDetail: ep,
     });
+    SendEvent("click_collection_video", {
+      cid: this.data.collectId,
+      video_id: this.data.eps[this.data.playingEp].id,
+      tag_id: this.data.tagId,
+    });
     if (!this.data.videoDetail.lock) {
       this.getVideoPlayUrl();
     }
@@ -298,6 +305,22 @@ Page({
     }
   },
 
+  // 视频播放
+  makeVideoPlay() {
+    if (!this.data.videoDetail.lock && this.data.videoStatus == 2) {
+      const videoContext = wx.createVideoContext("my-video");
+      videoContext.play();
+    }
+  },
+
+  // 视频暂停
+  makeVideoPause() {
+    if (this.data.videoStatus == 1) {
+      const videoContext = wx.createVideoContext("my-video");
+      videoContext.pause();
+    }
+  },
+
   // 视频播放事件
   onVideoPlay() {
     this.setData({
@@ -306,6 +329,11 @@ Page({
     });
 
     // 可以添加播放埋点
+    SendEvent("collection_video_play", {
+      cid: this.data.collectId,
+      video_id: this.data.eps[this.data.playingEp].id,
+      tag_id: this.data.tagId,
+    });
   },
 
   // 视频暂停事件
@@ -440,6 +468,11 @@ Page({
     const { id, info, index } = e.currentTarget.dataset;
     this.setData({
       collectId: id,
+      tagId: info.tagId,
+    });
+    SendEvent("click_collection", {
+      cid: this.data.collectId,
+      tag_id: this.data.tagId,
     });
     console.log(id, info, index, "合集详情");
     this.getCollectVideoDetail();
@@ -488,7 +521,20 @@ Page({
             "videoDetail.lock": false,
             eps: this.data.eps,
           });
+
+          SendEvent("unlock_collection", {
+            cid: this.data.collectId,
+            video_id: this.data.eps[this.playingEp].id,
+            // tag_id: this.data.tagId,
+            ad_num: hadRewardNum + 1,
+          });
+
           this.getVideoPlayUrl();
+        } else {
+          SendEvent("unlock_collection_fail", {
+            cid: this.data.collectId,
+            video_id: this.data.eps[this.playingEp].id,
+          });
         }
       });
     }
@@ -528,6 +574,7 @@ Page({
     });
     interstitialAd.onClose(() => {
       console.log("合集视频页插屏广告onClose");
+      this.makeVideoPlay();
     });
   },
 
@@ -535,9 +582,16 @@ Page({
   interstitalPlayFn() {
     if (this.data.globalConfig.isShowInsert !== 1) return;
     if (interstitialAd) {
-      interstitialAd.show().catch((err) => {
-        console.error("合集视频页插屏显示错误", err);
-      });
+      interstitialAd
+        .show()
+        .then(() => {
+          setTimeout(() => {
+            this.makeVideoPause();
+          }, 500);
+        })
+        .catch((err) => {
+          console.error("合集视频页插屏显示错误", err);
+        });
     }
   },
 });