@aochuang/client-sdk 1.0.363 → 1.0.365

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 (168) hide show
  1. package/components/index.js +1 -6
  2. package/components/layout/layout.vue +4 -1
  3. package/components/session-select/session-select-item.vue +9 -8
  4. package/components/wechat-chat-control/image/image.vue +8 -13
  5. package/components/wechat-chat-control/url/url-miniprogram.vue +5 -1
  6. package/components/wework-chat-control/channel-live/channel-live.vue +2 -7
  7. package/components/wework-chat-control/company-card/company-card.vue +1 -1
  8. package/components/wework-chat-control/custom-expression/custom-expression.vue +1 -2
  9. package/components/wework-chat-control/file-url/file-url.vue +16 -34
  10. package/components/wework-chat-control/image/image.vue +2 -137
  11. package/components/wework-chat-control/index.js +7 -15
  12. package/components/wework-chat-control/location/location.vue +3 -3
  13. package/components/wework-chat-control/red-envelopes/red-envelopes.vue +2 -3
  14. package/components/wework-chat-control/text/text.vue +144 -24
  15. package/components/wework-chat-control/url/url-miniprogram.vue +7 -6
  16. package/components/wework-chat-control/url/url.vue +2 -26
  17. package/components/wework-chat-control/util.js +17 -26
  18. package/components/wework-chat-control/video/video.vue +2 -10
  19. package/components/wework-chat-control/voice/voice.vue +2 -9
  20. package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +35 -0
  21. package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +36 -0
  22. package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +35 -0
  23. package/components/wework-chat-panel/chat-panel-controls/image/image.vue +36 -0
  24. package/components/wework-chat-panel/chat-panel-controls/index.js +35 -0
  25. package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +28 -0
  26. package/components/wework-chat-panel/chat-panel-controls/link/link.vue +35 -0
  27. package/components/wework-chat-panel/chat-panel-controls/location/location.vue +35 -0
  28. package/components/wework-chat-panel/chat-panel-controls/text/text.vue +43 -0
  29. package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +39 -0
  30. package/components/wework-chat-panel/chat-panel-controls/video/video.vue +37 -0
  31. package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +35 -0
  32. package/components/wework-chat-panel/chat-panel-item.vue +25 -56
  33. package/components/wework-chat-panel/chat-panel.vue +13 -96
  34. package/package.json +3 -10
  35. package/services/client-chat/client-chat-wechat/client-chat-session.js +290 -79
  36. package/services/client-chat/client-chat-wechat/client-chat.js +69 -99
  37. package/services/client-chat/client-chat-wework/client-chat-account.js +1 -84
  38. package/services/client-chat/client-chat-wework/client-chat-concats.js +17 -81
  39. package/services/client-chat/client-chat-wework/client-chat-message.js +5 -45
  40. package/services/client-chat/client-chat-wework/client-chat-session.js +4 -59
  41. package/services/client-chat/client-chat-wework/client-chat-socket.js +1 -13
  42. package/services/client-chat/client-chat-wework/client-chat.js +11 -320
  43. package/services/client-chat/client-chat-wework/utils.js +5 -5
  44. package/uni-common/account-portray/account-portray.vue +51 -0
  45. package/uni-common/account-select/account-select-item.vue +172 -0
  46. package/uni-common/account-select/account-select.vue +252 -0
  47. package/uni-common/all-friend-avatar/all-friend-avatar.vue +49 -0
  48. package/uni-common/friend-avatar/default.svg +1 -0
  49. package/uni-common/friend-avatar/friend-avatar.vue +27 -0
  50. package/uni-common/friend-avatar/index.js +3 -0
  51. package/uni-common/friend-loader/friend-loader.vue +53 -0
  52. package/uni-common/friend-portray/friend-portray.vue +56 -0
  53. package/uni-common/group-avatar/default.svg +1 -0
  54. package/uni-common/group-avatar/group-avatar.vue +18 -0
  55. package/uni-common/group-avatar/index.js +3 -0
  56. package/uni-common/room-avatar/default.svg +6 -0
  57. package/uni-common/room-avatar/index.js +3 -0
  58. package/uni-common/room-avatar/room-avatar.vue +27 -0
  59. package/uni-common/room-loader/room-loader.vue +53 -0
  60. package/uni-common/room-portray/room-portray.vue +56 -0
  61. package/uni-components/chat-control/calling/calling.vue +91 -0
  62. package/uni-components/chat-control/calling/phone-fill.svg +1 -0
  63. package/uni-components/chat-control/calling/vidicon-fill.svg +1 -0
  64. package/uni-components/chat-control/channel-video/channel-video.vue +89 -0
  65. package/uni-components/chat-control/channel-video-card/channel-video-card.vue +105 -0
  66. package/uni-components/chat-control/channel-video-live/channel-video-live.vue +92 -0
  67. package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +20 -0
  68. package/uni-components/chat-control/chat-control-config-item/index.js +3 -0
  69. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +25 -0
  70. package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +21 -0
  71. package/{components/wework-chat-control/wework-chat-control-config.vue → uni-components/chat-control/chat-control-config.vue} +13 -16
  72. package/uni-components/chat-control/chat-control.vue +218 -0
  73. package/uni-components/chat-control/company-card/company-card.vue +123 -0
  74. package/uni-components/chat-control/const.js +28 -0
  75. package/uni-components/chat-control/expression/expression.vue +41 -0
  76. package/uni-components/chat-control/image/image.vue +68 -0
  77. package/uni-components/chat-control/index.js +89 -0
  78. package/uni-components/chat-control/location/location.vue +110 -0
  79. package/uni-components/chat-control/member-change/member-change.vue +32 -0
  80. package/uni-components/chat-control/quote-message/quote-message.vue +216 -0
  81. package/uni-components/chat-control/real-time-position/real-time-position.vue +62 -0
  82. package/uni-components/chat-control/redpacket/red-envelope.svg +1 -0
  83. package/uni-components/chat-control/redpacket/redpacket.vue +75 -0
  84. package/uni-components/chat-control/share-card/share-card.vue +101 -0
  85. package/uni-components/chat-control/system/system.vue +69 -0
  86. package/uni-components/chat-control/system-batch-message/system-batch-message.vue +30 -0
  87. package/uni-components/chat-control/system-text/system-text.vue +32 -0
  88. package/uni-components/chat-control/text/text.vue +67 -0
  89. package/uni-components/chat-control/text-with-at/text-with-at.vue +51 -0
  90. package/uni-components/chat-control/transfer/red-transfer.svg +1 -0
  91. package/uni-components/chat-control/transfer/transfer.vue +80 -0
  92. package/uni-components/chat-control/unkonw/unkonw.vue +37 -0
  93. package/uni-components/chat-control/url/icons/file-excel-line.svg +1 -0
  94. package/uni-components/chat-control/url/icons/file-info-line.svg +1 -0
  95. package/uni-components/chat-control/url/icons/file-music-line.svg +1 -0
  96. package/uni-components/chat-control/url/icons/file-pdf-line.svg +1 -0
  97. package/uni-components/chat-control/url/icons/file-ppt-line.svg +1 -0
  98. package/uni-components/chat-control/url/icons/file-settings-line.svg +1 -0
  99. package/uni-components/chat-control/url/icons/file-text-line.svg +1 -0
  100. package/uni-components/chat-control/url/icons/file-unknow-line.svg +1 -0
  101. package/uni-components/chat-control/url/icons/file-word-line.svg +1 -0
  102. package/uni-components/chat-control/url/icons/file-zip-line.svg +1 -0
  103. package/uni-components/chat-control/url/icons/index.js +24 -0
  104. package/uni-components/chat-control/url/miniprogram.svg +1 -0
  105. package/uni-components/chat-control/url/url-miniprogram.vue +116 -0
  106. package/uni-components/chat-control/url/url.vue +306 -0
  107. package/uni-components/chat-control/url-new/icons/file-excel-line.svg +1 -0
  108. package/uni-components/chat-control/url-new/icons/file-info-line.svg +1 -0
  109. package/uni-components/chat-control/url-new/icons/file-music-line.svg +1 -0
  110. package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +1 -0
  111. package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +1 -0
  112. package/uni-components/chat-control/url-new/icons/file-settings-line.svg +1 -0
  113. package/uni-components/chat-control/url-new/icons/file-text-line.svg +1 -0
  114. package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +1 -0
  115. package/uni-components/chat-control/url-new/icons/file-word-line.svg +1 -0
  116. package/uni-components/chat-control/url-new/icons/file-zip-line.svg +1 -0
  117. package/uni-components/chat-control/url-new/icons/index.js +24 -0
  118. package/uni-components/chat-control/url-new/url-new.vue +110 -0
  119. package/uni-components/chat-control/utils.js +12 -0
  120. package/uni-components/chat-control/video/video.vue +156 -0
  121. package/uni-components/chat-control/voice/voice.vue +166 -0
  122. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +84 -0
  123. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +28 -0
  124. package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +85 -0
  125. package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +157 -0
  126. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +158 -0
  127. package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +61 -0
  128. package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +58 -0
  129. package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +54 -0
  130. package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +42 -0
  131. package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +42 -0
  132. package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +25 -0
  133. package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +158 -0
  134. package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +75 -0
  135. package/uni-components/chat-editor/chat-editor.vue +257 -0
  136. package/uni-components/chat-editor/index.js +10 -0
  137. package/uni-components/chat-editor/util.js +65 -0
  138. package/uni-components/chat-panel/chat-panel-chats-box.vue +238 -0
  139. package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +273 -0
  140. package/uni-components/chat-panel/chat-panel-chats-item.vue +578 -0
  141. package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +71 -0
  142. package/uni-components/chat-panel/chat-panel-chats.vue +368 -0
  143. package/uni-components/chat-panel/chat-panel.vue +227 -0
  144. package/uni-components/contacts-group-select/contacts-group-select-item.vue +85 -0
  145. package/uni-components/contacts-group-select/contacts-group-select-panel.vue +119 -0
  146. package/uni-components/contacts-group-select/contacts-group-select.vue +150 -0
  147. package/common/.DS_Store +0 -0
  148. package/components/.DS_Store +0 -0
  149. package/components/wechat-chat-control/.DS_Store +0 -0
  150. package/components/wechat-chat-control/transfer/.DS_Store +0 -0
  151. package/components/wechat-chat-control/url/.DS_Store +0 -0
  152. package/components/wechat-chat-control/voice/.DS_Store +0 -0
  153. package/components/wework-chat-control/channel-card/channel-card.vue +0 -144
  154. package/components/wework-chat-control/link/.DS_Store +0 -0
  155. package/components/wework-chat-control/merge-message/merge-message-panel.vue +0 -63
  156. package/components/wework-chat-control/merge-message/merge-message.vue +0 -84
  157. package/components/wework-chat-control/merge-message/util.js +0 -59
  158. package/components/wework-chat-control/metting/enterprise-wechat.png +0 -0
  159. package/components/wework-chat-control/metting/meeting-video.svg +0 -4
  160. package/components/wework-chat-control/metting/metting.vue +0 -181
  161. package/components/wework-chat-control/text/text-default.vue +0 -99
  162. package/components/wework-chat-control/text/text-quote.vue +0 -105
  163. package/components/wework-chat-control/url/url-channel-live.vue +0 -53
  164. package/components/wework-chat-control/video/.DS_Store +0 -0
  165. package/components/wework-chat-control/wework-chat-control-config-item.vue +0 -24
  166. package/components/wework-chat-control/wework-chat-control-config-msg.vue +0 -25
  167. package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +0 -73
  168. package/services/.DS_Store +0 -0
