综合演练 聊天代码调整

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'
});
}
// 获取仿真会话消息列表(新版地图)
export function getSimulationChatMemberNew(group, conversationId) {
return request({
url: `/simulation/${group}/${conversationId}/members`,
method: 'get'
});
}

View File

@ -2,7 +2,7 @@
<!-- v-quickMenuDrag -->
<div class="chatBox">
<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">
<chat-coversition-list ref="chatCoversitionList" @setCurrentCoversition="setCurrentCoversition" @setHeadTitle="setHeadTitle" />
<div class="chat-window">
@ -11,9 +11,6 @@
<div class="minimality" @click="handleMinimality('min')">
<i class="el-icon-remove" />
</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()">
<i class="el-icon-plus" style="font-weight: bolder;" />
</div>
@ -96,16 +93,6 @@ export default {
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() {
this.initPage();
},
@ -244,10 +231,6 @@ export default {
handleSetting() {
this.$refs.chatSetting.doShow();
},
// handleMembers() {
// this.$refs.chatSetting.doClose();
// this.$refs.chatMemberList.doShow();
// },
handleCreateGroup() {
this.$refs.createGroup.doShow();
}
@ -278,6 +261,10 @@ export default {
margin-left: 15px;
display: inline-block;
margin-top: 10px;
width: 70%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.chat-box-content{
width: 100%;

View File

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

View File

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

View File

@ -5,14 +5,16 @@
<div
v-for="member in memberList"
: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':''"
>{{ member.memberName }}</div>
<!-- :class="member.online?'each-chat-member':'each-chat-member each-chat-member-outline'" -->
</div>
</div>
</template>
<script>
import {getSimulationMembersNew} from '@/api/chat';
// getSimulationMembersNew,
import {getSimulationChatMemberNew} from '@/api/chat';
import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie';
export default {
@ -21,6 +23,10 @@ export default {
group: {
type: String,
required: true
},
currentCoversition:{
type: Object,
required: true
}
},
data() {
@ -34,24 +40,19 @@ export default {
return this.$store.state.user.id;
}
},
mounted() {
watch:{
currentCoversition:function (val, old) {
if (val) {
this.getSimulationMembers();
}
}
},
mounted() {
},
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() {
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);
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
roleTypeList.forEach(function(element) {