From 4ae91369cbeda288841eacb4b1463f085f6f56e9 Mon Sep 17 00:00:00 2001 From: yanran200730 Date: Fri, 17 Jun 2022 11:23:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E6=97=B6=E5=96=8A=E8=AF=9D=E9=9C=80?= =?UTF-8?q?=E6=B1=82=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apps/AppBroadcast/LiveBroadcast.vue | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/apps/AppBroadcast/LiveBroadcast.vue b/src/apps/AppBroadcast/LiveBroadcast.vue index 38c42dca..fbd81e01 100644 --- a/src/apps/AppBroadcast/LiveBroadcast.vue +++ b/src/apps/AppBroadcast/LiveBroadcast.vue @@ -63,7 +63,7 @@ -

{{ time }}

+

{{ time }}S

@@ -93,8 +93,7 @@ isRecording: false, recorder: null, blobFile: null, - counterDownTime: 0, - time: '00:00:00', + time: 60, timingTimeout: null, equipmentList: [], recordList: [], @@ -192,13 +191,11 @@ }, timing () { - var durationObj = this.$dayjs.duration(this.counterDownTime * 1000) - var hours = durationObj.hours() > 9 ? durationObj.hours() : '0' + durationObj.hours() - var min = durationObj.minutes() > 9 ? durationObj.minutes() : '0' + durationObj.minutes() - var seconds = durationObj.seconds() > 9 ? durationObj.seconds() : '0' + durationObj.seconds() + this.time = this.time - 1 - this.time = hours + ':' + min + ':' + seconds - this.counterDownTime++ + if (this.time === 0) { + this.stop() + } this.timingTimeout = setTimeout(() => { this.timing() }, 1000) @@ -238,17 +235,16 @@ }, stop (isCancel) { - this.counterDownTime = 0 clearTimeout(this.timingTimeout) this.recorder.stop((blob, duration) => { this.recorder.close() this.recorder = null if (isCancel) { + this.time = 60 return false } - this.time = '00:00:00' let formData = {} formData = new FormData() formData.append('file', new window.File([blob], `${(new Date).getTime()}` )) @@ -286,6 +282,8 @@ }).catch(() => { this.isShow = false }) + + this.time = 60 console.log(blob, (window.URL || webkitURL).createObjectURL(blob), '时长:' + duration + 'ms') }, msg => { console.log('录音失败:' + msg)