Commit 5e7a5254ba014675d85cb85f5412b7ada3ce0dff

Authored by 王强
1 parent 4c5e0044

倒计时优化~

src/pages/discountList/discountList.vue
@@ -198,23 +198,22 @@ @@ -198,23 +198,22 @@
198 if (datas.discount_time > 0 && datas.list && datas.list.length) { 198 if (datas.discount_time > 0 && datas.list && datas.list.length) {
199 199
200 // 设置倒计时时间 200 // 设置倒计时时间
201 - this.$set(this, 'discountTime', datas.discount_time); 201 + this.$set(this, 'discountTime', parseInt(datas.discount_time) + 3);
202 202
203 // 设置倒计时超时轮训 203 // 设置倒计时超时轮训
204 let timeoutInterval = setInterval(() => { 204 let timeoutInterval = setInterval(() => {
205 205
  206 + // 倒计时超时时间计数
  207 + this.discountTimeout++;
  208 +
206 // 判断是否超时 209 // 判断是否超时
207 - if (this.discountTimeout > this.discountTime) { 210 + if (this.discountTimeout >= this.discountTime) {
208 211
209 // 停止倒计时 212 // 停止倒计时
210 clearInterval(timeoutInterval); 213 clearInterval(timeoutInterval);
211 214
212 // 刷新页面 215 // 刷新页面
213 window.location.reload(); 216 window.location.reload();
214 - } else {  
215 -  
216 - // 倒计时超时时间计数  
217 - this.discountTimeout++;  
218 } 217 }
219 }, 1000); 218 }, 1000);
220 } 219 }
src/pages/optimization2/optimization2.vue
@@ -321,23 +321,22 @@ @@ -321,23 +321,22 @@
321 if (datas.discount_time > 0 && datas.discount && datas.discount.length) { 321 if (datas.discount_time > 0 && datas.discount && datas.discount.length) {
322 322
323 // 设置倒计时时间 323 // 设置倒计时时间
324 - this.$set(this, 'discountTime', datas.discount_time); 324 + this.$set(this, 'discountTime', parseInt(datas.discount_time) + 3);
325 325
326 // 设置倒计时超时轮训 326 // 设置倒计时超时轮训
327 let timeoutInterval = setInterval(() => { 327 let timeoutInterval = setInterval(() => {
328 328
  329 + // 倒计时超时时间计数
  330 + this.discountTimeout++;
  331 +
329 // 判断是否超时 332 // 判断是否超时
330 - if (this.discountTimeout > this.discountTime) { 333 + if (this.discountTimeout >= this.discountTime) {
331 334
332 // 停止倒计时 335 // 停止倒计时
333 clearInterval(timeoutInterval); 336 clearInterval(timeoutInterval);
334 337
335 // 刷新页面 338 // 刷新页面
336 - window.location.reload();  
337 - } else {  
338 -  
339 - // 倒计时超时时间计数  
340 - this.discountTimeout++; 339 + // window.location.reload();
341 } 340 }
342 }, 1000); 341 }, 1000);
343 } 342 }