@aochuang/client-sdk 1.0.340 → 1.0.342

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 (38) 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/calling/calling.vue +3 -0
  4. package/components/wechat-chat-control/voice/voice.vue +4 -0
  5. package/components/wework-chat-control/company-card/company-card.vue +1 -1
  6. package/components/wework-chat-control/file-url/file-url.vue +5 -2
  7. package/components/wework-chat-control/image/image.vue +2 -137
  8. package/components/wework-chat-control/index.js +6 -6
  9. package/components/wework-chat-control/text/text.vue +3 -22
  10. package/components/wework-chat-control/util.js +6 -12
  11. package/components/wework-chat-control/video/video.vue +2 -10
  12. package/components/wework-chat-control/voice/voice.vue +1 -1
  13. package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +35 -0
  14. package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +36 -0
  15. package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +35 -0
  16. package/components/wework-chat-panel/chat-panel-controls/image/image.vue +36 -0
  17. package/components/wework-chat-panel/chat-panel-controls/index.js +35 -0
  18. package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +28 -0
  19. package/components/wework-chat-panel/chat-panel-controls/link/link.vue +35 -0
  20. package/components/wework-chat-panel/chat-panel-controls/location/location.vue +35 -0
  21. package/components/wework-chat-panel/chat-panel-controls/text/text.vue +43 -0
  22. package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +39 -0
  23. package/components/wework-chat-panel/chat-panel-controls/video/video.vue +37 -0
  24. package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +35 -0
  25. package/components/wework-chat-panel/chat-panel-item.vue +35 -12
  26. package/components/wework-chat-panel/chat-panel.vue +12 -95
  27. package/package.json +1 -1
  28. package/services/client-chat/client-chat-wechat/client-chat.js +20 -8
  29. package/services/client-chat/client-chat-wework/client-chat-concats.js +17 -81
  30. package/services/client-chat/client-chat-wework/client-chat-message.js +5 -5
  31. package/services/client-chat/client-chat-wework/client-chat-session.js +2 -50
  32. package/services/client-chat/client-chat-wework/client-chat-socket.js +1 -5
  33. package/services/client-chat/client-chat-wework/client-chat.js +6 -258
  34. package/services/client-chat/client-chat-wework/utils.js +5 -5
  35. package/components/wework-chat-control/wework-chat-control-config-item.vue +0 -24
  36. package/components/wework-chat-control/wework-chat-control-config-msg.vue +0 -25
  37. package/components/wework-chat-control/wework-chat-control-config.vue +0 -62
  38. package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +0 -73
@@ -126,7 +126,11 @@ export default class ClientChatContacts {
126
126
  */
127
127
  roomBindMemberMap: {},
128
128
 
129
- modifiedAccountMap: {}
129
+ /**
130
+ * 标记通讯录是否修改了
131
+ * 如果修改了,比如接收到了分配好友的会话时,一定通讯录变了,变了的时候界面需要根据这个状态刷新通讯录
132
+ */
133
+ isModify: false
130
134
  })
131
135
 
132
136
  friendMap = {}
@@ -233,6 +237,10 @@ export default class ClientChatContacts {
233
237
  return this.data.roomGroupData
234
238
  }
235
239
 
240
+ get isModify () {
241
+ return this.data.isModify
242
+ }
243
+
236
244
  setRoomGroup (data) {
237
245
  this.data.roomGroupData = []
238
246
  if (data && data.length) {
@@ -483,10 +491,10 @@ export default class ClientChatContacts {
483
491
  }
484
492
  }
485
493
  const qwAccountId = this.roomMap[id].qwAccountId
486
- if (qwAccountId && this.data.accountBindRoomMap[qwAccountId] && this.data.accountBindRoomMap[qwAccountId][groupId]) {
487
- const bindIndex = this.data.accountBindRoomMap[qwAccountId][groupId].indexOf(this.roomMap[id])
494
+ if (qwAccountId && this.data.accountBindFriendMap[qwAccountId] && this.data.accountBindFriendMap[qwAccountId][groupId]) {
495
+ const bindIndex = this.data.accountBindFriendMap[qwAccountId][groupId].indexOf(this.roomMap[id])
488
496
  if (bindIndex >= 0) {
489
- this.data.accountBindRoomMap[qwAccountId][groupId].splice(bindIndex, 1)
497
+ this.data.accountBindFriendMap[qwAccountId][groupId].splice(bindIndex, 1)
490
498
  }
491
499
  }
492
500
  })
