fix: 会话ID取错修改

feature/im-0602-ch
ch 3 years ago
parent 5d795b11b4
commit 0df5bbcc18

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-05-18 14:54:47 * @Date: 2022-05-18 14:54:47
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-06-09 11:38:48 * @LastEditTime: 2022-06-09 19:13:55
* @Description: file content * @Description: file content
*/ */
import { CreateUUID, FormatDate, ToAsyncAwait } from "@/common/utils"; import { CreateUUID, FormatDate, ToAsyncAwait } from "@/common/utils";
@ -85,7 +85,13 @@ class MsbIm {
console.log('[im] close'); console.log('[im] close');
this.interceptors.onClose && this.interceptors.onClose(); this.interceptors.onClose && this.interceptors.onClose();
}; };
if (uni) { let isUni = false;
try {
isUni = uni;
} catch (e) {
isUni = false;
}
if (isUni) {
this.socket = uni.connectSocket({ this.socket = uni.connectSocket({
...this.option, ...this.option,
fail(e) { fail(e) {
@ -138,7 +144,14 @@ class MsbIm {
}; };
const par = fromatPotoReq(data.traceId, data.traceType, data.content); const par = fromatPotoReq(data.traceId, data.traceType, data.content);
if (uni) {
let isUni = false;
try {
isUni = uni;
} catch (e) {
isUni = false;
}
if (isUni) {
this.socket.send({ this.socket.send({
data: par, data: par,
fail(e) { fail(e) {
@ -159,6 +172,7 @@ class MsbIm {
if (data[this.option.ioKey] || data.code !== 200) { if (data[this.option.ioKey] || data.code !== 200) {
return false; return false;
} }
console.log('[im] 主动接收的消息', data);
let ctx = data.content; let ctx = data.content;
let historyData = [...this.sessionData], let historyData = [...this.sessionData],
newData = []; newData = [];
@ -181,9 +195,10 @@ class MsbIm {
fromAvatar: ctx.fromAvatar, fromAvatar: ctx.fromAvatar,
fromId: ctx.fromId, fromId: ctx.fromId,
fromNickname: ctx.fromNickname, fromNickname: ctx.fromNickname,
id: ctx.id, id: ctx.sessionId,
lastMessage: ctx, lastMessage: ctx,
messageList: [ctx], messageList: [ctx],
updateTimeStamp : ctx.createTimeStamp,
unreadCount: 1, unreadCount: 1,
}, },
]; ];

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-03-22 16:13:00 * @Date: 2022-03-22 16:13:00
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-06-02 18:26:55 * @LastEditTime: 2022-06-09 19:17:31
* @Description: file content * @Description: file content
--> -->
<template> <template>
@ -56,7 +56,7 @@ export default {
}, },
computed:{ computed:{
sessionData (){ sessionData (){
return this.$store.state.imData; return this.$store.state.imData.sort((a,b) => b.updateTimeStamp - a.updateTimeStamp);
} }
}, },
methods:{ methods:{
@ -69,7 +69,6 @@ export default {
} }
} }
this.$Router.push(`/messageChat?sessionId=${item.id}`); this.$Router.push(`/messageChat?sessionId=${item.id}`);
} }
} }
} }

Loading…
Cancel
Save