diff --git a/src/views/pages/comProduct/index.vue b/src/views/pages/comProduct/index.vue index de29c51..a8464c9 100644 --- a/src/views/pages/comProduct/index.vue +++ b/src/views/pages/comProduct/index.vue @@ -174,6 +174,7 @@ export default { interceptCode: [ ...interceptCode ], passCode: [ ...passCode ], pollSwitch: false, // 同步轮询开关,暂定关闭,保留逻辑 + visibilityStatus: false, showData: ['31', '32', '33', '2', '1'] as Array, // 区分 列表 和 详情 pageData: new Map([['31', []], ['32', []], ['33', []], ['2', []], ['1', []]]), @@ -317,6 +318,8 @@ export default { methods: { // 可见性 visibilityFunc() { + if (this.visibilityStatus) return; + this.visibilityStatus = true; const that = this; document.addEventListener('visibilitychange', function () { const visibilityState = document.visibilityState; @@ -688,6 +691,7 @@ export default { } }, beforeUnmount() { + this.visibilityStatus = false; document.removeEventListener('visibilitychange', this.visibilityFunc); this.codeTime && clearInterval(this.codeTime); this.codeTime = null; diff --git a/src/views/templates/cmsCash/index.vue b/src/views/templates/cmsCash/index.vue index efd05ee..be85bfb 100644 --- a/src/views/templates/cmsCash/index.vue +++ b/src/views/templates/cmsCash/index.vue @@ -143,6 +143,7 @@ export default { passCode: [ ...passCode ], weekArray: [ ...weekArray ], pollSwitch: false, // 同步轮询开关,暂定关闭,保留逻辑 + visibilityStatus: false, bgDefault: 'https://lsxdmgoss.oss-cn-chengdu.aliyuncs.com/MarketingSystem/image/front/common_img_main_1.png', bgInput: 'https://lsxdmgoss.oss-cn-chengdu.aliyuncs.com/MarketingSystem/image/front/zfb-red-banner.png', @@ -192,6 +193,8 @@ export default { methods: { // 可见性 visibilityFunc() { + if (this.visibilityStatus) return; + this.visibilityStatus = true; const that = this; document.addEventListener('visibilitychange', function () { const visibilityState = document.visibilityState; @@ -361,6 +364,7 @@ export default { } }, beforeUnmount() { + this.visibilityStatus = false; document.removeEventListener('visibilitychange', this.visibilityFunc); this.pollTime && clearTimeout(this.pollTime); this.pollTime = 'end'; diff --git a/src/views/templates/cmsVoucher/index.vue b/src/views/templates/cmsVoucher/index.vue index f7cc770..ff55ecf 100644 --- a/src/views/templates/cmsVoucher/index.vue +++ b/src/views/templates/cmsVoucher/index.vue @@ -117,6 +117,7 @@ export default { passCode: [ ...passCode ], weekArray: [ ...weekArray ], pollSwitch: false, // 同步轮询开关,暂定关闭,保留逻辑 + visibilityStatus: false, }; }, created() { @@ -130,6 +131,8 @@ export default { methods: { // 可见性 visibilityFunc() { + if (this.visibilityStatus) return; + this.visibilityStatus = true; const that = this; document.addEventListener('visibilitychange', function () { const visibilityState = document.visibilityState; @@ -290,6 +293,7 @@ export default { } }, beforeUnmount() { + this.visibilityStatus = false; document.removeEventListener('visibilitychange', this.visibilityFunc); this.pollTime && clearTimeout(this.pollTime); this.pollTime = 'end';