From a32438e379b0d9a0dba49be1379f490e0d80da21 Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Tue, 2 Nov 2021 15:00:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/superFusionPlatform/main.js | 98 +- .../mainPlatform/MainPlatform.vue | 1486 ++++++++++------- .../message/Conversation/index.vue | 61 +- .../message/MessageList/index.vue | 246 +-- 4 files changed, 1114 insertions(+), 777 deletions(-) diff --git a/src/views/superFusionPlatform/main.js b/src/views/superFusionPlatform/main.js index fd64f76..7431e42 100644 --- a/src/views/superFusionPlatform/main.js +++ b/src/views/superFusionPlatform/main.js @@ -55,6 +55,7 @@ function getTotalUnreadCount() { // Vue.prototype.RongIMClientNum = totalUnreadCount vueCom.$bus.emit('totalNoticeChange', totalUnreadCount); + console.log("获取未读总数成功", totalUnreadCount); // this.notice_count = total_notice(totalUnreadCount); }); @@ -62,52 +63,6 @@ function getTotalUnreadCount() { } -mineReadfile().then(value => { - - RongIMClient = RongIMLib.init({ - appkey: value.key, - }); - RongIMClient.connect({ token: value.token }) - .then((user) => { - console.log("连接成功, 用户 id 为:", user.id); - localStorage.setItem("user_info", JSON.stringify({ id: user.id })); - // 获取消息数量 - getTotalUnreadCount() - - // 添加事件监听 - RongIMClient.watch({ - // 监听消息通知 - message(event) { - // 新接收到的消息内容 - const message = event.message; - console.log("event", event); - - getTotalUnreadCount() - if (event.message.type === 1) { - vueCom.$bus.emit("handelSendMessage", 1, event.message); - } - }, - // 监听 IM 连接状态变化 - status(event) { - // 链接监听失败回调 - console.log('connection status:', event.status); - } - }); - // 发送全局融云以便其他地方调取融云方法 - Vue.prototype.RongIMClient = RongIMClient - - }) - .catch((error) => { - - console.log("连接失败: ", error.code, error.msg); - }); - -}, reason => { - console.log(reason, 222) -}) - - - Vue.use(Toast); @@ -216,6 +171,57 @@ function gotoPage(to, from, next) { if (to.name === 'login') { next({ replace: true, name: 'mainPlatform' }); } else { + + + mineReadfile().then(value => { + + RongIMClient = RongIMLib.init({ + appkey: value.key, + }); + RongIMClient.connect({ token: value.token }) + .then((user) => { + console.log("连接成功, 用户 id 为:", user.id); + localStorage.setItem("user_info", JSON.stringify({ id: user.id })); + // 获取消息数量 + getTotalUnreadCount() + + // 添加事件监听 + RongIMClient.watch({ + // 监听消息通知 + message(event) { + // 新接收到的消息内容 + const message = event.message; + console.log("event", event); + // 未读数计算 + getTotalUnreadCount() + // 个人对话消息发送 + if (event.message.type === 1) { + vueCom.$bus.emit("handelSendMessage", 1, event.message); + } + // 刷新会话列表 + vueCom.$bus.emit('rongyunIMCGetList'); + }, + // 监听 IM 连接状态变化 + status(event) { + // 链接监听失败回调 + console.log('connection status:', event.status); + + } + }); + // 发送全局融云以便其他地方调取融云方法 + Vue.prototype.RongIMClient = RongIMClient + + }) + .catch((error) => { + + console.log("连接失败: ", error.code, error.msg); + }); + + }, reason => { + console.log(reason, 222) + }) + + next(); } } diff --git a/src/views/superFusionPlatform/mainPlatform/MainPlatform.vue b/src/views/superFusionPlatform/mainPlatform/MainPlatform.vue index d1591b7..d139f8d 100644 --- a/src/views/superFusionPlatform/mainPlatform/MainPlatform.vue +++ b/src/views/superFusionPlatform/mainPlatform/MainPlatform.vue @@ -1,627 +1,941 @@ - - diff --git a/src/views/superFusionPlatform/messageProcessing/message/Conversation/index.vue b/src/views/superFusionPlatform/messageProcessing/message/Conversation/index.vue index 1e4ab77..9715135 100644 --- a/src/views/superFusionPlatform/messageProcessing/message/Conversation/index.vue +++ b/src/views/superFusionPlatform/messageProcessing/message/Conversation/index.vue @@ -20,12 +20,12 @@ @@ -41,12 +41,15 @@ export default { data() { return { list: [], - nowConversationIndex: 0, + nowTargetId: "", targetId: "", - nowInfo: { - targetId: "", - type: 0, - }, + // nowInfo: { + // targetId: "", + // type: 0, + // }, + showCard: false, + target_info: {}, + user_info: {}, }; }, components: { @@ -55,37 +58,51 @@ export default { AInput: Input, ConversationItem, }, - props: ["getTargetId"], mounted() { - console.log(this, "this111111"); this.rongyunIMCGetList(); this.$bus.on("rongyunIMCGetList", this.rongyunIMCGetList); + this.$bus.on("setNowIndex", this.setNowIndex); + + this.target_info = JSON.parse(localStorage.getItem("conversation_info")); + this.user_info = JSON.parse(localStorage.getItem("user_info")); + this.nowTargetId = this.target_info.targetId; }, watch: { // 根据列表页面发回的targetid获取聊天记录 // targetId(e) { // this.$bus.emit("getList", e, 1); // }, - nowInfo(e) { - // console.log(e, "nowInfo"); - - this.$bus.emit("getList", e.targetId, e.type); - }, + // nowInfo(e) { + // console.log(e, "nowInfo"); + // this.$bus.emit("getList", e.targetId, e.type); + // }, // list(e) { - // console.log(e, "e list"); + // e[0] ? (this.nowTargetId = e[0].targetId) : ""; // }, }, + methods: { + //设置当前索引 + // setNowIndex(e) { + // this.nowTargetId = e; + // }, // 获取会话列表 rongyunIMCGetList() { + this.list = []; + this.showCard = false; this.RongIMClient.Conversation.getList({ count: 30, startTime: 0, order: 0, - }).then((conversationList) => { - this.list = conversationList; - console.log("获取会话列表成功~", conversationList); - }); + }) + .then((conversationList) => { + // this.list = conversationList; + console.log("获取会话列表成功~", conversationList); + return conversationList; + }) + .then((result) => { + this.list = result; + }); }, }, }; diff --git a/src/views/superFusionPlatform/messageProcessing/message/MessageList/index.vue b/src/views/superFusionPlatform/messageProcessing/message/MessageList/index.vue index aa2190e..7979745 100644 --- a/src/views/superFusionPlatform/messageProcessing/message/MessageList/index.vue +++ b/src/views/superFusionPlatform/messageProcessing/message/MessageList/index.vue @@ -1,98 +1,94 @@