xhj il y a 2 ans
Parent
commit
3fdcb82fb9
4 fichiers modifiés avec 79 ajouts et 10 suppressions
  1. 24 2
      card/index/index.vue
  2. 23 1
      match/activityDetail/activityDetail.vue
  3. 27 5
      topic/content/content.vue
  4. 5 2
      utils/request.js

+ 24 - 2
card/index/index.vue

@@ -497,7 +497,11 @@ import util from '../../utils/util.js';
 				isShowUpdate: false, //是否显示更新信息弹窗
 				isUpdateInfo: false, //更新用户信息
 				isUpdateMobile: false, //绑定手机号
-
+				
+				
+				enterTime : '',//进入页面时间
+				outTime : '',//页面卸载时间
+				stayTime : 0//页面停留时间
 			};
 		},
 		components:{ serviceContact },
@@ -521,6 +525,9 @@ import util from '../../utils/util.js';
 		},
 
 		async onShow() {
+			// 用户进入时间
+			this.enterTime = new Date();
+			console.log('---用户进入时间---',this.enterTime);
 			this.getConfig()
 			if (this.scene) {
 				this.cardId = this.scene.split('_')[0]
@@ -533,6 +540,22 @@ import util from '../../utils/util.js';
 			this.userInfo = req.getStorage('userInfo')
 			this.getCardInfo();
 		},
+		onHide(){
+			// 用户退出时间
+			this.outTime = new Date();
+			//停留时间(毫秒)
+			this.stayTime = (this.outTime.getTime() - this.enterTime.getTime());
+			console.log('---用户浏览---',Math.ceil(this.stayTime/1000))
+			req.saveBehaviorNew(this.cardInfo.id,1,4,'','',this.options.userId,Math.ceil(this.stayTime/1000))
+		},
+		onUnload(){
+			// 用户退出时间
+			this.outTime = new Date();
+			//停留时间(毫秒)
+			this.stayTime = (this.outTime.getTime() - this.enterTime.getTime());
+			console.log('---用户浏览总时长---',Math.ceil(this.stayTime/1000))
+			req.saveBehaviorNew(this.cardInfo.id,1,4,'','',this.options.userId,Math.ceil(this.stayTime/1000))
+		},
 		onReachBottom() {
 			this.form.page++;
 			this.getOfficeList();
@@ -649,7 +672,6 @@ import util from '../../utils/util.js';
 							// 用户浏览
 							if (this.isFirst) {
 								this.userBehavior(4)
-								req.saveBehaviorNew(this.cardInfo.id,1,4)
 							}
 						}
 						this.isFirst = false

+ 23 - 1
match/activityDetail/activityDetail.vue

@@ -145,6 +145,10 @@ export default {
 			isShowUpdate: false, //是否显示更新信息弹窗
 			isUpdateInfo: false,//更新用户信息
 			isUpdateMobile: false,//绑定手机号
+			
+			enterTime : '',//进入页面时间
+			outTime : '',//页面卸载时间
+			stayTime : 0//页面停留时间
 		};
 	},
 	async onLoad(options) {
@@ -164,6 +168,8 @@ export default {
 		}
 	},
 	async onShow() {
+		this.enterTime = new Date();
+		console.log('---用户进入时间---',this.enterTime);
 		// this.isLogin = req.isAuth();
 		// await this.loadCodeParams();
 		if(!this.options.isSharePYQ){
@@ -179,6 +185,22 @@ export default {
 		this.userBehavior(4);
 		await this.getPrice();
 	},
+	onHide(){
+		// 用户退出时间
+		this.outTime = new Date();
+		//停留时间(毫秒)
+		this.stayTime = (this.outTime.getTime() - this.enterTime.getTime());
+		console.log('---用户浏览---',Math.ceil(this.stayTime/1000))
+		req.saveBehaviorNew(this.detail.id,2,4,'','',this.options.userId,Math.ceil(this.stayTime/1000))
+	},
+	onUnload(){
+		// 用户退出时间
+		this.outTime = new Date();
+		//停留时间(毫秒)
+		this.stayTime = (this.outTime.getTime() - this.enterTime.getTime());
+		console.log('---用户浏览总时长---',Math.ceil(this.stayTime/1000))
+		req.saveBehaviorNew(this.detail.id,2,4,'','',this.options.userId,Math.ceil(this.stayTime/1000))
+	},
 	onReachBottom: function() {
 	},
 	onShareAppMessage: function() {
@@ -357,7 +379,7 @@ export default {
 					this.cardInfo.follow = !this.cardInfo.follow
 				}
 				if(type == 4) {
-					req.saveBehaviorNew(this.detail.id,2,4)
+					// req.saveBehaviorNew(this.detail.id,2,4)
 				}
 			});
 		},

+ 27 - 5
topic/content/content.vue

