Browse Source

退群后同时删除会话

master
xsx 2 years ago
parent
commit
3c716caa37
  1. 44
      im-uniapp/App.vue
  2. 2
      im-uniapp/pages/group/group-info.vue
  3. 9
      im-uniapp/store/chatStore.js

44
im-uniapp/App.vue

@ -58,21 +58,21 @@
}) })
}, },
pullPrivateOfflineMessage(minId) { pullPrivateOfflineMessage(minId) {
store.commit("loadingPrivateMsg",true) store.commit("loadingPrivateMsg", true)
http({ http({
url: "/message/private/pullOfflineMessage?minId=" + minId, url: "/message/private/pullOfflineMessage?minId=" + minId,
method: 'GET' method: 'GET'
}).catch(()=>{ }).catch(() => {
store.commit("loadingPrivateMsg",false) store.commit("loadingPrivateMsg", false)
}) })
}, },
pullGroupOfflineMessage(minId) { pullGroupOfflineMessage(minId) {
store.commit("loadingGroupMsg",true) store.commit("loadingGroupMsg", true)
http({ http({
url: "/message/group/pullOfflineMessage?minId=" + minId, url: "/message/group/pullOfflineMessage?minId=" + minId,
method: 'GET' method: 'GET'
}).catch(()=>{ }).catch(() => {
store.commit("loadingGroupMsg",false) store.commit("loadingGroupMsg", false)
}) })
}, },
handlePrivateMessage(msg) { handlePrivateMessage(msg) {
@ -114,12 +114,12 @@
// #endif // #endif
// //
let delayTime = 100; let delayTime = 100;
if(msg.type == enums.MESSAGE_TYPE.RTC_CALL_VOICE if (msg.type == enums.MESSAGE_TYPE.RTC_CALL_VOICE ||
|| msg.type == enums.MESSAGE_TYPE.RTC_CALL_VIDEO){ msg.type == enums.MESSAGE_TYPE.RTC_CALL_VIDEO) {
let mode = msg.type == enums.MESSAGE_TYPE.RTC_CALL_VIDEO? "video":"voice"; let mode = msg.type == enums.MESSAGE_TYPE.RTC_CALL_VIDEO ? "video" : "voice";
let pages = getCurrentPages(); let pages = getCurrentPages();
let curPage = pages[pages.length-1].route; let curPage = pages[pages.length - 1].route;
if(curPage != "pages/chat/chat-private-video"){ if (curPage != "pages/chat/chat-private-video") {
const friendInfo = encodeURIComponent(JSON.stringify(friend)); const friendInfo = encodeURIComponent(JSON.stringify(friend));
uni.navigateTo({ uni.navigateTo({
url: `/pages/chat/chat-private-video?mode=${mode}&friend=${friendInfo}&isHost=false` url: `/pages/chat/chat-private-video?mode=${mode}&friend=${friendInfo}&isHost=false`
@ -128,8 +128,8 @@
} }
} }
setTimeout(() => { setTimeout(() => {
uni.$emit('WS_RTC_PRIVATE',msg); uni.$emit('WS_RTC_PRIVATE', msg);
},delayTime) }, delayTime)
return; return;
} }
let chatInfo = { let chatInfo = {
@ -149,7 +149,7 @@
handleGroupMessage(msg) { handleGroupMessage(msg) {
// //
if (msg.type == enums.MESSAGE_TYPE.LOADING) { if (msg.type == enums.MESSAGE_TYPE.LOADING) {
store.commit("loadingGroupMsg",JSON.parse(msg.content)) store.commit("loadingGroupMsg", JSON.parse(msg.content))
return; return;
} }
// //
@ -191,10 +191,10 @@
// #endif // #endif
// //
let delayTime = 100; let delayTime = 100;
if(msg.type == enums.MESSAGE_TYPE.RTC_GROUP_SETUP){ if (msg.type == enums.MESSAGE_TYPE.RTC_GROUP_SETUP) {
let pages = getCurrentPages(); let pages = getCurrentPages();
let curPage = pages[pages.length-1].route; let curPage = pages[pages.length - 1].route;
if(curPage != "pages/chat/chat-group-video"){ if (curPage != "pages/chat/chat-group-video") {
const userInfos = encodeURIComponent(msg.content); const userInfos = encodeURIComponent(msg.content);
const inviterId = msg.sendId; const inviterId = msg.sendId;
const groupId = msg.groupId const groupId = msg.groupId
@ -207,8 +207,8 @@
} }
// chat-group-video // chat-group-video
setTimeout(() => { setTimeout(() => {
uni.$emit('WS_RTC_GROUP',msg); uni.$emit('WS_RTC_GROUP', msg);
},delayTime) }, delayTime)
return; return;
} }
@ -272,8 +272,8 @@
// this.audioTip.src = "/static/audio/tip.wav"; // this.audioTip.src = "/static/audio/tip.wav";
// this.audioTip.play(); // this.audioTip.play();
}, },
isExpired(loginInfo){ isExpired(loginInfo) {
if(!loginInfo || !loginInfo.expireTime){ if (!loginInfo || !loginInfo.expireTime) {
return true; return true;
} }
return loginInfo.expireTime < new Date().getTime(); return loginInfo.expireTime < new Date().getTime();
@ -311,7 +311,7 @@
uni.switchTab({ uni.switchTab({
url: "/pages/chat/chat" url: "/pages/chat/chat"
}) })
} else{ } else {
// //
// #ifdef H5 // #ifdef H5
uni.navigateTo({ uni.navigateTo({

2
im-uniapp/pages/group/group-info.vue

@ -112,6 +112,7 @@
url:"/pages/group/group" url:"/pages/group/group"
}); });
this.$store.commit("removeGroup", this.groupId); this.$store.commit("removeGroup", this.groupId);
this.$store.commit("removeGroupChat",this.groupId);
},100) },100)
} }
}) })
@ -141,6 +142,7 @@
url:"/pages/group/group" url:"/pages/group/group"
}); });
this.$store.commit("removeGroup", this.groupId); this.$store.commit("removeGroup", this.groupId);
this.$store.commit("removeGroupChat",this.groupId);
},100) },100)
} }
}) })

9
im-uniapp/store/chatStore.js

@ -133,6 +133,15 @@ export default {
} }
} }
}, },
removeGroupChat(state, groupId) {
let chats = this.getters.findChats();
for (let idx in chats) {
if (chats[idx].type == 'GROUP' &&
chats[idx].targetId == groupId) {
this.commit("removeChat", idx);
}
}
},
moveTop(state, idx) { moveTop(state, idx) {
let chats = this.getters.findChats(); let chats = this.getters.findChats();
let chat = chats[idx]; let chat = chats[idx];

Loading…
Cancel
Save