This commit is contained in:
liuye
2024-07-18 15:14:34 +08:00
parent b91d8f01ce
commit 8140e15f5d

View File

@@ -144,42 +144,12 @@ export default {
methods: {
...mapActions(['autoLogin', 'getUserInfo']),
startRecord() {
// if(this.isFlag) return
// this.isStart = true
// uni.authorize({
// scope: 'scope.record',
// success() {
// // const options = {
// // duration: 10000,
// // sampleRate: 44100,
// // numberOfChannels: 1,
// // encodeBitRate: 192000,
// // format: 'aac',
// // frameSize: 50
// // }
// const options = {
// duration: 60000,
// sampleRate: 16000,
// format: 'mp3'
// }
// recorderManager.start(options);
// },
// fail(err) {
// this.isStart = false
// uni.showModal({
// title: "提示",
// content: "您的录音权限未开启",
// })
// }
// })
this.isStart = true
this.recorder = Recorder({
type: 'mp3',
sampleRate: 16000,
bitRate: 16
})
this.recorder.open(() => {
this.recorder.start()
})
@@ -220,25 +190,6 @@ export default {
this.type = 'text'
this.content = ''
},
upLoad(filePath) {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: `${this.$http.defaults.baseURL}/admin/file/add`,
filePath,
fileType: 'audio',
name: 'file',
success: uploadFileRes => {
this.voiceUrl = JSON.parse(uploadFileRes.data).data[0].split(';')[0]
this.voiceId = JSON.parse(uploadFileRes.data).data[0].split(';')[1]
this.sendVoice()
resolve(uploadFileRes)
},
fail: err => {
reject(err)
}
})
})
},
sendMsg() {
if(!this.user.token) {
return this.$u.toast("请先进行登录")
@@ -308,15 +259,38 @@ export default {
}
})
},
// play(src, index) {
// innerAudioContext.stop();
// if(this.messageList[index].isPlay) {
// innerAudioContext.onStop(() => {
// this.messageList[index].isPlay = false
// })
// return
// }
// this.messageList.map((item) => {
// if(item.sdkFileUrl) {
// item.isPlay = false
// }
// })
// this.messageList[index].isPlay = true
// innerAudioContext.src = src;
// this.$nextTick(() => {
// innerAudioContext.play();
// })
// innerAudioContext.onEnded(() => {
// this.messageList[index].isPlay = false
// })
// },
// playStop(index) {
// innerAudioContext.stop();
// innerAudioContext.onStop(() => {
// this.messageList[index].isPlay = false
// })
// },
play(src, index) {
innerAudioContext.stop();
if(this.messageList[index].isPlay) {
innerAudioContext.onStop(() => {
this.messageList[index].isPlay = false
})
return
}
this.messageList.map((item) => {
if(item.sdkFileUrl) {
item.isPlay = false