Sfoglia il codice sorgente

统计服务增加class

Rorschach 5 anni fa
parent
commit
a4fad1107c
3 ha cambiato i file con 43 aggiunte e 16 eliminazioni
  1. 27 5
      pages/main/class/class.js
  2. 2 2
      pages/main/class/class.wxml
  3. 14 9
      pages/social/works/works.js

+ 27 - 5
pages/main/class/class.js

@@ -26,7 +26,7 @@ Page({
     lazyVideoUrl: '',
     isIOS: app.globalData.isIOS,
     modalType: "text",
-    
+
     modalText: [{
         text: '您还不是本课程的会员',
         type: 'bigOrange'
@@ -36,9 +36,10 @@ Page({
         type: 'normal'
       }
     ],
-    modalBtnText:'去开团',
+    modalBtnText: '去开团',
     isModalShow: false,
     productId: 0,
+    videoPlayTime: 0
   },
   onLoad: function (option) {
     console.log(option);
@@ -58,8 +59,8 @@ Page({
     httpRequestApi.getClassDetail(this.uid, option.id).success(res => {
       console.log(res);
       const classId = this.data.id;
-      httpRequestApi.userIntoPage('pages/main/class/class','官方课程页面').success((res)=>{
-        
+      httpRequestApi.userIntoPage('pages/main/class/class', '官方课程页面').success((res) => {
+
       })
       this.setData({
         title: res.data.data.lesson.title,
@@ -159,7 +160,7 @@ Page({
       url: `../../groupPage/grade-details/grade-details?productId=${this.data.productId}`
     })
   },
-  modalCloseHandler: function (){
+  modalCloseHandler: function () {
     this.setData({
       isModalShow: false
     })
@@ -255,8 +256,29 @@ Page({
       this.getReadInfo();
     }
   },
+  // 视频时间变动
+  videoTimeChange: function (e) {
+    this.videoPlayTime = e.detail.currentTime;
+  },
   onHide: function () {
     let videoCtx = wx.createVideoContext('classVideo', this);
     videoCtx.stop();
   },
+  onUnload: function () {
+    if (this.videoPlayTime) {
+      const data = {
+        "title": this.data.title,
+        "lessonId": this.data.id,
+        "productId": this.data.productId,
+        "playStopTime": this.videoPlayTime || 0,
+        "type": 'EXAMPLE',
+      }
+
+      httpRequestApi.playLogReport(data).success(res => {
+        console.log(res)
+      })
+    }
+
+
+  }
 })

+ 2 - 2
pages/main/class/class.wxml

@@ -2,9 +2,9 @@
     <view class="videoSection" wx:if="{{!isIOS}}">
         <cover-image wx:if="{{!videoLoad}}" class="video-playBtn" bindtap="videoPlayHandler" src="../../../static/image/play-btn.png"></cover-image>
         <image wx:if="{{!videoLoad}}" class="videoIcon" src="{{iconImg}}" />
-        <video wx:if="{{videoLoad}}" id="classVideo" class="videoSection" src="{{videoUrl}}" autoPlay="{{autoPlay}}" controls="{{controls}}" show-center-play-btn="{{centerBtn}}" show-fullscreen-btn="{{fullScreenBtn}}" show-play-btn="{{playBtn}}"></video>
+        <video wx:if="{{videoLoad}}" bindtimeupdate="videoTimeChange" id="classVideo" class="videoSection" src="{{videoUrl}}" autoPlay="{{autoPlay}}" controls="{{controls}}" show-center-play-btn="{{centerBtn}}" show-fullscreen-btn="{{fullScreenBtn}}" show-play-btn="{{playBtn}}"></video>
     </view>
-    <video wx:if="{{isIOS}}" id="classVideo" class="videoSection" src="{{videoUrl}}" autoPlay="{{autoPlay}}" controls="{{controls}}" show-center-play-btn="{{centerBtn}}" show-fullscreen-btn="{{fullScreenBtn}}" show-play-btn="{{playBtn}}"></video>
+    <video wx:if="{{isIOS}}" bindtimeupdate="videoTimeChange" id="classVideo" class="videoSection" src="{{videoUrl}}" autoPlay="{{autoPlay}}" controls="{{controls}}" show-center-play-btn="{{centerBtn}}" show-fullscreen-btn="{{fullScreenBtn}}" show-play-btn="{{playBtn}}"></video>
     <view class="readWorksSection">
         <view class="peopleNum">
             <image class="peoplesIcon" src="../../../static/image/peoples.png" />

+ 14 - 9
pages/social/works/works.js

@@ -94,16 +94,21 @@ Page({
         this.videoCtx = null
     },
     onUnload: function () {
-        const data = {
-            "title": this.data.title,
-            "lessonId": this.data.classId,
-            "productId": this.data.productId,
-            "playStopTime": this.videoPlayTime || 0,
-            "userReadId": this.data.userReadId
+        console.log(this.videoPlayTime)
+        if(this.videoPlayTime){
+            const data = {
+                "title": this.data.title,
+                "lessonId": this.data.classId,
+                "productId": this.data.productId,
+                "playStopTime": this.videoPlayTime,
+                "userReadId": this.data.userReadId,
+                "type": 'READ',
+            }
+            httpRequestApi.playLogReport(data).success(res =>{
+                console.log(res)
+            })
         }
-        httpRequestApi.playLogReport(data).success(res =>{
-            console.log(res)
-        })
+        
         if (this.innerAudioContext) {
             this.innerAudioContext.destroy();
         }