From d50a3ed44e2edab2a7a661c43491c3aa42c57794 Mon Sep 17 00:00:00 2001 From: peng <peng.com> Date: 星期四, 25 九月 2025 14:17:05 +0800 Subject: [PATCH] 用户行为分享基础埋点 --- pages/product/goods.vue | 86 ++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 81 insertions(+), 5 deletions(-) diff --git a/pages/product/goods.vue b/pages/product/goods.vue index 83fa403..3146a0b 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,17 @@ IMLink: "", // IM鍦板潃 wholesaleList: [], takeDownFromSale: false, // 涓嬫灦閿�鍞姸鎬� + pageSessionNo:"", + sendOnShow:false, + actionParam:{ + sessionId:'', + actionType:"PAGE", + joinType:"SELF", + pageCode:"GOODS_DETAILS", + pageParams:"{}", + pageStatus:"JOIN", + pageType:"DETAIL" + } }; }, @@ -497,7 +509,31 @@ this.productRefHeight = windowHeight - bottomHeight + "px"; }, async onLoad (options) { - this.routerVal = options; + + if(options.q){ + const queryParam = { + id:'', + goodsId:'', + distributionId:'' + }; + const decodedUrl = decodeURIComponent(decodeURIComponent(options.q)); + console.log('鍘熷URL:', decodedUrl); + const params = this.parseUrlParams(decodedUrl); + const id = params.id; + const gooodsId = params.goodsId; + 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) + console.log(this.routerVal) + // #ifdef MP-WEIXIN // 灏忕▼搴忛粯璁ゅ垎浜� uni.showShareMenu({ @@ -506,7 +542,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) { @@ -522,6 +579,23 @@ }, methods: { + // 瑙f瀽URL鍙傛暟 + parseUrlParams(url) { + const params = {}; + // 澶勭悊鍙兘瀛樺湪鐨刪ash锛堝鏋滄湁鐨勮瘽锛� + const cleanUrl = url.split('#')[0]; + const queryStr = cleanUrl.split('?')[1] || ''; + + queryStr.split('&').forEach(pair => { + const [key, value] = pair.split('='); + if (key) { + // 濡傛灉鍊煎瓨鍦紝鍒欒В鐮侊紝鍚﹀垯璁句负绌哄瓧绗︿覆 + params[key] = value ? decodeURIComponent(value) : ''; + } + }); + + return params; + }, // 閲嶆柊鎵撳紑涓嬫灦 reStartTakeDownSale(){ this.$refs.takeDownSale.show = true @@ -555,6 +629,8 @@ * 鍒濆鍖栦俊鎭� */ async init (id, goodsId, distributionId = "") { + console.log('鎵撳嵃id:' + id) + console.log('鎵撳嵃goodsId:'+ goodsId) this.isGroup = false; //鍒濆鍖栨嫾鍥� this.productId = id; // skuId // 杩欓噷璇锋眰鑾峰彇鍒伴〉闈㈡暟鎹� 瑙f瀽鏁版嵁 @@ -611,7 +687,7 @@ this.goodsSpec = response.data.result.specs; this.PromotionList = response.data.result.promotionMap; this.goodsParams = response.data.result.goodsParamsDTOList || []; - + console.log('浼樻儬鍗锋椿鍔�--------------------銆�',response.data.result.promotionMap) // 鍒ゆ柇鏄惁鎷煎洟娲诲姩鎴栬�呯Н鍒嗗晢鍝� 濡傛灉鏈夊垯鏄剧ず鎷煎洟娲诲姩淇℃伅 this.PromotionList && Object.keys(this.PromotionList).forEach((item) => { @@ -759,8 +835,8 @@ */ back () { if (getCurrentPages().length == 1) { - uni.switchTab({ - url: "/pages/tabbar/home/index", + uni.redirectTo({ + url: "/pages/commodity-square/commoditySquare", }); } else { uni.navigateBack(); -- Gitblit v1.8.0