优化订单倒倒计时JS逻辑
Signed-off-by: 🍓 <lixia.zhang@yoho.cn>
Showing
1 changed file
with
3 additions
and
5 deletions
@@ -45,8 +45,8 @@ function downCount(options) { | @@ -45,8 +45,8 @@ function downCount(options) { | ||
45 | // set new Date object | 45 | // set new Date object |
46 | return utc; | 46 | return utc; |
47 | }, | 47 | }, |
48 | - | ||
49 | - difference = targetDateFunction() - currentDateFunction();// difference of dates | 48 | + difference = targetDateFunction() - currentDateFunction(),// difference of dates |
49 | + interval; | ||
50 | 50 | ||
51 | // Throw error if date is not set | 51 | // Throw error if date is not set |
52 | if (!settings) { | 52 | if (!settings) { |
@@ -68,11 +68,10 @@ function downCount(options) { | @@ -68,11 +68,10 @@ function downCount(options) { | ||
68 | _minute = _second * 60, | 68 | _minute = _second * 60, |
69 | _hour = _minute * 60, | 69 | _hour = _minute * 60, |
70 | _day = _hour * 24, | 70 | _day = _hour * 24, |
71 | - interval, | ||
72 | days, | 71 | days, |
73 | hours, | 72 | hours, |
74 | minutes, | 73 | minutes, |
75 | - seconds; | 74 | + seconds; |
76 | 75 | ||
77 | // calculate dates | 76 | // calculate dates |
78 | days = Math.floor(difference / _day), | 77 | days = Math.floor(difference / _day), |
@@ -97,7 +96,6 @@ function downCount(options) { | @@ -97,7 +96,6 @@ function downCount(options) { | ||
97 | return; | 96 | return; |
98 | } | 97 | } |
99 | } | 98 | } |
100 | - countdown(); | ||
101 | interval = setInterval(countdown, 1000);// start | 99 | interval = setInterval(countdown, 1000);// start |
102 | } | 100 | } |
103 | 101 |
-
Please register or login to post a comment