@@ -87,6 +87,11 @@ export default {
 			isShowUpdate: false, //是否显示更新信息弹窗
 			isUpdateInfo: false,//更新用户信息
 			isUpdateMobile: false,//绑定手机号
+			
+			
+			enterTime : '',//进入页面时间
+			outTime : '',//页面卸载时间
+			stayTime : 0//页面停留时间
 		};
 	},
 
@@ -114,17 +119,34 @@ export default {
 		// await this.monitor();
 	},
 	async onShow(){
-		
+		// 用户进入时间
+		this.enterTime = new Date();
+		console.log('---用户进入时间---',this.enterTime);
 		this.getConfig()
 		this.getBrowse();
 	},
-
+	onHide(){
+		// 用户退出时间
+		this.outTime = new Date();
+		//停留时间(毫秒)
+		this.stayTime = (this.outTime.getTime() - this.enterTime.getTime());
+		console.log('---用户浏览---',Math.ceil(this.stayTime/1000))
+		req.saveBehaviorNew(this.id,3,4,'','',this.query.userId,Math.ceil(this.stayTime/1000))
+	},
+	onUnload(){
+		// 用户退出时间
+		this.outTime = new Date();
+		//停留时间(毫秒)
+		this.stayTime = (this.outTime.getTime() - this.enterTime.getTime());
+		console.log('---用户浏览总时长---',Math.ceil(this.stayTime/1000))
+		req.saveBehaviorNew(this.id,3,4,'','',this.query.userId,Math.ceil(this.stayTime/1000))
+	},
 	onShareAppMessage() {
 		req.saveBehaviorNew(this.id,3,6)
 		return {
 			title: this.detaile.title,
 			imageUrl: this.detaile.pic,
-			path: '/topic/content/content?id=' + this.id +'&isShare=' + true+(this.userInfo.userType==1?('&shareId='+this.userInfo.saleNo):'')
+			path: '/topic/content/content?id=' + this.id +'&isShare=' + true+(this.userInfo.userType==1?('&shareId='+this.userInfo.saleNo):'') + (req.getStorage('userInfo')?'&userId=' + req.getStorage('userInfo').id:'')
 		};
 	},
 	onShareTimeline() {
@@ -133,7 +155,7 @@ export default {
 			title: this.detaile.title,
 			imageUrl: this.tempFilePath?this.tempFilePath:this.detaile.pic,
 			path: '/topic/content/content',
-			query:'id=' + this.id+'&isSharePYQ=' + true +'&isShare=' + true+(this.userInfo.userType==1?('&shareId='+this.userInfo.saleNo):'')
+			query:'id=' + this.id+'&isSharePYQ=' + true +'&isShare=' + true+(this.userInfo.userType==1?('&shareId='+this.userInfo.saleNo):'') + (req.getStorage('userInfo')?'&userId=' + req.getStorage('userInfo').id:'')
 		};
 	},
 	methods: {
@@ -243,7 +265,7 @@ export default {
 			dataP.behavior = 4; //1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、分享
 			dataP.bindId = this.id;
 			req.postRequestLoding('/api/v3/behavior/save', dataP, data => {
-				req.saveBehaviorNew(this.id,3,4)
+				
 			});
 		},
 		// 用户行为

+ 5 - 2
utils/request.js

@@ -1296,10 +1296,12 @@ const getBehavior = (params, success) => {
   * @param type  用户行为操作对象(1.名片 2.活动 3.文章 4.社区页面 5.海报 6.点击发现页面 7.点击首页页面 8.点击我的页面 10.聊一聊 11.电话 12.微信 13.通讯录 14.评价名片)
   * @param behavior  用户行为(1.关注 2.收藏 3.点赞 4.浏览 5.确认 6.分享 7.发布 8.评价 9.投票 10.点击 11.取消关注 12.取消点赞 13.评价 14.保存通讯录 15.聊一聊 16.加入)
   * @param content  用户行为内容(非必填)
+  * @param shareUid  用户打开浏览时转发人id(非必填)
+  * @param browsingDuration  用户浏览时长(非必填,单位s)
   * @return 
   * @createTime: 2023-10-16 10:48:32
   */
-const saveBehaviorNew = async (bindId,type,behavior,content, success) => {
+const saveBehaviorNew = async (bindId,type,behavior,content, success,shareUid,browsingDuration) => {
 	let params = {
 		uid:'',
 		bindId:bindId,
@@ -1310,7 +1312,8 @@ const saveBehaviorNew = async (bindId,type,behavior,content, success) => {
 		model:'',//设备型号
 		os:'',//操作系统
 		osVersion:'',//操作系统版本
-		
+		shareUid:shareUid?shareUid:'',
+		browsingDuration:browsingDuration?browsingDuration:''
 	}
 	await new Promise((resolve,reject)=>{
 		uni.getSystemInfoAsync({