dxz1228 vor 2 Jahren
Ursprung
Commit
50fdf41bb5
2 geänderte Dateien mit 19 neuen und 7 gelöschten Zeilen
  1. 18 6
      src/pages/home/index.vue
  2. 1 1
      src/pages/miaosha/index.vue

+ 18 - 6
src/pages/home/index.vue

@@ -218,9 +218,10 @@ function loadList(action: 'page' | 'reload', callback?: (items) => void) {
218 218
 function getCountdown() {
219 219
   const now = new Date();
220 220
   const startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseHours(msSeckillDate.value), 0, 0);
221
+  // const startDate = new Date('2023-12-26 10:55:00');
221 222
   const endDate = new Date(startDate.getTime() + 60 * 60 * 1000); // 结束时间为开始时间的一小时后
222 223
 
223
-  if (now < endDate) {
224
+  if (now > startDate && now < endDate) {
224 225
     let milliseconds = endDate - now;
225 226
 
226 227
     const hours = Math.floor(milliseconds / (1000 * 60 * 60));
@@ -233,12 +234,24 @@ function getCountdown() {
233 234
       minutes: minutes < 10 ? '0' + minutes : minutes,
234 235
       seconds: seconds < 10 ? '0' + seconds : seconds
235 236
     }
236
-  } else {
237
+  } else if (now >= endDate) {
238
+    clearInterval(timer);
239
+    //加载秒杀数据
240
+    console.log('时间到,自动关闭');
241
+    // loadList('reload')
242
+    uni.reLaunch({
243
+      url: '/pages/home/index'
244
+    })
245
+  } else if (now < startDate) {
246
+    console.log(111);
247
+
248
+  } else if (now == startDate) {
237 249
     clearInterval(timer);
238 250
     //加载秒杀数据
239
-    console.log('自动关闭');
240
-    uni.switchTab({
241
-      url:'pages/home/index'
251
+    console.log('时间到,自动关闭');
252
+    // loadList('reload')
253
+    uni.reLaunch({
254
+      url: '/pages/home/index'
242 255
     })
243 256
   }
244 257
 }
@@ -260,7 +273,6 @@ onUnload(() => {
260 273
 
261 274
 
262 275
 
263
-
264 276
 watch(() => state.isShowSignIn, (val) => {
265 277
   val ? uni.hideTabBar() : uni.showTabBar()
266 278
 })

+ 1 - 1
src/pages/miaosha/index.vue

@@ -270,7 +270,7 @@ function onClickLeft() {
270 270
       </scroll-view> -->
271 271
       <scroll-view class=" whitespace-nowrap  w-screen  text-sm py-3" :scroll-with-animation="true" :scroll-x="true"
272 272
         :show-scrollbar="false">
273
-        <div class="flex  items-center justify-center">
273
+        <div class="flex  items-center ">
274 274
           <div @tap="handleSeckillDateClick(item)" v-for="(item, index) in state.list" :key="index"
275 275
             class="basis-1/3   relative px-3 text-[#FFFFFF]" style="text-align: center;">
276 276
             <div>{{ item.seckill_date?.slice(0, 5) }}</div>