|
@@ -6,32 +6,43 @@ var cmSysVitaMixins = function () {
|
|
|
return {
|
|
|
browseTime: 0, // 浏览时长初始值为 0
|
|
|
clearTimeSet: null,
|
|
|
+ cmSysParams:{
|
|
|
+ pagePath:'',//页面路径
|
|
|
+ accessDuration:0,//停留时间
|
|
|
+ pageType:'',//页面类型
|
|
|
+ pageLabel:'',//页面标签
|
|
|
+ userId:0,//用户Id
|
|
|
+ productId:0//商品Id
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
methods: {
|
|
|
setTime() {
|
|
|
//设置定时器
|
|
|
let _self = this;
|
|
|
+ if(GLOBAL_TOKEN){ this.cmSysParams.userId = GLOBAL_USER_ID; }
|
|
|
+ this.cmSysParams.pagePath = window.location.href;
|
|
|
this.clearTimeSet = setInterval(() => {
|
|
|
- _self.browseTime++;
|
|
|
- console.log(_self.browseTime, "时长累计");
|
|
|
+ _self.cmSysParams.accessDuration++;
|
|
|
+ console.log(`页面路径:${_self.cmSysParams.pagePath}`,`停留:${_self.cmSysParams.accessDuration}s`,`标签:${_self.cmSysParams.pageLabel}`)
|
|
|
}, 1000);
|
|
|
},
|
|
|
- cmSysVitas() {
|
|
|
+ userRecordStatistics(params) {
|
|
|
var _this = this;
|
|
|
- UserApi.cmSysVitas({},function (response) {
|
|
|
+ UserApi.userRecordStatistics(params,function (response) {
|
|
|
if(response.code === 0){
|
|
|
- _this.bankInfo = response.data;
|
|
|
+ console.log('<-------上送用户行为记录成功------>')
|
|
|
}else{
|
|
|
console.log('<-------上送用户行为记录异常------>')
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
beforeunloadHandler(e) {
|
|
|
- console.log('关闭窗口之后')
|
|
|
- debugger
|
|
|
+ console.log('关闭窗口之后',this.cmSysParams)
|
|
|
clearInterval(this.clearTimeSet); // 离开页面后清除定时器
|
|
|
- this.cmSysVitas(); // 上送后台接口,将浏览时长等信息传到后台,离开当前路由后调用
|
|
|
+ this.userRecordStatistics(this.cmSysParams); // 上送后台接口,将浏览时长等信息传到后台,离开当前路由后调用
|
|
|
+ debugger
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|