2020-04-27 18:50:15 +08:00
|
|
|
<template>
|
|
|
|
<div class="chatcontentIn">
|
|
|
|
<div v-for="(chatContent,index) in chatContentList" :key="index" class="chatContentInClass">
|
|
|
|
<div :class="chatContent.self?'rightUser':'leftUser'">
|
|
|
|
<div class="userHeader">
|
2020-05-13 19:31:14 +08:00
|
|
|
<div v-if="chatContent.group&& !chatContent.self" class="userName">{{ covertName(chatContent.member) }}</div>
|
2020-04-27 18:50:15 +08:00
|
|
|
<div :class="chatContent.self?'userChatTime textRight':'userChatTime'">{{ formatTime(chatContent.chatTime) }}</div>
|
|
|
|
</div>
|
2020-04-28 14:04:22 +08:00
|
|
|
<div class="userBubble" @click="playAudio('audio'+index)">
|
2020-04-27 18:50:15 +08:00
|
|
|
<div class="userMessage">
|
2020-05-13 19:31:14 +08:00
|
|
|
<span v-if="chatContent.group||!chatContent.member.robot">@{{ covertName(chatContent.targetName) }}</span>
|
2020-04-28 14:04:22 +08:00
|
|
|
<span class="el-icon-video-play playicon" />
|
|
|
|
<span class="messageText">{{ chatContent.message }}</span>
|
|
|
|
<audio :id="'audio'+index" :src="baseUrl+chatContent.src" style="display:none" />
|
2020-04-27 18:50:15 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2020-05-12 16:46:41 +08:00
|
|
|
import {getSimulationContextListNew} from '@/api/chat';
|
2020-05-12 17:49:00 +08:00
|
|
|
import ConstConfig from '@/scripts/ConstConfig';
|
|
|
|
import Cookies from 'js-cookie';
|
2020-04-27 18:50:15 +08:00
|
|
|
export default {
|
|
|
|
props:{
|
|
|
|
currentCoversition:{
|
|
|
|
type:Object,
|
|
|
|
required:true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
chatContentList:[],
|
2020-04-28 14:04:22 +08:00
|
|
|
coversition:{},
|
|
|
|
baseUrl:process.env.VUE_APP_VOICE_API
|
2020-04-27 18:50:15 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
watch:{
|
|
|
|
'$store.state.socket.simulationText':function (val, old) { // 仿真聊天
|
|
|
|
if (this.currentCoversition.id == val.conversationId) {
|
2020-04-28 14:04:22 +08:00
|
|
|
const simulationText = this.$store.state.socket.simulationText;
|
|
|
|
this.chatContentList.push(simulationText);
|
2020-04-27 18:50:15 +08:00
|
|
|
}
|
2020-05-12 16:46:41 +08:00
|
|
|
},
|
|
|
|
$route() {
|
|
|
|
this.inintData();
|
|
|
|
},
|
|
|
|
currentCoversition:function (val, old) {
|
|
|
|
if (val) {
|
|
|
|
this.chatContentList = [];
|
|
|
|
this.coversition = this.currentCoversition;
|
|
|
|
this.inintData();
|
|
|
|
}
|
2020-04-27 18:50:15 +08:00
|
|
|
}
|
|
|
|
},
|
2020-05-12 16:46:41 +08:00
|
|
|
mounted() {
|
|
|
|
// this.coversition = this.currentCoversition;
|
|
|
|
// this.inintData();
|
2020-04-27 18:50:15 +08:00
|
|
|
},
|
|
|
|
methods:{
|
2020-04-28 14:04:22 +08:00
|
|
|
inintData() {
|
2020-05-12 16:46:41 +08:00
|
|
|
getSimulationContextListNew(this.$route.query.group, this.coversition.id).then(res=>{
|
|
|
|
const userId = this.$store.state.user.id;
|
|
|
|
const coversitionList = res.data.map(coversition=>{
|
|
|
|
coversition.self = false;
|
|
|
|
if (coversition.member.userId == userId) {
|
|
|
|
coversition.self = true;
|
|
|
|
}
|
|
|
|
coversition.src = coversition.isAudio ? `/jlcloud/audio/${coversition.audioPath}` : '';
|
2020-05-12 17:49:00 +08:00
|
|
|
coversition.memberName = coversition.member.name;
|
2020-05-13 19:31:14 +08:00
|
|
|
coversition.targetName = coversition.targetMember ? coversition.targetMember : 'All';
|
2020-05-12 17:49:00 +08:00
|
|
|
coversition.memberRole = coversition.member.role;
|
2020-05-12 16:46:41 +08:00
|
|
|
return coversition;
|
|
|
|
});
|
|
|
|
this.chatContentList = coversitionList;
|
|
|
|
});
|
|
|
|
// const coversitionListAll = Object.assign({}, this.$store.state.socket.coversitionList);
|
|
|
|
// const coversitionList = coversitionListAll[this.coversition.id] || [];
|
|
|
|
// // console.log('inintData---coversitionList' + JSON.stringify(this.$store.state.socket.coversitionList[this.coversition.id]));
|
|
|
|
// this.chatContentList = coversitionList;
|
2020-04-28 14:04:22 +08:00
|
|
|
},
|
2020-04-27 18:50:15 +08:00
|
|
|
formatTime(time) {
|
|
|
|
return /\d{2}:\d{2}:\d{2}/.exec(time)[0] || time;
|
2020-04-28 14:04:22 +08:00
|
|
|
},
|
2020-05-13 19:31:14 +08:00
|
|
|
covertName(data) {
|
|
|
|
if (data != 'All') {
|
|
|
|
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
|
|
|
|
roleTypeList.forEach(function(element) {
|
|
|
|
const rolename = element.value;
|
|
|
|
if (Cookies.get('user_lang') == 'en') {
|
|
|
|
if (rolename == data.role) {
|
|
|
|
data.role = element.enLabel;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (rolename == data.role) {
|
|
|
|
data.role = element.label;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const deviceName = data.deviceName ? '-' + data.deviceName : '';
|
|
|
|
const memberName = data.name ? '-' + data.name : '';
|
|
|
|
return data.role + deviceName + memberName;
|
|
|
|
} else {
|
|
|
|
return 'All';
|
|
|
|
}
|
2020-05-12 17:49:00 +08:00
|
|
|
},
|
2020-04-28 14:04:22 +08:00
|
|
|
playAudio(id) {
|
|
|
|
document.querySelector('#' + id).play();
|
2020-04-27 18:50:15 +08:00
|
|
|
}
|
2020-05-12 16:46:41 +08:00
|
|
|
// reloadData(currentCoversition) {
|
|
|
|
// this.chatContentList = [];
|
|
|
|
// this.coversition = currentCoversition;
|
|
|
|
// this.inintData();
|
|
|
|
// }
|
2020-04-27 18:50:15 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.chatcontentIn{
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
display: inline-block;
|
|
|
|
overflow: auto;
|
|
|
|
padding-bottom: 20px;
|
2020-04-28 14:04:22 +08:00
|
|
|
cursor:auto;
|
2020-04-27 18:50:15 +08:00
|
|
|
}
|
|
|
|
.leftUser{
|
|
|
|
float: left;
|
|
|
|
margin-left: 10px;
|
|
|
|
margin-top: 10px;
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
.rightUser{
|
|
|
|
float: right;
|
|
|
|
margin-right: 10px;
|
|
|
|
margin-top: 10px;
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
.userHeader{margin-bottom: 2px;}
|
2020-05-12 17:49:00 +08:00
|
|
|
.userName{font-size: 12px;display:inline-block;}
|
|
|
|
.userChatTime{font-size: 12px;display:inline-block;}
|
2020-04-27 18:50:15 +08:00
|
|
|
.userBubble{
|
2020-04-28 14:04:22 +08:00
|
|
|
max-width: 200px;
|
2020-04-27 18:50:15 +08:00
|
|
|
font-size: 12px;
|
|
|
|
padding: 10px;
|
|
|
|
background: #ccc;
|
|
|
|
border-radius: 5px;
|
2020-04-28 14:04:22 +08:00
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.playicon{
|
|
|
|
font-size: 20px;
|
|
|
|
vertical-align: top;
|
2020-04-27 18:50:15 +08:00
|
|
|
}
|
2020-05-12 17:49:00 +08:00
|
|
|
.textRight{text-align: right;width: 100%;}
|
2020-04-27 18:50:15 +08:00
|
|
|
.userMessage{}
|
2020-04-28 14:04:22 +08:00
|
|
|
.messageText{line-height: 20px;}
|
2020-04-27 18:50:15 +08:00
|
|
|
.chatContentInClass{
|
|
|
|
display: inline-block;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 谷歌、safari、qq浏览器、360浏览器滚动条样式
|
|
|
|
// 定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸
|
|
|
|
.chatcontentIn::-webkit-scrollbar {
|
|
|
|
width: 6px;
|
|
|
|
height: 6px;
|
|
|
|
// height: 110px;
|
|
|
|
background-color: #FFFFFF;
|
|
|
|
}
|
|
|
|
/*定义滚动条轨道 内阴影+圆角*/
|
|
|
|
.chatcontentIn::-webkit-scrollbar-track {
|
|
|
|
// box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
|
|
|
|
border-radius: 10px;
|
|
|
|
background-color: #FFFFFF;;
|
|
|
|
}
|
|
|
|
/*定义滑块 内阴影+圆角*/
|
|
|
|
.chatcontentIn::-webkit-scrollbar-thumb {
|
|
|
|
border-radius: 10px;
|
|
|
|
// box-shadow: inset 0 0 6px rgba(0,0,0,.3);
|
|
|
|
background-color: #cacaca;
|
|
|
|
}
|
|
|
|
/*滑块效果*/
|
|
|
|
.chatcontentIn::-webkit-scrollbar-thumb:hover {
|
|
|
|
border-radius: 5px;
|
|
|
|
// box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
|
|
|
|
background: rgba(0,0,0,0.4);
|
|
|
|
}
|
|
|
|
/*IE滚动条颜色*/
|
|
|
|
html {
|
|
|
|
scrollbar-face-color:#bfbfbf;/*滚动条颜色*/
|
|
|
|
scrollbar-highlight-color:#000;
|
|
|
|
scrollbar-3dlight-color:#000;
|
|
|
|
scrollbar-darkshadow-color:#000;
|
|
|
|
scrollbar-Shadow-color:#adadad;/*滑块边色*/
|
|
|
|
scrollbar-arrow-color:rgba(0,0,0,0.4);/*箭头颜色*/
|
|
|
|
scrollbar-track-color:#eeeeee;/*背景颜色*/
|
|
|
|
}
|
|
|
|
</style>
|