diff --git a/src/views/secondHandCar/forSale.vue b/src/views/secondHandCar/forSale.vue index 2a9e25dc..0413ab1d 100644 --- a/src/views/secondHandCar/forSale.vue +++ b/src/views/secondHandCar/forSale.vue @@ -141,6 +141,12 @@ export default { } this.imgSrcList.unshift(res?.data?.vehicleAnglePhoto) } + document.addEventListener('visibilitychange', async ( ) => { + let state = document.visibilityState + if (state == 'hidden') { // 用户离开了 + this.getDuration() + } + }); }, destroyed() { this.getDuration() diff --git a/src/views/secondHandCar/wantBuySale.vue b/src/views/secondHandCar/wantBuySale.vue index 03e63ff5..79dec68d 100644 --- a/src/views/secondHandCar/wantBuySale.vue +++ b/src/views/secondHandCar/wantBuySale.vue @@ -85,6 +85,12 @@ export default { }) this.detailInfo = res?.data } + document.addEventListener('visibilitychange', async ( ) => { + let state = document.visibilityState + if (state == 'hidden') { // 用户离开了 + this.getDuration() + } + }); }, destroyed() { this.getDuration()