@@ -82,8 +82,7 @@ export default class ClientChatSession {
82
82
  /**
83
83
  * 删除会话
84
84
  */
85
- deleteSessionMethod: null,
86
- modifiedAccountMap: {}
85
+ deleteSessionMethod: null
87
86
  })
88
87
 
89
88
  accountIds = []
@@ -120,23 +119,6 @@ export default class ClientChatSession {
120
119
  return this.data.loading
121
120
  }
122
121
 
123
- isModify (qwAccountId) {
124
- return !!(qwAccountId && this.data.modifiedAccountMap[qwAccountId])
125
- }
126
-
127
- markModify (qwAccountIds) {
128
- const ids = Array.isArray(qwAccountIds) ? qwAccountIds : [qwAccountIds]
129
- ids.filter(Boolean).forEach(id => {
130
- Vue.set(this.data.modifiedAccountMap, id, true)
131
- })
132
- }
133
-
134
- unmarkModify (qwAccountId) {
135
- if (qwAccountId) {
136
- Vue.delete(this.data.modifiedAccountMap, qwAccountId)
137
- }
138
- }
139
-
140
122
  get loadAssignTaskSessioning () {
141
123
  return this.data.loadAssignTaskSessioning
142
124
  }
@@ -223,35 +205,6 @@ export default class ClientChatSession {
223
205
  getSessionByLocal (sessionId) {
224
206
  return this.sessionMap[sessionId]
225
207
  }
226
-
227
- /**
228
- * 强制从服务端刷新会话,绕过本地缓存。
229
- */
230
- refreshSession (sessionId) {
231
- if (!sessionId) {
232
- return Promise.reject('缺少会话id')
233
- }
234
- return this.getSessionMethod({
235
- id: sessionId
236
- }).then(rs => {
237
- if (!rs || !rs.data) {
238
- return Promise.reject('未找到会话' + sessionId)
239
- }
240
- // 事件计算出的 sessionId 是本地索引,始终保持与服务端返回对象一致。
241
- const serverSession = Object.assign({}, rs.data, {
242
- id: sessionId
243
- })
244
- const localSession = this.getSessionByLocal(sessionId)
245
- if (localSession) {
246
- this.updateSession(sessionId, serverSession)
247
- } else {
248
- this.addSession(serverSession)
249
- }
250
- return Object.assign({}, rs, {
251
- data: serverSession
252
- })
253
- })
254
- }
255
208
 
256
209
  findSession (findFn) {
257
210
  let result
@@ -465,9 +418,6 @@ export default class ClientChatSession {
465
418
  }
466
419
  }
467
420
  delete this.sessionMap[id]
468
- if (this.data.currentSessionId === id) {
469
- this.data.currentSessionId = null
470
- }
471
421
  if (checkLastUpdateSession !== false) {
472
422
  // todo 后面可能会删掉这块的逻辑,因为后端排序逻辑变了
473
423
  this.checkAndUpdateLastUpdateSession()
@@ -612,9 +562,7 @@ export default class ClientChatSession {
612
562
  return true
613
563
  }
614
564
  })
