@aochuang/client-sdk 1.0.348 → 1.0.350

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/components/index.js +1 -6
  2. package/components/session-select/session-select-item.vue +9 -8
  3. package/components/wechat-chat-control/url/url-miniprogram.vue +5 -1
  4. package/components/wework-chat-control/company-card/company-card.vue +1 -1
  5. package/components/wework-chat-control/file-url/file-url.vue +5 -2
  6. package/components/wework-chat-control/image/image.vue +2 -137
  7. package/components/wework-chat-control/index.js +6 -6
  8. package/components/wework-chat-control/text/text.vue +3 -22
  9. package/components/wework-chat-control/util.js +6 -12
  10. package/components/wework-chat-control/video/video.vue +2 -10
  11. package/components/wework-chat-control/voice/voice.vue +1 -1
  12. package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +35 -0
  13. package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +36 -0
  14. package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +35 -0
  15. package/components/wework-chat-panel/chat-panel-controls/image/image.vue +36 -0
  16. package/components/wework-chat-panel/chat-panel-controls/index.js +35 -0
  17. package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +28 -0
  18. package/components/wework-chat-panel/chat-panel-controls/link/link.vue +35 -0
  19. package/components/wework-chat-panel/chat-panel-controls/location/location.vue +35 -0
  20. package/components/wework-chat-panel/chat-panel-controls/text/text.vue +43 -0
  21. package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +39 -0
  22. package/components/wework-chat-panel/chat-panel-controls/video/video.vue +37 -0
  23. package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +35 -0
  24. package/components/wework-chat-panel/chat-panel-item.vue +35 -12
  25. package/components/wework-chat-panel/chat-panel.vue +12 -95
  26. package/package.json +3 -10
  27. package/services/client-chat/client-chat-wechat/client-chat-session.js +170 -54
  28. package/services/client-chat/client-chat-wework/client-chat-concats.js +17 -81
  29. package/services/client-chat/client-chat-wework/client-chat-message.js +6 -46
  30. package/services/client-chat/client-chat-wework/client-chat-session.js +2 -50
  31. package/services/client-chat/client-chat-wework/client-chat-socket.js +1 -9
  32. package/services/client-chat/client-chat-wework/client-chat.js +13 -283
  33. package/services/client-chat/client-chat-wework/utils.js +5 -5
  34. package/uni-common/account-portray/account-portray.vue +51 -0
  35. package/uni-common/account-select/account-select-item.vue +172 -0
  36. package/uni-common/account-select/account-select.vue +252 -0
  37. package/uni-common/all-friend-avatar/all-friend-avatar.vue +49 -0
  38. package/uni-common/friend-avatar/default.svg +1 -0
  39. package/uni-common/friend-avatar/friend-avatar.vue +27 -0
  40. package/uni-common/friend-avatar/index.js +3 -0
  41. package/uni-common/friend-loader/friend-loader.vue +53 -0
  42. package/uni-common/friend-portray/friend-portray.vue +56 -0
  43. package/uni-common/group-avatar/default.svg +1 -0
  44. package/uni-common/group-avatar/group-avatar.vue +18 -0
  45. package/uni-common/group-avatar/index.js +3 -0
  46. package/uni-common/room-avatar/default.svg +6 -0
  47. package/uni-common/room-avatar/index.js +3 -0
  48. package/uni-common/room-avatar/room-avatar.vue +27 -0
  49. package/uni-common/room-loader/room-loader.vue +53 -0
  50. package/uni-common/room-portray/room-portray.vue +56 -0
  51. package/uni-components/chat-control/calling/calling.vue +91 -0
  52. package/uni-components/chat-control/calling/phone-fill.svg +1 -0
  53. package/uni-components/chat-control/calling/vidicon-fill.svg +1 -0
  54. package/uni-components/chat-control/channel-video/channel-video.vue +89 -0
  55. package/uni-components/chat-control/channel-video-card/channel-video-card.vue +105 -0
  56. package/uni-components/chat-control/channel-video-live/channel-video-live.vue +92 -0
  57. package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +20 -0
  58. package/uni-components/chat-control/chat-control-config-item/index.js +3 -0
  59. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +25 -0
  60. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +21 -0
  61. package/{components/wework-chat-control/wework-chat-control-config.vue → uni-components/chat-control/chat-control-config.vue} +13 -16
  62. package/uni-components/chat-control/chat-control.vue +218 -0
  63. package/uni-components/chat-control/company-card/company-card.vue +123 -0
  64. package/uni-components/chat-control/const.js +28 -0
  65. package/uni-components/chat-control/expression/expression.vue +41 -0
  66. package/uni-components/chat-control/image/image.vue +68 -0
  67. package/uni-components/chat-control/index.js +89 -0
  68. package/uni-components/chat-control/location/location.vue +110 -0
  69. package/uni-components/chat-control/member-change/member-change.vue +32 -0
  70. package/uni-components/chat-control/quote-message/quote-message.vue +216 -0
  71. package/uni-components/chat-control/real-time-position/real-time-position.vue +62 -0
  72. package/uni-components/chat-control/redpacket/red-envelope.svg +1 -0
  73. package/uni-components/chat-control/redpacket/redpacket.vue +75 -0
  74. package/uni-components/chat-control/share-card/share-card.vue +101 -0
  75. package/uni-components/chat-control/system/system.vue +69 -0
  76. package/uni-components/chat-control/system-batch-message/system-batch-message.vue +30 -0
  77. package/uni-components/chat-control/system-text/system-text.vue +32 -0
  78. package/uni-components/chat-control/text/text.vue +67 -0
  79. package/uni-components/chat-control/text-with-at/text-with-at.vue +51 -0
  80. package/uni-components/chat-control/transfer/red-transfer.svg +1 -0
  81. package/uni-components/chat-control/transfer/transfer.vue +80 -0
  82. package/uni-components/chat-control/unkonw/unkonw.vue +37 -0
  83. package/uni-components/chat-control/url/icons/file-excel-line.svg +1 -0
  84. package/uni-components/chat-control/url/icons/file-info-line.svg +1 -0
  85. package/uni-components/chat-control/url/icons/file-music-line.svg +1 -0
  86. package/uni-components/chat-control/url/icons/file-pdf-line.svg +1 -0
  87. package/uni-components/chat-control/url/icons/file-ppt-line.svg +1 -0
  88. package/uni-components/chat-control/url/icons/file-settings-line.svg +1 -0
  89. package/uni-components/chat-control/url/icons/file-text-line.svg +1 -0
  90. package/uni-components/chat-control/url/icons/file-unknow-line.svg +1 -0
  91. package/uni-components/chat-control/url/icons/file-word-line.svg +1 -0
  92. package/uni-components/chat-control/url/icons/file-zip-line.svg +1 -0
  93. package/uni-components/chat-control/url/icons/index.js +24 -0
  94. package/uni-components/chat-control/url/miniprogram.svg +1 -0
  95. package/uni-components/chat-control/url/url-miniprogram.vue +116 -0
  96. package/uni-components/chat-control/url/url.vue +306 -0
  97. package/uni-components/chat-control/url-new/icons/file-excel-line.svg +1 -0
  98. package/uni-components/chat-control/url-new/icons/file-info-line.svg +1 -0
  99. package/uni-components/chat-control/url-new/icons/file-music-line.svg +1 -0
  100. package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +1 -0
  101. package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +1 -0
  102. package/uni-components/chat-control/url-new/icons/file-settings-line.svg +1 -0
  103. package/uni-components/chat-control/url-new/icons/file-text-line.svg +1 -0
  104. package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +1 -0
  105. package/uni-components/chat-control/url-new/icons/file-word-line.svg +1 -0
  106. package/uni-components/chat-control/url-new/icons/file-zip-line.svg +1 -0
  107. package/uni-components/chat-control/url-new/icons/index.js +24 -0
  108. package/uni-components/chat-control/url-new/url-new.vue +110 -0
  109. package/uni-components/chat-control/utils.js +12 -0
  110. package/uni-components/chat-control/video/video.vue +156 -0
  111. package/uni-components/chat-control/voice/voice.vue +166 -0
  112. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +84 -0
  113. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +28 -0
  114. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +85 -0
  115. package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +157 -0
  116. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +158 -0
  117. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +61 -0
  118. package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +58 -0
  119. package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +54 -0
  120. package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +42 -0
  121. package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +42 -0
  122. package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +25 -0
  123. package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +158 -0
  124. package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +75 -0
  125. package/uni-components/chat-editor/chat-editor.vue +257 -0
  126. package/uni-components/chat-editor/index.js +10 -0
  127. package/uni-components/chat-editor/util.js +65 -0
  128. package/uni-components/chat-panel/chat-panel-chats-box.vue +238 -0
  129. package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +273 -0
  130. package/uni-components/chat-panel/chat-panel-chats-item.vue +578 -0
  131. package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +71 -0
  132. package/uni-components/chat-panel/chat-panel-chats.vue +368 -0
  133. package/uni-components/chat-panel/chat-panel.vue +227 -0
  134. package/uni-components/contacts-group-select/contacts-group-select-item.vue +85 -0
  135. package/uni-components/contacts-group-select/contacts-group-select-panel.vue +119 -0
  136. package/uni-components/contacts-group-select/contacts-group-select.vue +150 -0
  137. package/components/wechat-chat-control/.DS_Store +0 -0
  138. package/components/wechat-chat-control/transfer/.DS_Store +0 -0
  139. package/components/wechat-chat-control/url/.DS_Store +0 -0
  140. package/components/wechat-chat-control/voice/.DS_Store +0 -0
  141. package/components/wework-chat-control/link/.DS_Store +0 -0
  142. package/components/wework-chat-control/video/.DS_Store +0 -0
  143. package/components/wework-chat-control/wework-chat-control-config-item.vue +0 -24
  144. package/components/wework-chat-control/wework-chat-control-config-msg.vue +0 -25
  145. package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +0 -73
