diff --git a/im-ui/src/view/Chat.vue b/im-ui/src/view/Chat.vue
index 68a34b0..ecd9599 100644
--- a/im-ui/src/view/Chat.vue
+++ b/im-ui/src/view/Chat.vue
@@ -8,6 +8,7 @@
@@ -96,6 +97,10 @@
.l-chat-loadding{
height: 50px;
background-color: #eee;
+
+ .chat-loading-box{
+ height: 100%;
+ }
}
.l-friend-ist {
diff --git a/im-uniapp/App.vue b/im-uniapp/App.vue
index f7a4b71..2dddb5e 100644
--- a/im-uniapp/App.vue
+++ b/im-uniapp/App.vue
@@ -58,6 +58,10 @@
this.exit();
} else if (res.code != 3000) {
// 重新连接
+ uni.showToast({
+ title: '连接已断开,尝试重新连接...',
+ icon: 'none',
+ })
wsApi.connect();
}
})
@@ -66,7 +70,7 @@
store.commit("loadingPrivateMsg", true)
http({
url: "/message/private/loadMessage?minId=" + minId,
- method: 'get'
+ method: 'GET'
}).then((msgInfos) => {
msgInfos.forEach((msgInfo) => {
msgInfo.selfSend = msgInfo.sendId == store.state.userStore.userInfo.id;
@@ -76,6 +80,7 @@
this.insertPrivateMessage(friend,msgInfo);
}
})
+ store.commit("refreshChats");
if (msgInfos.length == 100) {
// 继续拉取
this.loadPrivateMessage(msgInfos[99].id);
@@ -88,7 +93,7 @@
store.commit("loadingGroupMsg", true)
http({
url: "/message/group/loadMessage?minId=" + minId,
- method: 'get'
+ method: 'GET'
}).then((msgInfos) => {
msgInfos.forEach((msgInfo) => {
msgInfo.selfSend = msgInfo.sendId == store.state.userStore.userInfo.id;
@@ -98,6 +103,7 @@
this.insertGroupMessage(group,msgInfo);
}
})
+ store.commit("refreshChats");
if (msgInfos.length == 100) {
// 继续拉取
this.loadGroupMessage(msgInfos[99].id);
diff --git a/im-uniapp/store/chatStore.js b/im-uniapp/store/chatStore.js
index 3358b23..c961c26 100644
--- a/im-uniapp/store/chatStore.js
+++ b/im-uniapp/store/chatStore.js
@@ -79,7 +79,6 @@ export default {
if (state.chats[idx].type == 'PRIVATE' &&
state.chats[idx].targetId == friendId) {
state.chats[idx].messages.forEach((m) => {
- console.log("readedMessage")
if (m.selfSend && m.status != MESSAGE_STATUS.RECALL) {
m.status = MESSAGE_STATUS.READED
}
@@ -128,17 +127,20 @@ export default {
break;
}
}
- // 插入新的数据
- if (msgInfo.type == MESSAGE_TYPE.IMAGE) {
- chat.lastContent = "[图片]";
- } else if (msgInfo.type == MESSAGE_TYPE.FILE) {
- chat.lastContent = "[文件]";
- } else if (msgInfo.type == MESSAGE_TYPE.AUDIO) {
- chat.lastContent = "[语音]";
- } else {
- chat.lastContent = msgInfo.content;
+
+ // 会话列表内容
+ if(!state.loadingPrivateMsg && !state.loadingPrivateMsg){
+ if (msgInfo.type == MESSAGE_TYPE.IMAGE) {
+ chat.lastContent = "[图片]";
+ } else if (msgInfo.type == MESSAGE_TYPE.FILE) {
+ chat.lastContent = "[文件]";
+ } else if (msgInfo.type == MESSAGE_TYPE.AUDIO) {
+ chat.lastContent = "[语音]";
+ } else {
+ chat.lastContent = msgInfo.content;
+ }
+ chat.lastSendTime = msgInfo.sendTime;
}
- chat.lastSendTime = msgInfo.sendTime;
// 未读加1
if (!msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED) {
chat.unreadCount++;
@@ -234,6 +236,29 @@ export default {
loadingGroupMsg(state, loadding) {
state.loadingGroupMsg = loadding;
},
+ refreshChats(state){
+ state.chats.forEach((chat)=>{
+ if(chat.messages.length>0){
+ let msgInfo = chat.messages[chat.messages.length-1];
+ if (msgInfo.type == MESSAGE_TYPE.IMAGE) {
+ chat.lastContent = "[图片]";
+ } else if (msgInfo.type == MESSAGE_TYPE.FILE) {
+ chat.lastContent = "[文件]";
+ } else if (msgInfo.type == MESSAGE_TYPE.AUDIO) {
+ chat.lastContent = "[语音]";
+ } else {
+ chat.lastContent = msgInfo.content;
+ }
+ chat.lastSendTime = msgInfo.sendTime;
+ }else{
+ chat.lastContent = "";
+ chat.lastSendTime = new Date()
+ }
+ })
+ state.chats.sort((chat1, chat2) => {
+ return chat2.lastSendTime-chat1.lastSendTime;
+ });
+ },
saveToStorage(state) {
let userId = userStore.state.userInfo.id;
let key = "chats-" + userId;
@@ -242,10 +267,10 @@ export default {
groupMsgMaxId: state.groupMsgMaxId,
chats: state.chats
}
- uni.setStorage({
- key: key,
- data: chatsData
- })
+ // uni.setStorage({
+ // key: key,
+ // data: chatsData
+ // })
},
clear(state) {
state.chats = [];
diff --git a/im-uniapp/store/friendStore.js b/im-uniapp/store/friendStore.js
index 539e99d..b13c08d 100644
--- a/im-uniapp/store/friendStore.js
+++ b/im-uniapp/store/friendStore.js
@@ -36,7 +36,6 @@ export default {
state.friends.forEach((f) => {
let userTerminal = onlineTerminals.find((o) => f.id == o.userId);
if (userTerminal) {
- console.log(userTerminal)
f.online = true;
f.onlineTerminals = userTerminal.terminals;
f.onlineWeb = userTerminal.terminals.indexOf(TERMINAL_TYPE.WEB) >= 0