|
@@ -1439,6 +1439,7 @@ export default {
|
|
|
},
|
|
|
//1.7 从通讯录进入会话大厅
|
|
|
retrieveSession(){
|
|
|
+ console.log("开始执行retrieveSession方法!")
|
|
|
//1.获取会话列表
|
|
|
this.$store.dispatch('chat/getConversation',{}).then(res=> {
|
|
|
//2.查询当前会话中是否已经存在该好友的会话
|
|
@@ -1459,12 +1460,15 @@ export default {
|
|
|
this.conversationList = data;
|
|
|
//5.判断对话是否已经在会话列表中存在
|
|
|
if(flag==true){
|
|
|
+ console.log("会话存在!选中会话!")
|
|
|
//6.如果存在,则选中该会话
|
|
|
this.selectConversation(SeleteItem)
|
|
|
}else{
|
|
|
+ console.log("会话不存在!创建单聊!")
|
|
|
//7.如果不存在,则创建单聊
|
|
|
this.createSession();
|
|
|
}
|
|
|
+ //8.循环更新会话列表
|
|
|
this.forSearchConversationList();
|
|
|
}).catch(() => {
|
|
|
this.$message.error('获取会话列表失败!')
|
|
@@ -1490,6 +1494,10 @@ export default {
|
|
|
//打开左侧loading防止重复点击
|
|
|
this.hallLeftLoading = true;
|
|
|
this.ws.send(JSON.stringify(message));
|
|
|
+
|
|
|
+ //bug
|
|
|
+ //如果双方不是好友,此处可以弹出错误
|
|
|
+
|
|
|
//2秒后搜索会话列表 防止创建失败
|
|
|
setTimeout(() => {
|
|
|
that.$store.dispatch('chat/getConversation',{}).then(res=> {
|
|
@@ -1515,13 +1523,18 @@ export default {
|
|
|
if(flag==true){
|
|
|
//如果存在,则选中该会话
|
|
|
that.selectConversation(SeleteItem)
|
|
|
+ }else{
|
|
|
+ that.$message.error('创建会话失败,请重新从通讯录发起会话!')
|
|
|
}
|
|
|
|
|
|
}).catch(() => {
|
|
|
that.$message.error('获取会话列表失败!')
|
|
|
})
|
|
|
}, 2000);
|
|
|
- }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ this.$message.error('WebSocket连接失败!创建会话失败!')
|
|
|
+ }
|
|
|
},
|
|
|
//1.9 循环更新会话列表
|
|
|
forSearchConversationList(){
|
|
@@ -2489,13 +2502,16 @@ export default {
|
|
|
console.log(this.$route.query.friend_id)
|
|
|
//判断当前路由是否携带friend_id
|
|
|
if(this.$route.query.friend_id){
|
|
|
+ console.log("从通讯录进入,开始创建会话!")
|
|
|
//1.从通讯录进入会话大厅
|
|
|
this.retrieveSession();
|
|
|
//2.获取我的用户id
|
|
|
this.myUserId = this.$store.state.user.userid;
|
|
|
//把这个id存一下
|
|
|
this.createMessageId = this.$route.query.friend_id;
|
|
|
+
|
|
|
}else{
|
|
|
+ console.log("直接进入,无需创建会话!")
|
|
|
//直接进入会话大厅
|
|
|
//1.获取会话列表
|
|
|
this.getConversationList();
|