From d50a3ed44e2edab2a7a661c43491c3aa42c57794 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 25 九月 2025 14:17:05 +0800
Subject: [PATCH] 用户行为分享基础埋点

---
 pages/tabbar/index/home.vue |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/pages/tabbar/index/home.vue b/pages/tabbar/index/home.vue
index 23cbbdf..8a4ae99 100644
--- a/pages/tabbar/index/home.vue
+++ b/pages/tabbar/index/home.vue
@@ -266,6 +266,7 @@
 import { setPopupRedisTime, getPopupAcitivty } from '@/api/popup.js'
 import { changeCollect } from "@/api/collect.js";
 import { saveShare, saveShareClickRecord } from "@/api/share.js";
+import { getSessionId, userAction } from "@/api/userAction.js";
 import { silentLogin } from "@/api/connect.js";
 import { getUserInfo } from "@/api/members";
 import storage from "@/utils/storage.js";
@@ -368,10 +369,28 @@
 			similarlyNomore: false, // 鏄惁杩樻湁鏇村鐩镐技瑙嗛
 			similaryVideoIndex: 0, // 鐩镐技瑙嗛鐨勬挱鏀句綅缃�
 			similarlyLoading: false, // 鐩镐技瑙嗛鍔犺浇
-			marginBottom: 0 // 搴曢儴瀹夊叏鍖哄煙
+			marginBottom: 0 ,// 搴曢儴瀹夊叏鍖哄煙
+			pageSessionNo:"",
+			actionParam:{
+					sessionId:'',
+					actionType:"PAGE",
+					joinType:"SELF",
+					pageCode:"RECOMMEND_VIDEO",
+					pageParams:"{}",
+					pageStatus:"JOIN",
+					pageType:"LIST"
+				}
 		}
 	},
 	onShow() {
+		getSessionId().then(res=>{
+			this.pageSessionNo = res.data.data
+			if(this.pageSessionNo){
+			let	param = this.actionParam;
+				param.sessionId = this.pageSessionNo
+				userAction(param)
+			}
+		})
 
 		this.openActivityPopup()
 
@@ -399,9 +418,19 @@
 			this.totalHidenTime += duration
 		}
 	},
-	onHide() {
-		this.startHidenTime = Date.now()
-	},
+  onUnload() {
+    let	param = this.actionParam;
+    if (this.sendOnShow)return
+    param.pageStatus = "LEAVE"
+    userAction(param)
+  },
+  onHide() {
+    this.startHidenTime = Date.now()
+    let	param = this.actionParam;
+    this.sendOnShow = true;
+    param.pageStatus = "LEAVE"
+    userAction(param)
+  },
 	onLoad(option) {
 
 		console.log('-----------鍒嗕韩鍑虹殑鏁版嵁---------->', option)
@@ -419,6 +448,9 @@
 			const shareType = params.shareType;
 			const videoId = params.videoId;
 			queryParam.videoId = videoId
+			this.actionParam.joinType = "SCAN";
+			this.actionParam.pageParams = JSON.stringify(params);
+			
 			console.log('瑙f瀽鍙傛暟:', { shareType, videoId });
 		}
 		const token = storage.getAccessToken();
@@ -426,6 +458,8 @@
 			this.wxSilentLogin(() => {
 				// 鍒ゆ柇鏄笉鏄偣鍑诲垎浜摼鎺ヨ繘鏉ョ殑
 				if (option.userId && option.videoId) {
+					this.actionParam.joinType = "SHARE";
+					this.actionParam.pageParams = JSON.stringify(option);
 					queryParam.videoId = option.videoId
 					// 淇濆瓨鍒嗕韩鐐瑰嚮璁板綍
 					saveShareClickRecord({ refId: option.videoId, shareUserId: option.userId })

--
Gitblit v1.8.0