更新
This commit is contained in:
parent
07c0ee4030
commit
5614e9859b
@ -39,10 +39,10 @@
|
||||
<text>{{ item.query }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="message" v-if="item.inputs.type == 'image'">
|
||||
<view class="message" v-if="item.inputs.type == 'image'" @click="previewImage(item.query)">
|
||||
<image :src="'data:image/png;base64,'+item.query" class="msg-img" mode="widthFix"></image>
|
||||
</view>
|
||||
<view class="message" v-if="item.inputs.type == 'voice'" @tap="playVoice(item.filePath)">
|
||||
<view class="message" v-if="item.inputs.type == 'voice'" @tap="playVoice(item.url)">
|
||||
<!-- 音频 -->
|
||||
<view class="msg-text voice" :style="{width:item.time*4+'rpx'}">
|
||||
<image src="/static/chat/sy.png" class="voice-img"></image>
|
||||
@ -62,7 +62,7 @@
|
||||
<view class="po_i" v-if="!item.showImage&&clickIdx==index">
|
||||
<view class="size_" @click="showImageFunction (item)">image</view>
|
||||
</view>
|
||||
<image :src="'data:image/png;base64,'+item.answer" v-if="item.showImage" class="msg-img"
|
||||
<image :src="'data:image/png;base64,'+item.answer" @click="previewImage(item.answer)" v-if="item.showImage" class="msg-img"
|
||||
mode="widthFix"></image>
|
||||
<text v-else>{{ item.imageText }}</text>
|
||||
</view>
|
||||
@ -103,6 +103,7 @@ import {
|
||||
import requestChat from '../../utils/requestChat'
|
||||
import permision from "@/js_sdk/wa-permission/permission.js"
|
||||
import request from '../../utils/request'
|
||||
import {base64ToPath} from "image-tools";
|
||||
//音频播放
|
||||
const innerAudioContext = uni.createInnerAudioContext();
|
||||
// 录音
|
||||
@ -250,6 +251,7 @@ export default {
|
||||
this.userId = infoData.userId
|
||||
this.userAvatar = infoData.userAvatar
|
||||
this.getMessageByStore()
|
||||
this.goBottom()
|
||||
}
|
||||
this.getRecordsToken()
|
||||
|
||||
@ -259,7 +261,6 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
async voiceTxt(item) {
|
||||
console.log('执行了')
|
||||
let res = await request({
|
||||
url: 'youDaoApi/tts',
|
||||
method: 'post',
|
||||
@ -269,10 +270,28 @@ export default {
|
||||
language: item.lang
|
||||
}
|
||||
})
|
||||
console.log('语音合成', res)
|
||||
this.playBase64Mp3(res.data)
|
||||
this.show = false
|
||||
|
||||
},
|
||||
// 预览图片单张
|
||||
previewImage(photoImg) {
|
||||
console.log('预览图片')
|
||||
photoImg = 'data:image/jpeg;base64,' + photoImg;
|
||||
base64ToPath(photoImg).then((resInfo)=>{
|
||||
uni.getImageInfo({
|
||||
src: resInfo,
|
||||
success: function(res){
|
||||
uni.previewImage({
|
||||
urls:[res.path]
|
||||
});
|
||||
},
|
||||
fail: function(err){
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
}).catch((err)=>{
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
showTxt(item) {
|
||||
item.showImage = false
|
||||
@ -363,8 +382,6 @@ export default {
|
||||
strStatus = "被永久拒绝权限"
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
startSocket() {
|
||||
this.socketId = this.userId + "_" + Date.now()
|
||||
@ -538,12 +555,19 @@ export default {
|
||||
|
||||
//音频播放
|
||||
playVoice(e) {
|
||||
let innerAudioContext1 = uni.createInnerAudioContext();
|
||||
innerAudioContext1.autoplay = true;
|
||||
innerAudioContext1.src = 'data:audio/mp3;base64,'+e.replace(/[\r\n]/g, "");
|
||||
innerAudioContext1.onPlay(() => {
|
||||
console.log('开始播放');
|
||||
});
|
||||
console.log('地址',e)
|
||||
// let innerAudioContext1 = uni.createInnerAudioContext();
|
||||
// innerAudioContext1.autoplay = true;
|
||||
// innerAudioContext1.playbackRate = 0.5;
|
||||
innerAudioContext.src = this.imagesUrl + e;
|
||||
console.log(innerAudioContext.src)
|
||||
innerAudioContext.play()
|
||||
// innerAudioContext.onPlay(() => {
|
||||
// console.log('开始播放');
|
||||
// });
|
||||
// innerAudioContext.onError((err) => {
|
||||
// console.log('播放错误:', err);
|
||||
// });
|
||||
|
||||
// console.log('音频开始')
|
||||
// innerAudioContext.src = `data:audio/mp3;base64,${e}`;
|
||||
@ -614,6 +638,7 @@ export default {
|
||||
'filePath': inputData.filePath,
|
||||
"lang": this.lang,
|
||||
'isTrans':true,
|
||||
'url': inputData.url
|
||||
};
|
||||
if (this.info.conversation == 'Translator') {
|
||||
msgItem.response_mode = 'blocking'
|
||||
@ -685,6 +710,7 @@ export default {
|
||||
},
|
||||
// 滚动到底部
|
||||
goBottom() {
|
||||
// this.scrollToBottom()
|
||||
this.scrollToView = '';
|
||||
this.$nextTick(() => {
|
||||
|
||||
@ -692,7 +718,15 @@ export default {
|
||||
this.scrollToView = this.scrollId;
|
||||
this.$forceUpdate()
|
||||
})
|
||||
}
|
||||
},
|
||||
// 滚动到底部
|
||||
scrollToBottom() {
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.scrollTop = 999999; // 设一个足够大的值,确保滚动到底部
|
||||
}, 50); // 增加微小延迟,等待 DOM 渲染完成
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -237,7 +237,7 @@ export default {
|
||||
base64: res1.base64
|
||||
}
|
||||
}).then(res2 => {
|
||||
that.send(json.id, 1, res1.base64)
|
||||
that.send(json.id, 1, res1.base64,null,res1.url)
|
||||
})
|
||||
})
|
||||
// that.send(json.id, 1, res.data)
|
||||
@ -347,7 +347,7 @@ export default {
|
||||
type: 2
|
||||
}
|
||||
}).then(ress => {
|
||||
that.send(ress.data, 2, res.base64, that.vlength, res.base64)
|
||||
that.send(ress.data, 2, res.base64, that.vlength, res.url)
|
||||
this.vlength = 0;
|
||||
})
|
||||
}).catch(error => {
|
||||
@ -375,13 +375,14 @@ export default {
|
||||
});
|
||||
},
|
||||
//发送
|
||||
send(msg, type, base64, time) {
|
||||
send(msg, type, base64, time,url) {
|
||||
let date = {
|
||||
message: msg,
|
||||
type: type,
|
||||
base64: base64,
|
||||
time: time,
|
||||
filePath: base64
|
||||
filePath: base64,
|
||||
url:url
|
||||
}
|
||||
this.$emit('inputs', date);
|
||||
setTimeout(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user