综合演练 聊天代码调整

This commit is contained in:
joylink_cuiweidong 2020-05-28 10:16:13 +08:00
parent 9fb51bd047
commit a471120ea0
6 changed files with 46 additions and 49 deletions

View File

@ -336,3 +336,12 @@ export function getSimulationContextListNew(group, conversationId) {
method: 'get' method: 'get'
}); });
} }
// 获取仿真会话消息列表(新版地图)
export function getSimulationChatMemberNew(group, conversationId) {
return request({
url: `/simulation/${group}/${conversationId}/members`,
method: 'get'
});
}

View File

@ -2,7 +2,7 @@
<!-- v-quickMenuDrag --> <!-- v-quickMenuDrag -->
<div class="chatBox"> <div class="chatBox">
<div v-show="!minimize" class="chat-box"> <div v-show="!minimize" class="chat-box">
<chat-member-list ref="chatMemberList" :group="group" @addCoversition="addCoversition" /> <chat-member-list ref="chatMemberList" :group="group" :current-coversition="currentCoversition" @addCoversition="addCoversition" />
<div class="chat-box-main"> <div class="chat-box-main">
<chat-coversition-list ref="chatCoversitionList" @setCurrentCoversition="setCurrentCoversition" @setHeadTitle="setHeadTitle" /> <chat-coversition-list ref="chatCoversitionList" @setCurrentCoversition="setCurrentCoversition" @setHeadTitle="setHeadTitle" />
<div class="chat-window"> <div class="chat-window">
@ -11,9 +11,6 @@
<div class="minimality" @click="handleMinimality('min')"> <div class="minimality" @click="handleMinimality('min')">
<i class="el-icon-remove" /> <i class="el-icon-remove" />
</div> </div>
<!-- <div v-show="currentCoversition.group==undefined?true:currentCoversition.group" class="showMembers" @click="handleMembers()">
<i class="el-icon-user-solid" />
</div> -->
<div v-show="currentCoversition.all==undefined?true&&isShow:currentCoversition.all&&isShow" class="chat-createGroup" @click="handleCreateGroup()"> <div v-show="currentCoversition.all==undefined?true&&isShow:currentCoversition.all&&isShow" class="chat-createGroup" @click="handleCreateGroup()">
<i class="el-icon-plus" style="font-weight: bolder;" /> <i class="el-icon-plus" style="font-weight: bolder;" />
</div> </div>
@ -96,16 +93,6 @@ export default {
return this.userRole != 'ADMIN' && this.userRole != 'AUDIENCE'; return this.userRole != 'ADMIN' && this.userRole != 'AUDIENCE';
} }
}, },
watch: {
'$store.state.socket.simulationRoleList': function (val) {
if (val && val.length) {
this.$nextTick(() => {
this.$refs.chatMemberList.setMemberStatus(val);
this.$refs.chatCoversitionList.setCoversitionStatus(val);
});
}
}
},
mounted() { mounted() {
this.initPage(); this.initPage();
}, },
@ -244,10 +231,6 @@ export default {
handleSetting() { handleSetting() {
this.$refs.chatSetting.doShow(); this.$refs.chatSetting.doShow();
}, },
// handleMembers() {
// this.$refs.chatSetting.doClose();
// this.$refs.chatMemberList.doShow();
// },
handleCreateGroup() { handleCreateGroup() {
this.$refs.createGroup.doShow(); this.$refs.createGroup.doShow();
} }
@ -278,6 +261,10 @@ export default {
margin-left: 15px; margin-left: 15px;
display: inline-block; display: inline-block;
margin-top: 10px; margin-top: 10px;
width: 70%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
} }
.chat-box-content{ .chat-box-content{
width: 100%; width: 100%;

View File

@ -7,14 +7,14 @@
<div v-if="chatContent.all&& !chatContent.self" class="userName">{{ covertName(chatContent.member) }}</div> <div v-if="chatContent.all&& !chatContent.self" class="userName">{{ covertName(chatContent.member) }}</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(baseUrl+chatContent.src)">
<div class="userMessage"> <div class="userMessage">
<span v-if="chatContent.all&&!chatContent.member.robot">@{{ covertName(chatContent.targetName) }}</span> <span v-if="chatContent.all&&!chatContent.member.robot">@{{ covertName(chatContent.targetName) }}</span>
<span class="el-icon-video-play playicon" /> <span class="el-icon-video-play playicon" />
<span class="messageText">{{ chatContent.message }}</span> <span class="messageText">{{ chatContent.message }}</span>
<audio :id="'audio'+index" :src="baseUrl+chatContent.src" style="display:none" />
</div> </div>
</div> </div>
<audio id="audioPlay" style="display:none" />
</div> </div>
</div> </div>
</div> </div>
@ -37,7 +37,6 @@ export default {
coversition:{}, coversition:{},
currentAudioList:[], currentAudioList:[],
isPlay:false, isPlay:false,
currentAudioIndex:0,
baseUrl:process.env.VUE_APP_VOICE_API baseUrl:process.env.VUE_APP_VOICE_API
}; };
}, },
@ -51,7 +50,7 @@ export default {
if (this.currentCoversition.id == val.id) { if (this.currentCoversition.id == val.id) {
this.chatContentList.push(simulationText); this.chatContentList.push(simulationText);
if (simulationText.member.userId != this.$store.state.user.id) { if (simulationText.member.userId != this.$store.state.user.id) {
this.currentAudioList.push(this.chatContentList.length - 1); this.currentAudioList.push(this.baseUrl + simulationText.src);
if (!this.isPlay) { if (!this.isPlay) {
this.isPlay = true; this.isPlay = true;
this.playAllAudio(); this.playAllAudio();
@ -64,7 +63,7 @@ export default {
// this.$emit('addCoversition', {data:simulationText, headerTitle:''}); // this.$emit('addCoversition', {data:simulationText, headerTitle:''});
this.chatContentList.push(simulationText); this.chatContentList.push(simulationText);
if (simulationText.member.userId != this.$store.state.user.id) { if (simulationText.member.userId != this.$store.state.user.id) {
this.currentAudioList.push(this.chatContentList.length - 1); this.currentAudioList.push(this.baseUrl + simulationText.src);
if (!this.isPlay) { if (!this.isPlay) {
this.isPlay = true; this.isPlay = true;
this.playAllAudio(); this.playAllAudio();
@ -120,7 +119,7 @@ export default {
return /\d{2}:\d{2}:\d{2}/.exec(time)[0] || time; return /\d{2}:\d{2}:\d{2}/.exec(time)[0] || time;
}, },
playAllAudio() { playAllAudio() {
this.playEachAudio(this.currentAudioList[this.currentAudioIndex]); // this.playEachAudio(this.currentAudioList[this.currentAudioIndex]);
}, },
playEachAudio(index) { playEachAudio(index) {
this.$nextTick(function() { this.$nextTick(function() {
@ -129,8 +128,8 @@ export default {
document.querySelector('#audio' + index).onended = function() { document.querySelector('#audio' + index).onended = function() {
that.currentAudioList.shift(); that.currentAudioList.shift();
if (that.currentAudioList.length > 0) { if (that.currentAudioList.length > 0) {
that.currentAudioIndex++; // that.currentAudioIndex++;
that.playEachAudio(that.currentAudioList[that.currentAudioIndex]); // that.playEachAudio(that.currentAudioList[that.currentAudioIndex]);
} else { } else {
that.isPlay = false; that.isPlay = false;
} }
@ -159,8 +158,9 @@ export default {
return 'All'; return 'All';
} }
}, },
playAudio(id) { playAudio(audioUrl) {
document.querySelector('#' + id).play(); document.querySelector('#audioPlay').src = audioUrl;
document.querySelector('#audioPlay').play();
} }
// reloadData(currentCoversition) { // reloadData(currentCoversition) {
// this.chatContentList = []; // this.chatContentList = [];

View File

@ -129,11 +129,6 @@ export default {
} }
return {coversitionName:coversitionName, isOnline:isOnline}; return {coversitionName:coversitionName, isOnline:isOnline};
} }
},
setCoversitionStatus(data) {
this.initPage(false);
this.$emit('setHeadTitle', !this.currentCoversition.isOnline ? this.currentCoversition.coverName + ' (离线)' : this.currentCoversition.coverName);
// this.changeCoversition(this.currentCoversition);
} }
} }
}; };

View File

@ -101,6 +101,11 @@ export default {
this.dialogVisible = false; this.dialogVisible = false;
this.checkList = []; this.checkList = [];
} }
}).catch(error=>{
this.$messageBox('创建会话失败: ' + error.messagfe);
this.loading = false;
this.dialogVisible = false;
this.checkList = [];
}); });
} }

View File

@ -5,14 +5,16 @@
<div <div
v-for="member in memberList" v-for="member in memberList"
:key="member.id" :key="member.id"
:class="member.online?'each-chat-member':'each-chat-member each-chat-member-outline'" class="each-chat-member"
:style="member.userId === userId ?'color:red':''" :style="member.userId === userId ?'color:red':''"
>{{ member.memberName }}</div> >{{ member.memberName }}</div>
<!-- :class="member.online?'each-chat-member':'each-chat-member each-chat-member-outline'" -->
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import {getSimulationMembersNew} from '@/api/chat'; // getSimulationMembersNew,
import {getSimulationChatMemberNew} from '@/api/chat';
import ConstConfig from '@/scripts/ConstConfig'; import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
export default { export default {
@ -21,6 +23,10 @@ export default {
group: { group: {
type: String, type: String,
required: true required: true
},
currentCoversition:{
type: Object,
required: true
} }
}, },
data() { data() {
@ -34,24 +40,19 @@ export default {
return this.$store.state.user.id; return this.$store.state.user.id;
} }
}, },
mounted() { watch:{
currentCoversition:function (val, old) {
if (val) {
this.getSimulationMembers(); this.getSimulationMembers();
}
}
},
mounted() {
}, },
methods:{ methods:{
setMemberStatus(memberInfo) {
this.getSimulationMembers();
// memberInfo.forEach(member=>{
// if (this.coversitionList) {
// this.coversitionList.forEach(item=>{
// if (item.id == member.id) {
// item.online = member.online;
// }
// });
// }
// });
},
getSimulationMembers() { getSimulationMembers() {
getSimulationMembersNew(this.$route.query.group).then(resp => { this.memberList = [];
getSimulationChatMemberNew(this.$route.query.group, this.currentCoversition.id).then(resp => {
let lastData = JSON.stringify(resp.data); let lastData = JSON.stringify(resp.data);
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew; const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
roleTypeList.forEach(function(element) { roleTypeList.forEach(function(element) {