Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f3428a56
authored
Nov 12, 2021
by
Sixong.Zhu
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
user info
parent
3083860b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
75 deletions
components/controller/chat-list.ts
components/message.vue
components/who-read-list.vue
model/index.ts
store/index.ts
utils/user-info.ts
xim/index.ts
components/controller/chat-list.ts
View file @
f3428a56
...
@@ -3,7 +3,7 @@ import { parserMessage } from ".";
...
@@ -3,7 +3,7 @@ import { parserMessage } from ".";
import
{
chatStore
,
ChatStore
}
from
"@/customer-service/store/model"
;
import
{
chatStore
,
ChatStore
}
from
"@/customer-service/store/model"
;
import
{
formatTime
,
TimeFormatRule
}
from
"@/customer-service/utils/time"
;
import
{
formatTime
,
TimeFormatRule
}
from
"@/customer-service/utils/time"
;
import
{
Chat
as
ChatItem
}
from
"@/customer-service/xim/models/chat"
;
import
{
Chat
as
ChatItem
}
from
"@/customer-service/xim/models/chat"
;
import
Xim
from
"@/customer-service/xim
"
;
import
{
getUserInfo
}
from
"@/customer-service/utils/user-info
"
;
@
Component
({
components
:
{}
})
@
Component
({
components
:
{}
})
export
default
class
ChatList
extends
Vue
{
export
default
class
ChatList
extends
Vue
{
...
@@ -61,18 +61,9 @@ export default class ChatList extends Vue {
...
@@ -61,18 +61,9 @@ export default class ChatList extends Vue {
protected
parseMesage
(
data
:
ChatItem
)
{
protected
parseMesage
(
data
:
ChatItem
)
{
if
(
data
.
last_msg_sender
&&
data
.
last_msg_sender
!==
"0"
)
{
if
(
data
.
last_msg_sender
&&
data
.
last_msg_sender
!==
"0"
)
{
if
(
this
.
userNames
[
data
.
last_msg_sender
]
===
undefined
)
{
if
(
this
.
userNames
[
data
.
last_msg_sender
]
===
undefined
)
{
this
.
updateUserName
({
id
:
data
.
last_msg_sender
,
name
:
""
});
const
id
=
data
.
last_msg_sender
Xim
.
getSdk
()
this
.
updateUserName
({
id
,
name
:
""
});
.
model
(
"user"
)
getUserInfo
(
id
).
then
(
d
=>
this
.
updateUserName
({
id
,
name
:
d
.
name
}))
.
detail
(
data
.
last_msg_sender
)
.
query
()
.
then
((
userInfo
:
any
)
=>
{
this
.
updateUserName
({
id
:
data
.
last_msg_sender
,
name
:
userInfo
.
row
.
first_name
.
display
as
string
,
});
})
.
catch
(()
=>
{
});
}
}
}
}
if
(
data
.
last_msg_content
===
""
)
{
if
(
data
.
last_msg_content
===
""
)
{
...
...
components/message.vue
View file @
f3428a56
...
@@ -35,9 +35,7 @@
...
@@ -35,9 +35,7 @@
/>
/>
<avatar
<avatar
v-if=
"
v-if=
"
(avatar || showHostAvatar) &&
avatar && !isQuestionAnswerMessage && !isWithdrawMessage
!isQuestionAnswerMessage &&
!isWithdrawMessage
"
"
:src=
"
:src=
"
chatRole === 'admin' || chatRole === 'customer-service'
chatRole === 'admin' || chatRole === 'customer-service'
...
@@ -145,6 +143,7 @@
...
@@ -145,6 +143,7 @@
import
QuestionAnswerMessage
from
"./message-item/question-answer-message.vue"
;
import
QuestionAnswerMessage
from
"./message-item/question-answer-message.vue"
;
import
xim
from
"./../xim"
;
import
xim
from
"./../xim"
;
import
{
ChatRole
}
from
"@/customer-service/model"
;
import
{
ChatRole
}
from
"@/customer-service/model"
;
import
{
getUserMapping
}
from
"../utils/user-info"
;
const
twoMinutes
=
2
*
60
*
1000
;
const
twoMinutes
=
2
*
60
*
1000
;
...
@@ -221,7 +220,6 @@
...
@@ -221,7 +220,6 @@
private
readerListOffset
=
false
;
private
readerListOffset
=
false
;
private
defaultMessageHandledStatus
=
dto
.
MessageHandled
.
Default
;
private
defaultMessageHandledStatus
=
dto
.
MessageHandled
.
Default
;
private
showHostAvatar
:
boolean
=
false
;
private
get
canWithdraw
()
{
private
get
canWithdraw
()
{
if
(
this
.
backend
&&
this
.
data
)
{
if
(
this
.
backend
&&
this
.
data
)
{
...
@@ -292,25 +290,12 @@
...
@@ -292,25 +290,12 @@
}
}
private
get
avatar
()
{
private
get
avatar
()
{
const
avatar
=
chat
.
getUserMapping
();
const
mapping
=
getUserMapping
();
if
(
Object
.
getOwnPropertyNames
(
avatar
).
length
>
0
)
{
this
.
showHostAvatar
=
true
;
}
else
{
this
.
showHostAvatar
=
false
;
}
if
(
this
.
isSendingMessage
)
{
if
(
avatar
&&
this
.
chatMyId
)
{
const
user
=
avatar
[
this
.
chatMyId
];
if
(
user
&&
user
.
avatar
)
{
return
user
.
avatar
;
}
}
}
if
(
avatar
&&
this
.
data
)
{
if
(
this
.
data
)
{
const
value
=
avatar
[
this
.
data
.
eid
];
const
value
=
mapping
[
this
.
data
.
eid
];
if
(
value
&&
value
.
avatar
)
{
if
(
value
&&
value
.
icon
)
{
return
value
.
avatar
;
return
value
.
icon
;
}
}
}
}
...
@@ -320,14 +305,18 @@
...
@@ -320,14 +305,18 @@
private
get
chatRole
()
{
private
get
chatRole
()
{
if
(
this
.
chatMembers
)
{
if
(
this
.
chatMembers
)
{
const
t
=
this
.
chatMembers
.
find
((
i
)
=>
i
.
eid
===
this
.
data
.
eid
);
const
t
=
this
.
chatMembers
.
find
((
i
)
=>
i
.
eid
===
this
.
data
.
eid
);
if
(
t
?.
type
===
ChatRole
.
Default
)
{
if
(
t
)
{
if
(
t
.
type
===
ChatRole
.
Default
)
{
return
"default"
;
return
"default"
;
}
else
if
(
t
?.
type
===
ChatRole
.
Admin
)
{
}
if
(
t
.
type
===
ChatRole
.
Admin
)
{
return
"admin"
;
return
"admin"
;
}
else
if
(
t
?.
type
===
ChatRole
.
CustomerService
)
{
}
if
(
t
.
type
===
ChatRole
.
CustomerService
)
{
return
"customer-service"
;
return
"customer-service"
;
}
}
}
}
}
return
""
;
return
""
;
}
}
...
...
components/who-read-list.vue
View file @
f3428a56
...
@@ -63,8 +63,8 @@
...
@@ -63,8 +63,8 @@
import
{
unique
}
from
"../utils"
;
import
{
unique
}
from
"../utils"
;
import
avatar
from
"@/customer-service/components/avatar.vue"
;
import
avatar
from
"@/customer-service/components/avatar.vue"
;
import
{
ChatStore
}
from
"@/customer-service/store/model"
;
import
{
ChatStore
}
from
"@/customer-service/store/model"
;
import
chat
from
"@/customer-service/xim/index"
;
import
xim
from
"@/customer-service/xim/xim"
;
import
xim
from
"@/customer-service/xim/xim"
;
import
{
getUserInfo
}
from
"../utils/user-info"
;
const
chatStoreNamespace
=
namespace
(
"chatStore"
);
const
chatStoreNamespace
=
namespace
(
"chatStore"
);
...
@@ -116,8 +116,8 @@
...
@@ -116,8 +116,8 @@
}
}
private
async
getUserNameByid
(
eid
:
string
)
{
private
async
getUserNameByid
(
eid
:
string
)
{
const
data
=
await
chat
.
getSdk
().
model
(
"user"
).
detail
(
eid
).
query
(
);
const
data
=
await
getUserInfo
(
eid
);
return
data
.
row
.
first_name
.
value
as
string
;
return
data
.
name
;
}
}
private
async
getReader
()
{
private
async
getReader
()
{
...
...
model/index.ts
View file @
f3428a56
...
@@ -65,11 +65,6 @@ export interface ChatOption {
...
@@ -65,11 +65,6 @@ export interface ChatOption {
eventHub
?:
Vue
;
eventHub
?:
Vue
;
/**
* 用户信息(头像,别名)可选
*/
user
?:
{
icon
?:
string
;
username
?:
string
};
message
?:
ChatMessageController
;
message
?:
ChatMessageController
;
}
}
...
...
store/index.ts
View file @
f3428a56
...
@@ -1060,23 +1060,15 @@ export default {
...
@@ -1060,23 +1060,15 @@ export default {
return
Promise
.
resolve
({
id
,
name
:
cache
[
id
]
});
return
Promise
.
resolve
({
id
,
name
:
cache
[
id
]
});
}
}
return
new
Promise
<
{
id
:
string
;
name
:
string
}
>
(
return
new
Promise
<
{
id
:
string
;
name
:
string
}
>
(
(
resolve
,
reject
)
=>
{
(
resolve
,
reject
)
=>
Chat
.
getSdk
()
getUserInfo
(
id
).
then
(
d
=>
{
.
model
(
"user"
)
.
detail
(
id
)
.
query
()
.
then
((
userInfo
:
any
)
=>
{
const
name
=
userInfo
.
row
.
first_name
.
display
as
string
;
Vue
.
set
(
Vue
.
set
(
state
[
ChatStore
.
STATE_CHAT_USERNAME
],
state
[
ChatStore
.
STATE_CHAT_USERNAME
],
id
,
id
,
name
d
.
name
);
);
resolve
({
id
,
name
});
resolve
({
id
,
name
:
d
.
name
});
})
}).
catch
(
reject
)
.
catch
(
reject
);
}
);
);
},
},
},
},
...
...
utils/user-info.ts
View file @
f3428a56
...
@@ -4,8 +4,10 @@ export type UserMapping = {
...
@@ -4,8 +4,10 @@ export type UserMapping = {
[
eid
:
string
]:
{
[
eid
:
string
]:
{
name
:
string
;
name
:
string
;
phone
:
string
;
phone
:
string
;
icon
:
string
;
};
};
};
};
const
userMapping
:
UserMapping
=
{};
const
userMapping
:
UserMapping
=
{};
export
const
getUserMapping
=
()
=>
userMapping
;
export
const
getUserMapping
=
()
=>
userMapping
;
...
@@ -14,10 +16,19 @@ export async function getUserInfo(eid: string) {
...
@@ -14,10 +16,19 @@ export async function getUserInfo(eid: string) {
if
(
userMapping
[
eid
])
{
if
(
userMapping
[
eid
])
{
return
userMapping
[
eid
];
return
userMapping
[
eid
];
}
}
const
info
=
await
Chat
.
getSdk
().
model
(
"user"
).
detail
(
eid
).
query
();
const
info
=
await
Chat
.
getSdk
().
domainService
(
'passport'
,
'anonymous'
,
`oidc.account/user_info?id=
${
eid
}
`
).
request
<
any
,
any
,
{
avatar_url
:
string
;
email
:
string
;
id
:
string
;
mobile
:
string
;
realname
:
string
;
uniplatId
:
string
;
username
:
string
;
}
>
(
'get'
);
const
data
=
{
const
data
=
{
name
:
info
.
row
.
first_name
.
value
as
string
,
name
:
info
.
username
||
info
.
realname
||
info
.
mobile
||
info
.
mobile
,
phone
:
info
.
row
.
last_name
.
value
as
string
,
phone
:
info
.
mobile
,
icon
:
info
.
avatar_url
};
};
userMapping
[
eid
]
=
data
;
userMapping
[
eid
]
=
data
;
return
data
;
return
data
;
...
...
xim/index.ts
View file @
f3428a56
...
@@ -27,9 +27,6 @@ class Chat implements ChatMessageController {
...
@@ -27,9 +27,6 @@ class Chat implements ChatMessageController {
private
connected
=
false
;
private
connected
=
false
;
private
messageController
:
ChatMessageController
|
null
=
null
;
private
messageController
:
ChatMessageController
|
null
=
null
;
private
userMapping
:
{
[
key
:
string
]:
{
name
:
string
;
avatar
:
string
}
}
=
{};
public
onReady
(
action
:
()
=>
void
)
{
public
onReady
(
action
:
()
=>
void
)
{
if
(
this
.
connected
)
{
if
(
this
.
connected
)
{
action
();
action
();
...
@@ -54,12 +51,6 @@ class Chat implements ChatMessageController {
...
@@ -54,12 +51,6 @@ class Chat implements ChatMessageController {
(
this
.
serviceType
=
option
.
serviceType
);
(
this
.
serviceType
=
option
.
serviceType
);
option
.
product
&&
(
this
.
product
=
option
.
product
);
option
.
product
&&
(
this
.
product
=
option
.
product
);
this
.
eventHub
=
option
.
eventHub
||
null
;
this
.
eventHub
=
option
.
eventHub
||
null
;
if
(
option
.
user
)
{
this
.
userMapping
[
this
.
_sdk
().
global
.
uid
]
=
{
name
:
option
.
user
.
username
||
""
,
avatar
:
option
.
user
.
icon
||
""
,
};
}
option
.
message
&&
(
this
.
messageController
=
option
.
message
);
option
.
message
&&
(
this
.
messageController
=
option
.
message
);
...
@@ -171,10 +162,6 @@ class Chat implements ChatMessageController {
...
@@ -171,10 +162,6 @@ class Chat implements ChatMessageController {
this
.
debug
(
`client status
${
e
}
`
);
this
.
debug
(
`client status
${
e
}
`
);
}
}
public
getUserMapping
()
{
return
this
.
userMapping
;
}
private
debug
(
message
:
string
)
{
private
debug
(
message
:
string
)
{
ChatLoggerService
.
logger
&&
ChatLoggerService
.
logger
.
debug
(
message
);
ChatLoggerService
.
logger
&&
ChatLoggerService
.
logger
.
debug
(
message
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment