diff --git a/src/views/secondHandCar/forSale.vue b/src/views/secondHandCar/forSale.vue index 919b9a30..7f3955ae 100644 --- a/src/views/secondHandCar/forSale.vue +++ b/src/views/secondHandCar/forSale.vue @@ -140,19 +140,15 @@ export default { } this.imgSrcList.unshift(res?.data?.vehicleAnglePhoto) } - window.addEventListener('message', function(event) { - console.log("iframeCloseDialog",event) - if (event.data == 'iframeCloseDialog') { - // 执行关闭操作 - console.log('Dialog is closing...'); - // 你可以在这里执行一些清理操作或其他逻辑 - } - }); - document.addEventListener('visibilitychange', async ( ) => { + document.addEventListener('visibilitychange', ( ) => { let state = document.visibilityState if (state == 'hidden') { // 用户离开了 console.log("用户离开了1") - await this.getDuration(1); + // 使用 sendBeacon 发送数据 + /*const data = new FormData(); + data.append('duration', 1); + navigator.sendBeacon('/api/getDuration', data);*/ + this.getDuration(1); console.log("用户离开了2") } });