修改会话问题

This commit is contained in:
fan 2020-09-01 11:20:53 +08:00
parent 6eed1b58a9
commit 716e7c2117
4 changed files with 97 additions and 69 deletions

View File

@ -247,7 +247,6 @@ export default {
const that = this;
this.recorders.stopRecording(function(blobURL) {
const data = URL.createObjectURL(that.recorders.getBlob());
console.log('--------', data);
clearInterval(that.inter);
that.seconds = 0;
const blob = that.recorders.getBlob();
@ -307,6 +306,9 @@ export default {
},
inviteMember() {
this.$refs.chatToolTip.doShow();
},
addAudioList(data) {
this.$refs.chatContent.addAudioList(data);
}
}
};

View File

@ -30,12 +30,20 @@ export default {
},
data() {
return {
// currentAudioList:[],
// currentAudioIndex:0,
// isPlay:false,
currentAudioList:[],
currentAudioIndex:0,
isPlay:false,
isAutoPlay: false,
baseUrl:process.env.VUE_APP_VOICE_API + 'audio/'
};
},
watch: {
'currentAudioList': function(val) {
if (val.length > 0 && !this.isPlay && !this.isAutoPlay) {
this.playEachAudio(val[0].src);
}
}
},
mounted() {
// this.coversition = this.currentCoversition;
// this.inintData();
@ -47,50 +55,36 @@ export default {
document.querySelector('.chatcontentIn').scrollTop = scrollTop;
});
},
// playEachAudio(audioUrl) {
// this.$nextTick(function() {
// document.querySelector('#audioPlay').src = audioUrl;
// document.querySelector('#audioPlay').play();
// const that = this;
// document.querySelector('#audioPlay').onended = function() {
// that.currentAudioList.shift();
// console.log(that.currentAudioList.length);
// if (that.currentAudioList.length > 0) {
// that.playEachAudio(that.currentAudioList[that.currentAudioIndex]);
// } else {
// that.isPlay = false;
// }
// };
// });
// },
// covertName(data, status) {
// if (status) {
// let result = '';
// const members = data.members || this.conversitionMemberList;
// (members || []).forEach(member => {
// if (member.memberId != data.memberId) {
// result += ('@' + this.covertEachName(member.memberId));
// }
// });
// return result;
// } else {
// return this.covertEachName(data.memberId);
// }
// },
// covertEachName(memberId) {
// let name = '';
// const member = this.$store.state.training.memberData[memberId];
// if (member && member.userId) {
// const user = this.simulationUsers[member.userId];
// name = member.label + '(' + user.nickName + ')';
// } else if (member) {
// name = member.label;
// }
// return name;
// },
playEachAudio(audioUrl) {
this.$nextTick(function() {
this.isAutoPlay = true;
document.querySelector('#audioPlay').src = this.baseUrl + audioUrl;
document.querySelector('#audioPlay').play();
const that = this;
document.querySelector('#audioPlay').onended = function() {
that.currentAudioList.shift();
if (that.currentAudioList.length > 0) {
that.playEachAudio(that.currentAudioList[0].src);
} else {
that.isAutoPlay = false;
}
};
});
},
playAudio(audioUrl) {
this.isPlay = true;
document.querySelector('#audioPlay').src = audioUrl;
document.querySelector('#audioPlay').play();
const that = this;
document.querySelector('#audioPlay').onended = function() {
that.isPlay = false;
that.isAutoPlay = false;
};
},
addAudioList(converstion) {
this.currentAudioList.push(converstion);
this.scrollTop();
}
// conversationChange() {
// this.currentAudioList = [];

View File

