From 3fea9f0720e7751e4737ded74b3aa89db273688d Mon Sep 17 00:00:00 2001 From: peng <peng.com> Date: 星期日, 28 九月 2025 17:55:11 +0800 Subject: [PATCH] 用户行为分析 --- pages/prize/PrizeDetail/PrizeDetail.vue | 53 +++++++++++++++++++++----- pages/tabbar/user/my.vue | 8 ++- api/userAction.js | 2 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/api/userAction.js b/api/userAction.js index 8e1d9d5..40ed5e9 100644 --- a/api/userAction.js +++ b/api/userAction.js @@ -35,7 +35,7 @@ * * @param params */ - export function share(data) { + export function userShare(data) { return http.request({ url: "/lmk/action-record/share", method: Method.POST, diff --git a/pages/prize/PrizeDetail/PrizeDetail.vue b/pages/prize/PrizeDetail/PrizeDetail.vue index 0272909..165273c 100644 --- a/pages/prize/PrizeDetail/PrizeDetail.vue +++ b/pages/prize/PrizeDetail/PrizeDetail.vue @@ -148,7 +148,7 @@ </template> <script> import bgConfig from '@/pages/prize/PrizeDetail/prize-bgConfig.js' - import { getSessionId, userAction } from "@/api/userAction.js"; + import { getSessionId, userAction ,userShare } from "@/api/userAction.js"; import { prizeInfo, @@ -224,7 +224,13 @@ pageParams:"{}", pageStatus:"JOIN", pageType:"DETAIL" - } + }, + shareParam:{ + pageCode:"PRIZE_DETAIL", + shareOption:"{}", + pageType:"DETAIL" + }, + shareId:'', }; }, computed: { @@ -234,14 +240,14 @@ } }, onUnload() { - let param = this.actionParam; + let param = Object.assign({}, this.actionParam); if (this.sendOnShow)return param.pageStatus = "LEAVE" userAction(param) }, onHide() { this.startHidenTime = Date.now() - let param = this.actionParam; + let param = Object.assign({}, this.actionParam); this.sendOnShow = true; param.pageStatus = "LEAVE" userAction(param) @@ -249,14 +255,20 @@ onShow() { getSessionId().then(res=>{ this.pageSessionNo = res.data.data + this.actionParam.sessionId = res.data.data if(this.pageSessionNo){ - let param = this.actionParam; + let param = Object.assign({}, this.actionParam); param.sessionId = this.pageSessionNo userAction(param) } }) }, async onLoad(option) { + if(option.shareId){ + this.actionParam.shareId = option.shareId; + this.actionParam.joinType = 'SHARE' + console.log('瑙﹀彂onLoad') + } this.actionParam.pageParams = JSON.stringify(option) const pages = getCurrentPages() @@ -303,17 +315,38 @@ // this.startAutoScroll() }, onShareAppMessage() { - return { + // 杩斿洖涓�涓狿romise + return new Promise((resolve) => { + this.shareId = ''; + this.shareParam.shareOption = JSON.stringify({ + id:this.activityId + }) + userShare(this.shareParam).then(res => { + this.shareId = res.data.data; + console.log('------------------1銆�', this.shareId); + + // 褰撹幏鍙栧埌shareId鍚庯紝鍐峳esolve鍒嗕韩閰嶇疆 + resolve({ title: this.activityName, - path: '/pages/prize/PrizeDetail/PrizeDetail?id=' + this.activityId, + path: '/pages/prize/PrizeDetail/PrizeDetail?id=' + this.activityId + '&shareId=' + this.shareId, imageUrl: this.activityCover, success(e) { - console.log("鍒嗕韩鎴愬姛", e) + console.log("鍒嗕韩鎴愬姛", e); }, fail(e) { - console.log('鍒嗕韩澶辫触', e) + console.log('鍒嗕韩澶辫触', e); } - } + }); + }).catch(err => { + // 澶勭悊閿欒鎯呭喌锛屼緥濡備娇鐢ㄩ粯璁ゅ弬鏁� + console.error('鑾峰彇鍒嗕韩ID澶辫触', err); + resolve({ + title: this.activityName, + path: '/pages/prize/PrizeDetail/PrizeDetail?id=' + this.activityId, + imageUrl: this.activityCover + }); + }); + }); }, beforeDestroy() { this.stopAutoScroll() diff --git a/pages/tabbar/user/my.vue b/pages/tabbar/user/my.vue index eaf717e..d3b8b31 100644 --- a/pages/tabbar/user/my.vue +++ b/pages/tabbar/user/my.vue @@ -218,15 +218,16 @@ } } this.initCOS() + }, onUnload() { - let param = this.actionParam; + let param = Object.assign({}, this.actionParam); if (this.sendOnShow)return param.pageStatus = "LEAVE" userAction(param) }, onHide() { this.startHidenTime = Date.now() - let param = this.actionParam; + let param =Object.assign({}, this.actionParam); this.sendOnShow = true; param.pageStatus = "LEAVE" userAction(param) @@ -238,8 +239,9 @@ onShow() { getSessionId().then(res=>{ this.pageSessionNo = res.data.data + this.actionParam.sessionId = res.data.data if(this.pageSessionNo){ - let param = this.actionParam; + let param = Object.assign({}, this.actionParam); param.sessionId = this.pageSessionNo userAction(param) } -- Gitblit v1.8.0