Browse Source

修改倒计时逻辑

master
liaoxinyu 1 year ago
parent
commit
a8e19806d7
  1. 3
      i18n/lang/en.json
  2. 3
      i18n/lang/zh-TW.json
  3. 29
      pages/purchase/index.vue

3
i18n/lang/en.json

@ -432,7 +432,8 @@
"b8": "Buy", "b8": "Buy",
"b9": "Subscription is successful", "b9": "Subscription is successful",
"issueNumber" :"issue number", "issueNumber" :"issue number",
"Countdown" :"Subscription Countdown", "Countdown" :"Countdown begins to purchase",
"Countdown1" :"Countdown to purchase end",
"hour" :"hour", "hour" :"hour",
"point" :"minute", "point" :"minute",
"Second" :"second", "Second" :"second",

3
i18n/lang/zh-TW.json

@ -432,7 +432,8 @@
"b8": "購買", "b8": "購買",
"b9": "申購成功", "b9": "申購成功",
"issueNumber" :"發行數量", "issueNumber" :"發行數量",
"Countdown" :"申購倒數計時", "Countdown" :"申購開始倒計時",
"Countdown1" :"申購結束倒計時",
"hour" :"时", "hour" :"时",
"point" :"分", "point" :"分",
"Second" :"秒", "Second" :"秒",

29
pages/purchase/index.vue

@ -71,7 +71,7 @@
<!-- 申购 --> <!-- 申购 -->
<view class="bg-panel-3 p-md box-shadow"> <view class="bg-panel-3 p-md box-shadow">
<view class="title p-b-xs border-b">{{ $t("purchase.a5") }}</view> <view class="title p-b-xs border-b">{{ $t("purchase.a5") }}</view>
<view class="title border-b" style="padding:10px 0px">{{ $t("purchase.Countdown") }}<span style="margin-right: 7px;">{{ days }}{{$t("purchase.day")}}</span><span>{{ hours }}:</span><span>{{ minutes }}:</span><span>{{ seconds }}</span></view> <view class="title border-b" style="padding:10px 0px">{{ timerbool?$t("purchase.Countdown1"):$t("purchase.Countdown") }}<span style="margin-right: 7px;">{{ days }}{{$t("purchase.day")}}</span><span>{{ hours }}:</span><span>{{ minutes }}:</span><span>{{ seconds }}</span></view>
<view class="m-y-md"> <view class="m-y-md">
<view class="label">{{ $t("purchase.a1") }}</view> <view class="label">{{ $t("purchase.a1") }}</view>
<v-picker <v-picker
@ -224,7 +224,8 @@ export default {
seconds: '00', seconds: '00',
timer1: null, timer1: null,
// //
remainingSeconds: 0 remainingSeconds: 0,
timerbool:false
} }
}, },
computed: { computed: {
@ -260,7 +261,19 @@ export default {
getInfo() { getInfo() {
Subscride.subscribe().then((res) => { Subscride.subscribe().then((res) => {
this.detail = res.data; this.detail = res.data;
//
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()
}
}); });
}, },
// //
@ -377,16 +390,6 @@ export default {
this.subscribeTokenList(); this.subscribeTokenList();
this.getInfo(); this.getInfo();
}, },
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()
}
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

Loading…
Cancel
Save