实训平台 综合演练 聊天代码调整

This commit is contained in:
joylink_cuiweidong 2020-05-12 17:49:00 +08:00
parent 808236a6fa
commit 376662d96e
2 changed files with 22 additions and 5 deletions

View File

@ -144,7 +144,7 @@ function handleSimulationInfo(state, data) {
voice: data.isAudio, voice: data.isAudio,
src: data.isAudio ? `/jlcloud/audio/${data.audioPath}` : '', src: data.isAudio ? `/jlcloud/audio/${data.audioPath}` : '',
memberName:data.member.name, memberName:data.member.name,
memberRole:data.member.name, memberRole:data.member.role,
memberOnline:data.member.online, memberOnline:data.member.online,
chatTime: data.chatTime, chatTime: data.chatTime,
targetOnline:data.targetMember ? data.targetMember.online : null, targetOnline:data.targetMember ? data.targetMember.online : null,

View File

@ -3,7 +3,7 @@
<div v-for="(chatContent,index) in chatContentList" :key="index" class="chatContentInClass"> <div v-for="(chatContent,index) in chatContentList" :key="index" class="chatContentInClass">
<div :class="chatContent.self?'rightUser':'leftUser'"> <div :class="chatContent.self?'rightUser':'leftUser'">
<div class="userHeader"> <div class="userHeader">
<div v-if="chatContent.group" class="userName">{{ chatContent.memberName }}</div> <div v-if="chatContent.group&& !chatContent.self" class="userName">{{ handle(chatContent) }}</div>
<div :class="chatContent.self?'userChatTime textRight':'userChatTime'">{{ formatTime(chatContent.chatTime) }}</div> <div :class="chatContent.self?'userChatTime textRight':'userChatTime'">{{ formatTime(chatContent.chatTime) }}</div>
</div> </div>
<div class="userBubble" @click="playAudio('audio'+index)"> <div class="userBubble" @click="playAudio('audio'+index)">
@ -19,6 +19,8 @@
</template> </template>
<script> <script>
import {getSimulationContextListNew} from '@/api/chat'; import {getSimulationContextListNew} from '@/api/chat';
import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie';
export default { export default {
props:{ props:{
currentCoversition:{ currentCoversition:{
@ -65,6 +67,8 @@ export default {
coversition.self = true; coversition.self = true;
} }
coversition.src = coversition.isAudio ? `/jlcloud/audio/${coversition.audioPath}` : ''; coversition.src = coversition.isAudio ? `/jlcloud/audio/${coversition.audioPath}` : '';
coversition.memberName = coversition.member.name;
coversition.memberRole = coversition.member.role;
return coversition; return coversition;
}); });
this.chatContentList = coversitionList; this.chatContentList = coversitionList;
@ -77,6 +81,19 @@ export default {
formatTime(time) { formatTime(time) {
return /\d{2}:\d{2}:\d{2}/.exec(time)[0] || time; return /\d{2}:\d{2}:\d{2}/.exec(time)[0] || time;
}, },
handle(chatContent) {
let data = chatContent.memberRole;
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
roleTypeList.forEach(function(element) {
const rolename = element.value;
if (Cookies.get('user_lang') == 'en') {
data = data.replace(rolename, element.enLabel);
} else {
data = data.replace(rolename, element.label);
}
});
return data + '-' + chatContent.memberName;
},
playAudio(id) { playAudio(id) {
document.querySelector('#' + id).play(); document.querySelector('#' + id).play();
} }
@ -110,8 +127,8 @@ export default {
display: inline-block; display: inline-block;
} }
.userHeader{margin-bottom: 2px;} .userHeader{margin-bottom: 2px;}
.userName{} .userName{font-size: 12px;display:inline-block;}
.userChatTime{font-size: 12px;} .userChatTime{font-size: 12px;display:inline-block;}
.userBubble{ .userBubble{
max-width: 200px; max-width: 200px;
font-size: 12px; font-size: 12px;
@ -124,7 +141,7 @@ export default {
font-size: 20px; font-size: 20px;
vertical-align: top; vertical-align: top;
} }
.textRight{text-align: right;} .textRight{text-align: right;width: 100%;}
.userMessage{} .userMessage{}
.messageText{line-height: 20px;} .messageText{line-height: 20px;}
.chatContentInClass{ .chatContentInClass{