@@ -620,37 +628,6 @@ export default class ClientChatContacts {
620
628
  return rs
621
629
  })
622
630
  }
623
-
624
- /**
625
- * 强制从服务端刷新好友资料,绕过本地缓存。
626
- */
627
- refreshFriend (friendId) {
628
- if (!friendId) {
629
- return Promise.reject('缺少好友id')
630
- }
631
- if (!this.getContactsFriendMethod) {
632
- return Promise.reject(new Error('getContactsFriendMethod未定义'))
633
- }
634
- return this.getContactsFriendMethod({
635
- id: friendId
636
- }).then(rs => {
637
- if (!rs || !rs.data) {
638
- return Promise.reject('未找到好友' + friendId)
639
- }
640
- if (this.friendMap[friendId]) {
641
- const nextKeys = Object.keys(rs.data)
642
- Object.keys(this.friendMap[friendId]).forEach(key => {
643
- if (!nextKeys.includes(key)) {
644
- Vue.delete(this.friendMap[friendId], key)
645
- }
646
- })
647
- this.updateFriend(friendId, rs.data)
648
- } else {
649
- this.addFriend(rs.data)
650
- }
651
- return rs
652
- })
653
- }
654
631
 
655
632
  setRoomMemberData (roomId, data) {
656
633
  if (!roomId) {
@@ -761,52 +738,12 @@ export default class ClientChatContacts {
761
738
  })
762
739
  }
763
740
 
