Commit d3dfc84f authored by yaya's avatar yaya

feat: 倒计时优化

parent 20b42351
...@@ -53,7 +53,7 @@ export default { ...@@ -53,7 +53,7 @@ export default {
if (!this.timer) { if (!this.timer) {
this.timer = setInterval(() => { this.timer = setInterval(() => {
const deltaTime = this.last - (Date.now()) const deltaTime = this.last - (Date.now())
if (deltaTime > 60 * 60 * 1000) { if (deltaTime > 0) {
this.formatTime = this.formatDuring(deltaTime) this.formatTime = this.formatDuring(deltaTime)
// const newTime = formatTime.split(':') // const newTime = formatTime.split(':')
// if (newTime.length >= 3) { // if (newTime.length >= 3) {
...@@ -63,9 +63,12 @@ export default { ...@@ -63,9 +63,12 @@ export default {
// this.zzz = null // this.zzz = null
// // this.showMS = false; // // this.showMS = false;
// } // }
} else if (deltaTime > 0) { } else {
this.ticker.clearInterval(this.timer) this.formatTime = '已超时'
this.timer = null this.$emit('finishCountDown')
if (this.timer) {
clearTimeout(this.timer)
}
} }
}, 1000) }, 1000)
} }
...@@ -94,8 +97,10 @@ export default { ...@@ -94,8 +97,10 @@ export default {
// 得到秒数 // 得到秒数
const seconds = parseInt((mss % (1000 * 60)) / 1000) const seconds = parseInt((mss % (1000 * 60)) / 1000)
const str2 = seconds < 10 ? ('0' + seconds) : seconds const str2 = seconds < 10 ? ('0' + seconds) : seconds
console.log('======mss=', '剩余' + str + ':' + str1 + ':' + str2)
return '剩余' + str + ':' + str1 + ':' + str2 return '剩余' + str + ':' + str1 + ':' + str2
} else { } else {
this.$emit('finishCountDown')
return '已超时' return '已超时'
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
style="margin-left: 10px;">{{ systemStateName }} style="margin-left: 10px;">{{ systemStateName }}
</el-button> </el-button>
<div v-if="isHasPrice && (systemState === 1 || systemState === 8) && timeStr" style="margin-left: 10px"> <div v-if="isHasPrice && (systemState === 1 || systemState === 8) && timeStr" style="margin-left: 10px">
<NormalCountdown :last="timeStr"/> <NormalCountdown :last="timeStr" @finishCountDown="handleGetDetail"/>
</div> </div>
<div style="margin-right: auto"/> <div style="margin-right: auto"/>
<div v-if="systemState === 1" style="margin-right: 12px"> <div v-if="systemState === 1" style="margin-right: 12px">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment