From 15b88a3930ff26120bded601f1490d44f317c6d8 Mon Sep 17 00:00:00 2001 From: Dragon <13925835632@139.com> Date: Thu, 23 Mar 2023 11:26:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=A8=E6=88=BF=EF=BC=9A=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/peko/activity/act-ocean/js/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/view/peko/activity/act-ocean/js/index.js b/view/peko/activity/act-ocean/js/index.js index 534d8ce..5b767a6 100644 --- a/view/peko/activity/act-ocean/js/index.js +++ b/view/peko/activity/act-ocean/js/index.js @@ -1294,4 +1294,16 @@ $(function () { $countDown.html(countDownTime) } }) -}) \ No newline at end of file +}) +//返回页面 重新请求接口 +var hiddenProperty = 'hidden' in document ? 'hidden' : + 'webkitHidden' in document ? 'webkitHidden' : + 'mozHidden' in document ? 'mozHidden' : null; + +var visibilityChangeEvent = hiddenProperty.replace(/hidden/i, 'visibilitychange'); +var onVisibilityChange = function () { + if (!document[hiddenProperty]) { + location.reload() + } +} +document.addEventListener(visibilityChangeEvent, onVisibilityChange); \ No newline at end of file