615
- if (index >= 0) {
616
- this.data.sessionGroupData[groupField][topField][oldSortFields.day][oldSortFields.milliseconds].splice(index, 1)
617
- }
565
+ this.data.sessionGroupData[groupField][topField][oldSortFields.day][oldSortFields.milliseconds].splice(index, 1)
618
566
  }
619
567
  })
620
568
  // 按照新的时间来分组排序
@@ -687,9 +635,7 @@ export default class ClientChatSession {
687
635
  return true
688
636
  }
689
637
  })
690
- if (index >= 0) {
691
- this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds].splice(index, 1)
692
- }
638
+ this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds].splice(index, 1)
693
639
  }
694
640
  })
695
641
  // 所有的
@@ -969,7 +915,6 @@ export default class ClientChatSession {
969
915
  this.data.sessionData = {}
970
916
  this.data.sessionGroupData = {}
971
917
  this.data.sessionMuteMap = {}
972
- this.data.modifiedAccountMap = {}
973
918
  // this.data.sessionUnreadCountMap = {}
974
919
  this.sessionMap = {}
975
920
  if (this.cancelLoadDataRequest) {
@@ -981,4 +926,4 @@ export default class ClientChatSession {
981
926
  this.cancelRefreshRequest = null
982
927
  }
983
928
  }
984
- }
929
+ }
@@ -15,16 +15,11 @@ export default class ClietChatSocket {
15
15
  // 执行回调事件前的方法
16
16
  beforeFireCallback: null,
17
17
  onCmdQwNewMessage: null,
18
- onCmdQwContactInfoChanged: null,
19
- onCmdQwContactRequestChanged: null,
20
- onCmdQwAcceptContactRequest: null,
21
- onCmdQwRoomInfoChanged: null,
22
18
  onCmdSendMessageResult: null,
23
19
  onCmdFriendInfoChanged: null,
24
20
  onCmdDownloadVideoResult: null,
25
21
  onCmdChatroomInfoChanged: null,
26
22
  onCmdChatroomInfoChangedBatch: null,
27
- onHeartbeatSuccess: null,
28
23
  onHeartbeatCheck: null
29
24
  }, options)
