fix: bug
This commit is contained in:
@@ -72,6 +72,7 @@ export const commonUploadVoiceFile = (file, url, data = {}, fileKey='voice') =>
|
||||
};
|
||||
if (token)
|
||||
header['summary'] = token
|
||||
console.log(`${base_url}${url}`)
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: `${base_url}${url}`,
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
<view class="btns-cont">
|
||||
<view class="play-btn">
|
||||
<image class="icon"
|
||||
v-show="!isPlaying"
|
||||
v-show="!(!voiceLoading&&(props.activeVoiceId === dataInfo.id))"
|
||||
@click="playVoice"
|
||||
src="@/static/images/course/play-blue.png"
|
||||
style="width: 100%;height: 100%;"
|
||||
></image>
|
||||
<image class="icon"
|
||||
v-show="isPlaying"
|
||||
v-show="!voiceLoading&&(props.activeVoiceId === dataInfo.id)"
|
||||
@click.stop="pauseVoice"
|
||||
src="@/static/images/course/stop-blue.png"
|
||||
style="width: 100%;height: 100%;"
|
||||
@@ -94,11 +94,10 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
}
|
||||
const playVoice = () =>{
|
||||
emit('changePlay', unref(dataInfo)?.id)
|
||||
if(talkVoiceObj.value && talkVoiceObj.value.src && talkVoiceObj.value.src === itemVoice.value) {
|
||||
if(talkVoiceObj.value && talkVoiceObj.value.src) {
|
||||
talkVoiceObj.value.play()
|
||||
return
|
||||
}else{
|
||||
initVoice()
|
||||
talkVoiceObj.value.src = ''
|
||||
if(unref(dataInfo).talkingVoice){
|
||||
setTimeout(()=>{
|
||||
@@ -110,15 +109,15 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
}
|
||||
}
|
||||
const initVoice = () => {
|
||||
talkVoiceObj.value = uni.createInnerAudioContext()
|
||||
talkVoiceObj.value.onEnded(()=>{
|
||||
emit('changePlay', '')
|
||||
talkVoiceObj.value.src = ''
|
||||
})
|
||||
talkVoiceObj.value.onError(()=>{
|
||||
talkVoiceObj.value.src = ''
|
||||
})
|
||||
if(unref(dataInfo).intrctWay === '02'){
|
||||
talkVoiceObj.value = uni.createInnerAudioContext()
|
||||
talkVoiceObj.value.onEnded(()=>{
|
||||
emit('changePlay', '')
|
||||
talkVoiceObj.value.src = ''
|
||||
})
|
||||
talkVoiceObj.value.onError(()=>{
|
||||
talkVoiceObj.value.src = ''
|
||||
})
|
||||
itemVoice.value = unref(dataInfo).talkingVoice
|
||||
talkVoiceObj.value.src = itemVoice.value
|
||||
setTimeout(()=>{
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
type: String
|
||||
}
|
||||
})
|
||||
watch(() => props.activeVoiceId, () => {},{deep: true,immediate: true})
|
||||
watch(() => props.talkingInfo, () => {},{deep: true,immediate: true})
|
||||
const { talkingType } = toRefs(props)
|
||||
const handleEvents = (type) => {
|
||||
|
||||
+23
-12
@@ -198,7 +198,8 @@ import {
|
||||
talkingText: body.intrctContent,
|
||||
isLoading: false,
|
||||
id: _id,
|
||||
...body
|
||||
...body,
|
||||
talkingVoice: askData.value.talkingVoice
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -352,21 +353,31 @@ import {
|
||||
isLoading: true
|
||||
})
|
||||
scrollToBottomNow()
|
||||
console.log(voicePath,111111111)
|
||||
commonUploadVoiceFile(voicePath, '/traask/traAskchat/voiceTrans', {}).then(res=>{
|
||||
let _res = JSON.parse(res.data)
|
||||
if(_res.rtnCode === '0000'){
|
||||
askData.value = {
|
||||
reqBatch: reqBatch.value,
|
||||
intrctWay: '02',//01-文本;02-语音;03-图片
|
||||
intrctContent: _res.body.transContent,
|
||||
bucketKey: _res.body.fileId,
|
||||
ossFileAddr: _res.body.ossFileAddr,
|
||||
talkingVoice: voicePath
|
||||
if(!!(_res.body.transContent || '').trim()){
|
||||
askData.value = {
|
||||
reqBatch: reqBatch.value,
|
||||
intrctWay: '02',//01-文本;02-语音;03-图片
|
||||
intrctContent: _res.body.transContent,
|
||||
bucketKey: _res.body.fileId,
|
||||
ossFileAddr: _res.body.ossFileAddr,
|
||||
talkingVoice: voicePath
|
||||
}
|
||||
sendMessage({
|
||||
"commond" : 'ASK',
|
||||
"body": askData.value
|
||||
})
|
||||
}else{
|
||||
talkingList.value.pop()
|
||||
uni.showToast({
|
||||
title: '语音内容不能为空!',
|
||||
icon: "none",
|
||||
duration:1000
|
||||
});
|
||||
}
|
||||
sendMessage({
|
||||
"commond" : 'ASK',
|
||||
"body": askData.value
|
||||
})
|
||||
}else{}
|
||||
}).catch(err=>{
|
||||
talkingList.value.pop()
|
||||
|
||||
Reference in New Issue
Block a user