@ -108,9 +108,12 @@ export default {
//
'$store.state.socket.createConversition':function(val) {
if (this.memberData.length > 0) {
const member = this.memberData.find(member=>{ return member.id == val.creatorId; });
if (member && member.userId == this.$store.state.user.id) {
const conversitionMember = this.memberData.find(member=>{ return member.userId == this.$store.state.user.id; });
if (conversitionMember && val.memberIds.includes(conversitionMember.id)) {
//
if (val.creatorId !== conversitionMember.id) {
this.$message.success(this.coverName(val) + '与你开启会话');
}
this.isHasCoversition = true;
this.isStartRecord = true;
this.isQuitShow = true;
@ -118,6 +121,7 @@ export default {
const memberList = [];
val.memberIds.forEach(id=>{
if (val.creatorId == id) {
const member = this.memberData.find(member=>{ return member.id == id; });
member.connect = true;
memberList.push(member);
} else {
@ -177,7 +181,11 @@ export default {
'$store.state.socket.conversationInfo':function (val, old) { // 仿
const simulationText = this.$store.state.socket.conversationInfo;
if (val.messageType == 'MESSAGE' && (this.conversitionId == val.id || this.userRole == 'AUDIENCE')) {
this.chatContentList.push(this.addContent(simulationText.message));
const content = this.addContent(simulationText.message);
this.chatContentList.push(content);
if (!content.self) {
this.$refs.chatbox.addAudioList(content);
}
}
},
// ()
@ -217,23 +225,23 @@ export default {
},
//
'$store.state.socket.inviteSimulationConversition':function(val) {
const member = this.memberData.find(member=>{ return member.id == val.creatorId; });
if (member) {
this.inviteUserName = member.label;
this.conversitionId = val.id;
member.connect = true;
member.online = true;
this.inviteUser = member;
this.currentMemberList.push(member);
const member = this.memberData.find(member=>{ return member.id == val.memberId; });
member.connect = true;
this.currentMemberList.push(member);
this.isStartRecord = true;
// this.$refs.chatbox.inviteMember();
this.$message.success(this.inviteUserName + '与你开启会话');
}
// const conversitionMember = this.memberData.find(member=>{ return member.id == val.creatorId; });
// if (conversitionMember) {
// this.inviteUserName = conversitionMember.label;
// this.conversitionId = val.id;
// conversitionMember.connect = true;
// conversitionMember.online = true;
// this.inviteUser = conversitionMember;
//
// this.currentMemberList.push(conversitionMember);
// const member = this.memberData.find(member=>{ return member.id == val.memberId; });
// member.connect = true;
// this.currentMemberList.push(member);
// this.isStartRecord = true;
// this.isHasCoversition = true;
// // this.$refs.chatbox.inviteMember();
// this.$message.success(this.inviteUserName + '');
// }
}
},
@ -254,6 +262,10 @@ export default {
}
return text;
},
coverName(inviteUser) {
const member = this.memberData.find(member=>{ return member.id == inviteUser.creatorId; });
return member.label;
},
clearAllData() {
this.resetCoversition();
this.createCoversition = true;

View File

@ -92,7 +92,7 @@
<div class="record_tip_confirm" @click="stopRecording()">确定</div>
<div class="record_tip_cancle" @click="cancleRecording()">取消</div>
</div>
<chat-member-list ref="chatMemberList" :conversition-member-list="conversitionMemberList" :simulation-users="simulationUsers" @connectMember="connectMember" />
<chat-member-list ref="chatMemberList" :conversition-member-list="conversitionMemberList" :simulation-users="simulationUsers" />
</div>
<div class="chat-box-footer">
<div class="chat-box-footer-tool" />
@ -169,7 +169,8 @@ export default {
isConversitionCreator: false,
messageList: [],
commonMessageList: [],
privateMessageList: []
privateMessageList: [],
temData: []
};
},
computed:{
@ -217,9 +218,12 @@ export default {
});
},
'$store.state.socket.createConversition':function(val) {
const member = this.memberData[val.creatorId];
if (member && member.userId == this.$store.state.user.id) {
const member = this.temData.find(member=>{ return member.userId == this.$store.state.user.id; });
if (member && val.memberIds.includes(member.id)) {
const memberList = [];
if (val.creatorId !== member.id) {
this.$message.success(this.coverName(val) + '与你开启会话');
}
val.memberIds.forEach(id=>{
if (val.creatorId == id) {
memberList.push({memberId:id, connect:true});
@ -278,6 +282,12 @@ export default {
this.$refs.tree.filter(this.queryMember);
}
},
'$store.state.socket.inviteSimulationConversition':function(val) {
// this.userName = this.coverName(val);
// this.conversitionId = val.id;
// this.commonConversation = false;
// this.$message.success(this.userName + '');
},
'$store.state.training.simulationUserList': {
handler(val, o) {
this.simulationUsers = {};
@ -361,6 +371,7 @@ export default {
type: 'role',
children: depotDispatcherList
}];
this.temData = [...dispatcherList, ...stationSupervisorList, ...driverList, ...maintainerList, ...depotDispatcherList];
this.initCommonMemberList();
this.$nextTick(() => {
if (this.$refs.tree) {
@ -410,6 +421,15 @@ export default {
this.userString = '群聊列表为空, 请选择人员';
}
},
coverName(inviteUser) {
const member = this.$store.state.training.memberData[inviteUser.creatorId];
if (member.userId) {
const user = this.simulationUsers[member.userId];
return member.label + '(' + user.nickName + ')';
} else {
return member.label;
}
},
//
startRecording() {
this.scriptTip = '';