|
|
@@ -126,25 +126,28 @@ function loadList(action: 'page' | 'reload', callback?: (items) => void) {
|
|
126
|
126
|
|
|
127
|
127
|
//计算秒杀
|
|
128
|
128
|
function getCountdown() {
|
|
129
|
|
- const now = new Date();
|
|
130
|
|
- const startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseHours(currentSeckillDate.value.slice(0, 5)), 0, 0);
|
|
131
|
|
- const endDate = new Date(startDate.getTime() + 60 * 60 * 1000);
|
|
132
|
|
- // 结束时间为开始时间的一小时后
|
|
133
|
|
-
|
|
134
|
|
- if (now < endDate) {
|
|
135
|
|
- let milliseconds = endDate - now;
|
|
136
|
|
-
|
|
137
|
|
- const hours = Math.floor(milliseconds / (1000 * 60 * 60));
|
|
138
|
|
- const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60));
|
|
139
|
|
- const seconds = Math.floor((milliseconds % (1000 * 60)) / 1000);
|
|
140
|
|
-
|
|
141
|
|
- // 更新数据
|
|
142
|
|
- remainingTime.value = {
|
|
143
|
|
- hours: hours < 10 ? '0' + hours : hours,
|
|
144
|
|
- minutes: minutes < 10 ? '0' + minutes : minutes,
|
|
145
|
|
- seconds: seconds < 10 ? '0' + seconds : seconds
|
|
|
129
|
+ if (currentSeckillDate.value) {
|
|
|
130
|
+ const now = new Date();
|
|
|
131
|
+ const startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseHours(currentSeckillDate.value.slice(0, 5)), 0, 0);
|
|
|
132
|
+ const endDate = new Date(startDate.getTime() + 60 * 60 * 1000);
|
|
|
133
|
+ // 结束时间为开始时间的一小时后
|
|
|
134
|
+
|
|
|
135
|
+ if (now < endDate) {
|
|
|
136
|
+ let milliseconds = endDate - now;
|
|
|
137
|
+
|
|
|
138
|
+ const hours = Math.floor(milliseconds / (1000 * 60 * 60));
|
|
|
139
|
+ const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60));
|
|
|
140
|
+ const seconds = Math.floor((milliseconds % (1000 * 60)) / 1000);
|
|
|
141
|
+
|
|
|
142
|
+ // 更新数据
|
|
|
143
|
+ remainingTime.value = {
|
|
|
144
|
+ hours: hours < 10 ? '0' + hours : hours,
|
|
|
145
|
+ minutes: minutes < 10 ? '0' + minutes : minutes,
|
|
|
146
|
+ seconds: seconds < 10 ? '0' + seconds : seconds
|
|
|
147
|
+ }
|
|
146
|
148
|
}
|
|
147
|
149
|
}
|
|
|
150
|
+
|
|
148
|
151
|
}
|
|
149
|
152
|
|
|
150
|
153
|
function parseHours(time: any) {
|