@aochuang/client-sdk 1.0.343 → 1.0.344

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 (141) hide show
  1. package/components/index.js +6 -1
  2. package/components/session-select/session-select-item.vue +8 -9
  3. package/components/wechat-chat-control/calling/calling.vue +0 -3
  4. package/components/wechat-chat-control/voice/voice.vue +0 -4
  5. package/components/wework-chat-control/company-card/company-card.vue +1 -1
  6. package/components/wework-chat-control/file-url/file-url.vue +2 -5
  7. package/components/wework-chat-control/image/image.vue +137 -2
  8. package/components/wework-chat-control/index.js +6 -6
  9. package/components/wework-chat-control/text/text.vue +22 -3
  10. package/components/wework-chat-control/util.js +12 -6
  11. package/components/wework-chat-control/video/video.vue +10 -2
  12. package/components/wework-chat-control/voice/voice.vue +1 -1
  13. package/components/wework-chat-control/wework-chat-control-config-item.vue +24 -0
  14. package/components/wework-chat-control/wework-chat-control-config-msg.vue +25 -0
  15. package/{uni-components/chat-control/chat-control-config.vue → components/wework-chat-control/wework-chat-control-config.vue} +16 -13
  16. package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +73 -0
  17. package/components/wework-chat-panel/chat-panel-item.vue +12 -35
  18. package/components/wework-chat-panel/chat-panel.vue +95 -12
  19. package/package.json +10 -3
  20. package/services/client-chat/client-chat-wechat/client-chat-session.js +3 -4
  21. package/services/client-chat/client-chat-wechat/client-chat.js +8 -20
  22. package/services/client-chat/client-chat-wework/client-chat-concats.js +81 -17
  23. package/services/client-chat/client-chat-wework/client-chat-message.js +5 -5
  24. package/services/client-chat/client-chat-wework/client-chat-session.js +50 -2
  25. package/services/client-chat/client-chat-wework/client-chat-socket.js +9 -1
  26. package/services/client-chat/client-chat-wework/client-chat.js +278 -11
  27. package/services/client-chat/client-chat-wework/utils.js +5 -5
  28. package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +0 -35
  29. package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +0 -36
  30. package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +0 -35
  31. package/components/wework-chat-panel/chat-panel-controls/image/image.vue +0 -36
  32. package/components/wework-chat-panel/chat-panel-controls/index.js +0 -35
  33. package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +0 -28
  34. package/components/wework-chat-panel/chat-panel-controls/link/link.vue +0 -35
  35. package/components/wework-chat-panel/chat-panel-controls/location/location.vue +0 -35
  36. package/components/wework-chat-panel/chat-panel-controls/text/text.vue +0 -43
  37. package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +0 -39
  38. package/components/wework-chat-panel/chat-panel-controls/video/video.vue +0 -37
  39. package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +0 -35
  40. package/uni-common/account-portray/account-portray.vue +0 -51
  41. package/uni-common/account-select/account-select-item.vue +0 -172
  42. package/uni-common/account-select/account-select.vue +0 -252
  43. package/uni-common/all-friend-avatar/all-friend-avatar.vue +0 -49
  44. package/uni-common/friend-avatar/default.svg +0 -1
  45. package/uni-common/friend-avatar/friend-avatar.vue +0 -27
  46. package/uni-common/friend-avatar/index.js +0 -3
  47. package/uni-common/friend-loader/friend-loader.vue +0 -53
  48. package/uni-common/friend-portray/friend-portray.vue +0 -56
  49. package/uni-common/group-avatar/default.svg +0 -1
  50. package/uni-common/group-avatar/group-avatar.vue +0 -18
  51. package/uni-common/group-avatar/index.js +0 -3
  52. package/uni-common/room-avatar/default.svg +0 -6
  53. package/uni-common/room-avatar/index.js +0 -3
  54. package/uni-common/room-avatar/room-avatar.vue +0 -27
  55. package/uni-common/room-loader/room-loader.vue +0 -53
  56. package/uni-common/room-portray/room-portray.vue +0 -56
  57. package/uni-components/chat-control/calling/calling.vue +0 -91
  58. package/uni-components/chat-control/calling/phone-fill.svg +0 -1
  59. package/uni-components/chat-control/calling/vidicon-fill.svg +0 -1
  60. package/uni-components/chat-control/channel-video/channel-video.vue +0 -89
  61. package/uni-components/chat-control/channel-video-card/channel-video-card.vue +0 -105
  62. package/uni-components/chat-control/channel-video-live/channel-video-live.vue +0 -92
  63. package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +0 -20
  64. package/uni-components/chat-control/chat-control-config-item/index.js +0 -3
  65. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +0 -25
  66. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +0 -21
  67. package/uni-components/chat-control/chat-control.vue +0 -218
  68. package/uni-components/chat-control/company-card/company-card.vue +0 -123
  69. package/uni-components/chat-control/const.js +0 -28
  70. package/uni-components/chat-control/expression/expression.vue +0 -41
  71. package/uni-components/chat-control/image/image.vue +0 -68
  72. package/uni-components/chat-control/index.js +0 -89
  73. package/uni-components/chat-control/location/location.vue +0 -110
  74. package/uni-components/chat-control/member-change/member-change.vue +0 -32
  75. package/uni-components/chat-control/quote-message/quote-message.vue +0 -216
  76. package/uni-components/chat-control/real-time-position/real-time-position.vue +0 -62
  77. package/uni-components/chat-control/redpacket/red-envelope.svg +0 -1
  78. package/uni-components/chat-control/redpacket/redpacket.vue +0 -75
  79. package/uni-components/chat-control/share-card/share-card.vue +0 -101
  80. package/uni-components/chat-control/system/system.vue +0 -69
  81. package/uni-components/chat-control/system-batch-message/system-batch-message.vue +0 -30
  82. package/uni-components/chat-control/system-text/system-text.vue +0 -32
  83. package/uni-components/chat-control/text/text.vue +0 -67
  84. package/uni-components/chat-control/text-with-at/text-with-at.vue +0 -51
  85. package/uni-components/chat-control/transfer/red-transfer.svg +0 -1
  86. package/uni-components/chat-control/transfer/transfer.vue +0 -80
  87. package/uni-components/chat-control/unkonw/unkonw.vue +0 -37
  88. package/uni-components/chat-control/url/icons/file-excel-line.svg +0 -1
  89. package/uni-components/chat-control/url/icons/file-info-line.svg +0 -1
  90. package/uni-components/chat-control/url/icons/file-music-line.svg +0 -1
  91. package/uni-components/chat-control/url/icons/file-pdf-line.svg +0 -1
  92. package/uni-components/chat-control/url/icons/file-ppt-line.svg +0 -1
  93. package/uni-components/chat-control/url/icons/file-settings-line.svg +0 -1
  94. package/uni-components/chat-control/url/icons/file-text-line.svg +0 -1
  95. package/uni-components/chat-control/url/icons/file-unknow-line.svg +0 -1
  96. package/uni-components/chat-control/url/icons/file-word-line.svg +0 -1
  97. package/uni-components/chat-control/url/icons/file-zip-line.svg +0 -1
  98. package/uni-components/chat-control/url/icons/index.js +0 -24
  99. package/uni-components/chat-control/url/miniprogram.svg +0 -1
  100. package/uni-components/chat-control/url/url-miniprogram.vue +0 -116
  101. package/uni-components/chat-control/url/url.vue +0 -306
  102. package/uni-components/chat-control/url-new/icons/file-excel-line.svg +0 -1
  103. package/uni-components/chat-control/url-new/icons/file-info-line.svg +0 -1
  104. package/uni-components/chat-control/url-new/icons/file-music-line.svg +0 -1
  105. package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +0 -1
  106. package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +0 -1
  107. package/uni-components/chat-control/url-new/icons/file-settings-line.svg +0 -1
  108. package/uni-components/chat-control/url-new/icons/file-text-line.svg +0 -1
  109. package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +0 -1
  110. package/uni-components/chat-control/url-new/icons/file-word-line.svg +0 -1
  111. package/uni-components/chat-control/url-new/icons/file-zip-line.svg +0 -1
  112. package/uni-components/chat-control/url-new/icons/index.js +0 -24
  113. package/uni-components/chat-control/url-new/url-new.vue +0 -110
  114. package/uni-components/chat-control/utils.js +0 -12
  115. package/uni-components/chat-control/video/video.vue +0 -156
  116. package/uni-components/chat-control/voice/voice.vue +0 -166
  117. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +0 -84
  118. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +0 -28
  119. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +0 -85
  120. package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +0 -157
  121. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +0 -158
  122. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +0 -61
  123. package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +0 -58
  124. package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +0 -54
  125. package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +0 -42
  126. package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +0 -42
  127. package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +0 -25
  128. package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +0 -158
  129. package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +0 -75
  130. package/uni-components/chat-editor/chat-editor.vue +0 -257
  131. package/uni-components/chat-editor/index.js +0 -10
  132. package/uni-components/chat-editor/util.js +0 -65
  133. package/uni-components/chat-panel/chat-panel-chats-box.vue +0 -238
  134. package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +0 -273
  135. package/uni-components/chat-panel/chat-panel-chats-item.vue +0 -578
  136. package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +0 -71
  137. package/uni-components/chat-panel/chat-panel-chats.vue +0 -368
  138. package/uni-components/chat-panel/chat-panel.vue +0 -227
  139. package/uni-components/contacts-group-select/contacts-group-select-item.vue +0 -85
  140. package/uni-components/contacts-group-select/contacts-group-select-panel.vue +0 -119
  141. package/uni-components/contacts-group-select/contacts-group-select.vue +0 -150
