@aochuang/client-sdk 1.0.360 → 1.0.363
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.
- package/common/.DS_Store +0 -0
- package/components/.DS_Store +0 -0
- package/components/wechat-chat-control/.DS_Store +0 -0
- package/components/wechat-chat-control/transfer/.DS_Store +0 -0
- package/components/wechat-chat-control/url/.DS_Store +0 -0
- package/components/wechat-chat-control/voice/.DS_Store +0 -0
- package/components/wework-chat-control/link/.DS_Store +0 -0
- package/components/wework-chat-control/video/.DS_Store +0 -0
- package/package.json +1 -1
- package/services/.DS_Store +0 -0
- package/services/client-chat/client-chat-wework/client-chat-account.js +84 -1
- package/services/client-chat/client-chat-wework/client-chat-session.js +9 -2
- package/services/client-chat/client-chat-wework/client-chat-socket.js +4 -0
- package/services/client-chat/client-chat-wework/client-chat.js +39 -0
package/common/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -5,14 +5,20 @@ export default class ClientChatAccount {
|
|
|
5
5
|
data = Vue.observable({
|
|
6
6
|
accountData: [],
|
|
7
7
|
accountUnreadMessageNumData: [],
|
|
8
|
+
accountGreetingUnreadMsgCountData: {},
|
|
8
9
|
currentAccount: null
|
|
9
10
|
})
|
|
10
11
|
|
|
11
12
|
loadAccountDataMethod = null
|
|
12
13
|
|
|
13
14
|
getAccountUnreadMessageNumMethod = null
|
|
15
|
+
|
|
16
|
+
getAccountGreetingUnreadMsgCountMethod = null
|
|
14
17
|
|
|
15
18
|
accountMap = {}
|
|
19
|
+
|
|
20
|
+
// 好友请求数量请求合并,key为账号id列表
|
|
21
|
+
greetingUnreadRequestMap = {}
|
|
16
22
|
|
|
17
23
|
constructor (options) {
|
|
18
24
|
options = Object.assign({
|
|
@@ -21,11 +27,13 @@ export default class ClientChatAccount {
|
|
|
21
27
|
getAccountUnreadMessageNumMethod: null,
|
|
22
28
|
updateAccountMessageReadMethod: null,
|
|
23
29
|
deleteAccountSessionMethod: null,
|
|
30
|
+
getAccountGreetingUnreadMsgCountMethod: null,
|
|
24
31
|
onCurrentAccountChange: null,
|
|
25
32
|
onAccountAdded: null,
|
|
26
33
|
onAccountRemoved: null,
|
|
27
34
|
onUnreadMessageNumChange: null,
|
|
28
|
-
onDeleteAccountSession: null
|
|
35
|
+
onDeleteAccountSession: null,
|
|
36
|
+
onAccountLoaded: null
|
|
29
37
|
}, options)
|
|
30
38
|
if (!options.loadAccountDataMethod) {
|
|
31
39
|
throw new Error('缺少loadAccountDataMethod配置')
|
|
@@ -38,10 +46,12 @@ export default class ClientChatAccount {
|
|
|
38
46
|
this.getAccountUnreadMessageNumMethod = options.getAccountUnreadMessageNumMethod
|
|
39
47
|
this.updateAccountMessageReadMethod = options.updateAccountMessageReadMethod
|
|
40
48
|
this.deleteAccountSessionMethod = options.deleteAccountSessionMethod
|
|
49
|
+
this.getAccountGreetingUnreadMsgCountMethod = options.getAccountGreetingUnreadMsgCountMethod
|
|
41
50
|
this.onAccountAdded = options.onAccountAdded
|
|
42
51
|
this.onAccountRemoved = options.onAccountRemoved,
|
|
43
52
|
this.onUnreadMessageNumChange = options.onUnreadMessageNumChange
|
|
44
53
|
this.onDeleteAccountSession = options.onDeleteAccountSession
|
|
54
|
+
this.onAccountLoaded = options.onAccountLoaded
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
get accountData () {
|
|
@@ -55,6 +65,10 @@ export default class ClientChatAccount {
|
|
|
55
65
|
get currentAccount () {
|
|
56
66
|
return this.data.currentAccount
|
|
57
67
|
}
|
|
68
|
+
|
|
69
|
+
get accountGreetingUnreadMsgCountData () {
|
|
70
|
+
return this.data.accountGreetingUnreadMsgCountData
|
|
71
|
+
}
|
|
58
72
|
|
|
59
73
|
setCurrentAccount (accountId) {
|
|
60
74
|
let account = null
|
|
@@ -282,6 +296,9 @@ export default class ClientChatAccount {
|
|
|
282
296
|
this._cacheLoadPromise = this.loadAccountDataMethod()
|
|
283
297
|
this._cacheLoadPromise.then(rs => {
|
|
284
298
|
this.setAccountData(rs.data)
|
|
299
|
+
this.onAccountLoaded && this.onAccountLoaded({
|
|
300
|
+
data: rs.data
|
|
301
|
+
})
|
|
285
302
|
})
|
|
286
303
|
this.cancelConnectRequest = () => {
|
|
287
304
|
this._cacheLoadPromise.abort()
|
|
@@ -298,9 +315,75 @@ export default class ClientChatAccount {
|
|
|
298
315
|
return this.loadData()
|
|
299
316
|
}
|
|
300
317
|
|
|
318
|
+
/**
|
|
319
|
+
* 设置指定企微账号的待处理好友请求数量,并重算all
|
|
320
|
+
*/
|
|
321
|
+
setAccountGreetingUnreadMsgCount (params) {
|
|
322
|
+
if (!params || !params.qwAccountId) {
|
|
323
|
+
throw new Error('缺少必须参数')
|
|
324
|
+
}
|
|
325
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, params.qwAccountId, params.count || 0)
|
|
326
|
+
this.updateAllAccountGreetingUnreadMsgCount()
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
updateAllAccountGreetingUnreadMsgCount () {
|
|
330
|
+
const allCount = Object.keys(this.data.accountGreetingUnreadMsgCountData).reduce((rs, key) => {
|
|
331
|
+
return key === 'all' ? rs : rs + (this.data.accountGreetingUnreadMsgCountData[key] || 0)
|
|
332
|
+
}, 0)
|
|
333
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, 'all', allCount)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* 获取待处理好友请求数量
|
|
338
|
+
* qwAccountIds不传则刷新所有账号;后端数量为0的账号不返回,所以先置0再覆盖
|
|
339
|
+
*/
|
|
340
|
+
getAccountGreetingUnreadMsgCount (params) {
|
|
341
|
+
if (!this.getAccountGreetingUnreadMsgCountMethod) {
|
|
342
|
+
return Promise.reject(new Error('getAccountGreetingUnreadMsgCountMethod未定义'))
|
|
343
|
+
}
|
|
344
|
+
let qwAccountIds = (params || {}).qwAccountIds
|
|
345
|
+
if (qwAccountIds && !Array.isArray(qwAccountIds)) {
|
|
346
|
+
qwAccountIds = [qwAccountIds]
|
|
347
|
+
}
|
|
348
|
+
qwAccountIds = (qwAccountIds || []).filter((id, index, data) => id && data.indexOf(id) === index).map(String)
|
|
349
|
+
const isAll = !qwAccountIds.length
|
|
350
|
+
const requestKey = isAll ? 'all' : qwAccountIds.slice().sort().join(',')
|
|
351
|
+
if (this.greetingUnreadRequestMap[requestKey]) {
|
|
352
|
+
return this.greetingUnreadRequestMap[requestKey]
|
|
353
|
+
}
|
|
354
|
+
const request = this.getAccountGreetingUnreadMsgCountMethod({
|
|
355
|
+
qwAccountIds: isAll ? undefined : qwAccountIds
|
|
356
|
+
}).then(rs => {
|
|
357
|
+
const targetIds = isAll ? Object.keys(this.accountMap) : qwAccountIds
|
|
358
|
+
targetIds.forEach(id => {
|
|
359
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, id, 0)
|
|
360
|
+
})
|
|
361
|
+
;((rs && rs.data) || []).forEach(item => {
|
|
362
|
+
if (item && item.qwAccountId) {
|
|
363
|
+
Vue.set(this.data.accountGreetingUnreadMsgCountData, String(item.qwAccountId), item.count || 0)
|
|
364
|
+
}
|
|
365
|
+
})
|
|
366
|
+
this.updateAllAccountGreetingUnreadMsgCount()
|
|
367
|
+
return this.data.accountGreetingUnreadMsgCountData
|
|
368
|
+
}).finally(() => {
|
|
369
|
+
delete this.greetingUnreadRequestMap[requestKey]
|
|
370
|
+
})
|
|
371
|
+
this.greetingUnreadRequestMap[requestKey] = request
|
|
372
|
+
return request
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* 刷新所有账号的待处理好友请求数量
|
|
377
|
+
*/
|
|
378
|
+
refreshAllAccountGreetingUnreadMsgCount () {
|
|
379
|
+
return this.getAccountGreetingUnreadMsgCount()
|
|
380
|
+
}
|
|
381
|
+
|
|
301
382
|
reset () {
|
|
302
383
|
this.data.accountData = []
|
|
303
384
|
this.data.accountUnreadMessageNumData = []
|
|
385
|
+
this.data.accountGreetingUnreadMsgCountData = {}
|
|
386
|
+
this.greetingUnreadRequestMap = {}
|
|
304
387
|
if (this.cancelConnectRequest) {
|
|
305
388
|
this.cancelConnectRequest()
|
|
306
389
|
}
|
|
@@ -465,6 +465,9 @@ export default class ClientChatSession {
|
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
467
|
delete this.sessionMap[id]
|
|
468
|
+
if (this.data.currentSessionId === id) {
|
|
469
|
+
this.data.currentSessionId = null
|
|
470
|
+
}
|
|
468
471
|
if (checkLastUpdateSession !== false) {
|
|
469
472
|
// todo 后面可能会删掉这块的逻辑,因为后端排序逻辑变了
|
|
470
473
|
this.checkAndUpdateLastUpdateSession()
|
|
@@ -609,7 +612,9 @@ export default class ClientChatSession {
|
|
|
609
612
|
return true
|
|
610
613
|
}
|
|
611
614
|
})
|
|
612
|
-
|
|
615
|
+
if (index >= 0) {
|
|
616
|
+
this.data.sessionGroupData[groupField][topField][oldSortFields.day][oldSortFields.milliseconds].splice(index, 1)
|
|
617
|
+
}
|
|
613
618
|
}
|
|
614
619
|
})
|
|
615
620
|
// 按照新的时间来分组排序
|
|
@@ -682,7 +687,9 @@ export default class ClientChatSession {
|
|
|
682
687
|
return true
|
|
683
688
|
}
|
|
684
689
|
})
|
|
685
|
-
|
|
690
|
+
if (index >= 0) {
|
|
691
|
+
this.data.sessionGroupData[groupField][topField][sortFields.day][sortFields.milliseconds].splice(index, 1)
|
|
692
|
+
}
|
|
686
693
|
}
|
|
687
694
|
})
|
|
688
695
|
// 所有的
|
|
@@ -16,6 +16,8 @@ export default class ClietChatSocket {
|
|
|
16
16
|
beforeFireCallback: null,
|
|
17
17
|
onCmdQwNewMessage: null,
|
|
18
18
|
onCmdQwContactInfoChanged: null,
|
|
19
|
+
onCmdQwContactRequestChanged: null,
|
|
20
|
+
onCmdQwAcceptContactRequest: null,
|
|
19
21
|
onCmdQwRoomInfoChanged: null,
|
|
20
22
|
onCmdSendMessageResult: null,
|
|
21
23
|
onCmdFriendInfoChanged: null,
|
|
@@ -31,6 +33,8 @@ export default class ClietChatSocket {
|
|
|
31
33
|
this.socket = options.socket
|
|
32
34
|
this.socket.event.on('onCmdQwNewMessage', options.onCmdQwNewMessage)
|
|
33
35
|
this.socket.event.on('onCmdQwContactInfoChanged', options.onCmdQwContactInfoChanged)
|
|
36
|
+
this.socket.event.on('onCmdQwContactRequestChanged', options.onCmdQwContactRequestChanged)
|
|
37
|
+
this.socket.event.on('onCmdQwAcceptContactRequest', options.onCmdQwAcceptContactRequest)
|
|
34
38
|
this.socket.event.on('onCmdQwRoomInfoChanged', options.onCmdQwRoomInfoChanged)
|
|
35
39
|
this.socket.event.on('onHeartbeatSuccess', (evt) => {
|
|
36
40
|
options.onHeartbeatSuccess && options.onHeartbeatSuccess(evt)
|
|
@@ -40,6 +40,7 @@ class ClientChat {
|
|
|
40
40
|
getAccountUnreadMessageNumMethod: null,
|
|
41
41
|
updateAccountMessageReadMethod: null,
|
|
42
42
|
deleteAccountSessionMethod: null,
|
|
43
|
+
getAccountGreetingUnreadMsgCountMethod: null,
|
|
43
44
|
loadContactsRoomGroupDataMethod: null,
|
|
44
45
|
loadContactsFriendGroupDataMethod: null,
|
|
45
46
|
loadContactsFriendDataMethod: null,
|
|
@@ -262,12 +263,18 @@ class ClientChat {
|
|
|
262
263
|
loadAccountDataMethod: options.loadAccountDataMethod,
|
|
263
264
|
getAccountUnreadMessageNumMethod: options.getAccountUnreadMessageNumMethod,
|
|
264
265
|
updateAccountMessageReadMethod: options.updateAccountMessageReadMethod,
|
|
266
|
+
getAccountGreetingUnreadMsgCountMethod: options.getAccountGreetingUnreadMsgCountMethod,
|
|
265
267
|
onAccountAdded: ({ account }) => {
|
|
266
268
|
return this.account.refreshAccountUnreadMessageNum({
|
|
267
269
|
qwAccountId: account.id,
|
|
268
270
|
corpId: account.corpId
|
|
269
271
|
})
|
|
270
272
|
},
|
|
273
|
+
onAccountLoaded: () => {
|
|
274
|
+
if (options.getAccountGreetingUnreadMsgCountMethod) {
|
|
275
|
+
this.account.refreshAllAccountGreetingUnreadMsgCount().catch(() => {})
|
|
276
|
+
}
|
|
277
|
+
},
|
|
271
278
|
onCurrentAccountChange: ({ currentAccount }) => {
|
|
272
279
|
this.contacts.refreshAllFriendGroupCount({
|
|
273
280
|
qwAccountId: currentAccount ? currentAccount.id : null
|
|
@@ -283,6 +290,24 @@ class ClientChat {
|
|
|
283
290
|
})
|
|
284
291
|
this.socket = new ClientChatSocket({
|
|
285
292
|
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
|
+
},
|
|
286
311
|
onCmdQwContactInfoChanged: ({ data }) => {
|
|
287
312
|
const contacts = data && (Array.isArray(data.contacts)
|
|
288
313
|
? data.contacts
|
|
@@ -401,6 +426,20 @@ class ClientChat {
|
|
|
401
426
|
this.contacts.markModify(qwAccountIds)
|
|
402
427
|
}
|
|
403
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
|
+
|
|
404
443
|
updateRemovedSessionUnreadCounts (results) {
|
|
405
444
|
const accountUnreadCountMap = {}
|
|
406
445
|
;(results || []).forEach(result => {
|