新增语音时长0秒提示信息,调整取消后仍然调用发送语音的bug

This commit is contained in:
唐明明
2022-02-24 15:21:20 +08:00
parent da6b60131d
commit 3ea3a2decd
3 changed files with 18 additions and 2 deletions

View File

@@ -47,6 +47,7 @@
maxRecordTime: 60,
recorderManager: null,
mp3AudioSrc: null,
isMoveCancel: false,
isBetaPlay: false, // 暂时无用
startOffsetTop: 0
}
@@ -69,7 +70,6 @@
this.getAndroidPermission().then(code => {
switch (code) {
case 1:
this.showConfirm = true
this.startOffsetTop = e.target.offsetTop
this.showRecordTip = true
this.recorderManager.start()
@@ -104,6 +104,21 @@
clearInterval(this.interval)
// 监听录音结束
this.recorderManager.onStop(res => {
if(this.isMoveCancel) {
this.isMoveCancel = false
return
}
console.log(this.maxRecordTime - this.recordTime)
if((this.maxRecordTime - this.recordTime) <= 0){
uni.showToast({
title: '说话时间太短',
icon : 'none',
})
this.showRecordTip = false
return
}
this.mp3AudioSrc = res.tempFilePath
this.showRecordTip = false
this.senVoice()
@@ -132,9 +147,10 @@
touchmove(e){
if(this.startOffsetTop - e.changedTouches[0].pageY > 100){
if(this.showRecordTip){
this.isMoveCancel = true
this.showRecordTip = false
clearInterval(this.interval)
this.recorderManager.stop()
clearInterval(this.interval)
this.recordTime = this.maxRecordTime
this.mp3AudioSrc = null
return