@@ -32,6 +32,7 @@ class ClientChat {
32
32
  getLoginUserIdMethod: null,
33
33
  getLoginUserTokenMethod: null,
34
34
  loadAccountDataMethod: null,
35
+ getLoginAccountIdMethod: null, // 因为1.0有帮聊逻辑,帮聊消息以及通讯录的accountId不是登录用户的accountId,会导致找到的会话出现问题,所以这里提供一个方法让外部传入
35
36
  loadSessionDataMethod: null,
36
37
  updateSessionReadMethod: null,
37
38
  getSessionMethod: null,
@@ -57,8 +58,9 @@ class ClientChat {
57
58
  }
58
59
  if (!options.loadRoomMessageDataMethod) {
59
60
  throw new Error('loadRoomMessageDataMethod不能为空')
60
- }
61
+ }
61
62
  this.onOverwriteFriendInfoChange = options.onOverwriteFriendInfoChange
63
+ this.getLoginAccountIdMethod = options.getLoginAccountIdMethod
62
64
  this.event = new Event({
63
65
  checkOnMethod: (name) => {
64
66
  if (name === 'ready') {
@@ -86,7 +88,8 @@ class ClientChat {
86
88
  sortField: 'sendTime',
87
89
  clientChat: this,
88
90
  onAddMessageSuccess: ({ data }) => {
89
- let sessionId = createSessionId(data.corpId, data.qwAccountId, data.contactId)
91
+ const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
92
+ let sessionId = createSessionId(accountId, data.contactId)
90
93
  // 更新会话
91
94
  if (!sessionId) {
92
95
  return
@@ -100,6 +103,15 @@ class ClientChat {
100
103
  return this.session.getSession(sessionId).then(done)
101
104
  })
102
105
  this._sessionPollRequestMap[sessionId].start().then((rs) => {
106
+ // 后端更新会话是异步过程,返回的会话信息可能还未包含当前消息
107
+ if (rs && rs.data && !rs.data.unreadMsgCount) {
108
+ rs.data.unreadMsgCount = data.send ? 0 : 1
109
+ rs.data.lastMsgContent = data.content
110
+ rs.data.lastMsgType = data.msgType
111
+ rs.data.lastMsgTime = data.sendTime
112
+ rs.data.lastMsgId = data.id
113
+ rs.data.lastUpdateTime = data.updateDate
114
+ }
103
115
  // 更新账号未读消息数量
104
116
  this.account.updateAccountUnreadMessageNum(rs.data.qwAccountId, ({ unreadMesasgeNum }) => {
105
117
  return unreadMesasgeNum += (rs.data.unreadMsgCount || 0)
@@ -110,7 +122,7 @@ class ClientChat {
110
122
  } else {
111
123
  this.session.updateSession(sessionId, ({ session }) => {
112
124
  let unreadMsgCount = session.unreadMsgCount
113
- if (!data.isSend) {
125
+ if (!data.send) {
114
126
  unreadMsgCount = unreadMsgCount + 1
115
127
  }
116
128
  // 如果是当前会话,那么未读消息需要设置为0
@@ -155,7 +167,8 @@ class ClientChat {
155
167
  sortField: 'sendTime',
156
168
  clientChat: this,
157
169
  onAddMessageSuccess: ({ data }) => {
158
- let sessionId = createSessionId(data.corpId, data.qwAccountId, data.roomId)
170
+ const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
171
+ let sessionId = createSessionId(accountId, data.roomId)
159
172
  // 更新会话
160
173
  if (!sessionId) {
161
174
  return
@@ -170,6 +183,15 @@ class ClientChat {
170
183
  return this.session.getSession(sessionId).then(done)
171
184
  })
172
185
  this._sessionPollRequestMap[sessionId].start().then((rs) => {
186
+ // 后端更新会话是异步过程,返回的会话信息可能还未包含当前消息
187
+ if (rs && rs.data && !rs.data.unreadMsgCount) {
188
+ rs.data.unreadMsgCount = data.send ? 0 : 1
189
+ rs.data.lastMsgContent = data.content
190
+ rs.data.lastMsgType = data.msgType
191
+ rs.data.lastMsgTime = data.sendTime
192
+ rs.data.lastMsgId = data.id
193
+ rs.data.lastUpdateTime = data.updateDate
194
+ }
173
195
  // 更新账号未读消息数量
174
196
  this.account.updateAccountUnreadMessageNum(rs.data.qwAccountId, ({ unreadMesasgeNum }) => {
175
197
  return unreadMesasgeNum += (rs.data.unreadMsgCount || 0)
@@ -180,7 +202,7 @@ class ClientChat {
180
202
  } else {
181
203
  this.session.updateSession(sessionId, ({ session }) => {
182
204
  let unreadMsgCount = session.unreadMsgCount
183
- if (!data.isSend) {
205
+ if (!data.send) {
184
206
  unreadMsgCount = unreadMsgCount + 1
185
207
  }
186
208
  // 如果是当前会话,那么未读消息需要设置为0
@@ -258,6 +280,77 @@ class ClientChat {
258
280
  })
259
281
  this.socket = new ClientChatSocket({
260
282
  socket: options.socket,
283
+ onCmdQwContactInfoChanged: ({ data }) => {
284
+ const contacts = data && (Array.isArray(data.contacts)
285
+ ? data.contacts
286
+ : (data.contactId ? [data] : []))
287
+ if (!contacts || !contacts.length) {
288
+ this.markAccountsModified(data && data.qwAccountIds)
289
+ return
290
+ }
291
+ const tasks = []
292
+ const removedTasks = []
293
+ contacts.forEach(contact => {
294
+ if (!contact) {
295
+ return
296
+ }
297
+ const changeType = Number(contact.changeType)
298
+ if (changeType === 1) {
299
+ tasks.push(this.handleQwContactAdded(contact, data))
300
+ } else if (changeType === 2) {
301
+ tasks.push(this.handleQwContactUpdated(contact))
302
+ } else if (changeType === 3) {
303
+ removedTasks.push(this.handleQwContactRemoved(contact, data))
304
+ }
305
+ })
306
+ return Promise.all(tasks.concat(removedTasks)).then(results => {
307
+ const accountUnreadCountMap = {}
308
+ removedTasks.forEach((task, index) => {
309
+ const result = results[tasks.length + index]
310
+ if (!result || !result.accountId || !result.unreadCount) {
311
+ return
312
+ }
313
+ accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
314
+ })
315
+ return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
316
+ const removedUnreadCount = accountUnreadCountMap[accountId]
317
+ return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
318
+ return Math.max(0, unreadMesasgeNum - removedUnreadCount)
319
+ }).catch(error => {
320
+ console.warn('[client-chat] update account unread count failed', error)
321
+ })
322
+ }))
323
+ })
324
+ },
325
+ onCmdQwRoomInfoChanged: ({ data }) => {
326
+ const rooms = data && (Array.isArray(data.rooms)
327
+ ? data.rooms
328
+ : (data.roomId ? [data] : []))
329
+ if (!rooms || !rooms.length) {
330
+ this.markAccountsModified(data && data.qwAccountIds)
331
+ return
332
+ }
333
+ const tasks = []
334
+ const removedTasks = []
335
+ rooms.forEach(room => {
336
+ if (!room) {
337
+ return
338
+ }
339
+ const changeType = Number(room.changeType)
340
+ if (changeType === 1) {
341
+ tasks.push(this.handleQwRoomAdded(room, data))
342
+ } else if (changeType === 2) {
343
+ tasks.push(this.handleQwRoomUpdated(room))
344
+ } else if (changeType === 3) {
345
+ removedTasks.push(this.handleQwRoomRemoved(room, data))
346
+ }
347
+ })
348
+ return Promise.all(tasks.concat(removedTasks)).then(results => {
349
+ return this.updateRemovedSessionUnreadCounts(
350
+ results.slice(tasks.length)
351
+ )
352
+ })
353
+ },
261
354
  // 接受新消息
262
355
  onCmdQwNewMessage: ({ data }) => {
263
356
  // 插入消息
@@ -279,19 +372,193 @@ class ClientChat {
279
372
  })
280
373
  },
281
374
  onHeartbeatSuccess: ({ data }) => {
282
- if (!data.wq) {
283
- return
284
- }
285
- const onlineMap = data.wq || {}
375
+ const onlineMap = data || {}
286
376
  Object.keys(onlineMap).forEach(k => {
287
377
  this.account.updateAccount(k, {
288
378
  alive: onlineMap[k]
289
- })
379
+ })
380
+ })
381
+ }
382
+ })
383
+ }
384
+
385
+ getQwAccountCorpId (qwAccountId, corpId) {
386
+ if (corpId || !qwAccountId || !this.account) {
387
+ return corpId
388
+ }
389
+ const account = this.account.getAccountData().find(item => item.id === qwAccountId)
390
+ return account && account.corpId
391
+ }
392
+
393
+ markAccountsModified (qwAccountIds) {
394
+ if (!Array.isArray(qwAccountIds) || !qwAccountIds.length) {
395
+ return
396
+ }
397
+ this.session.markModify(qwAccountIds)
398
+ this.contacts.markModify(qwAccountIds)
399
+ }
400
+
401
+ updateRemovedSessionUnreadCounts (results) {
402
+ const accountUnreadCountMap = {}
403
+ ;(results || []).forEach(result => {
404
+ if (!result || !result.accountId || !result.unreadCount) {
405
+ return
406
+ }
407
+ accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
408
+ })
409
+ return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
410
+ const removedUnreadCount = accountUnreadCountMap[accountId]
411
+ return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
412
+ return Math.max(0, unreadMesasgeNum - removedUnreadCount)
413
+ }).catch(error => {
414
+ console.warn('[client-chat] update account unread count failed', error)
415
+ })
416
+ }))
417
+ }
418
+
419
+ handleQwContactAdded (contact, eventData) {
420
+ const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
421
+ const corpId = this.getQwAccountCorpId(
422
+ qwAccountId,
423
+ contact.corpId || (eventData && eventData.corpId)
424
+ )
425
+ const contactId = contact.contactId
426
+ const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
427
+ const sessionId = createSessionId(accountId, contactId)
428
+ if (!sessionId) {
429
+ return Promise.resolve()
430
+ }
431
+ const localSession = this.session.getSessionByLocal(sessionId)
432
+ const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
433
+ return this.session.refreshSession(sessionId).then(rs => {
434
+ const serverSession = rs && rs.data
435
+ const newUnread = serverSession ? (serverSession.unreadMsgCount || 0) : 0
436
+ const accountId = (serverSession && serverSession.qwAccountId) || qwAccountId
437
+ const unreadDiff = newUnread - oldUnread
438
+ if (accountId && unreadDiff) {
439
+ return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
440
+ return Math.max(0, unreadMesasgeNum + unreadDiff)
290
441
  })
291
442
  }
443
+ }).catch(error => {
444
+ console.warn('[client-chat] refresh added contact session failed', error)
445
+ })
446
+ }
447
+
448
+ handleQwContactUpdated (contact) {
449
+ if (!contact.contactId) {
450
+ return Promise.resolve()
451
+ }
452
+ return this.contacts.refreshFriend(contact.contactId).catch(error => {
453
+ console.warn('[client-chat] refresh contact failed', error)
454
+ })
455
+ }
456
+
457
+ handleQwContactRemoved (contact, eventData) {
458
+ if (!contact.contactId) {
459
+ return Promise.resolve()
460
+ }
461
+ this.contacts.removeFriend(contact.contactId)
462
+ let session = this.session.findSession(({ session }) => {
463
+ return String(session.type) === '0' &&
464
+ session.targetId === contact.contactId &&
465
+ (!contact.qwAccountId || session.qwAccountId === contact.qwAccountId)
466
+ })
467
+ if (!session) {
468
+ const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
469
+ const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
470
+ const sessionId = createSessionId(
471
+ accountId,
472
+ contact.contactId
473
+ )
474
+ session = sessionId && this.session.getSessionByLocal(sessionId)
475
+ }
476
+ if (!session) {
477
+ return Promise.resolve()
478
+ }
479
+ if (this.session.currentSession && this.session.currentSession.id === session.id) {
480
+ this.session.setCurrentSession(null)
481
+ }
482
+ const accountId = session.qwAccountId || contact.qwAccountId
483
+ const unreadCount = session.unreadMsgCount || 0
484
+ this.session.removeSession(session.id)
485
+ return Promise.resolve({
486
+ accountId,
487
+ unreadCount
292
488
  })
293
489
  }
294
490
 
491
+ handleQwRoomAdded (room, eventData) {
492
+ if (!room.roomId) {
493
+ return Promise.resolve()
494
+ }
495
+ const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
496
+ const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
497
+ const sessionId = createSessionId(accountId, room.roomId)
498
+ const localSession = sessionId && this.session.getSessionByLocal(sessionId)
499
+ const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
500
+ const tasks = [this.contacts.refreshRoom(room.roomId).catch(error => {
501
+ console.warn('[client-chat] refresh added room failed', error)
502
+ })]
503
+ if (sessionId) {
504
+ tasks.push(this.session.refreshSession(sessionId).then(rs => {
505
+ const serverSession = rs && rs.data
506
+ const unreadDiff = (serverSession ? (serverSession.unreadMsgCount || 0) : 0) - oldUnread
507
+ const changedAccountId = (serverSession && serverSession.qwAccountId) || qwAccountId
508
+ if (changedAccountId && unreadDiff) {
509
+ return this.account.updateAccountUnreadMessageNum(changedAccountId, ({ unreadMesasgeNum }) => {
510
+ return Math.max(0, unreadMesasgeNum + unreadDiff)
511
+ })
512
+ }
513
+ }).catch(error => {
514
+ console.warn('[client-chat] refresh added room session failed', error)
515
+ }))
516
+ }
517
+ return Promise.all(tasks)
518
+ }
519
+
520
+ handleQwRoomUpdated (room) {
521
+ if (!room.roomId) {
522
+ return Promise.resolve()
523
+ }
524
+ return this.contacts.refreshRoom(room.roomId).catch(error => {
525
+ console.warn('[client-chat] refresh room failed', error)
526
+ })
527
+ }
528
+
529
+ handleQwRoomRemoved (room, eventData) {
530
+ if (!room.roomId) {
531
+ return Promise.resolve()
532
+ }
533
+ this.contacts.removeRoom(room.roomId)
534
+ this.event.emit('roomRemoved', {
535
+ roomId: room.roomId
536
+ })
537
+ const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
538
+ let session = this.session.findSession(({ session }) => {
539
+ return String(session.type) === '1' &&
540
+ session.targetId === room.roomId &&
541
+ (!qwAccountId || session.qwAccountId === qwAccountId)
542
+ })
543
+ if (!session) {
544
+ const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
545
+ const sessionId = createSessionId(accountId, room.roomId)
546
+ session = sessionId && this.session.getSessionByLocal(sessionId)
547
+ }
548
+ if (!session) {
549
+ return Promise.resolve()
550
+ }
551
+ if (this.session.currentSession && this.session.currentSession.id === session.id) {
552
+ this.session.setCurrentSession(null)
553
+ }
554
+ const unreadCount = session.unreadMsgCount || 0
555
+ this.session.removeSession(session.id)
556
+ return Promise.resolve({
557
+ accountId: session.qwAccountId || qwAccountId,
558
+ unreadCount
559
+ })
560
+ }
561
+
295
562
  connect () {
296
563
  if (this.data.connectStatus === CONNECT_STATUS.Complete) {
297
564
  return Promise.resolve()
@@ -328,4 +595,4 @@ class ClientChat {
328
595
  }
329
596
  }
330
597
 
331
- export default ClientChat
598
+ 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 (corpId, accountId, targetId) {
17
- if (!corpId || !accountId || !targetId) {
16
+ export function createSessionId (accountId, targetId) {
17
+ if (!accountId || !targetId) {
18
18
  return
19
19
  }
20
- return shajs('sha1').update(`${corpId}${accountId}${targetId}`).digest('hex')
20
+ return shajs('sha1').update(`${accountId}${targetId}`).digest('hex')
21
21
  }
22
22
 
23
23
  /**
@@ -54,7 +54,7 @@ export function createSessionId (corpId, accountId, targetId) {
54
54
  * "msgSvrId": "4319123759514541049",
55
55
  * "msgType": 1,
56
56
  * "origin": "0",
57
- * "sendStatus": 0,
57
+ * "status": 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
+ }
@@ -1,35 +0,0 @@
1
- <script>
2
- import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
3
- import { companyCard } from '../../../wework-chat-control'
4
-
5
- export default {
6
- name: 'SdkWeworkChatPanelControlsCompanyCard',
7
- functional: true,
8
- props: {
9
- dir: {
10
- type: String
11
- },
12
- data: {
13
- type: Object,
14
- required: true
15
- },
16
- fetchUserMethod: {
17
- type: Function
18
- }
19
- },
20
- render (h, c) {
21
- const { props } = c
22
- return h(SdkChatPanelBox, {
23
- props: {
24
- dir: props.dir,
25
- data: props.data,
26
- fetchUserMethod: props.fetchUserMethod
27
- }
28
- }, [h(companyCard, {
29
- props: {
30
- data: props.data
31
- }
32
- })])
33
- }
34
- }
35
- </script>
@@ -1,36 +0,0 @@
1
- <script>
2
- import { expression } from '../../../wework-chat-control'
3
- import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
4
-
5
- export default {
6
- name: 'SdkWeworkChatPanelControlsExpression',
7
- functional: true,
8
- props: {
9
- dir: {
10
- type: String
11
- },
12
- data: {
13
- type: Object,
14
- default: () => ({})
15
- },
16
- fetchUserMethod: {
17
- type: Function
18
- }
19
- },
20
- render (h, c) {
21
- const { props } = c
22
- return h(SdkChatPanelBox, {
23
- props: {
24
- dir: props.dir,
25
- data: props.data,
26
- fetchUserMethod: props.fetchUserMethod
27
- }
28
- }, [h(expression, {
29
- props: {
30
- data: props.data
31
- },
32
- key: c.data.key
33
- })])
34
- }
35
- }
36
- </script>
@@ -1,35 +0,0 @@
1
- <script>
2
- import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
3
- import { fileUrl } from '../../../wework-chat-control'
4
-
5
- export default {
6
- name: 'SdkWeworkChatPanelControlsFileUrl',
7
- functional: true,
8
- props: {
9
- dir: {
10
- type: String
11
- },
12
- data: {
13
- type: Object,
14
- required: true
15
- },
16
- fetchUserMethod: {
17
- type: Function
18
- }
19
- },
20
- render (h, c) {
21
- const { props } = c
22
- return h(SdkChatPanelBox, {
23
- props: {
24
- dir: props.dir,
25
- data: props.data,
26
- fetchUserMethod: props.fetchUserMethod
27
- }
28
- }, [h(fileUrl, {
29
- props: {
30
- content: props.data.content
31
- }
32
- })])
33
- }
34
- }
35
- </script>
@@ -1,36 +0,0 @@
1
- <script>
2
- import { image } from '../../../wework-chat-control'
3
- import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
4
-
5
- export default {
6
- name: 'SdkWeworkChatPanelControlsImage',
7
- functional: true,
8
- props: {
9
- dir: {
10
- type: String
11
- },
12
- data: {
13
- type: Object,
14
- default: () => ({})
15
- },
16
- fetchUserMethod: {
17
- type: Function
18
- }
19
- },
20
- render (h, c) {
21
- const { props } = c
22
- return h(SdkChatPanelBox, {
23
- props: {
24
- dir: props.dir,
25
- data: props.data,
26
- fetchUserMethod: props.fetchUserMethod
27
- }
28
- }, [h(image, {
29
- props: {
30
- data: props.data
31
- },
32
- key: c.data.key
33
- })])
34
- }
35
- }
36
- </script>
@@ -1,35 +0,0 @@
1
- import text from './text/text.vue'
2
- import link from './link/link.vue'
3
- import companyCard from './company-card/company-card.vue'
4
- import video from './video/video.vue'
5
- import image from './image/image.vue'
6
- import unkonw from './unkonw/unkonw.vue'
7
- import expression from './expression/expression.vue'
8
- import voice from './voice/voice.vue'
9
- import jxSysText from './jx-sys-text/jx-sys-text.vue'
10
- import fileUrl from './file-url/file-url.vue'
11
- import location from './location/location.vue'
12
-
13
- export default {
14
- 0: text,
15
- 2: text,
16
- 14: image,
17
- 101: image,
18
- // '49': link,
19
- 22: video,
20
- 23: video,
21
- 103: video,
22
- 29: expression,
23
- 104: expression,
24
- 16: voice,
25
- 40: voice,
26
- 1011: jxSysText,
27
- 1022: jxSysText,
28
- 41: companyCard,
29
- 13: fileUrl,
30
- 15: fileUrl,
31
- 20: fileUrl,
32
- 102: fileUrl,
33
- 6: location,
34
- unkonw
35
- }
@@ -1,28 +0,0 @@
1
- <script>
2
- import { jxSysText } from '../../../wework-chat-control'
3
-
4
- export default {
5
- name: 'SdkWeworkChatPanelControlsJxSysText',
6
- functional: true,
7
- props: {
8
- dir: {
9
- type: String
10
- },
11
- data: {
12
- type: Object,
13
- required: true
14
- },
15
- fetchUserMethod: {
16
- type: Function
17
- }
18
- },
19
- render (h, c) {
20
- const { props } = c
21
- return h(jxSysText, {
22
- props: {
23
- content: props.data.content
24
- }
25
- })
26
- }
27
- }
28
- </script>
@@ -1,35 +0,0 @@
1
- <script>
2
- import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
3
- import { link } from '../../../wework-chat-control'
4
-
5
- export default {
6
- name: 'SdkWeworkChatPanelControlsLink',
7
- functional: true,
8
- props: {
9
- dir: {
10
- type: String
11
- },
12
- data: {
13
- type: Object,
14
- required: true
15
- },
16
- fetchUserMethod: {
17
- type: Function
18
- }
19
- },
20
- render (h, c) {
21
- const { props } = c
22
- return h(SdkChatPanelBox, {
23
- props: {
24
- dir: props.dir,
25
- data: props.data,
26
- fetchUserMethod: props.fetchUserMethod
27
- }
28
- }, [h(link, {
29
- props: {
30
- data: props.data
31
- }
32
- })])
33
- }
34
- }
35
- </script>
@@ -1,35 +0,0 @@
1
- <script>
2
- import SdkChatPanelBox from '../../../chat-panel/chat-panel-box'
3
- import { location } from '../../../wework-chat-control'
4
-
5
- export default {
6
- name: 'SdkWeworkChatPanelControlsLocation',
7
- functional: true,
8
- props: {
9
- dir: {
10
- type: String
11
- },
12
- data: {
13
- type: Object,
14
- required: true
15
- },
16
- fetchUserMethod: {
17
- type: Function
18
- }
19
- },
20
- render (h, c) {
21
- const { props } = c
22
- return h(SdkChatPanelBox, {
23
- props: {
24
- dir: props.dir,
25
- data: props.data,
26
- fetchUserMethod: props.fetchUserMethod
27
- }
28
- }, [h(location, {
29
- props: {
30
- content: props.data.content
31
- }
32
- })])
33
- }
34
- }
35
- </script>