Commit 46cf8d8f by liuquan

U:修复发送语音bug

U:修复语音bug,持续点击无效,以及显示bug
parent 17481f62
...@@ -50,6 +50,7 @@ Page({ ...@@ -50,6 +50,7 @@ Page({
msgContent: '', //默认消息文字 msgContent: '', //默认消息文字
isRecord: false, //录音显示 isRecord: false, //录音显示
isRecording: false, //是否正在录音 isRecording: false, //是否正在录音
isTouch:false, //防止录音单次点击出现bug
canSend: true, canSend: true,
title: "正在录音", title: "正在录音",
audioSave: '', //当前播放音频路径 audioSave: '', //当前播放音频路径
...@@ -94,6 +95,7 @@ Page({ ...@@ -94,6 +95,7 @@ Page({
console.log('recorder pause') console.log('recorder pause')
}) })
recorderManager.onError(function (errMsg) { recorderManager.onError(function (errMsg) {
wx.
console.warn('recorder error:', errMsg); console.warn('recorder error:', errMsg);
}); });
recorderManager.onStop((res) => { recorderManager.onStop((res) => {
...@@ -1242,6 +1244,8 @@ Page({ ...@@ -1242,6 +1244,8 @@ Page({
*/ */
handleLongPress(e) { handleLongPress(e) {
var that = this; var that = this;
that.data.isTouch=true;
console.log("手指按下")
that.data.startPoint = e.touches[0]; that.data.startPoint = e.touches[0];
if (!this.data.payFlag) { if (!this.data.payFlag) {
that.moreService(); that.moreService();
...@@ -1276,11 +1280,13 @@ Page({ ...@@ -1276,11 +1280,13 @@ Page({
* 手指离开页面滑动 * 手指离开页面滑动
*/ */
handleTouchEnd() { handleTouchEnd() {
console.log("手指离开")
this.data.isTouch=false;
wx.hideLoading()
recorderManager.stop()
this.setData({ this.setData({
isRecording: false isRecording: false
}) })
wx.hideLoading()
recorderManager.stop()
}, },
// 开始录音之前要判断一下是否开启权限 // 开始录音之前要判断一下是否开启权限
startRecording() { startRecording() {
...@@ -1308,12 +1314,19 @@ Page({ ...@@ -1308,12 +1314,19 @@ Page({
} }
}) })
} else if (auth === true) { // 用户已经同意授权 } else if (auth === true) { // 用户已经同意授权
that.setData({ // console.log('this.data.isTouch',this.data.isTouch)
canSend: true, if(this.data.isTouch){
isRecording: true, that.setData({
title: "正在录音" canSend: true,
}) isRecording: true,
recorderManager.start(recordOptions) title: "正在录音"
})
recorderManager.start(recordOptions)
}else{
that.setData({
errorToptips: '说话时间太短'
})
}
} else { // 第一次进来,未发起授权 } else { // 第一次进来,未发起授权
wx.authorize({ wx.authorize({
scope: 'scope.record', scope: 'scope.record',
......
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