二手车交易,后台点击弹框关闭时记录浏览量
This commit is contained in:
@ -71,7 +71,12 @@ export default {
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
// 页面加载时记录进入时间
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data === 'dialogClosed') {
|
||||
console.log('Dialog 已关闭');
|
||||
this.getDuration(1)
|
||||
}
|
||||
});
|
||||
this.startTime = new Date();
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
this.id=this.$route.query.id || urlParams.get('id');
|
||||
@ -84,18 +89,10 @@ export default {
|
||||
})
|
||||
this.detailInfo = res?.data
|
||||
}
|
||||
document.addEventListener('visibilitychange', async ( ) => {
|
||||
let state = document.visibilityState
|
||||
if (state == 'hidden') { // 用户离开了
|
||||
console.log("用户离开了1")
|
||||
await this.getDuration(1);
|
||||
console.log("用户离开了2")
|
||||
}
|
||||
});
|
||||
},
|
||||
/*destroyed() {
|
||||
destroyed() {
|
||||
this.getDuration(1)
|
||||
},*/
|
||||
},
|
||||
methods:{
|
||||
getDuration(type){
|
||||
const endTime = new Date();
|
||||
|
||||
Reference in New Issue
Block a user