Commit 5e7a5254ba014675d85cb85f5412b7ada3ce0dff
1 parent
4c5e0044
倒计时优化~
Showing
2 changed files
with
11 additions
and
13 deletions
src/pages/discountList/discountList.vue
| ... | ... | @@ -198,23 +198,22 @@ |
| 198 | 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 | 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 | 213 | clearInterval(timeoutInterval); |
| 211 | 214 | |
| 212 | 215 | // 刷新页面 |
| 213 | 216 | window.location.reload(); |
| 214 | - } else { | |
| 215 | - | |
| 216 | - // 倒计时超时时间计数 | |
| 217 | - this.discountTimeout++; | |
| 218 | 217 | } |
| 219 | 218 | }, 1000); |
| 220 | 219 | } | ... | ... |
src/pages/optimization2/optimization2.vue
| ... | ... | @@ -321,23 +321,22 @@ |
| 321 | 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 | 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 | 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 | 341 | }, 1000); |
| 343 | 342 | } | ... | ... |