|
@@ -81,12 +81,7 @@
|
|
|
p-id="3078"
|
|
|
width="48"
|
|
|
height="48"
|
|
|
- @click="
|
|
|
- () => {
|
|
|
- chatVisible = true;
|
|
|
- this.$bus.$emit('scrollToBottom');
|
|
|
- }
|
|
|
- "
|
|
|
+ @click="onOpenChatRoom"
|
|
|
>
|
|
|
<path
|
|
|
d="M512 796a456.672 456.672 0 0 1-74.768-6.4L262 896V718.976C170.64 654.832 112 556.48 112 446 112 252.704 291.088 96 512 96s400 156.704 400 350S732.912 796 512 796z m0-650c-193.296 0-350 134.32-350 300 0 101.664 59.2 191.344 149.376 245.6l-1.6 115.968 117.68-70.736a404.8 404.8 0 0 0 84.544 9.168c193.296 0 350-134.304 350-300S705.296 146 512 146zM336 400a48 48 0 1 1-48 48 48 48 0 0 1 48-48z m176 0a48 48 0 1 1-48 48 48 48 0 0 1 48-48z m176 0a48 48 0 1 1-48 48 48 48 0 0 1 48-48z"
|
|
@@ -241,7 +236,6 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
|
- console.log(this.$store.state.user, "userInfo");
|
|
|
this.chatVisible = false;
|
|
|
setTimeout(() => {
|
|
|
this.loadChatDom = true;
|
|
@@ -263,11 +257,14 @@ export default {
|
|
|
|
|
|
this.init();
|
|
|
|
|
|
- this.$bus.$on("getNoReadNum", this.getNoReadMessage);
|
|
|
+ this.$bus.$on("getNoReadNum", obj => {
|
|
|
+ console.log(obj, "getNoReadNum");
|
|
|
+ this.getNoReadMessage(obj);
|
|
|
+ });
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
this.$bus.$off("showguide", () => {});
|
|
|
- this.$bus.$off("getNoReadNum", this.getNoReadMessage);
|
|
|
+ this.$bus.$off("getNoReadNum", () => {});
|
|
|
// core.off(CoreEvent.MESSAGES, this.handleMessages);
|
|
|
const Events = RongIMLib.Events;
|
|
|
RongIMLib.removeEventListener(Events.MESSAGES, this.handleMessages);
|
|
@@ -278,31 +275,38 @@ export default {
|
|
|
if (res.code === RongIMLib.ErrorCode.SUCCESS) {
|
|
|
console.log("链接成功, 链接用户 id 为: ", res.data.userId);
|
|
|
// this.isConnect = true;
|
|
|
- this.getNoReadMessage();
|
|
|
+ this.getNoReadMessage(true);
|
|
|
} else {
|
|
|
console.warn("链接失败, code:", res.code);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // const Events = RongIMLib.Events;
|
|
|
- // RongIMLib.addEventListener(Events.MESSAGES, this.getNoReadMessage);
|
|
|
+ const Events = RongIMLib.Events;
|
|
|
+ RongIMLib.addEventListener(Events.MESSAGES, this.handleMessages);
|
|
|
// RongIMLib.addEventListener(Events.MESSAGE_RECEIPT_RESPONSE, message => {
|
|
|
// console.log("121212", message);
|
|
|
// });
|
|
|
},
|
|
|
handleMessages(newMessage) {
|
|
|
console.log(newMessage, "newMessage");
|
|
|
- this.getNoReadMessage();
|
|
|
+ this.getNoReadMessage(true);
|
|
|
},
|
|
|
- getNoReadMessage() {
|
|
|
- RongIMLib.getTotalUnreadCount().then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- console.log(res.code, res);
|
|
|
- this.noReadNum = res.data || 0;
|
|
|
- } else {
|
|
|
- console.log(res.code, res.msg, res);
|
|
|
- }
|
|
|
- });
|
|
|
+ onOpenChatRoom() {
|
|
|
+ this.chatVisible = true;
|
|
|
+ this.$bus.$emit("scrollToBottom");
|
|
|
+ this.getNoReadMessage(true);
|
|
|
+ },
|
|
|
+ getNoReadMessage(status) {
|
|
|
+ if (status || this.chatVisible) {
|
|
|
+ RongIMLib.getTotalUnreadCount().then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ console.log(res.code, res);
|
|
|
+ this.noReadNum = res.data || 0;
|
|
|
+ } else {
|
|
|
+ console.log(res.code, res.msg, res);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
showInstructions() {
|
|
|
this.isShow = !this.isShow;
|
|
@@ -565,4 +569,4 @@ export default {
|
|
|
.el-image-viewer__close {
|
|
|
display: none !important;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|