diff --git a/pages/im/components/sent/sentVoice.vue b/pages/im/components/sent/sentVoice.vue
index f435ff2..d9ee19f 100644
--- a/pages/im/components/sent/sentVoice.vue
+++ b/pages/im/components/sent/sentVoice.vue
@@ -1,18 +1,21 @@
-
+
按住说话
-
-
-
- 录音中 {{recordTime}} s
-
-
-
- { this.mp3AudioSrc = null, this.showConfirm = false }">取消
- 试听
- 发送
+
+
+
+ 上滑取消
+
@@ -39,13 +42,13 @@
data() {
return {
showRecordTip: false,
- showConfirm: false,
recordTime: 60,
interval: 0,
maxRecordTime: 60,
recorderManager: null,
mp3AudioSrc: null,
- isBetaPlay: false
+ isBetaPlay: false, // 暂时无用
+ startOffsetTop: 0
}
},
computed: {
@@ -57,23 +60,17 @@
this.recorderManager = uni.getRecorderManager()
},
methods: {
- onShowLay(){
- // this.showRecordTip = true
- uni.vibrateShort({
- complete: com => {
- console.log(com)
- }
- })
- },
// 检查安卓录制权限
async getAndroidPermission() {
return await permision.requestAndroidPermission('android.permission.RECORD_AUDIO')
},
// 录制语音消息
- startRecord() {
+ startRecord(e) {
this.getAndroidPermission().then(code => {
switch (code) {
- case 1:
+ case 1:
+ this.showConfirm = true
+ this.startOffsetTop = e.target.offsetTop
this.showRecordTip = true
this.recorderManager.start()
this.interval = setInterval(() => {
@@ -99,7 +96,7 @@
})
},
// 结束录音
- stopRecord(e) {
+ stopRecord(e) {
if (!this.showRecordTip) return
// 延迟500毫秒结束录音
setTimeout(()=> {
@@ -107,10 +104,9 @@
clearInterval(this.interval)
// 监听录音结束
this.recorderManager.onStop(res => {
- console.log(res)
this.mp3AudioSrc = res.tempFilePath
- this.showConfirm = true
this.showRecordTip = false
+ this.senVoice()
})
},500)
},
@@ -127,12 +123,24 @@
this.recordTime), this.sender, () => {
this.recordTime = this.maxRecordTime
this.mp3AudioSrc = null
- this.showConfirm = false
setTimeout(() => {
this.$emit('success')
}, 500)
})
},
+ // 移动按钮
+ touchmove(e){
+ if(this.startOffsetTop - e.changedTouches[0].pageY > 100){
+ if(this.showRecordTip){
+ this.showRecordTip = false
+ clearInterval(this.interval)
+ this.recorderManager.stop()
+ this.recordTime = this.maxRecordTime
+ this.mp3AudioSrc = null
+ return
+ }
+ }
+ },
// 试听语音
startPlay() {
let betaAudio = uni.createInnerAudioContext()
@@ -159,7 +167,27 @@
}
}
}
-
+
+
+