From 9ab710d3b7cfd204890c6dcfcd18d13e3a602c2c Mon Sep 17 00:00:00 2001 From: zhangds Date: Mon, 25 Mar 2024 18:54:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E5=80=92=E8=AE=A1?= =?UTF-8?q?=E6=97=B6=E5=87=BD=E6=95=B0=20=20=E5=92=8C=20=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=BF=87=E6=9C=9F=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packkey/libs.js => libs.js | 28 ++++++++++++++++++++ outtime.html | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) rename packkey/libs.js => libs.js (59%) create mode 100644 outtime.html diff --git a/packkey/libs.js b/libs.js similarity index 59% rename from packkey/libs.js rename to libs.js index 2e34302..a220f8e 100644 --- a/packkey/libs.js +++ b/libs.js @@ -40,3 +40,31 @@ const getQueryString = (name) => { if (r != null) return unescape(r[2]); return null; }; + +/** 倒计时函数 + * @param {*} timestamp + * @returns + */ +const pageOutTime = (timestamp) => { + if (timestamp) { + const now = new Date().getTime(); // 获取当前时间的时间戳 + let diff = Number(timestamp) - now; // 计算差异(以毫秒为单位) + + // 判断还剩多久 + if (diff <= 0) { + // window.location.replace("/outtime.html"); + console.log("时间已到"); + return false; + } else { + // 将差异转换为小时、分钟、秒 + const hours = Math.floor(diff / (1000 * 60 * 60)); + diff -= hours * (1000 * 60 * 60); + const minutes = Math.floor(diff / (1000 * 60)); + diff -= minutes * (1000 * 60); + const seconds = Math.floor(diff / 1000); + + // 返回结果数组 + return [hours, minutes, seconds]; + } + } +}; diff --git a/outtime.html b/outtime.html new file mode 100644 index 0000000..cd4e600 --- /dev/null +++ b/outtime.html @@ -0,0 +1,52 @@ + + + + + + + 兑换码已过期 + + + + + + +
+ + +
+ + + + \ No newline at end of file