二手车交易,后台点击弹框关闭时记录浏览量
This commit is contained in:
@ -98,6 +98,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {myMixins} from "@/utils/myMixins"
|
||||
import {carInfoDetail,saveRecord} from "@/api/secondHandCar";
|
||||
import { Dialog } from 'vant';
|
||||
@ -119,8 +120,13 @@ export default {
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
// console.log(" localStorage.setItem('indexActiveTab', this.activeTab);", localStorage.getItem('indexActiveTab'))
|
||||
// 页面加载时记录进入时间
|
||||
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');
|
||||
@ -140,22 +146,10 @@ export default {
|
||||
}
|
||||
this.imgSrcList.unshift(res?.data?.vehicleAnglePhoto)
|
||||
}
|
||||
document.addEventListener('visibilitychange', ( ) => {
|
||||
let state = document.visibilityState
|
||||
if (state == 'hidden') { // 用户离开了
|
||||
console.log("用户离开了1")
|
||||
// 使用 sendBeacon 发送数据
|
||||
/*const data = new FormData();
|
||||
data.append('duration', 1);
|
||||
navigator.sendBeacon('/api/getDuration', data);*/
|
||||
this.getDuration(1);
|
||||
console.log("用户离开了2")
|
||||
}
|
||||
});
|
||||
},
|
||||
/* destroyed() {
|
||||
destroyed() {
|
||||
this.getDuration(1)
|
||||
},*/
|
||||
},
|
||||
methods:{
|
||||
formatToWan(num) {
|
||||
let result = (num / 10000).toString();
|
||||
|
@ -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