From d1cada30a4b98000ef9c8970f0e2b53ed76e352c Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 30 九月 2025 11:16:00 +0800
Subject: [PATCH] 商品行为分析

---
 pages/video/video-similar.vue |   87 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/pages/video/video-similar.vue b/pages/video/video-similar.vue
index 6fc7b5d..19a4b88 100644
--- a/pages/video/video-similar.vue
+++ b/pages/video/video-similar.vue
@@ -108,7 +108,7 @@
 
 <script>
 import { getGoodsSimilarlyVideos, savePlayRecord, changeCollect, changeThumbsUp } from "@/api/video.js"
-
+import { getSessionId, userAction ,userShare } from "@/api/userAction.js";
 export default {
 	data() {
 		return {
@@ -146,10 +146,41 @@
 			// 鍙虫粦杩斿洖棣栭〉鐩稿叧
 			touchStartX: 0,
 			touchEndX: 0,
-			minSwipeDistance: 100 // 鏈�灏忔粦鍔ㄨ窛绂�
+			minSwipeDistance: 100 ,// 鏈�灏忔粦鍔ㄨ窛绂�
+			pageSessionNo:"",
+			actionParam:{
+				sessionId:'',
+				actionType:"PAGE",
+				joinType:"SELF",
+				pageCode:"RECOMMEND_VIDEO_RIGHT_VIDEO",
+				pageParams:"{}",
+				pageStatus:"JOIN",
+				pageType:"DETAIL"
+			},
+			shareParam:{
+				pageCode:"RECOMMEND_VIDEO_RIGHT_VIDEO",
+				shareOption:"{}",
+				pageType:"DETAIL"
+			},
+			shareId:'',
 		}
 	},
 	onLoad(options) {
+		if(options.shareId){
+			this.actionParam.shareId = options.shareId;
+			this.actionParam.joinType = 'SHARE'
+			console.log('瑙﹀彂onLoad')
+			uni.setStorage({
+				key: 'shareId',
+				data: options.shareId,
+				success: function () {
+					console.log('缂撳瓨shareId鎴愬姛');
+				}
+			});
+		}
+		
+		this.actionParam.pageParams = JSON.stringify(options)
+		
 		// 鑾峰彇浼犻�掔殑鍟嗗搧淇℃伅
 		if (options.goodsId) {
 			this.loadSimilarVideos(options.goodsId, options.currentVideoId);
@@ -161,6 +192,15 @@
 			const videoContext = uni.createVideoContext(`video${this.currentIndex}`, this);
 			videoContext.play();
 		}
+		getSessionId().then(res=>{
+					this.pageSessionNo = res.data.data
+					this.actionParam.sessionId = res.data.data
+					if(this.pageSessionNo){
+					let	param = Object.assign({}, this.actionParam);
+						param.sessionId = this.pageSessionNo
+						userAction(param)
+					}
+		})	
 	},
 	onHide() {
 		// 椤甸潰闅愯棌鏃舵殏鍋滆棰�
@@ -168,6 +208,49 @@
 			const videoContext = uni.createVideoContext(`video${this.currentIndex}`, this);
 			videoContext.pause();
 		}
+		this.startHidenTime = Date.now()
+		let param = Object.assign({}, this.actionParam);
+		this.sendOnShow = true;
+		param.pageStatus = "LEAVE"
+		userAction(param)
+	},
+	onShareAppMessage(e){
+		const userInfo = storage.getUserInfo();
+		if (!userInfo) {
+			console.log("鏈櫥褰曚笉鑳藉垎浜�");
+			return
+		}
+		const videoInfo = e.target.dataset.obj;
+		return new Promise((resolve) => {
+					this.shareId = '';
+					let shareObj ={
+						videoId:videoInfo.id,
+						userId:userInfo.id
+					}
+					this.shareParam.shareOption = JSON.stringify(shareObj)
+					userShare(this.shareParam).then(res => {
+					  this.shareId = res.data.data;
+					  resolve({
+						title: videoInfo.title,
+						path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}&shareId=${this.shareId}`,
+						imageUrl: videoInfo.coverUrl,
+						success(e) {
+						  console.log("鍒嗕韩鎴愬姛", e);
+						},
+						fail(e) {
+						  console.log('鍒嗕韩澶辫触', e);
+						}
+					  });
+					}).catch(err => {
+					  // 澶勭悊閿欒鎯呭喌锛屼緥濡備娇鐢ㄩ粯璁ゅ弬鏁�
+					  console.error('鑾峰彇鍒嗕韩ID澶辫触', err);
+					  resolve({
+							title: videoInfo.title,
+							path: `/pages/tabbar/index/home?videoId=${videoInfo.id}&userId=${userInfo.id}`,
+							imageUrl: videoInfo.coverUrl
+					  });
+					});
+		});
 	},
 	methods: {
 		// 鍔犺浇鐩镐技瑙嗛

--
Gitblit v1.8.0