公共会话切换

This commit is contained in:
fan 2020-07-20 10:48:53 +08:00
parent ba90420115
commit 826b4da854
2 changed files with 77 additions and 84 deletions

View File

@ -37,7 +37,7 @@
</div> </div>
<div class="chat-box-footer"> <div class="chat-box-footer">
<div style="width: 400px;font-size: 14px;">{{ userString }}</div> <div style="width: 400px;font-size: 14px;">{{ userString }}</div>
<!--<el-button size="mini" type="primary" class="chat-box-footer-create" @click="goCommonConversation">公共会话</el-button>--> <el-button size="mini" type="primary" class="chat-box-footer-create" @click="goCommonConversation">公共会话</el-button>
<el-button size="mini" type="primary" class="chat-box-footer-create" :loading="createLoading" @click="createCoversition()">创建群聊</el-button> <el-button size="mini" type="primary" class="chat-box-footer-create" :loading="createLoading" @click="createCoversition()">创建群聊</el-button>
</div> </div>
</div> </div>
@ -61,6 +61,7 @@
:message-list="messageList" :message-list="messageList"
:simulation-users="simulationUsers" :simulation-users="simulationUsers"
:user-role="userRole" :user-role="userRole"
:common-conversation="commonConversation"
@changeMessageList="changeMessageList" @changeMessageList="changeMessageList"
/> />
<div v-if="recordSending" class="chat_record_tip"> <div v-if="recordSending" class="chat_record_tip">
@ -75,9 +76,9 @@
<div class="chat-box-footer"> <div class="chat-box-footer">
<div class="chat-box-footer-tool" /> <div class="chat-box-footer-tool" />
<el-button v-if="isConversitionCreator && isButtonShow" size="mini" type="danger" class="chat-box-footer-quit" :loading="quitLoading" @click="quitConversition()">退出群聊</el-button> <el-button v-if="isConversitionCreator && isButtonShow" size="mini" type="danger" class="chat-box-footer-quit" :loading="quitLoading" @click="quitConversition()">退出群聊</el-button>
<!--<el-button v-if="!commonConversation" class="chat-box-footer-send" size="mini" type="primary" @click="goCommonConversation">公共会话</el-button>--> <el-button v-if="!commonConversation" class="chat-box-footer-send" size="mini" type="primary" @click="goCommonConversation">公共会话</el-button>
<!--<el-button v-if="!conversitionId && userRole !== 'AUDIENCE'" class="chat-box-footer-send" size="mini" type="primary" @click="cancelCommonConversation">成员列表</el-button>--> <el-button v-if="!conversitionId && userRole !== 'AUDIENCE'" class="chat-box-footer-send" size="mini" type="primary" @click="cancelCommonConversation">成员列表</el-button>
<!--<el-button v-if="conversitionId && commonConversation" class="chat-box-footer-send" size="mini" type="primary" @click="cancelCommonConversation">私有会话</el-button>--> <el-button v-if="conversitionId && commonConversation" class="chat-box-footer-send" size="mini" type="primary" @click="cancelCommonConversation">私有会话</el-button>
<el-button v-if="isButtonShow" class="chat-box-footer-send" size="mini" type="primary" :disabled="recordSending" @click="startRecording()">发送语音</el-button> <el-button v-if="isButtonShow" class="chat-box-footer-send" size="mini" type="primary" :disabled="recordSending" @click="startRecording()">发送语音</el-button>
</div> </div>
</div> </div>
@ -126,7 +127,7 @@ export default {
recordSending:false, recordSending:false,
currentCoversition:{}, currentCoversition:{},
conversitionId: '', conversitionId: '',
commonConversation: true, commonConversation: false,
seconds:0, seconds:0,
inter:null, inter:null,
recorders: null, recorders: null,
@ -152,8 +153,12 @@ export default {
memberIdList: [], memberIdList: [],
quitLoading: false, quitLoading: false,
conversitionMemberList: [], conversitionMemberList: [],
commonMemberList: [],
privateMemberList: [],
isConversitionCreator: false, isConversitionCreator: false,
messageList: [] messageList: [],
commonMessageList: [],
privateMessageList: []
}; };
}, },
computed:{ computed:{
@ -178,7 +183,8 @@ export default {
}, },
userRole(val) { userRole(val) {
if (val === 'AUDIENCE') { if (val === 'AUDIENCE') {
this.isAudienceInitData(); // this.isAudienceInitData();
this.goCommonConversation();
} }
}, },
'$store.state.map.mapViewLoadedCount':function(val) { '$store.state.map.mapViewLoadedCount':function(val) {
@ -208,8 +214,8 @@ export default {
memberList.push({memberId:id, connect:false}); memberList.push({memberId:id, connect:false});
} }
}); });
console.log(memberList, val.memberIds);
this.conversitionMemberList = memberList; this.conversitionMemberList = memberList;
this.privateMemberList = memberList;
} }
}, },
'$store.state.map.activeTrainListChange': function (val) { // '$store.state.map.activeTrainListChange': function (val) { //
@ -239,7 +245,9 @@ export default {
if (val.id === this.conversitionId) { if (val.id === this.conversitionId) {
this.conversitionId = ''; this.conversitionId = '';
this.conversitionMemberList = []; this.conversitionMemberList = [];
this.privateMemberList = [];
this.messageList = []; this.messageList = [];
this.privateMessageList = [];
} }
}, },
'$store.state.training.memberList': function (val) { '$store.state.training.memberList': function (val) {
@ -324,18 +332,6 @@ export default {
setSetting(data) { setSetting(data) {
this.form = data; this.form = data;
}, },
setCurrentCoversition(coversition) {
if (coversition && coversition.id) {
this.currentCoversition = coversition;
this.headerTitle = coversition.name;
} else {
this.headerTitle = '';
}
if (this.recordSending) {
this.cancleRecording();
}
this.$refs.chatContent.scrollTop();
},
setHeadTitle(headerTitle) { setHeadTitle(headerTitle) {
this.headerTitle = headerTitle; this.headerTitle = headerTitle;
}, },
@ -346,8 +342,8 @@ export default {
this.createLoading = true; this.createLoading = true;
startConversition(this.group, this.memberIdList).then(resp => { startConversition(this.group, this.memberIdList).then(resp => {
this.conversitionId = resp.data.id; this.conversitionId = resp.data.id;
// this.conversitionMemberList = resp.data.memberList;
this.messageList = []; this.messageList = [];
this.privateMessageList = [];
this.userString = ''; this.userString = '';
this.isConversitionCreator = true; this.isConversitionCreator = true;
this.$message.success('创建会话成功!'); this.$message.success('创建会话成功!');
@ -502,7 +498,9 @@ export default {
overSimulationConversition(this.group, this.conversitionId).then(resp => { overSimulationConversition(this.group, this.conversitionId).then(resp => {
this.conversitionId = ''; this.conversitionId = '';
this.conversitionMemberList = []; this.conversitionMemberList = [];
this.privateMemberList = [];
this.messageList = []; this.messageList = [];
this.privateMessageList = [];
this.quitLoading = false; this.quitLoading = false;
}).catch(() => { }).catch(() => {
this.$message.error('退出会话失败!'); this.$message.error('退出会话失败!');
@ -513,8 +511,10 @@ export default {
this.userString = ''; this.userString = '';
this.conversitionId = data.id; this.conversitionId = data.id;
this.conversitionMemberList = data.memberList; this.conversitionMemberList = data.memberList;
this.commonMemberList = data.memberList;
this.isConversitionCreator = false; this.isConversitionCreator = false;
this.messageList = []; this.messageList = [];
this.privateMessageList = [];
if (data.messageList && data.messageList) { if (data.messageList && data.messageList) {
data.messageList.forEach(message => { data.messageList.forEach(message => {
const member = this.memberData[message.memberId]; const member = this.memberData[message.memberId];
@ -523,6 +523,7 @@ export default {
message.self = this.$store.state.userId == member.userId; message.self = this.$store.state.userId == member.userId;
} }
this.messageList.push(message); this.messageList.push(message);
this.privateMessageList.push(message);
}); });
} }
}, },
@ -541,9 +542,8 @@ export default {
isAudienceInitData() { isAudienceInitData() {
getAllConversition(this.group).then(resp => { getAllConversition(this.group).then(resp => {
if (resp.data && resp.data.length) { if (resp.data && resp.data.length) {
const messageList = []; const messages = [];
resp.data.forEach(conversation => { resp.data.forEach(conversation => {
if (this.userRole == 'AUDIENCE') {
(conversation.messageList || []).forEach(message => { (conversation.messageList || []).forEach(message => {
const member = this.memberData[message.memberId]; const member = this.memberData[message.memberId];
message.src = `/audio/${message.audioPath}`; message.src = `/audio/${message.audioPath}`;
@ -551,31 +551,12 @@ export default {
if (member) { if (member) {
message.self = this.$store.state.userId == member.userId; message.self = this.$store.state.userId == member.userId;
} }
messageList.push(message); messages.push(message);
});
} else {
const user = this.simulationUsers[this.$store.state.user.id];
this.isConversitionCreator = conversation.creatorId == user.memberId;
!conversation.over && conversation.memberList.forEach(member =>{
if (member.memberId == user.memberId && member.connect) {
this.conversitionMemberList = conversation.memberList;
this.conversitionId = conversation.id;
this.messageList = [];
conversation.messageList.forEach(message => {
const member = this.memberData[message.memberId];
message.src = `/audio/${message.audioPath}`;
if (member) {
message.self = this.$store.state.userId == member.userId;
}
this.messageList.push(message);
});
}
});
}
});
this.messageList = messageList.sort(this.sortByMessageTime);
}
}); });
this.commonMessageList = messages.sort(this.sortByMessageTime);
console.log(this.userRole);
if (this.userRole == 'AUDIENCE') {
this.messageList = this.commonMessageList;
this.conversitionMemberList = []; this.conversitionMemberList = [];
const temDispatcherList = []; const temDispatcherList = [];
const temStationSupervisorList = []; const temStationSupervisorList = [];
@ -598,16 +579,49 @@ export default {
} }
}); });
this.conversitionMemberList = [...temDispatcherList, ...temStationSupervisorList, ...temMaintainerList, ...temDriverList]; this.conversitionMemberList = [...temDispatcherList, ...temStationSupervisorList, ...temMaintainerList, ...temDriverList];
} else {
const user = this.simulationUsers[this.$store.state.user.id];
this.isConversitionCreator = conversation.creatorId == user.memberId;
!conversation.over && conversation.memberList.forEach(member =>{
if (member.memberId == user.memberId && member.connect) {
this.conversitionMemberList = conversation.memberList;
this.conversitionId = conversation.id;
this.messageList = [];
conversation.messageList.forEach(message => {
const member = this.memberData[message.memberId];
message.src = `/audio/${message.audioPath}`;
if (member) {
message.self = this.$store.state.userId == member.userId;
}
this.privateMessageList.push(message);
this.messageList.push(message);
});
}
});
}
});
}
});
}, },
changeMessageList(data) { changeMessageList(data) {
this.messageList.push(data); this.messageList.push(data);
this.commonMessageList.push(data);
if (this.userRole !== 'AUDIENCE') {
this.privateMessageList.push(data);
}
},
goCommonConversation() {
!this.commonConversation && this.$refs.chatContent && this.$refs.chatContent.conversationChange();
this.commonConversation = true;
this.conversitionMemberList = this.commonMemberList;
this.messageList = this.commonMemberList;
},
cancelCommonConversation() {
this.commonConversation && this.$refs.chatContent && this.$refs.chatContent.conversationChange();
this.commonConversation = false;
this.conversitionMemberList = this.privateMemberList;
this.messageList = this.privateMessageList;
} }
// goCommonConversation() {
// this.commonConversation = true;
// },
// cancelCommonConversation() {
// this.commonConversation = false;
// }
} }
}; };
</script> </script>

View File

@ -93,37 +93,13 @@ export default {
// this.inintData(); // this.inintData();
}, },
methods:{ methods:{
inintData() {
// if (this.coversition.id) {
// 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 ? `/audio/${coversition.audioPath}` : '';
// coversition.targetUser = coversition.targetMember ? coversition.targetMember : 'All';
// return coversition;
// });
// this.chatContentList = coversitionList;
// this.scrollTop();
// });
// }
// 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;
},
scrollTop() { scrollTop() {
this.$nextTick(function() { this.$nextTick(function() {
const scrollTop = document.querySelector('.chatcontentInner').offsetHeight - document.querySelector('.chatcontentIn').offsetHeight + 30; const scrollTop = document.querySelector('.chatcontentInner').offsetHeight - document.querySelector('.chatcontentIn').offsetHeight + 30;
document.querySelector('.chatcontentIn').scrollTop = scrollTop; document.querySelector('.chatcontentIn').scrollTop = scrollTop;
}); });
}, },
// formatTime(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]);
}, },
@ -171,6 +147,9 @@ export default {
playAudio(audioUrl) { playAudio(audioUrl) {
document.querySelector('#audioPlay').src = audioUrl; document.querySelector('#audioPlay').src = audioUrl;
document.querySelector('#audioPlay').play(); document.querySelector('#audioPlay').play();
},
conversationChange() {
} }
} }
}; };