timeout.js
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @LastEditors: limin
* @LastEditTime: 2025-01-08 16:04:45
* @FilePath: \gl_tape\mixin\timeout.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const TIMER_DURATION = 40 * 60 * 1000 //40分钟
const TIMER_INTERVAL = 1 * 60 * 1000 //1分钟检一次
const TIMER_TIMEOUT = TIMER_DURATION / TIMER_INTERVAL
export default {
methods: {
//结束提示
stopRecorder() {
this.setReceptionStatus(0)
this.record.withError()
this.stop()
},
//监听点击事件
initTime() {
this.endWatchClick()
this.__timer = setInterval(() => {
if (this.__counter >= TIMER_TIMEOUT) {
//关闭录音
this.endWatchClick()
this.stopRecorder()
}
this.__counter++
}, TIMER_INTERVAL)
},
endWatchClick() {
if (this.__timer) clearInterval(this.__timer)
this.__timer = null
this.__counter = 0
},
handleTouchStart() {
this.__counter = 0
}
}
}