From 6c60e6afccdc94bb8bdab4ce91b1e5e6d5696ad5 Mon Sep 17 00:00:00 2001 From: liaoxinyu Date: Mon, 10 Mar 2025 18:15:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=80=92=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/en.json | 3 ++- src/i18n/tw.json | 3 ++- src/views/purchase/index.vue | 28 ++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/i18n/en.json b/src/i18n/en.json index 7270d6a..b091c2c 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -913,7 +913,8 @@ "prompt": "Tips", "subscribeSuccess": "Apply Success", "issueNumber" :"issue number", - "Countdown" :"Subscription Countdown", + "Countdown" :"Countdown begins to purchase", + "Countdown1" :"Countdown to purchase end", "hour" :"hour", "point" :"minute", "Second" :"second", diff --git a/src/i18n/tw.json b/src/i18n/tw.json index 5e929f9..636c229 100644 --- a/src/i18n/tw.json +++ b/src/i18n/tw.json @@ -855,7 +855,8 @@ "prompt": "提示", "subscribeSuccess": "申購成功", "issueNumber" :"發行數量", - "Countdown" :"申購倒數計時", + "Countdown" :"申購開始倒計時", + "Countdown1" :"申購結束倒計時", "hour" :"时", "point" :"分", "Second" :"秒", diff --git a/src/views/purchase/index.vue b/src/views/purchase/index.vue index db51d43..360f353 100644 --- a/src/views/purchase/index.vue +++ b/src/views/purchase/index.vue @@ -52,7 +52,7 @@
-
{{$t("purchase.Countdown")}}: {{ days }}{{$t("purchase.day")}}{{ hours }}:{{ minutes }}:{{ seconds }}
+
{{timerbool?$t("purchase.Countdown1"):$t("purchase.Countdown")}}: {{ days }}{{$t("purchase.day")}}{{ hours }}:{{ minutes }}:{{ seconds }}
@@ -333,7 +333,8 @@ export default { seconds: '00', timer1: null, // 存储固定的初始时间差(单位:秒) - remainingSeconds: 0 + remainingSeconds: 0, + timerbool:false } }, computed: { @@ -393,6 +394,19 @@ export default { Subscride.subscribe().then((res) => { this.detail = res; // console.log(this.detail.announce_time,'1111') + // 初始化固定时间差 + const start = new Date(this.detail.start_subscription_time).getTime(); + const end = new Date(this.detail.end_subscription_time).getTime(); + const now = Date.now(); + if(now < start && now < end){ + this.timerbool = false + this.remainingSeconds = Math.floor((start - now) / 1000); + this.startTimer() + }else if (now > start && now < end) { + this.timerbool = true + this.remainingSeconds = Math.floor((end - now) / 1000); + this.startTimer() + } }); }, @@ -504,16 +518,6 @@ export default { return num < 10 ? `0${num}` : num.toString(); } }, - mounted() { - // 初始化固定时间差 - const start = new Date(this.detail.start_subscription_time).getTime(); - const end = new Date(this.detail.end_subscription_time).getTime(); - const now = Date.now(); - if (now > start && now < end) { - this.remainingSeconds = Math.floor((end - now) / 1000); - this.startTimer() - } - }, created() { this.subscribeTokenList(); this.getInfo();