1 {{ detail.coin_name }} = {{detail.issue_price}}
@@ -50,6 +52,7 @@
+
{{$t("purchase.Countdown")}}: {{ days }}{{$t("purchase.day")}}{{ hours }}:{{ minutes }}:{{ seconds }}
@@ -322,8 +325,16 @@ export default {
activityList:[{rate: "", amount: ""},{rate: "", amount: ""},{rate: "", amount: ""},{rate: "", amount: ""},{rate: "", amount: ""}],
activestep:0,
issue_price:0.03,
- timer:''
- };
+ timer:'',
+
+ days: 0,
+ hours: '00',
+ minutes: '00',
+ seconds: '00',
+ timer1: null,
+ // 存储固定的初始时间差(单位:秒)
+ remainingSeconds: 0
+ }
},
computed: {
total() {
@@ -381,7 +392,7 @@ export default {
getInfo() {
Subscride.subscribe().then((res) => {
this.detail = res;
- console.log(this.detail.announce_time,'1111')
+ // console.log(this.detail.announce_time,'1111')
});
},
@@ -450,7 +461,59 @@ export default {
}
});
},
+
+
+ price1(item){
+ if (item) {
+ let price = item.toString();
+ let parts = price.split(".");
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+ return parts.join(".");
+ }
+ },
+ startTimer() {
+ this.timer1 = setInterval(() => {
+ this.remainingSeconds -= 1; // 每秒减少1秒
+ this.updateDisplay();
+
+ if (this.remainingSeconds <= 0) {
+ this.clearTimer();
+ this.$emit('time-end');
+ }
+ }, 1000);
+ this.updateDisplay(); // 初始显示
+ },
+ clearTimer() {
+ if (this.timer1) {
+ clearInterval(this.timer1);
+ this.timer1 = null;
+ }
+ },
+ updateDisplay() {
+ const seconds = this.remainingSeconds % 60;
+ const minutes = Math.floor(this.remainingSeconds / 60) % 60;
+ const hours = Math.floor(this.remainingSeconds / 3600) % 24;
+ const days = Math.floor(this.remainingSeconds / 86400);
+
+ this.days = days;
+ this.hours = this.padZero(hours);
+ this.minutes = this.padZero(minutes);
+ this.seconds = this.padZero(seconds);
+ },
+ padZero(num) {
+ 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();
@@ -459,6 +522,7 @@ export default {
this.timer=setInterval(this.getTransferRecords,5000)
},
beforeDestroy() {
+ // this.clearTimer()
clearInterval(this.timer);
}
};