From 89efee9a2e20fc04b4537d859917b47cf68a814c Mon Sep 17 00:00:00 2001 From: peng <peng.com> Date: 星期五, 26 九月 2025 18:28:40 +0800 Subject: [PATCH] 用户行为分享基础埋点 --- pages/product/goods.vue | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 47 insertions(+), 2 deletions(-) diff --git a/pages/product/goods.vue b/pages/product/goods.vue index a7bbf36..94fd6cd 100644 --- a/pages/product/goods.vue +++ b/pages/product/goods.vue @@ -187,7 +187,7 @@ <storeLayout v-if="false" id="main7" :storeDetail="storeDetail" :goodsDetail="goodsDetail" :res="recommendList" /> <!-- 瀹濊礉璇︽儏 --> - <GoodsIntro id="main9" :res="goodsDetail" :goodsParams="goodsParams" :goodsId="goodsDetail.goodsId" + <GoodsIntro id="main9" :res="goodsDetail" :goodsParams="goodsParams" :goodsId="goodsDetail.goodsId" v-if="goodsDetail.id" /> <!-- 瀹濊礉鎺ㄨ崘 --> @@ -305,6 +305,7 @@ import popups from "@/pages/product/popups/popups.vue"; //姘旀场妗� import takeDownFormSaleGoods from "@/pages/product/m-take-down-sale-goods/index.vue"; //涓嬫灦妗� import setup from "./product/popup/popup"; +import { getSessionId, userAction } from "@/api/userAction.js"; import { getSTSToken } from '@/api/common.js' @@ -444,6 +445,23 @@ IMLink: "", // IM鍦板潃 wholesaleList: [], takeDownFromSale: false, // 涓嬫灦閿�鍞姸鎬� + pageSessionNo:"", + sendOnShow:false, + actionParam:{ + sessionId:'', + actionType:"PAGE", + joinType:"SELF", + pageCode:"GOODS_DETAILS", + pageParams:"{}", + pageStatus:"JOIN", + pageType:"DETAIL", + shareId:null, + }, + shareParam:{ + pageCode:"GOODS_DETAILS", + shareOption:"{}", + pageType:"DETAIL" + } }; }, @@ -501,7 +519,8 @@ if(options.q){ const queryParam = { id:'', - goodsId:'' + goodsId:'', + distributionId:'' }; const decodedUrl = decodeURIComponent(decodeURIComponent(options.q)); console.log('鍘熷URL:', decodedUrl); @@ -511,8 +530,11 @@ queryParam.id = id; queryParam.goodsId = gooodsId; this.routerVal = queryParam; + this.actionParam.pageParams = JSON.stringify(params) + this.actionParam.joinType = 'SCAN' }else{ this.routerVal = options; + this.actionParam.pageParams = JSON.stringify(options) } console.log('鎵撳嵃淇℃伅') console.log(options) @@ -526,7 +548,28 @@ }); // #endif }, + 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) + }, async onShow () { + getSessionId().then(res=>{ + this.pageSessionNo = res.data.data + if(this.pageSessionNo){ + let param = this.actionParam; + param.sessionId = this.pageSessionNo + userAction(param) + } + }) this.goodsDetail = {}; //濡傛灉鏈夊弬鏁癷ds璇存槑浜嬪垎閿�鐭繛鎺ワ紝闇�瑕佽幏鍙栧弬鏁� if (this.routerVal.scene) { @@ -592,6 +635,8 @@ * 鍒濆鍖栦俊鎭� */ async init (id, goodsId, distributionId = "") { + console.log('鎵撳嵃id:' + id) + console.log('鎵撳嵃goodsId:'+ goodsId) this.isGroup = false; //鍒濆鍖栨嫾鍥� this.productId = id; // skuId // 杩欓噷璇锋眰鑾峰彇鍒伴〉闈㈡暟鎹� 瑙f瀽鏁版嵁 -- Gitblit v1.8.0