Browse Source

Merge branch 'video-md'

jwyu 2 năm trước cách đây
mục cha
commit
d5c6dff747
2 tập tin đã thay đổi với 25 bổ sung2 xóa
  1. 15 0
      src/api/video.js
  2. 10 2
      src/views/video/List.vue

+ 15 - 0
src/api/video.js

@@ -13,4 +13,19 @@
  */
  export const apiVideoList=params=>{
     return get('/community/video/list',params)
+}
+
+/**
+ * 视频播放埋点
+ * @param video_id
+ * @param source_agent 来源平台:1:小程序、2:小程序(pc)、3:公众号、4:官网web(pc)
+ */
+export const apiVideoPlayLog=params=>{
+    let source_agent=2
+	if(window.__wxjs_environment === 'miniprogram'){
+		source_agent=2
+	}else{
+		source_agent=4
+	}
+    return post('/community/video/play_log',{...params,source_agent:source_agent})
 }

+ 10 - 2
src/views/video/List.vue

@@ -3,7 +3,7 @@ import {ref,reactive,onMounted,onActivated} from 'vue'
 import { useElementSize } from '@vueuse/core'
 
 import {apiFICCPermissionList,apiGetWechatQRCode} from '@/api/common'
-import {apiVideoList} from '@/api/video'
+import {apiVideoList,apiVideoPlayLog} from '@/api/video'
 
 import SelfList from '@/components/SelfList.vue'
 
@@ -65,7 +65,7 @@ const getVideoList=async ()=>{
         }
     }
 }
-getVideoList()
+// getVideoList()
 
 //刷新列表
 const refreshList=()=>{
@@ -86,6 +86,12 @@ const onLoad=()=>{
 let curVideoId=ref(0)
 const handelClickPlay=(item)=>{
     curVideoId.value=item.community_video_id
+    //记录播放
+    apiVideoPlayLog({video_id:Number(item.community_video_id)}).then(res=>{
+        if(res.code===200){
+            console.log('视频埋点成功');
+        }
+    })
 }
 
 
@@ -112,6 +118,7 @@ onMounted(() => {
 });
 
 onActivated(()=>{
+    curVideoId.value=0
     //向小程序发送消息
     let postData = {
         path: "/pages/video/videoList",
@@ -190,6 +197,7 @@ onActivated(()=>{
                         disablePictureInPicture
                         autoplay
                         v-if="item.community_video_id==curVideoId"
+                        @ended="curVideoId=0"
                     ></video>
                     <div v-else class="poster-img" :style="'background-image:url('+item.cover_img_url+')'" @click="handelClickPlay(item)"></div>
                     <div class="time">发布时间:{{item.publish_time}}</div>