diff --git a/pages/chat/chat.js b/pages/chat/chat.js
index e03766f..46a9e65 100644
--- a/pages/chat/chat.js
+++ b/pages/chat/chat.js
@@ -7,6 +7,7 @@ Page({
activeTab: 'conv',
conversations: [],
friends: [],
+ groups: [],
messages: [],
currentTarget: '',
currentChatType: 'SINGLE',
@@ -25,6 +26,7 @@ Page({
this.loadConversations()
this.loadFriends()
+ this.loadGroups()
},
onUnload() {
@@ -65,6 +67,21 @@ Page({
this.setData({ activeTab: e.currentTarget.dataset.tab })
},
+ async loadGroups() {
+ try {
+ const groups = await app.globalData.sdk.listGroups()
+ this.setData({ groups })
+ } catch (err) {
+ console.error('loadGroups failed', err)
+ }
+ },
+
+ startGroupChat(e) {
+ const id = e.currentTarget.dataset.id
+ this.setData({ currentTarget: id, currentChatType: 'GROUP', messages: [] })
+ this.loadHistory(id, 'GROUP')
+ },
+
selectConv(e) {
const { id, type } = e.currentTarget.dataset
this.setData({ currentTarget: id, currentChatType: type, messages: [] })
diff --git a/pages/chat/chat.wxml b/pages/chat/chat.wxml
index 6905061..74dcdb1 100644
--- a/pages/chat/chat.wxml
+++ b/pages/chat/chat.wxml
@@ -8,6 +8,7 @@
会话
好友
+ 群组
@@ -25,6 +26,14 @@
暂无好友
+
+
+
+ {{item.name}}
+ {{item.memberIds ? JSON.parse(item.memberIds).length : 0}} 人
+
+ 暂无群组
+