@@ -15,14 +15,11 @@ export default class ClietChatSocket {
15
15
  // 执行回调事件前的方法
16
16
  beforeFireCallback: null,
17
17
  onCmdQwNewMessage: null,
18
- onCmdQwContactInfoChanged: null,
19
- onCmdQwRoomInfoChanged: null,
20
18
  onCmdSendMessageResult: null,
21
19
  onCmdFriendInfoChanged: null,
22
20
  onCmdDownloadVideoResult: null,
23
21
  onCmdChatroomInfoChanged: null,
24
22
  onCmdChatroomInfoChangedBatch: null,
25
- onHeartbeatSuccess: null,
26
23
  onHeartbeatCheck: null
27
24
  }, options)
28
25
  if (!options.socket) {
@@ -30,11 +27,6 @@ export default class ClietChatSocket {
30
27
  }
31
28
  this.socket = options.socket
32
29
  this.socket.event.on('onCmdQwNewMessage', options.onCmdQwNewMessage)
33
- this.socket.event.on('onCmdQwContactInfoChanged', options.onCmdQwContactInfoChanged)
34
- this.socket.event.on('onCmdQwRoomInfoChanged', options.onCmdQwRoomInfoChanged)
35
- this.socket.event.on('onHeartbeatSuccess', (evt) => {
36
- options.onHeartbeatSuccess && options.onHeartbeatSuccess(evt)
37
- })
38
30
  this.socket.event.on('onHeartbeatCheck', ({ mergeParams }) => {
39
31
  options.onHeartbeatCheck && options.onHeartbeatCheck({
40
32
  mergeParams
@@ -70,4 +62,4 @@ export default class ClietChatSocket {
70
62
  setUrl (url) {
71
63
  this.socket.setUrl(url)
72
64
  }
73
- }
65
+ }
@@ -32,7 +32,6 @@ class ClientChat {
32
32
  getLoginUserIdMethod: null,
33
33
  getLoginUserTokenMethod: null,
34
34
  loadAccountDataMethod: null,
35
- getLoginAccountIdMethod: null, // 因为1.0有帮聊逻辑,帮聊消息以及通讯录的accountId不是登录用户的accountId,会导致找到的会话出现问题,所以这里提供一个方法让外部传入
36
35
  loadSessionDataMethod: null,
37
36
  updateSessionReadMethod: null,
38
37
  getSessionMethod: null,
@@ -51,7 +50,6 @@ class ClientChat {
51
50
  getContactsRoomMethod: null,
52
51
  loadFriendMessageDataMethod: null,
53
52
  loadRoomMessageDataMethod: null,
54
- checkMessageSendResultMethod: null,
55
53
  onOverwriteFriendInfoChange: null // 为了兼容1.0拉取会话逻辑加的,1.0暂时不支持根据taskId拉取
56
54
  }, options)
57
55
  if (!options.loadFriendMessageDataMethod) {
@@ -59,9 +57,8 @@ class ClientChat {
59
57
  }
60
58
  if (!options.loadRoomMessageDataMethod) {
61
59
  throw new Error('loadRoomMessageDataMethod不能为空')
62
- }
60
+ }
63
61
  this.onOverwriteFriendInfoChange = options.onOverwriteFriendInfoChange
64
- this.getLoginAccountIdMethod = options.getLoginAccountIdMethod
65
62
  this.event = new Event({
66
63
  checkOnMethod: (name) => {
67
64
  if (name === 'ready') {
@@ -88,10 +85,8 @@ class ClientChat {
88
85
  groupField: 'contactId',
89
86
  sortField: 'sendTime',
90
87
  clientChat: this,
91
- checkMessageSendResultMethod: options.checkMessageSendResultMethod,
92
88
  onAddMessageSuccess: ({ data }) => {
93
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
94
- let sessionId = createSessionId(accountId, data.contactId)
89
+ let sessionId = createSessionId(data.corpId, data.qwAccountId, data.contactId)
95
90
  // 更新会话
96
91
  if (!sessionId) {
97
92
  return
@@ -105,15 +100,6 @@ class ClientChat {
105
100
  return this.session.getSession(sessionId).then(done)
106
101
  })
107
102
  this._sessionPollRequestMap[sessionId].start().then((rs) => {
108
- // 后端更新会话是异步过程,返回的会话信息可能还未包含当前消息
109
- if (rs && rs.data && !rs.data.unreadMsgCount) {
110
- rs.data.unreadMsgCount = data.send ? 0 : 1
111
- rs.data.lastMsgContent = data.content
112
- rs.data.lastMsgType = data.msgType
113
- rs.data.lastMsgTime = data.sendTime
114
- rs.data.lastMsgId = data.id
115
- rs.data.lastUpdateTime = data.updateDate
116
- }
117
103
  // 更新账号未读消息数量
118
104
  this.account.updateAccountUnreadMessageNum(rs.data.qwAccountId, ({ unreadMesasgeNum }) => {
119
105
  return unreadMesasgeNum += (rs.data.unreadMsgCount || 0)
@@ -124,7 +110,7 @@ class ClientChat {
124
110
  } else {
125
111
  this.session.updateSession(sessionId, ({ session }) => {
126
112
  let unreadMsgCount = session.unreadMsgCount
127
- if (!data.send) {
113
+ if (!data.isSend) {
128
114
  unreadMsgCount = unreadMsgCount + 1
129
115
  }
130
116
  // 如果是当前会话,那么未读消息需要设置为0
@@ -158,7 +144,7 @@ class ClientChat {
158
144
  groupField: 'contactId',
159
145
  sortField: 'sendTime',
160
146
  clientChat: this,
161
- checkMessageSendResultMethod: options.checkMessageSendResultMethod,
147
+ // checkMessageSendResultMethod: options.checkMessageSendResultMethod,
162
148
  // loadLossMessageDataMethod: options.loadLossFriendMessageDataMethod,
163
149
  queryMethod: (params) => {
164
150
  return options.loadFriendMessageDataMethod(params)
@@ -168,10 +154,8 @@ class ClientChat {
168
154
  groupField: 'roomId',
169
155
  sortField: 'sendTime',
170
156
  clientChat: this,
171
- checkMessageSendResultMethod: options.checkMessageSendResultMethod,
172
157
  onAddMessageSuccess: ({ data }) => {
173
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
174
- let sessionId = createSessionId(accountId, data.roomId)
158
+ let sessionId = createSessionId(data.corpId, data.qwAccountId, data.roomId)
175
159
  // 更新会话
176
160
  if (!sessionId) {
177
161
  return
@@ -186,15 +170,6 @@ class ClientChat {
186
170
  return this.session.getSession(sessionId).then(done)
187
171
  })
188
172
  this._sessionPollRequestMap[sessionId].start().then((rs) => {
189
- // 后端更新会话是异步过程,返回的会话信息可能还未包含当前消息
190
- if (rs && rs.data && !rs.data.unreadMsgCount) {
191
- rs.data.unreadMsgCount = data.send ? 0 : 1
192
- rs.data.lastMsgContent = data.content
193
- rs.data.lastMsgType = data.msgType
194
- rs.data.lastMsgTime = data.sendTime
195
- rs.data.lastMsgId = data.id
196
- rs.data.lastUpdateTime = data.updateDate
197
- }
198
173
  // 更新账号未读消息数量
199
174
  this.account.updateAccountUnreadMessageNum(rs.data.qwAccountId, ({ unreadMesasgeNum }) => {
200
175
  return unreadMesasgeNum += (rs.data.unreadMsgCount || 0)
@@ -205,7 +180,7 @@ class ClientChat {
205
180
  } else {
206
181
  this.session.updateSession(sessionId, ({ session }) => {
207
182
  let unreadMsgCount = session.unreadMsgCount
208
- if (!data.send) {
183
+ if (!data.isSend) {
209
184
  unreadMsgCount = unreadMsgCount + 1
210
185
  }
211
186
  // 如果是当前会话,那么未读消息需要设置为0
@@ -239,7 +214,7 @@ class ClientChat {
239
214
  groupField: 'roomId',
240
215
  sortField: 'sendTime',
241
216
  clientChat: this,
242
- checkMessageSendResultMethod: options.checkMessageSendResultMethod,
217
+ // checkMessageSendResultMethod: options.checkMessageSendResultMethod,
243
218
  // loadLossMessageDataMethod: options.loadLossRoomMessageDataMethod,
244
219
  queryMethod: (params) => {
245
220
  return options.loadRoomMessageDataMethod(params)
@@ -283,77 +258,6 @@ class ClientChat {
283
258
  })
284
259
  this.socket = new ClientChatSocket({
285
260
  socket: options.socket,
286
- onCmdQwContactInfoChanged: ({ data }) => {
287
- const contacts = data && (Array.isArray(data.contacts)
288
- ? data.contacts
289
- : (data.contactId ? [data] : []))
290
- if (!contacts || !contacts.length) {
291
- this.markAccountsModified(data && data.qwAccountIds)
292
- return
293
- }
294
- const tasks = []
295
- const removedTasks = []
296
- contacts.forEach(contact => {
297
- if (!contact) {
298
- return
299
- }
300
- const changeType = Number(contact.changeType)
301
- if (changeType === 1) {
302
- tasks.push(this.handleQwContactAdded(contact, data))
303
- } else if (changeType === 2) {
304
- tasks.push(this.handleQwContactUpdated(contact))
305
- } else if (changeType === 3) {
306
- removedTasks.push(this.handleQwContactRemoved(contact, data))
307
- }
308
- })
309
- return Promise.all(tasks.concat(removedTasks)).then(results => {
310
- const accountUnreadCountMap = {}
311
- removedTasks.forEach((task, index) => {
312
- const result = results[tasks.length + index]
313
- if (!result || !result.accountId || !result.unreadCount) {
314
- return
315
- }
316
- accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
317
- })
318
- return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
319
- const removedUnreadCount = accountUnreadCountMap[accountId]
320
- return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
321
- return Math.max(0, unreadMesasgeNum - removedUnreadCount)
322
- }).catch(error => {
323
- console.warn('[client-chat] update account unread count failed', error)
324
- })
325
- }))
326
- })
327
- },
328
- onCmdQwRoomInfoChanged: ({ data }) => {
329
- const rooms = data && (Array.isArray(data.rooms)
330
- ? data.rooms
331
- : (data.roomId ? [data] : []))
332
- if (!rooms || !rooms.length) {
333
- this.markAccountsModified(data && data.qwAccountIds)
334
- return
335
- }
336
- const tasks = []
337
- const removedTasks = []
338
- rooms.forEach(room => {
339
- if (!room) {
340
- return
341
- }
342
- const changeType = Number(room.changeType)
343
- if (changeType === 1) {
344
- tasks.push(this.handleQwRoomAdded(room, data))
345
- } else if (changeType === 2) {
346
- tasks.push(this.handleQwRoomUpdated(room))
347
- } else if (changeType === 3) {
348
- removedTasks.push(this.handleQwRoomRemoved(room, data))
349
- }
350
- })
351
- return Promise.all(tasks.concat(removedTasks)).then(results => {
352
- return this.updateRemovedSessionUnreadCounts(
353
- results.slice(tasks.length)
354
- )
355
- })
356
- },
357
261
  // 接受新消息
358
262
  onCmdQwNewMessage: ({ data }) => {
359
263
  // 插入消息
@@ -375,193 +279,19 @@ class ClientChat {
375
279
  })
376
280
  },
377
281
  onHeartbeatSuccess: ({ data }) => {
378
- const onlineMap = data || {}
282
+ if (!data.wq) {
283
+ return
284
+ }
285
+ const onlineMap = data.wq || {}
379
286
  Object.keys(onlineMap).forEach(k => {
380
287
  this.account.updateAccount(k, {
381
288
  alive: onlineMap[k]
382
- })
383
- })
384
- }
385
- })
386
- }
387
-
388
- getQwAccountCorpId (qwAccountId, corpId) {
389
- if (corpId || !qwAccountId || !this.account) {
390
- return corpId
391
- }
392
- const account = this.account.getAccountData().find(item => item.id === qwAccountId)
393
- return account && account.corpId
394
- }
395
-
396
- markAccountsModified (qwAccountIds) {
397
- if (!Array.isArray(qwAccountIds) || !qwAccountIds.length) {
398
- return
399
- }
400
- this.session.markModify(qwAccountIds)
401
- this.contacts.markModify(qwAccountIds)
402
- }
403
-
404
- updateRemovedSessionUnreadCounts (results) {
405
- const accountUnreadCountMap = {}
406
- ;(results || []).forEach(result => {
407
- if (!result || !result.accountId || !result.unreadCount) {
408
- return
409
- }
410
- accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
411
- })
412
- return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
413
- const removedUnreadCount = accountUnreadCountMap[accountId]
414
- return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
415
- return Math.max(0, unreadMesasgeNum - removedUnreadCount)
416
- }).catch(error => {
417
- console.warn('[client-chat] update account unread count failed', error)
418
- })
419
- }))
420
- }
421
-
422
- handleQwContactAdded (contact, eventData) {
423
- const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
424
- const corpId = this.getQwAccountCorpId(
425
- qwAccountId,
426
- contact.corpId || (eventData && eventData.corpId)
427
- )
428
- const contactId = contact.contactId
429
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
430
- const sessionId = createSessionId(accountId, contactId)
431
- if (!sessionId) {
432
- return Promise.resolve()
433
- }
434
- const localSession = this.session.getSessionByLocal(sessionId)
435
- const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
436
- return this.session.refreshSession(sessionId).then(rs => {
437
- const serverSession = rs && rs.data
438
- const newUnread = serverSession ? (serverSession.unreadMsgCount || 0) : 0
439
- const accountId = (serverSession && serverSession.qwAccountId) || qwAccountId
440
- const unreadDiff = newUnread - oldUnread
441
- if (accountId && unreadDiff) {
442
- return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
443
- return Math.max(0, unreadMesasgeNum + unreadDiff)
289
+ })
444
290
  })
445
291
  }
446
- }).catch(error => {
447
- console.warn('[client-chat] refresh added contact session failed', error)
448
- })
449
- }
450
-
451
- handleQwContactUpdated (contact) {
452
- if (!contact.contactId) {
453
- return Promise.resolve()
454
- }
455
- return this.contacts.refreshFriend(contact.contactId).catch(error => {
456
- console.warn('[client-chat] refresh contact failed', error)
457
- })
458
- }
459
-
460
- handleQwContactRemoved (contact, eventData) {
461
- if (!contact.contactId) {
462
- return Promise.resolve()
463
- }
464
- this.contacts.removeFriend(contact.contactId)
465
- let session = this.session.findSession(({ session }) => {
466
- return String(session.type) === '0' &&
467
- session.targetId === contact.contactId &&
468
- (!contact.qwAccountId || session.qwAccountId === contact.qwAccountId)
469
- })
470
- if (!session) {
471
- const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
472
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
473
- const sessionId = createSessionId(
474
- accountId,
475
- contact.contactId
476
- )
477
- session = sessionId && this.session.getSessionByLocal(sessionId)
478
- }
479
- if (!session) {
480
- return Promise.resolve()
481
- }
482
- if (this.session.currentSession && this.session.currentSession.id === session.id) {
483
- this.session.setCurrentSession(null)
484
- }
485
- const accountId = session.qwAccountId || contact.qwAccountId
486
- const unreadCount = session.unreadMsgCount || 0
487
- this.session.removeSession(session.id)
488
- return Promise.resolve({
489
- accountId,
490
- unreadCount
491
292
  })
492
293
  }
493
294
 
494
- handleQwRoomAdded (room, eventData) {
495
- if (!room.roomId) {
496
- return Promise.resolve()
497
- }
498
- const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
499
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
500
- const sessionId = createSessionId(accountId, room.roomId)
501
- const localSession = sessionId && this.session.getSessionByLocal(sessionId)
502
- const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
503
- const tasks = [this.contacts.refreshRoom(room.roomId).catch(error => {
504
- console.warn('[client-chat] refresh added room failed', error)
505
- })]
506
- if (sessionId) {
507
- tasks.push(this.session.refreshSession(sessionId).then(rs => {
508
- const serverSession = rs && rs.data
509
- const unreadDiff = (serverSession ? (serverSession.unreadMsgCount || 0) : 0) - oldUnread
510
- const changedAccountId = (serverSession && serverSession.qwAccountId) || qwAccountId
511
- if (changedAccountId && unreadDiff) {
512
- return this.account.updateAccountUnreadMessageNum(changedAccountId, ({ unreadMesasgeNum }) => {
513
- return Math.max(0, unreadMesasgeNum + unreadDiff)
514
- })
515
- }
516
- }).catch(error => {
517
- console.warn('[client-chat] refresh added room session failed', error)
518
- }))
519
- }
520
- return Promise.all(tasks)
521
- }
522
-
523
- handleQwRoomUpdated (room) {
524
- if (!room.roomId) {
525
- return Promise.resolve()
526
- }
527
- return this.contacts.refreshRoom(room.roomId).catch(error => {
528
- console.warn('[client-chat] refresh room failed', error)
529
- })
530
- }
531
-
532
- handleQwRoomRemoved (room, eventData) {
533
- if (!room.roomId) {
534
- return Promise.resolve()
535
- }
536
- this.contacts.removeRoom(room.roomId)
537
- this.event.emit('roomRemoved', {
538
- roomId: room.roomId
539
- })
540
- const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
541
- let session = this.session.findSession(({ session }) => {
542
- return String(session.type) === '1' &&
543
- session.targetId === room.roomId &&
544
- (!qwAccountId || session.qwAccountId === qwAccountId)
545
- })
546
- if (!session) {
547
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
548
- const sessionId = createSessionId(accountId, room.roomId)
549
- session = sessionId && this.session.getSessionByLocal(sessionId)
550
- }
551
- if (!session) {
552
- return Promise.resolve()
553
- }
554
- if (this.session.currentSession && this.session.currentSession.id === session.id) {
555
- this.session.setCurrentSession(null)
556
- }
557
- const unreadCount = session.unreadMsgCount || 0
558
- this.session.removeSession(session.id)
559
- return Promise.resolve({
560
- accountId: session.qwAccountId || qwAccountId,
561
- unreadCount
562
- })
563
- }
564
-
565
295
  connect () {
566
296
  if (this.data.connectStatus === CONNECT_STATUS.Complete) {
567
297
  return Promise.resolve()
@@ -598,4 +328,4 @@ class ClientChat {
598
328
  }
599
329
  }
600
330
 
601
- export default ClientChat
331
+ export default ClientChat
@@ -13,11 +13,11 @@ export function isUni () {
13
13
  * @param accountId - 客服id
14
14
  * @param targetId - wechatFriendId | wechatChatroomId
15
15
  */
16
- export function createSessionId (accountId, targetId) {
17
- if (!accountId || !targetId) {
16
+ export function createSessionId (corpId, accountId, targetId) {
17
+ if (!corpId || !accountId || !targetId) {
18
18
  return
19
19
  }
20
- return shajs('sha1').update(`${accountId}${targetId}`).digest('hex')
20
+ return shajs('sha1').update(`${corpId}${accountId}${targetId}`).digest('hex')
21
21
  }
22
22
 
23
23
  /**
@@ -54,7 +54,7 @@ export function createSessionId (accountId, targetId) {
54
54
  * "msgSvrId": "4319123759514541049",
55
55
  * "msgType": 1,
56
56
  * "origin": "0",
57
- * "status": 0,
57
+ * "sendStatus": 0,
58
58
  * "tenantId": "1761952223049924608",
59
59
  * "wechatAccountId": "ad9d9ae2a8be4f27311312cdd4af3549dc8427ef",
60
60
  * "wechatFriendId": "2089efcc7f8f40b00b7f05fa4c6dfd3bb642774d",
@@ -79,4 +79,4 @@ export function createSessionData (message) {
79
79
  wechatAccountId: message.wechatAccountId
80
80
  }
81
81
  return nextSession
82
- }
82
+ }
@@ -0,0 +1,51 @@
1
+ <template>
2
+ <bi-portray
3
+ :avatar="accountData && accountData.avatar"
4
+ :name="accountData && (accountData.memo || accountData.nickname)"
5
+ :loading="loading"
6
+ ></bi-portray>
7
+ </template>
8
+
9
+ <script>
10
+ import BiPortray from '@aochuang/common/uni-common/portray/portray.vue'
11
+
12
+ export default {
13
+ name: 'BiAccountPortray',
14
+ components: {
15
+ BiPortray
16
+ },
17
+ props: {
18
+ id: {
19
+ type: String,
20
+ required: true
21
+ }
22
+ },
23
+ data () {
24
+ return {
25
+ loading: false,
26
+ accountData: null
27
+ }
28
+ },
29
+ watch: {
30
+ id () {
31
+ this.loadData()
32
+ }
33
+ },
34
+ created () {
35
+ this.loadData()
36
+ },
37
+ methods: {
38
+ loadData () {
39
+ this.loading = true
40
+ this.$clientChat.account.getAccount(this.id).then(rs => {
41
+ this.accountData = rs.data
42
+ }).finally(() => {
43
+ this.loading = false
44
+ })
45
+ }
46
+ }
47
+ }
48
+ </script>
49
+
50
+ <style>
51
+ </style>
@@ -0,0 +1,172 @@
1
+ <template>
2
+ <view
3
+ class="bi-account-select-item"
4
+ :class="['bi-account-select-item--' + type, {'is-active': selected, 'is-online': isAll ? false : data && data.online, 'is-offline': isAll ? false : data && !data.online}]"
5
+ >
6
+ <view class="bi-account-select-item__icon">
7
+ <template v-if="isAll">
8
+ <bi-all-friend-avatar :size="avatarSize" :round="type === 'simple'"></bi-all-friend-avatar>
9
+ </template>
10
+ <template v-else>
11
+ <bi-avatar :src="data.avatar" :size="avatarSize" :round="type === 'simple'"></bi-avatar>
12
+ </template>
13
+ </view>
14
+ <view class="bi-account-select-item__text">
15
+ <template v-if="isAll">全部好友</template>
16
+ <template v-else>
17
+ {{ data.memo || data.nickname }}
18
+ </template>
19
+ </view>
20
+ <bi-badge class="bi-account-select-item__count" :value="unreadCount" :max="99" v-if="unreadCount"></bi-badge>
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ import BiAvatar from '@aochuang/common/uni-components/avatar/avatar.vue'
26
+ import BiBadge from '@aochuang/common/uni-components/badge/badge.vue'
27
+ import BiAllFriendAvatar from '../all-friend-avatar/all-friend-avatar.vue'
28
+
29
+ export default {
30
+ name: 'BiAccountSelectItem',
31
+ components: {
32
+ BiAvatar,
33
+ BiBadge,
34
+ BiAllFriendAvatar
35
+ },
36
+ props: {
37
+ isAll: {
38
+ type: Boolean
39
+ },
40
+ type: {
41
+ type: String,
42
+ validator (value) {
43
+ return ['default', 'simple'].includes(value)
44
+ }
45
+ },
46
+ selected: {
47
+ type: Boolean
48
+ },
49
+ data: {
50
+ type: Object
51
+ }
52
+ },
53
+ computed: {
54
+ avatarSize () {
55
+ return this.type === 'default' ? 'small' : 'mini'
56
+ },
57
+ accountUnreadMessageNumData () {
58
+ return this.$clientChat.account.accountUnreadMessageNumData || []
59
+ },
60
+ unreadCount () {
61
+ if (this.isAll) {
62
+ return this.accountUnreadMessageNumData.reduce((rs, account) => {
63
+ if (account.num) {
64
+ rs += account.num
65
+ }
66
+ return rs
67
+ }, 0)
68
+ } else {
69
+ const unreadMessageNumItem = this.accountUnreadMessageNumData.find(v => v.id === this.data.id)
70
+ return unreadMessageNumItem ? unreadMessageNumItem.num : 0
71
+ }
72
+ }
73
+ },
74
+ created () {
75
+ if (!this.isAll && !this.data) {
76
+ throw new Error('缺少data数据')
77
+ }
78
+ }
79
+ }
80
+ </script>
81
+
82
+ <style lang="less">
83
+ .bi-account-select-item{
84
+ display: flex;
85
+ flex-direction: row;
86
+ align-items: center;
87
+ position: relative;
88
+ transition: all .25s;
89
+ max-width: 100%;
90
+ &.is-active {
91
+ background: #3c9cff;
92
+ color: #fff;
93
+ &:after {
94
+ border-right-color: #fff;
95
+ border-bottom-color: #fff;
96
+ }
97
+ }
98
+ &.is-online {
99
+ .bi-account-select-item__icon{
100
+ &:after {
101
+ opacity: 1;
102
+ background-color: #40bf48;
103
+ border-color: #fff;
104
+ }
105
+ }
106
+ }
107
+ &.is-offline {
108
+ .bi-account-select-item__icon{
109
+ &:after {
110
+ opacity: 1;
111
+ background-color: #ccc;
112
+ border-color: #fff;
113
+ }
114
+ }
115
+ }
116
+ }
117
+ .bi-account-select-item__icon{
118
+ background-color: #eee;
119
+ margin-right: 6px;
120
+ position: relative;
121
+ line-height: 1em;
122
+ &:after {
123
+ content: '';
124
+ width: 8px;
125
+ height: 8px;
126
+ background-color: transparent;
127
+ border-radius: 50%;
128
+ border: 2px solid transparent;
129
+ position: absolute;
130
+ bottom: -2px;
131
+ right: -2px;
132
+ opacity: 0;
133
+ }
134
+ }
135
+ .bi-account-select-item__text{
136
+ flex: 1;
137
+ min-width: 0;
138
+ overflow: hidden;
139
+ text-overflow: ellipsis;
140
+ white-space: nowrap;
141
+ }
142
+ .bi-account-select-item--default {
143
+ padding: 6px 24px 6px 12px;
144
+ &:after {
145
+ content: '';
146
+ width: 6px;
147
+ height: 6px;
148
+ border: 1px solid #ccc;
149
+ border-left: 0;
150
+ border-top: 0;
151
+ transform: rotate(-45deg) translateY(-50%);
152
+ position: absolute;
153
+ right: 12px;
154
+ top: 50%;
155
+ }
156
+ .bi-account-select-item__icon {
157
+ width: 32px;
158
+ height: 32px;
159
+ border-radius: 3px;
160
+ }
161
+ }
162
+ .bi-account-select-item--simple {
163
+ .bi-account-select-item__icon {
164
+ width: 24px;
165
+ height: 24px;
166
+ border-radius: 50%;
167
+ }
168
+ .bi-account-select-item__count{
169
+ transform: scale(.8);
170
+ }
171
+ }
172
+ </style>