30
25
  if (!options.socket) {
@@ -32,13 +27,6 @@ export default class ClietChatSocket {
32
27
  }
33
28
  this.socket = options.socket
34
29
  this.socket.event.on('onCmdQwNewMessage', options.onCmdQwNewMessage)
35
- this.socket.event.on('onCmdQwContactInfoChanged', options.onCmdQwContactInfoChanged)
36
- this.socket.event.on('onCmdQwContactRequestChanged', options.onCmdQwContactRequestChanged)
37
- this.socket.event.on('onCmdQwAcceptContactRequest', options.onCmdQwAcceptContactRequest)
38
- this.socket.event.on('onCmdQwRoomInfoChanged', options.onCmdQwRoomInfoChanged)
39
- this.socket.event.on('onHeartbeatSuccess', (evt) => {
40
- options.onHeartbeatSuccess && options.onHeartbeatSuccess(evt)
41
- })
42
30
  this.socket.event.on('onHeartbeatCheck', ({ mergeParams }) => {
43
31
  options.onHeartbeatCheck && options.onHeartbeatCheck({
44
32
  mergeParams
@@ -74,4 +62,4 @@ export default class ClietChatSocket {
74
62
  setUrl (url) {
75
63
  this.socket.setUrl(url)
76
64
  }
77
- }
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,
@@ -40,7 +39,6 @@ class ClientChat {
40
39
  getAccountUnreadMessageNumMethod: null,
41
40
  updateAccountMessageReadMethod: null,
42
41
  deleteAccountSessionMethod: null,
43
- getAccountGreetingUnreadMsgCountMethod: null,
44
42
  loadContactsRoomGroupDataMethod: null,
45
43
  loadContactsFriendGroupDataMethod: null,
46
44
  loadContactsFriendDataMethod: null,
@@ -52,7 +50,6 @@ class ClientChat {
52
50
  getContactsRoomMethod: null,
53
51
  loadFriendMessageDataMethod: null,
54
52
  loadRoomMessageDataMethod: null,
55
- checkMessageSendResultMethod: null,
56
53
  onOverwriteFriendInfoChange: null // 为了兼容1.0拉取会话逻辑加的,1.0暂时不支持根据taskId拉取
57
54
  }, options)
58
55
  if (!options.loadFriendMessageDataMethod) {
@@ -60,9 +57,8 @@ class ClientChat {
60
57
  }
61
58
  if (!options.loadRoomMessageDataMethod) {
62
59
  throw new Error('loadRoomMessageDataMethod不能为空')
63
- }
60
+ }
64
61
  this.onOverwriteFriendInfoChange = options.onOverwriteFriendInfoChange
65
- this.getLoginAccountIdMethod = options.getLoginAccountIdMethod
66
62
  this.event = new Event({
67
63
  checkOnMethod: (name) => {
68
64
  if (name === 'ready') {
@@ -89,10 +85,8 @@ class ClientChat {
89
85
  groupField: 'contactId',
90
86
  sortField: 'sendTime',
91
87
  clientChat: this,
92
- checkMessageSendResultMethod: options.checkMessageSendResultMethod,
93
88
  onAddMessageSuccess: ({ data }) => {
94
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
95
- let sessionId = createSessionId(accountId, data.contactId)
89
+ let sessionId = createSessionId(data.corpId, data.qwAccountId, data.contactId)
96
90
  // 更新会话
97
91
  if (!sessionId) {
98
92
  return
@@ -106,15 +100,6 @@ class ClientChat {
106
100
  return this.session.getSession(sessionId).then(done)
107
101
  })
108
102
  this._sessionPollRequestMap[sessionId].start().then((rs) => {
109
- // 后端更新会话是异步过程,返回的会话信息可能还未包含当前消息
110
- if (rs && rs.data && !rs.data.unreadMsgCount) {
111
- rs.data.unreadMsgCount = data.isSend ? 0 : 1
112
- rs.data.lastMsgContent = data.content
113
- rs.data.lastMsgType = data.msgType
114
- rs.data.lastMsgTime = data.sendTime
115
- rs.data.lastMsgId = data.id
116
- rs.data.lastUpdateTime = data.updateDate
117
- }
118
103
  // 更新账号未读消息数量
119
104
  this.account.updateAccountUnreadMessageNum(rs.data.qwAccountId, ({ unreadMesasgeNum }) => {
120
105
  return unreadMesasgeNum += (rs.data.unreadMsgCount || 0)
@@ -159,7 +144,7 @@ class ClientChat {
159
144
  groupField: 'contactId',
160
145
  sortField: 'sendTime',
161
146
  clientChat: this,
162
- checkMessageSendResultMethod: options.checkMessageSendResultMethod,
147
+ // checkMessageSendResultMethod: options.checkMessageSendResultMethod,
163
148
  // loadLossMessageDataMethod: options.loadLossFriendMessageDataMethod,
164
149
  queryMethod: (params) => {
165
150
  return options.loadFriendMessageDataMethod(params)
@@ -169,10 +154,8 @@ class ClientChat {
169
154
  groupField: 'roomId',
170
155
  sortField: 'sendTime',
171
156
  clientChat: this,
172
- checkMessageSendResultMethod: options.checkMessageSendResultMethod,
173
157
  onAddMessageSuccess: ({ data }) => {
174
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
175
- let sessionId = createSessionId(accountId, data.roomId)
158
+ let sessionId = createSessionId(data.corpId, data.qwAccountId, data.roomId)
176
159
  // 更新会话
177
160
  if (!sessionId) {
178
161
  return
@@ -187,15 +170,6 @@ class ClientChat {
187
170
  return this.session.getSession(sessionId).then(done)
188
171
  })
189
172
  this._sessionPollRequestMap[sessionId].start().then((rs) => {
190
- // 后端更新会话是异步过程,返回的会话信息可能还未包含当前消息
191
- if (rs && rs.data && !rs.data.unreadMsgCount) {
192
- rs.data.unreadMsgCount = data.isSend ? 0 : 1
193
- rs.data.lastMsgContent = data.content
194
- rs.data.lastMsgType = data.msgType
195
- rs.data.lastMsgTime = data.sendTime
196
- rs.data.lastMsgId = data.id
197
- rs.data.lastUpdateTime = data.updateDate
198
- }
199
173
  // 更新账号未读消息数量
200
174
  this.account.updateAccountUnreadMessageNum(rs.data.qwAccountId, ({ unreadMesasgeNum }) => {
201
175
  return unreadMesasgeNum += (rs.data.unreadMsgCount || 0)
@@ -240,7 +214,7 @@ class ClientChat {
240
214
  groupField: 'roomId',
241
215
  sortField: 'sendTime',
242
216
  clientChat: this,
243
- checkMessageSendResultMethod: options.checkMessageSendResultMethod,
217
+ // checkMessageSendResultMethod: options.checkMessageSendResultMethod,
244
218
  // loadLossMessageDataMethod: options.loadLossRoomMessageDataMethod,
245
219
  queryMethod: (params) => {
246
220
  return options.loadRoomMessageDataMethod(params)
@@ -263,18 +237,12 @@ class ClientChat {
263
237
  loadAccountDataMethod: options.loadAccountDataMethod,
264
238
  getAccountUnreadMessageNumMethod: options.getAccountUnreadMessageNumMethod,
265
239
  updateAccountMessageReadMethod: options.updateAccountMessageReadMethod,
266
- getAccountGreetingUnreadMsgCountMethod: options.getAccountGreetingUnreadMsgCountMethod,
267
240
  onAccountAdded: ({ account }) => {
268
241
  return this.account.refreshAccountUnreadMessageNum({
269
242
  qwAccountId: account.id,
270
243
  corpId: account.corpId
271
244
  })
272
245
  },
273
- onAccountLoaded: () => {
274
- if (options.getAccountGreetingUnreadMsgCountMethod) {
275
- this.account.refreshAllAccountGreetingUnreadMsgCount().catch(() => {})
276
- }
277
- },
278
246
  onCurrentAccountChange: ({ currentAccount }) => {
279
247
  this.contacts.refreshAllFriendGroupCount({
280
248
  qwAccountId: currentAccount ? currentAccount.id : null
@@ -290,95 +258,6 @@ class ClientChat {
290
258
  })
291
259
  this.socket = new ClientChatSocket({
292
260
  socket: options.socket,
293
- onCmdQwContactRequestChanged: ({ data } = {}) => {
294
- // {
295
- // "cmdType": CmdQwContactRequestChanged
296
- // "seq": 123,
297
- // "cmdType": "CmdQwContactRequestChanged",
298
- // "changeType": 1,
299
- // "record": { ...QwContactRequestRecordDto...
300
- // }
301
- // changeType:1 = 新增、2 = 状态变化(值来自 ChangeTypeEnum,序列化为数字)
302
- // 触发时机:新同步到一条好友请求 → changeType=1;之后每次状态流转(1/2/3/4)→ changeType=2
303
- // 推送目标:该记录 accountId 对应的客服端。若该请求未分配客服(设备无保管者)则不推送,前端不能依赖推送判断「没有新的好友请求」
304
- // 新增和状态流转都会影响待处理数量,刷新对应账号的好友请求数
305
- this.refreshGreetingUnreadMsgCountByPush(data)
306
- },
307
- onCmdQwAcceptContactRequest: ({ data } = {}) => {
308
- // CmdQwAcceptContactRequest 请求字段不变(qwAccountId、remoteId),错误提示文案不变。但点击通过后状态立即变为 1(请求中),需等设备回执:超时→2、失败→3、成功→4。原来把「通过成功」判断为 2 的逻辑必须改成 4
309
- this.refreshGreetingUnreadMsgCountByPush(data)
310
- },
311
- onCmdQwContactInfoChanged: ({ data }) => {
312
- const contacts = data && (Array.isArray(data.contacts)
313
- ? data.contacts
314
- : (data.contactId ? [data] : []))
315
- if (!contacts || !contacts.length) {
316
- this.markAccountsModified(data && data.qwAccountIds)
317
- return
318
- }
319
- const tasks = []
320
- const removedTasks = []
321
- contacts.forEach(contact => {
322
- if (!contact) {
323
- return
324
- }
325
- const changeType = Number(contact.changeType)
326
- if (changeType === 1) {
327
- tasks.push(this.handleQwContactAdded(contact, data))
328
- } else if (changeType === 2) {
329
- tasks.push(this.handleQwContactUpdated(contact))
330
- } else if (changeType === 3) {
331
- removedTasks.push(this.handleQwContactRemoved(contact, data))
332
- }
333
- })
334
- return Promise.all(tasks.concat(removedTasks)).then(results => {
335
- const accountUnreadCountMap = {}
336
- removedTasks.forEach((task, index) => {
337
- const result = results[tasks.length + index]
338
- if (!result || !result.accountId || !result.unreadCount) {
339
- return
340
- }
341
- accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
342
- })
343
- return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
344
- const removedUnreadCount = accountUnreadCountMap[accountId]
345
- return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
346
- return Math.max(0, unreadMesasgeNum - removedUnreadCount)
347
- }).catch(error => {
348
- console.warn('[client-chat] update account unread count failed', error)
349
- })
350
- }))
351
- })
352
- },
353
- onCmdQwRoomInfoChanged: ({ data }) => {
354
- const rooms = data && (Array.isArray(data.rooms)
355
- ? data.rooms
356
- : (data.roomId ? [data] : []))
357
- if (!rooms || !rooms.length) {
358
- this.markAccountsModified(data && data.qwAccountIds)
359
- return
360
- }
361
- const tasks = []
362
- const removedTasks = []
363
- rooms.forEach(room => {
364
- if (!room) {
365
- return
366
- }
367
- const changeType = Number(room.changeType)
368
- if (changeType === 1) {
369
- tasks.push(this.handleQwRoomAdded(room, data))
370
- } else if (changeType === 2) {
371
- tasks.push(this.handleQwRoomUpdated(room))
372
- } else if (changeType === 3) {
373
- removedTasks.push(this.handleQwRoomRemoved(room, data))
374
- }
375
- })
376
- return Promise.all(tasks.concat(removedTasks)).then(results => {
377
- return this.updateRemovedSessionUnreadCounts(
378
- results.slice(tasks.length)
379
- )
380
- })
381
- },
382
261
  // 接受新消息
383
262
  onCmdQwNewMessage: ({ data }) => {
384
263
  // 插入消息
@@ -400,207 +279,19 @@ class ClientChat {
400
279
  })
401
280
  },
402
281
  onHeartbeatSuccess: ({ data }) => {
403
- const onlineMap = data || {}
282
+ if (!data.wq) {
283
+ return
284
+ }
285
+ const onlineMap = data.wq || {}
404
286
  Object.keys(onlineMap).forEach(k => {
405
287
  this.account.updateAccount(k, {
406
288
  alive: onlineMap[k]
407
- })
408
- })
409
- }
410
- })
411
- }
412
-
413
- getQwAccountCorpId (qwAccountId, corpId) {
414
- if (corpId || !qwAccountId || !this.account) {
415
- return corpId
416
- }
417
- const account = this.account.getAccountData().find(item => item.id === qwAccountId)
418
- return account && account.corpId
419
- }
420
-
421
- markAccountsModified (qwAccountIds) {
422
- if (!Array.isArray(qwAccountIds) || !qwAccountIds.length) {
423
- return
424
- }
425
- this.session.markModify(qwAccountIds)
426
- this.contacts.markModify(qwAccountIds)
427
- }
428
-
429
- /**
430
- * 根据好友请求相关推送刷新待处理好友请求数量
431
- * 推送里能拿到账号id就只刷该账号,否则刷全部
432
- */
433
- refreshGreetingUnreadMsgCountByPush (data) {
434
- if (!this.account || !this.account.getAccountGreetingUnreadMsgCountMethod) {
435
- return
436
- }
437
- const record = (data && data.record) || data || {}
438
- const qwAccountId = record.qwAccountId || record.accountId || (data && data.qwAccountId)
439
- const params = qwAccountId && this.account.accountMap[qwAccountId] ? { qwAccountIds: [qwAccountId] } : undefined
440
- this.account.getAccountGreetingUnreadMsgCount(params).catch(() => {})
441
- }
442
-
443
- updateRemovedSessionUnreadCounts (results) {
444
- const accountUnreadCountMap = {}
445
- ;(results || []).forEach(result => {
446
- if (!result || !result.accountId || !result.unreadCount) {
447
- return
448
- }
449
- accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
450
- })
451
- return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
452
- const removedUnreadCount = accountUnreadCountMap[accountId]
453
- return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
454
- return Math.max(0, unreadMesasgeNum - removedUnreadCount)
455
- }).catch(error => {
456
- console.warn('[client-chat] update account unread count failed', error)
457
- })
458
- }))
459
- }
460
-
461
- handleQwContactAdded (contact, eventData) {
462
- const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
463
- const corpId = this.getQwAccountCorpId(
464
- qwAccountId,
465
- contact.corpId || (eventData && eventData.corpId)
466
- )
467
- const contactId = contact.contactId
468
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
469
- const sessionId = createSessionId(accountId, contactId)
470
- if (!sessionId) {
471
- return Promise.resolve()
472
- }
473
- const localSession = this.session.getSessionByLocal(sessionId)
474
- const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
475
- return this.session.refreshSession(sessionId).then(rs => {
476
- const serverSession = rs && rs.data
477
- const newUnread = serverSession ? (serverSession.unreadMsgCount || 0) : 0
478
- const accountId = (serverSession && serverSession.qwAccountId) || qwAccountId
479
- const unreadDiff = newUnread - oldUnread
480
- if (accountId && unreadDiff) {
481
- return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
482
- return Math.max(0, unreadMesasgeNum + unreadDiff)
289
+ })
483
290
  })
484
291
  }
485
- }).catch(error => {
486
- console.warn('[client-chat] refresh added contact session failed', error)
487
- })
488
- }
489
-
490
- handleQwContactUpdated (contact) {
491
- if (!contact.contactId) {
492
- return Promise.resolve()
493
- }
494
- return this.contacts.refreshFriend(contact.contactId).catch(error => {
495
- console.warn('[client-chat] refresh contact failed', error)
496
- })
497
- }
498
-
499
- handleQwContactRemoved (contact, eventData) {
500
- if (!contact.contactId) {
501
- return Promise.resolve()
502
- }
503
- this.contacts.removeFriend(contact.contactId)
504
- let session = this.session.findSession(({ session }) => {
505
- return String(session.type) === '0' &&
506
- session.targetId === contact.contactId &&
507
- (!contact.qwAccountId || session.qwAccountId === contact.qwAccountId)
508
- })
509
- if (!session) {
510
- const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
511
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
512
- const sessionId = createSessionId(
513
- accountId,
514
- contact.contactId
515
- )
516
- session = sessionId && this.session.getSessionByLocal(sessionId)
517
- }
518
- if (!session) {
519
- return Promise.resolve()
520
- }
521
- if (this.session.currentSession && this.session.currentSession.id === session.id) {
522
- this.session.setCurrentSession(null)
523
- }
524
- const accountId = session.qwAccountId || contact.qwAccountId
525
- const unreadCount = session.unreadMsgCount || 0
526
- this.session.removeSession(session.id)
527
- return Promise.resolve({
528
- accountId,
529
- unreadCount
530
292
  })
531
293
  }
532
294
 
533
- handleQwRoomAdded (room, eventData) {
534
- if (!room.roomId) {
535
- return Promise.resolve()
536
- }
537
- const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
538
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
539
- const sessionId = createSessionId(accountId, room.roomId)
540
- const localSession = sessionId && this.session.getSessionByLocal(sessionId)
541
- const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
542
- const tasks = [this.contacts.refreshRoom(room.roomId).catch(error => {
543
- console.warn('[client-chat] refresh added room failed', error)
544
- })]
545
- if (sessionId) {
546
- tasks.push(this.session.refreshSession(sessionId).then(rs => {
547
- const serverSession = rs && rs.data
548
- const unreadDiff = (serverSession ? (serverSession.unreadMsgCount || 0) : 0) - oldUnread
549
- const changedAccountId = (serverSession && serverSession.qwAccountId) || qwAccountId
550
- if (changedAccountId && unreadDiff) {
551
- return this.account.updateAccountUnreadMessageNum(changedAccountId, ({ unreadMesasgeNum }) => {
552
- return Math.max(0, unreadMesasgeNum + unreadDiff)
553
- })
554
- }
555
- }).catch(error => {
556
- console.warn('[client-chat] refresh added room session failed', error)
557
- }))
558
- }
559
- return Promise.all(tasks)
560
- }
561
-
562
- handleQwRoomUpdated (room) {
563
- if (!room.roomId) {
564
- return Promise.resolve()
565
- }
566
- return this.contacts.refreshRoom(room.roomId).catch(error => {
567
- console.warn('[client-chat] refresh room failed', error)
568
- })
569
- }
570
-
571
- handleQwRoomRemoved (room, eventData) {
572
- if (!room.roomId) {
573
- return Promise.resolve()
574
- }
575
- this.contacts.removeRoom(room.roomId)
576
- this.event.emit('roomRemoved', {
577
- roomId: room.roomId
578
- })
579
- const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
580
- let session = this.session.findSession(({ session }) => {
581
- return String(session.type) === '1' &&
582
- session.targetId === room.roomId &&
583
- (!qwAccountId || session.qwAccountId === qwAccountId)
584
- })
585
- if (!session) {
586
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
587
- const sessionId = createSessionId(accountId, room.roomId)
588
- session = sessionId && this.session.getSessionByLocal(sessionId)
589
- }
590
- if (!session) {
591
- return Promise.resolve()
592
- }
593
- if (this.session.currentSession && this.session.currentSession.id === session.id) {
594
- this.session.setCurrentSession(null)
595
- }
596
- const unreadCount = session.unreadMsgCount || 0
597
- this.session.removeSession(session.id)
598
- return Promise.resolve({
599
- accountId: session.qwAccountId || qwAccountId,
600
- unreadCount
601
- })
602
- }
603
-
604
295
  connect () {
605
296
  if (this.data.connectStatus === CONNECT_STATUS.Complete) {
606
297
  return Promise.resolve()
@@ -637,4 +328,4 @@ class ClientChat {
637
328
  }
638
329
  }
639
330
 
640
- 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>