|
@@ -171,6 +171,20 @@ export default {
|
|
|
},
|
|
|
countDown() {
|
|
|
let that = this
|
|
|
+
|
|
|
+ console.log('先重置')
|
|
|
+ this.timeStartCount=0
|
|
|
+ let timer = this.timer
|
|
|
+ // 清除当前定时任务
|
|
|
+ clearInterval(timer)
|
|
|
+ // 清除原来的值, 还原计时器的初始值. 恢复默认的null
|
|
|
+ this.timer = null
|
|
|
+
|
|
|
+ this.$store.state.timerIsStart = false
|
|
|
+ this.timeleft = 0
|
|
|
+ this.stopAudio('audio1')
|
|
|
+ this.stopAudio('audio2')
|
|
|
+
|
|
|
// 获取剩余时间
|
|
|
this.getTimeLeft()
|
|
|
this.$store.state.timerIsStart = true
|
|
@@ -178,7 +192,6 @@ export default {
|
|
|
this.timer = setInterval(function() {
|
|
|
that.timeleft--
|
|
|
that.timeStartCount++
|
|
|
-
|
|
|
// 如果剩余时间, 小于0, 执行暂停按钮的逻辑, 停止定时任务
|
|
|
if ((that.timeleft >= 1 && that.timeleft < 6) || that.timeStartCount < 6) {
|
|
|
//確保顯示不是零才播
|
|
@@ -205,12 +218,15 @@ export default {
|
|
|
}, 1000)
|
|
|
},
|
|
|
onhandlePause() {
|
|
|
+ console.log('暫停')
|
|
|
let that = this
|
|
|
this.getTimeLeft()
|
|
|
this.$store.state.timerIsStart = false
|
|
|
clearInterval(that.timer)
|
|
|
},
|
|
|
handleReset() {
|
|
|
+ console.log('重置')
|
|
|
+ this.timeStartCount=0
|
|
|
let timer = this.timer
|
|
|
// 清除当前定时任务
|
|
|
clearInterval(timer)
|
|
@@ -237,6 +253,10 @@ export default {
|
|
|
let isPlaying = audio.currentTime > 0 && !audio.paused && !audio.ended && audio.readyState > audio.HAVE_CURRENT_DATA
|
|
|
if (!isPlaying) {
|
|
|
audio.play()
|
|
|
+ }else{
|
|
|
+ this.stopAudio('audio1')
|
|
|
+ this.stopAudio('audio2')
|
|
|
+ audio.play()
|
|
|
}
|
|
|
}
|
|
|
},
|