764
- refreshRoom (id) {
765
- if (!id) {
766
- return Promise.reject('缺少群id')
767
- }
768
- if (!this.getContactsRoomMethod) {
769
- return Promise.reject(new Error('getContactsRoomMethod未定义'))
770
- }
771
- return this.getContactsRoomMethod({
772
- id
773
- }).then(rs => {
774
- if (!rs || !rs.data) {
775
- return Promise.reject('未找到群' + id)
776
- }
777
- const localRoom = this.roomMap[id]
778
- if (localRoom) {
779
- this.removeRoom(id)
780
- const nextKeys = Object.keys(rs.data)
781
- Object.keys(localRoom).forEach(key => {
782
- if (!nextKeys.includes(key)) {
783
- Vue.delete(localRoom, key)
784
- }
785
- })
786
- Object.keys(rs.data).forEach(key => {
787
- Vue.set(localRoom, key, rs.data[key])
788
- })
789
- }
790
- this.addRoom(localRoom || rs.data)
791
- return rs
792
- })
793
- }
794
-
795
- isModify (qwAccountId) {
796
- return !!(qwAccountId && this.data.modifiedAccountMap[qwAccountId])
797
- }
798
-
799
- markModify (qwAccountIds) {
800
- const ids = Array.isArray(qwAccountIds) ? qwAccountIds : [qwAccountIds]
801
- ids.filter(Boolean).forEach(id => {
802
- Vue.set(this.data.modifiedAccountMap, id, true)
803
- })
741
+ markModify () {
742
+ this.data.isModify = true
804
743
  }
805
744
 
806
- unmarkModify (qwAccountId) {
807
- if (qwAccountId) {
808
- Vue.delete(this.data.modifiedAccountMap, qwAccountId)
809
- }
745
+ unmarkModify () {
746
+ this.data.isModify = false
810
747
  }
811
748
 
812
749
  reset () {
@@ -821,7 +758,6 @@ export default class ClientChatContacts {
821
758
  this.data.groupBindRoomMap = {}
822
759
  this.data.accountBindFriendMap = {}
823
760
  this.data.accountBindRoomMap = {}
824
- this.data.modifiedAccountMap = {}
825
761
  this._cacheFriendGroupCountMap = null
826
762
  this._cacheRoomGroupCountMap = null
827
763
  if (this.cancelConnectRequest) {
@@ -833,4 +769,4 @@ export default class ClientChatContacts {
833
769
  this.cancelRefreshRequest = null
834
770
  }
835
771
  }
836
- }
772
+ }
@@ -74,7 +74,7 @@ export default class ClientChatMessage {
74
74
  * "msgSvrId": "4319123759514541049",
75
75
  * "msgType": 1,
76
76
  * "origin": "0",
77
- * "status": 0,
77
+ * "sendStatus": 0,
78
78
  * "tenantId": "1761952223049924608",
79
79
  * "wechatAccountId": "ad9d9ae2a8be4f27311312cdd4af3549dc8427ef",
80
80
  * "wechatFriendId": "2089efcc7f8f40b00b7f05fa4c6dfd3bb642774d",
@@ -215,11 +215,11 @@ export default class ClientChatMessage {
215
215
  }, data, {
216
216
  cmdType: 'CmdQwSendMessage'
217
217
  })).then(({ data }) => {
218
- if (data.status === 0) {
218
+ if (data.sendStatus === 0) {
219
219
  // 发送成功
220
- } else if (data.status === 2) {
220
+ } else if (data.sendStatus === 2) {
221
221
  // 发送失败
222
- } else if (data.status === 1) {
222
+ } else if (data.sendStatus === 1) {
223
223
  // 发送中
224
224
  }
225
225
  // 如果返回的是对象,证明发送成功了
@@ -277,4 +277,4 @@ export default class ClientChatMessage {
277
277
  reset () {
278
278
  this.data.messageData = {}
279
279
  }
280
- }
280
+ }
@@ -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
@@ -962,7 +915,6 @@ export default class ClientChatSession {
962
915
  this.data.sessionData = {}
963
916
  this.data.sessionGroupData = {}
964
917
  this.data.sessionMuteMap = {}
965
- this.data.modifiedAccountMap = {}
966
918
  // this.data.sessionUnreadCountMap = {}
967
919
  this.sessionMap = {}
968
920
  if (this.cancelLoadDataRequest) {
@@ -974,4 +926,4 @@ export default class ClientChatSession {
974
926
  this.cancelRefreshRequest = null
975
927
  }
976
928
  }
977
- }
929
+ }
@@ -15,8 +15,6 @@ 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,
@@ -29,8 +27,6 @@ export default class ClietChatSocket {
29
27
  }
30
28
  this.socket = options.socket
31
29
  this.socket.event.on('onCmdQwNewMessage', options.onCmdQwNewMessage)
32
- this.socket.event.on('onCmdQwContactInfoChanged', options.onCmdQwContactInfoChanged)
33
- this.socket.event.on('onCmdQwRoomInfoChanged', options.onCmdQwRoomInfoChanged)
34
30
  this.socket.event.on('onHeartbeatCheck', ({ mergeParams }) => {
35
31
  options.onHeartbeatCheck && options.onHeartbeatCheck({
36
32
  mergeParams
@@ -66,4 +62,4 @@ export default class ClietChatSocket {
66
62
  setUrl (url) {
67
63
  this.socket.setUrl(url)
68
64
  }
69
- }
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,
@@ -58,9 +57,8 @@ class ClientChat {
58
57
  }
59
58
  if (!options.loadRoomMessageDataMethod) {
60
59
  throw new Error('loadRoomMessageDataMethod不能为空')
61
- }
60
+ }
62
61
  this.onOverwriteFriendInfoChange = options.onOverwriteFriendInfoChange
63
- this.getLoginAccountIdMethod = options.getLoginAccountIdMethod
64
62
  this.event = new Event({
65
63
  checkOnMethod: (name) => {
66
64
  if (name === 'ready') {
@@ -88,8 +86,7 @@ class ClientChat {
88
86
  sortField: 'sendTime',
89
87
  clientChat: this,
90
88
  onAddMessageSuccess: ({ data }) => {
91
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
92
- let sessionId = createSessionId(accountId, data.contactId)
89
+ let sessionId = createSessionId(data.corpId, data.qwAccountId, data.contactId)
93
90
  // 更新会话
94
91
  if (!sessionId) {
95
92
  return
@@ -113,7 +110,7 @@ class ClientChat {
113
110
  } else {
114
111
  this.session.updateSession(sessionId, ({ session }) => {
115
112
  let unreadMsgCount = session.unreadMsgCount
116
- if (!data.send) {
113
+ if (!data.isSend) {
117
114
  unreadMsgCount = unreadMsgCount + 1
118
115
  }
119
116
  // 如果是当前会话,那么未读消息需要设置为0
@@ -158,8 +155,7 @@ class ClientChat {
158
155
  sortField: 'sendTime',
159
156
  clientChat: this,
160
157
  onAddMessageSuccess: ({ data }) => {
161
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : data.qwAccountId
162
- let sessionId = createSessionId(accountId, data.roomId)
158
+ let sessionId = createSessionId(data.corpId, data.qwAccountId, data.roomId)
163
159
  // 更新会话
164
160
  if (!sessionId) {
165
161
  return
@@ -184,7 +180,7 @@ class ClientChat {
184
180
  } else {
185
181
  this.session.updateSession(sessionId, ({ session }) => {
186
182
  let unreadMsgCount = session.unreadMsgCount
187
- if (!data.send) {
183
+ if (!data.isSend) {
188
184
  unreadMsgCount = unreadMsgCount + 1
189
185
  }
190
186
  // 如果是当前会话,那么未读消息需要设置为0
@@ -262,77 +258,6 @@ class ClientChat {
262
258
  })
263
259
  this.socket = new ClientChatSocket({
264
260
  socket: options.socket,
265
- onCmdQwContactInfoChanged: ({ data }) => {
266
- const contacts = data && (Array.isArray(data.contacts)
267
- ? data.contacts
268
- : (data.contactId ? [data] : []))
269
- if (!contacts || !contacts.length) {
270
- this.markAccountsModified(data && data.qwAccountIds)
271
- return
272
- }
273
- const tasks = []
274
- const removedTasks = []
275
- contacts.forEach(contact => {
276
- if (!contact) {
277
- return
278
- }
279
- const changeType = Number(contact.changeType)
280
- if (changeType === 1) {
281
- tasks.push(this.handleQwContactAdded(contact, data))
282
- } else if (changeType === 2) {
283
- tasks.push(this.handleQwContactUpdated(contact))
284
- } else if (changeType === 3) {
285
- removedTasks.push(this.handleQwContactRemoved(contact, data))
286
- }
287
- })
288
- return Promise.all(tasks.concat(removedTasks)).then(results => {
289
- const accountUnreadCountMap = {}
290
- removedTasks.forEach((task, index) => {
291
- const result = results[tasks.length + index]
292
- if (!result || !result.accountId || !result.unreadCount) {
293
- return
294
- }
295
- accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
296
- })
297
- return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
298
- const removedUnreadCount = accountUnreadCountMap[accountId]
299
- return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
300
- return Math.max(0, unreadMesasgeNum - removedUnreadCount)
301
- }).catch(error => {
302
- console.warn('[client-chat] update account unread count failed', error)
303
- })
304
- }))
305
- })
306
- },
307
- onCmdQwRoomInfoChanged: ({ data }) => {
308
- const rooms = data && (Array.isArray(data.rooms)
309
- ? data.rooms
310
- : (data.roomId ? [data] : []))
311
- if (!rooms || !rooms.length) {
312
- this.markAccountsModified(data && data.qwAccountIds)
313
- return
314
- }
315
- const tasks = []
316
- const removedTasks = []
317
- rooms.forEach(room => {
318
- if (!room) {
319
- return
320
- }
321
- const changeType = Number(room.changeType)
322
- if (changeType === 1) {
323
- tasks.push(this.handleQwRoomAdded(room, data))
324
- } else if (changeType === 2) {
325
- tasks.push(this.handleQwRoomUpdated(room))
326
- } else if (changeType === 3) {
327
- removedTasks.push(this.handleQwRoomRemoved(room, data))
328
- }
329
- })
330
- return Promise.all(tasks.concat(removedTasks)).then(results => {
331
- return this.updateRemovedSessionUnreadCounts(
332
- results.slice(tasks.length)
333
- )
334
- })
335
- },
336
261
  // 接受新消息
337
262
  onCmdQwNewMessage: ({ data }) => {
338
263
  // 插入消息
@@ -366,184 +291,7 @@ class ClientChat {
366
291
  }
367
292
  })
368
293
  }
369
-
370
- getQwAccountCorpId (qwAccountId, corpId) {
371
- if (corpId || !qwAccountId || !this.account) {
372
- return corpId
373
- }
374
- const account = this.account.getAccountData().find(item => item.id === qwAccountId)
375
- return account && account.corpId
376
- }
377
-
378
- markAccountsModified (qwAccountIds) {
379
- if (!Array.isArray(qwAccountIds) || !qwAccountIds.length) {
380
- return
381
- }
382
- this.session.markModify(qwAccountIds)
383
- this.contacts.markModify(qwAccountIds)
384
- }
385
-
386
- updateRemovedSessionUnreadCounts (results) {
387
- const accountUnreadCountMap = {}
388
- ;(results || []).forEach(result => {
389
- if (!result || !result.accountId || !result.unreadCount) {
390
- return
391
- }
392
- accountUnreadCountMap[result.accountId] = (accountUnreadCountMap[result.accountId] || 0) + result.unreadCount
393
- })
394
- return Promise.all(Object.keys(accountUnreadCountMap).map(accountId => {
395
- const removedUnreadCount = accountUnreadCountMap[accountId]
396
- return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
397
- return Math.max(0, unreadMesasgeNum - removedUnreadCount)
398
- }).catch(error => {
399
- console.warn('[client-chat] update account unread count failed', error)
400
- })
401
- }))
402
- }
403
-
404
- handleQwContactAdded (contact, eventData) {
405
- const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
406
- const corpId = this.getQwAccountCorpId(
407
- qwAccountId,
408
- contact.corpId || (eventData && eventData.corpId)
409
- )
410
- const contactId = contact.contactId
411
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
412
- const sessionId = createSessionId(accountId, contactId)
413
- if (!sessionId) {
414
- return Promise.resolve()
415
- }
416
- const localSession = this.session.getSessionByLocal(sessionId)
417
- const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
418
- return this.session.refreshSession(sessionId).then(rs => {
419
- const serverSession = rs && rs.data
420
- const newUnread = serverSession ? (serverSession.unreadMsgCount || 0) : 0
421
- const accountId = (serverSession && serverSession.qwAccountId) || qwAccountId
422
- const unreadDiff = newUnread - oldUnread
423
- if (accountId && unreadDiff) {
424
- return this.account.updateAccountUnreadMessageNum(accountId, ({ unreadMesasgeNum }) => {
425
- return Math.max(0, unreadMesasgeNum + unreadDiff)
426
- })
427
- }
428
- }).catch(error => {
429
- console.warn('[client-chat] refresh added contact session failed', error)
430
- })
431
- }
432
-
433
- handleQwContactUpdated (contact) {
434
- if (!contact.contactId) {
435
- return Promise.resolve()
436
- }
437
- return this.contacts.refreshFriend(contact.contactId).catch(error => {
438
- console.warn('[client-chat] refresh contact failed', error)
439
- })
440
- }
441
-
442
- handleQwContactRemoved (contact, eventData) {
443
- if (!contact.contactId) {
444
- return Promise.resolve()
445
- }
446
- this.contacts.removeFriend(contact.contactId)
447
- let session = this.session.findSession(({ session }) => {
448
- return String(session.type) === '0' &&
449
- session.targetId === contact.contactId &&
450
- (!contact.qwAccountId || session.qwAccountId === contact.qwAccountId)
451
- })
452
- if (!session) {
453
- const qwAccountId = contact.qwAccountId || (eventData && eventData.qwAccountId)
454
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
455
- const sessionId = createSessionId(
456
- accountId,
457
- contact.contactId
458
- )
459
- session = sessionId && this.session.getSessionByLocal(sessionId)
460
- }
461
- if (!session) {
462
- return Promise.resolve()
463
- }
464
- if (this.session.currentSession && this.session.currentSession.id === session.id) {
465
- this.session.setCurrentSession(null)
466
- }
467
- const accountId = session.qwAccountId || contact.qwAccountId
468
- const unreadCount = session.unreadMsgCount || 0
469
- this.session.removeSession(session.id)
470
- return Promise.resolve({
471
- accountId,
472
- unreadCount
473
- })
474
- }
475
294
 
476
- handleQwRoomAdded (room, eventData) {
477
- if (!room.roomId) {
478
- return Promise.resolve()
479
- }
480
- const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
481
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
482
- const sessionId = createSessionId(accountId, room.roomId)
483
- const localSession = sessionId && this.session.getSessionByLocal(sessionId)
484
- const oldUnread = localSession ? (localSession.unreadMsgCount || 0) : 0
485
- const tasks = [this.contacts.refreshRoom(room.roomId).catch(error => {
486
- console.warn('[client-chat] refresh added room failed', error)
487
- })]
488
- if (sessionId) {
489
- tasks.push(this.session.refreshSession(sessionId).then(rs => {
490
- const serverSession = rs && rs.data
491
- const unreadDiff = (serverSession ? (serverSession.unreadMsgCount || 0) : 0) - oldUnread
492
- const changedAccountId = (serverSession && serverSession.qwAccountId) || qwAccountId
493
- if (changedAccountId && unreadDiff) {
494
- return this.account.updateAccountUnreadMessageNum(changedAccountId, ({ unreadMesasgeNum }) => {
495
- return Math.max(0, unreadMesasgeNum + unreadDiff)
496
- })
497
- }
498
- }).catch(error => {
499
- console.warn('[client-chat] refresh added room session failed', error)
500
- }))
501
- }
502
- return Promise.all(tasks)
503
- }
504
-
505
- handleQwRoomUpdated (room) {
506
- if (!room.roomId) {
507
- return Promise.resolve()
508
- }
509
- return this.contacts.refreshRoom(room.roomId).catch(error => {
510
- console.warn('[client-chat] refresh room failed', error)
511
- })
512
- }
513
-
514
- handleQwRoomRemoved (room, eventData) {
515
- if (!room.roomId) {
516
- return Promise.resolve()
517
- }
518
- this.contacts.removeRoom(room.roomId)
519
- this.event.emit('roomRemoved', {
520
- roomId: room.roomId
521
- })
522
- const qwAccountId = room.qwAccountId || (eventData && eventData.qwAccountId)
523
- let session = this.session.findSession(({ session }) => {
524
- return String(session.type) === '1' &&
525
- session.targetId === room.roomId &&
526
- (!qwAccountId || session.qwAccountId === qwAccountId)
527
- })
528
- if (!session) {
529
- const accountId = this.getLoginAccountIdMethod ? this.getLoginAccountIdMethod() : qwAccountId
530
- const sessionId = createSessionId(accountId, room.roomId)
531
- session = sessionId && this.session.getSessionByLocal(sessionId)
532
- }
533
- if (!session) {
534
- return Promise.resolve()
535
- }
536
- if (this.session.currentSession && this.session.currentSession.id === session.id) {
537
- this.session.setCurrentSession(null)
538
- }
539
- const unreadCount = session.unreadMsgCount || 0
540
- this.session.removeSession(session.id)
541
- return Promise.resolve({
542
- accountId: session.qwAccountId || qwAccountId,
543
- unreadCount
544
- })
545
- }
546
-
547
295
  connect () {
548
296
  if (this.data.connectStatus === CONNECT_STATUS.Complete) {
549
297
  return Promise.resolve()
@@ -580,4 +328,4 @@ class ClientChat {
580
328
  }
581
329
  }
582
330
 
583
- 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
+ }
@@ -1,24 +0,0 @@
1
- <script>
2
- export default {
3
- name: 'SdkWeworkChatControlConfigItem',
4
- functional: true,
5
- inject: {
6
- SdkWeworkChatControlConfig: {
7
- default: null
8
- }
9
- },
10
- props: {
11
- /**
12
- * 消息类型
13
- */
14
- msgType: {
15
- type: [Number, String]
16
- }
17
- },
18
- render (h, c) {
19
- return c.scopedSlots.default({
20
- configData: c.injections.SdkWeworkChatControlConfig ? c.injections.SdkWeworkChatControlConfig.getControlConfig(c.props.msgType) : null
21
- })
22
- }
23
- }
24
- </script>
@@ -1,25 +0,0 @@
1
- <script>
2
- export default {
3
- name: 'SdkWeworkChatControlConfigMsg',
4
- functional: true,
5
- inject: {
6
- SdkWeworkChatControlConfig: {
7
- default: null
8
- }
9
- },
10
- props: {
11
- /**
12
- * 标准的企微客户端消息数据
13
- */
14
- msgData: {
15
- type: Object,
16
- required: true
17
- }
18
- },
19
- render (h, c) {
20
- return c.scopedSlots.default({
21
- configData: c.injections.SdkWeworkChatControlConfig ? c.injections.SdkWeworkChatControlConfig.getMessageConfig(c.props.msgData) : null
22
- })
23
- }
24
- }
25
- </script>