Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fns_front_2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenqikuai
fns_front_2
Commits
e689d495
Commit
e689d495
authored
Oct 13, 2021
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
3fe04d55
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
331 additions
and
95 deletions
+331
-95
App.vue
src/App.vue
+0
-3
branch.vue
src/components/Mine/Branch/branch.vue
+8
-12
ChatDBService.ts
src/db/ChatDBService.ts
+17
-7
ChatListCardDB.ts
src/db/ChatListCardDB.ts
+4
-2
ChatMessageDB.ts
src/db/ChatMessageDB.ts
+33
-5
index.ts
src/db/index.ts
+3
-2
navigate.ts
src/router/navigate.ts
+21
-0
index.ts
src/service/AddressService/index.ts
+17
-1
types.ts
src/service/AddressService/types.ts
+16
-0
messagesStore.ts
src/store/messagesStore.ts
+5
-3
displayName.ts
src/utils/displayName.ts
+34
-0
Chat.vue
src/views/Chat/Chat.vue
+130
-34
ChatContentMessage.vue
src/views/Chat/ChatContentMessage.vue
+2
-2
ChatInput.vue
src/views/Chat/ChatInput.vue
+8
-2
index.vue
src/views/LoanDetail/index.vue
+8
-14
index.vue
src/views/withMenu/ChatList/index.vue
+25
-8
No files found.
src/App.vue
View file @
e689d495
...
...
@@ -103,9 +103,6 @@ export default defineComponent({
if
(
getUserMsg
())
{
connect
();
}
getVisitorId
().
then
(
id
=>
{
console
.
log
(
id
,
"show id"
);
})
})
watch
(()
=>
connectionState
.
error
,
()
=>
{
...
...
src/components/Mine/Branch/branch.vue
View file @
e689d495
...
...
@@ -77,7 +77,10 @@
</div>
</div>
<!-- 底部操作 -->
<div
class=
"flex text-center py-3 text-gray-800 bg-branch-tab-bg rounded-b-2xl"
v-if=
"is_normal_work"
>
<div
class=
"flex text-center py-3 text-gray-800 bg-branch-tab-bg rounded-b-2xl"
v-if=
"is_normal_work"
>
<p
class=
"w-1/2 border-r border-gray-200 mb-0"
@
click=
"handleClickChatWithClientManager"
>
联系客服
</p>
<p
class=
"w-1/2 mb-0"
:class=
"isOpen ? 'text-app-blue' : 'text-gray-800'"
@
click=
"toCall"
>
电话咨询
</p>
</div>
...
...
@@ -97,6 +100,7 @@ import UserService from '@/service/UserService'
import
{
authCheck
}
from
'@/utils/authCheck'
import
router
from
'@/router'
import
ShowCall
from
'@/components/showCall/index.vue'
import
{
goToChatWithOutletRoboot
}
from
'@/router/navigate'
const
addressService
=
new
AddressService
()
...
...
@@ -182,6 +186,7 @@ const isOpen = computed(() => {
return
false
}
})
const
error
=
"由于施工原因,本营业厅暂时不营业搬迁中"
const
errorReason
=
ref
(
''
)
const
getErrorNote
=
()
=>
{
if
(
props
.
is_normal_work
)
return
...
...
@@ -219,19 +224,10 @@ const handleClickNagigate = () => {
const
handleClickChatWithClientManager
=
async
()
=>
{
authCheck
(
async
()
=>
{
const
ret
=
await
UserService
.
getInstance
().
contact_custom_service
({
out
LetID
:
props
.
outlet_id
as
number
goToChatWithOutletRoboot
({
out
letId
:
props
.
outlet_id
as
number
})
if
(
ret
.
code
===
200
)
{
router
.
push
({
name
:
'Chat'
,
query
:
{
targetId
:
ret
.
data
.
addr
,
}
})
}
})
}
</
script
>
...
...
src/db/ChatDBService.ts
View file @
e689d495
import
{
DisplayMessage
}
from
'@/store/messagesStore'
import
{
getMasterIdFromDisplayMsg
,
getTargetIdFromDisplayMsg
}
from
'@/utils/chatutils'
import
{
getMasterIdFromDisplayMsg
,
getTargetIdFromDisplayMsg
,
}
from
'@/utils/chatutils'
import
ChatListCardDB
from
'./ChatListCardDB'
import
ChatMessageDB
from
'./ChatMessageDB'
...
...
@@ -14,19 +17,25 @@ export default class ChatDBService {
msg
:
DisplayMessage
masterId
:
string
isChattingWithTargetId
:
boolean
isRoboot
?:
boolean
})
{
const
{
msg
,
masterId
,
isChattingWithTargetId
}
=
data
console
.
log
(
data
,
"show in handleEveryRecive"
);
await
ChatMessageDB
.
getInstance
().
saveMsg
(
msg
,
masterId
)
console
.
log
(
data
,
'show in handleEveryRecive'
)
const
thePersonAlreadyInChatList
=
await
ChatListCardDB
.
getInstance
().
thePersonAlreadyInChatList
(
getMasterIdFromDisplayMsg
(
msg
),
getTargetIdFromDisplayMsg
(
msg
),
)
console
.
log
(
thePersonAlreadyInChatList
,
'show thePersonAlreadyInChatList'
);
// const thePersonAlreadyInChatList = await ChatMessageDB.getInstance().thePersonAlreadyInChatList(
// getMasterIdFromDisplayMsg(msg),
// getTargetIdFromDisplayMsg(msg),
// )
await
ChatMessageDB
.
getInstance
().
saveMsg
(
msg
,
masterId
)
// console.log(
// thePersonAlreadyInChatList,
// 'show thePersonAlreadyInChatList',
// new Date().getTime(),
// )
if
(
thePersonAlreadyInChatList
)
{
await
ChatListCardDB
.
getInstance
().
updateNewestCard
({
...
...
@@ -37,6 +46,7 @@ export default class ChatDBService {
await
ChatListCardDB
.
getInstance
().
addNewCard
({
msg
,
isChattingWithTargetId
,
isRobootCard
:
data
.
isRoboot
,
})
}
}
...
...
src/db/ChatListCardDB.ts
View file @
e689d495
...
...
@@ -105,7 +105,8 @@ export default class ChatListCardDB extends MyAppDatabase {
async
addNewCard
(
data
:
{
msg
:
DisplayMessage
isChattingWithTargetId
:
boolean
isChattingWithTargetId
:
boolean
,
isRobootCard
?:
boolean
})
{
const
content
=
data
.
msg
.
content
?.
content
||
'[新消息]'
const
masterId
=
getMasterIdFromDisplayMsg
(
data
.
msg
)
...
...
@@ -118,7 +119,8 @@ export default class ChatListCardDB extends MyAppDatabase {
unreadMsgCount
:
data
.
isChattingWithTargetId
?
0
:
1
,
content
,
inChat
:
false
,
datetime
:
data
.
msg
.
datetime
datetime
:
data
.
msg
.
datetime
,
isRobootCard
:
data
.
isRobootCard
,
})
}
...
...
src/db/ChatMessageDB.ts
View file @
e689d495
...
...
@@ -30,7 +30,11 @@ export default class ChatMessageDB extends MyAppDatabase {
}
async
deleteMsg
({
uuid
,
logid
}:
{
uuid
?:
string
;
logid
?:
string
})
{
const
updateChatList
=
async
(
masterId
:
string
,
target
:
string
,
deletedMsgDatetime
:
number
)
=>
{
const
updateChatList
=
async
(
masterId
:
string
,
target
:
string
,
deletedMsgDatetime
:
number
,
)
=>
{
const
latestedMsg
=
await
this
.
getLatestedMessage
(
masterId
,
target
)
if
(
latestedMsg
)
{
...
...
@@ -39,8 +43,8 @@ export default class ChatMessageDB extends MyAppDatabase {
this
.
chatListCard
.
filter
((
i
)
=>
i
.
masterId
===
masterId
&&
i
.
targetId
===
target
)
.
modify
((
i
)
=>
{
i
.
content
=
latestedMsg
.
content
.
content
as
string
;
i
.
datetime
=
latestedMsg
.
datetime
;
i
.
content
=
latestedMsg
.
content
.
content
as
string
i
.
datetime
=
latestedMsg
.
datetime
})
}
else
{
/* 如果和target没有聊天消息 */
...
...
@@ -56,11 +60,21 @@ export default class ChatMessageDB extends MyAppDatabase {
if
(
uuid
)
{
const
item
=
await
this
.
chatMessage
.
where
(
'uuid'
).
equals
(
uuid
).
first
()
await
this
.
chatMessage
.
where
(
'uuid'
).
equals
(
uuid
).
delete
()
item
&&
updateChatList
(
item
?.
masterId
,
getTargetIdFromDisplayMsg
(
item
),
item
?.
datetime
)
item
&&
updateChatList
(
item
?.
masterId
,
getTargetIdFromDisplayMsg
(
item
),
item
?.
datetime
,
)
}
else
if
(
logid
)
{
const
item
=
await
this
.
chatMessage
.
where
(
'logid'
).
equals
(
logid
).
first
()
await
this
.
chatMessage
.
where
(
'logid'
).
equals
(
logid
).
delete
()
item
&&
updateChatList
(
item
?.
masterId
,
getTargetIdFromDisplayMsg
(
item
),
item
?.
datetime
)
item
&&
updateChatList
(
item
?.
masterId
,
getTargetIdFromDisplayMsg
(
item
),
item
?.
datetime
,
)
}
else
{
throw
new
Error
(
'没有uuid或者logid'
)
}
...
...
@@ -78,6 +92,20 @@ export default class ChatMessageDB extends MyAppDatabase {
}
}
async
thePersonAlreadyInChatList
(
masterId
:
string
,
personId
:
string
)
{
return
(
(
await
this
.
chatMessage
.
filter
(
(
i
)
=>
(
i
.
masterId
===
masterId
&&
i
.
state
===
null
&&
i
.
from
===
personId
)
||
(
i
.
state
!==
null
&&
i
.
target
===
personId
),
)
.
count
())
!==
0
)
}
/* from表示自己的address,target表示对话人的address */
getMessage
(
from
:
string
,
target
:
string
)
{
return
this
.
chatMessage
...
...
src/db/index.ts
View file @
e689d495
...
...
@@ -13,6 +13,7 @@ export interface iChatListCard {
content
:
string
datetime
:
number
inChat
:
boolean
// 会话状态,会话中?
isRobootCard
?:
boolean
}
export
class
MyAppDatabase
extends
Dexie
{
...
...
@@ -24,10 +25,10 @@ export class MyAppDatabase extends Dexie {
constructor
()
{
super
(
'MyAppDatabase'
)
this
.
version
(
1.
3
).
stores
({
this
.
version
(
1.
4
).
stores
({
chatMessage
:
'++id, content, from, uuid, state, uploadProgress, type, datetime, hideDatetime, logid, masterId, readed'
,
chatListCard
:
'++id, masterId, targetId, unreadMsgCount, content, inChat'
,
chatListCard
:
'++id, masterId, targetId, unreadMsgCount, content, inChat
, isRobootCard
'
,
contactPerson
:
'++id, addr, bank, phone, user_name, out_let_name'
,
userInfo
:
'++id, created_at, phone, remark, user_name, uuid, addr'
,
})
...
...
src/router/navigate.ts
0 → 100644
View file @
e689d495
import
router
from
'.'
export
function
goToChatWithOutletRoboot
(
data
:
{
outletId
:
number
})
{
router
.
push
({
name
:
'Chat'
,
query
:
{
targetId
:
data
.
outletId
,
outlet
:
'true'
,
},
})
}
export
function
gotoChatWithStaff
(
data
:
{
address
:
string
;
beginChat
?:
boolean
})
{
router
.
push
({
name
:
'Chat'
,
query
:
{
targetId
:
data
.
address
,
beginChat
:
data
.
beginChat
?
'true'
:
undefined
,
},
})
}
src/service/AddressService/index.ts
View file @
e689d495
import
{
Toast
}
from
'vant'
import
baseAxios
,
{
iRet
}
from
'../index'
import
{
iNearbyOutLet
}
from
'./types'
import
{
iNearbyOutLet
,
iOutLetDetail
}
from
'./types'
import
Bridge
from
'@/utils/jsBridge2'
class
AddressService
{
static
instance
:
AddressService
...
...
@@ -80,6 +80,22 @@ class AddressService {
data
,
})
}
getOutlet
(
data
:
{
outlet_name
?:
string
;
id
?:
number
})
{
let
theData
=
{
bank_code
:
Number
(
process
.
env
.
VUE_APP_BANK_CODE
)
}
as
any
if
(
data
.
outlet_name
)
{
theData
.
outlet_name
=
data
.
outlet_name
}
else
if
(
data
.
id
!==
undefined
)
{
theData
.
id
=
data
.
id
}
return
baseAxios
<
iOutLetDetail
>
({
url
:
'/address/getOutlet'
,
method
:
'post'
,
data
:
theData
,
})
}
}
export
default
AddressService
src/service/AddressService/types.ts
View file @
e689d495
...
...
@@ -13,3 +13,18 @@ export interface iNearbyOutLet {
export
interface
errorInfo
{
note
:
string
}
export
interface
iOutLetDetail
{
id
:
number
city_name
:
string
is_normal_work
:
boolean
latitude
:
string
location
:
string
longitude
:
string
opening_hours
:
string
outlet_name
:
string
region_name
:
string
weekend_status
:
number
province_name
:
string
}
\ No newline at end of file
src/store/messagesStore.ts
View file @
e689d495
...
...
@@ -104,7 +104,7 @@ class MessageStore {
* @param content 消息内容,需根据类型填写对应字段
* @param uuid 如果传入 uuid 则说明是重新发送之前失败的消息
*/
sendMessage
({
async
sendMessage
({
type
,
content
,
target
,
...
...
@@ -151,7 +151,7 @@ class MessageStore {
type
===
ChatMessageTypes
.
Image
&&
(
<
dtalk
.
proto
.
IAudioMsg
>
content
).
mediaUrl
)
this
.
send
(
type
,
content
,
_uuid
,
message
,
target
)
await
this
.
send
(
type
,
content
,
_uuid
,
message
,
target
)
return
}
...
...
@@ -187,7 +187,7 @@ class MessageStore {
}
// 文本类消息,不需要上传 OSS,直接发送
else
{
ChatDBService
.
getInstance
().
handleEveryReceive
({
await
ChatDBService
.
getInstance
().
handleEveryReceive
({
msg
:
message
,
masterId
:
getMasterIdFromDisplayMsg
(
message
),
isChattingWithTargetId
:
isChattingWith
(
...
...
@@ -293,6 +293,8 @@ class MessageStore {
uuid
,
})
.
then
(()
=>
{
console
.
log
(
'send success'
);
message
.
state
=
'success'
ChatMessageDB
.
getInstance
().
updateMsg
(
...
...
src/utils/displayName.ts
View file @
e689d495
import
{
iChatListCard
}
from
'@/db'
import
ContactPersonService
from
'@/db/ContactPersonService'
import
UserInfoDBService
from
'@/db/UserInfoService'
import
AddressService
from
'@/service/AddressService'
import
UserService
from
'@/service/UserService'
import
{
iContact
}
from
'@/service/UserService/types'
import
{
eRole
}
from
'@/types/roleType'
import
{
getUserMsg
}
from
'./userMsg'
/* 拿到地址对应的用户昵称 */
export
const
getDisplayNamesFromAddress
=
async
(
addressList
:
string
[],
):
Promise
<
string
[]
>
=>
{
...
...
@@ -58,6 +61,37 @@ export const getDisplayNamesFromAddress = async (
})
}
/* 获取网点名称 */
export
const
getDisplayNamesFromOutletId
=
async
(
outletids
:
number
[])
=>
{
const
promiseList
=
outletids
.
map
((
id
)
=>
{
return
AddressService
.
getInstance
()
.
getOutlet
({
id
,
})
.
then
((
ret
)
=>
{
if
(
ret
.
code
===
200
)
{
return
ret
.
data
.
outlet_name
}
})
})
const
list
=
await
Promise
.
all
(
promiseList
)
return
list
}
export
const
getDisplayNames
=
async
(
list
:
{
outletId
?:
number
;
address
?:
string
}[],
)
=>
{
const
promiseList
=
list
.
map
((
i
)
=>
{
if
(
i
.
outletId
!==
undefined
)
{
return
getDisplayNamesFromOutletId
([
i
.
outletId
]).
then
((
ret
)
=>
ret
[
0
])
}
else
if
(
i
.
address
!==
undefined
)
{
return
getDisplayNamesFromAddress
([
i
.
address
]).
then
((
ret
)
=>
ret
[
0
])
}
else
return
''
})
return
Promise
.
all
(
promiseList
)
}
export
const
getMsgFromAddress
=
async
(
addressList
:
string
[],
):
Promise
<
any
[]
>
=>
{
...
...
src/views/Chat/Chat.vue
View file @
e689d495
...
...
@@ -12,20 +12,20 @@
<ServiceRating
:setSelectedRate=
"handleSelect"
:selected=
"selected"
v-if=
"showServiceRating"
/>
<ChatOption>
<ChatOptionItemVue
v-if=
"isUser"
v-if=
"isUser
&& isChatWithRoboot
"
:selected=
"questionSelected"
@
click=
"handleClickQuestionOption"
value=
"常用问题"
/>
<ChatOptionItemVue
v-if=
"isUser"
v-if=
"isUser
&& isChatWithRoboot
"
:selected=
"serviceSelected"
:value=
"serviceShowValue"
@
click=
"handleClickService"
/>
<ChatOptionItemVue
:selected=
"false"
value=
"电话联系"
@
click=
"handleClickCall"
/>
</ChatOption>
<ChatInputVue
:serviceShowValue=
"serviceShowValue"
/>
<ChatInputVue
:serviceShowValue=
"serviceShowValue"
/>
<CommonUseSentence
class=
"transition-all h-0"
:class=
"
{ 'h-40': showShortSentences }"
...
...
@@ -52,13 +52,16 @@ import { v4 as uuidv4 } from 'uuid'
import
{
ChatMessageTypes
}
from
"@/types/chatMessageTypes"
;
import
{
useRoute
}
from
"vue-router"
;
import
{
queryFaqAnswer
,
queryFaqList
}
from
"@/service/FaqService"
;
import
{
getDisplayNamesFromAddress
,
getMsgFromAddress
}
from
"@/utils/displayName"
;
import
{
getDisplayNames
,
getDisplayNames
FromAddress
,
getMsgFromAddress
}
from
"@/utils/displayName"
;
import
{
MessageContent
}
from
"@/types/chat-message"
;
import
{
CONST_END_CHAT
,
CONST_START_CHAT
}
from
"@/config/chat"
;
import
ChatOptionItemVue
from
"@/components/ChatOptions/ChatOptionItem.vue"
;
import
ShowCall
from
"@/components/showCall/index.vue"
import
{
getUserMsg
}
from
"@/utils/userMsg"
;
import
{
eRole
}
from
"@/types/roleType"
;
import
ChatDBService
from
"@/db/ChatDBService"
;
import
UserService
from
"@/service/UserService"
;
import
{
gotoChatWithStaff
}
from
"@/router/navigate"
;
export
default
defineComponent
({
...
...
@@ -78,6 +81,7 @@ export default defineComponent({
const
handleClickQuestionOption
=
()
=>
{
questionSelected
.
value
=
!
questionSelected
.
value
}
watch
(
questionSelected
,
()
=>
{
setShowSentences
(
questionSelected
.
value
)
sentensesLoading
.
value
=
true
;
...
...
@@ -91,23 +95,33 @@ export default defineComponent({
const
serviceSelected
=
ref
(
false
);
const
serviceShowValue
=
ref
(
'人工服务'
)
const
handleClickService
=
()
=>
{
const
sendChatMessage
=
(
payload
:
{
type
:
ChatMessageTypes
;
content
:
MessageContent
;
target
?:
string
;
})
=>
{
messageStore
.
sendMessage
({
type
:
payload
.
type
,
content
:
payload
.
content
,
target
:
route
.
query
.
targetId
as
string
});
return
messageStore
.
sendMessage
({
type
:
payload
.
type
,
content
:
payload
.
content
,
target
:
payload
.
target
||
route
.
query
.
targetId
as
string
});
};
const
handleClickService
=
async
()
=>
{
if
(
serviceShowValue
.
value
===
'人工服务'
)
{
sendChatMessage
({
type
:
ChatMessageTypes
.
Card
,
content
:
{
bank
:
CONST_START_CHAT
.
user
.
id
,
name
:
CONST_START_CHAT
.
staff
.
id
,
account
:
''
,
}
as
MessageContent
questionSelected
.
value
=
false
;
const
ret
=
await
UserService
.
getInstance
().
contact_custom_service
({
outLetID
:
Number
(
route
.
query
.
targetId
)
as
number
})
serviceShowValue
.
value
=
'结束服务'
if
(
ret
.
code
===
200
)
{
gotoChatWithStaff
({
address
:
ret
.
data
.
addr
,
beginChat
:
true
});
}
else
{
return
;
}
}
else
if
(
serviceShowValue
.
value
===
'结束服务'
)
{
serviceShowValue
.
value
=
'人工服务'
sendChatMessage
({
...
...
@@ -118,15 +132,8 @@ export default defineComponent({
account
:
''
,
}
as
MessageContent
})
// showServiceRating.value = true;
}
}
onMounted
(
async
()
=>
{
const
inChat
=
await
ChatListCardDB
.
getInstance
().
getChatStatus
(
getFromId
()
as
string
,
target
)
serviceShowValue
.
value
=
inChat
?
'结束服务'
:
'人工服务'
})
const
initError
=
ref
(
false
);
const
showServiceRating
=
ref
(
false
);
...
...
@@ -145,12 +152,25 @@ export default defineComponent({
const
handleClickCall
=
()
=>
{
const
handleClickCall
=
async
()
=>
{
if
(
isChatWithRoboot
.
value
)
{
const
ret
=
await
UserService
.
getInstance
().
contact_custom_service
({
outLetID
:
Number
(
target
)
as
number
})
if
(
ret
.
code
===
200
)
{
callPhone
.
value
=
ret
.
data
.
phone
;
}
else
{
return
;
}
}
else
{
const
ret
=
await
getMsgFromAddress
([
target
])
callPhone
.
value
=
ret
[
0
].
phone
;
}
showCall
.
value
=
true
;
}
const
useSentence
=
(
content
:
string
)
=>
{
const
useSentence
=
async
(
content
:
string
)
=>
{
/* 问 */
messageStore
.
displayNewMessage
({
content
:
{
...
...
@@ -164,6 +184,23 @@ export default defineComponent({
type
:
ChatMessageTypes
.
robot
,
})
await
ChatDBService
.
getInstance
().
handleEveryReceive
({
msg
:
{
content
:
{
content
:
content
},
from
:
getFromId
()
as
string
,
target
:
target
,
uuid
:
uuidv4
(),
state
:
'success'
,
datetime
:
new
Date
().
getTime
(),
type
:
ChatMessageTypes
.
robot
,
},
masterId
:
getFromId
()
as
string
,
isChattingWithTargetId
:
true
,
isRoboot
:
true
,
})
queryFaqAnswer
({
question
:
content
}).
then
((
ret
)
=>
{
...
...
@@ -177,20 +214,32 @@ export default defineComponent({
from
:
target
,
target
:
getFromId
(),
uuid
:
uuidv4
(),
state
:
'success'
,
state
:
null
,
datetime
:
new
Date
().
getTime
(),
type
:
ChatMessageTypes
.
robot
,
})
ChatDBService
.
getInstance
().
handleEveryReceive
({
msg
:
{
content
:
{
content
:
ret
.
data
},
from
:
target
as
string
,
target
:
getFromId
(),
uuid
:
uuidv4
(),
state
:
null
,
datetime
:
new
Date
().
getTime
(),
type
:
ChatMessageTypes
.
robot
,
},
masterId
:
getFromId
()
as
string
,
isChattingWithTargetId
:
true
,
isRoboot
:
true
,
})
}
})
}
onMounted
(
async
()
=>
{
messageStore
.
messages
.
splice
(
0
,
messageStore
.
messages
.
length
);
const
messageList
=
await
ChatMessageDB
.
getInstance
().
getMessage
(
getFromId
()
as
string
,
target
);
messageStore
.
messages
.
push
(...
messageList
);
ChatListCardDB
.
getInstance
().
readMsg
(
getFromId
()
as
string
,
target
)
})
watch
(
chatCardTimeStamp
,
async
()
=>
{
const
messageList
=
await
ChatMessageDB
.
getInstance
().
getMessage
(
getFromId
()
as
string
,
target
);
...
...
@@ -199,14 +248,58 @@ export default defineComponent({
})
const
title
=
ref
(
''
)
const
isChatWithRoboot
=
computed
(()
=>
{
return
route
.
query
.
outlet
!==
undefined
})
const
initTitle
=
async
()
=>
{
console
.
log
(
isChatWithRoboot
.
value
,
"show isChatWithRoboot"
)
if
(
isChatWithRoboot
.
value
)
{
const
list
=
await
getDisplayNames
([{
outletId
:
Number
(
route
.
query
.
targetId
)
}])
title
.
value
=
list
[
0
]
as
string
;
}
else
{
const
list
=
await
getDisplayNames
([{
address
:
route
.
query
.
targetId
as
string
}])
title
.
value
=
list
[
0
]
as
string
;
}
}
const
initMessageList
=
async
()
=>
{
messageStore
.
messages
.
splice
(
0
,
messageStore
.
messages
.
length
);
const
messageList
=
await
ChatMessageDB
.
getInstance
().
getMessage
(
getFromId
()
as
string
,
route
.
query
.
targetId
as
string
);
messageStore
.
messages
.
push
(...
messageList
);
ChatListCardDB
.
getInstance
().
readMsg
(
getFromId
()
as
string
,
target
)
}
const
notifyUserAndStaffTheChatBegin
=
async
()
=>
{
await
sendChatMessage
({
type
:
ChatMessageTypes
.
Card
,
content
:
{
bank
:
CONST_START_CHAT
.
user
.
id
,
name
:
CONST_START_CHAT
.
staff
.
id
,
account
:
''
,
}
as
MessageContent
,
target
:
route
.
query
.
targetId
as
string
})
}
watch
(()
=>
route
.
query
.
targetId
,
async
()
=>
{
await
initMessageList
();
await
initTitle
();
if
(
!
isChatWithRoboot
.
value
&&
route
.
query
.
beginChat
!==
undefined
)
{
setTimeout
(()
=>
{
notifyUserAndStaffTheChatBegin
()
},
1000
)
}
})
onMounted
(
async
()
=>
{
const
list
=
await
getDisplayNamesFromAddress
([
target
])
title
.
value
=
list
[
0
];
const
ret
=
await
getMsgFromAddress
([
target
])
callPhone
.
value
=
ret
[
0
].
phone
;
initMessageList
();
initTitle
();
serviceShowValue
.
value
=
'人工服务'
})
const
showCall
=
ref
(
false
)
const
callPhone
=
ref
(
''
)
...
...
@@ -215,6 +308,8 @@ export default defineComponent({
})
return
{
connectionState
,
selected
,
...
...
@@ -233,6 +328,7 @@ export default defineComponent({
handleClickCall
,
showCall
,
callPhone
,
isChatWithRoboot
,
isUser
};
},
...
...
src/views/Chat/ChatContentMessage.vue
View file @
e689d495
...
...
@@ -92,7 +92,7 @@
</template>
<
script
lang=
"ts"
>
import
{
computed
,
defineComponent
,
ref
}
from
"vue"
;
import
{
computed
,
defineComponent
,
ref
,
PropType
}
from
"vue"
;
import
default_avatar_url
from
"@/assets/user_avatar.png"
;
import
{
messageStore
}
from
"@/store/messagesStore"
;
import
ChatContentMessageTextVue
from
"./ChatContentMessageText.vue"
;
...
...
@@ -121,7 +121,7 @@ export default defineComponent({
content
:
{
type
:
Object
,
required
:
true
},
type
:
{
type
:
Number
,
required
:
true
},
time
:
String
,
state
:
String
,
state
:
String
as
PropType
<
string
|
null
|
undefined
>
,
uuid
:
{
type
:
String
,
required
:
true
},
hideDatetime
:
Boolean
,
uploadProgress
:
Object
,
...
...
src/views/Chat/ChatInput.vue
View file @
e689d495
...
...
@@ -51,7 +51,7 @@ import { MessageContent } from "@/types/chat-message";
import
ChatInputTextVue
from
"./ChatInputText.vue"
;
import
ChatInputAlbumVue
from
"./ChatInputAlbum.vue"
;
import
ChatInputCameraVue
from
"./ChatInputCamera.vue"
;
import
{
getFromId
,
target
}
from
"@/store/appCallerStore"
;
import
{
getFromId
}
from
"@/store/appCallerStore"
;
import
{
textInputStore
}
from
"@/store/textInputStore"
;
import
{
v4
as
uuidv4
}
from
'uuid'
import
Icon
from
"@/components/common/Icon.vue"
;
...
...
@@ -78,6 +78,8 @@ export default defineComponent({
voice
,
}
const
target
=
route
.
query
.
targetId
as
string
/** 输入框类型,文本 or 语音 */
const
inputType
=
ref
(
InputType
.
text
);
...
...
@@ -119,7 +121,10 @@ export default defineComponent({
const
isStaff
=
getUserMsg
()?.
role
===
eRole
.
staff
;
const
isUser
=
getUserMsg
()?.
role
===
eRole
.
user
;
if
(
isUser
&&
props
.
serviceShowValue
===
"人工服务"
)
{
if
(
isUser
&&
route
.
query
.
outlet
!==
undefined
)
{
/* 当前角色是客户,
并且和网点机器人进行聊天
*/
messageStore
.
displayNewMessage
({
content
:
{
content
:
inputText
.
value
...
...
@@ -145,6 +150,7 @@ export default defineComponent({
},
masterId
:
getFromId
()
as
string
,
isChattingWithTargetId
:
true
,
isRoboot
:
true
,
})
textInputStore
.
clearTextMessage
();
}
else
{
...
...
src/views/LoanDetail/index.vue
View file @
e689d495
...
...
@@ -16,6 +16,7 @@ import { iNearbyOutLet } from "@/service/AddressService/types"
import
AddressService
from
"@/service/AddressService"
import
router
from
"@/router"
;
import
UserService
from
"@/service/UserService"
;
import
{
goToChatWithOutletRoboot
}
from
"@/router/navigate"
;
function
isInViewPort
(
element
:
HTMLElement
,
barHeight
:
number
)
{
const
viewWidth
=
window
.
innerWidth
||
document
.
documentElement
.
clientWidth
;
...
...
@@ -125,17 +126,9 @@ export default defineComponent({
number
:
1
,
})
if
(
ret
.
code
===
200
)
{
const
ret2
=
await
UserService
.
getInstance
().
contact_custom_service
({
out
LetID
:
ret
.
data
[
0
].
outlet_id
as
number
goToChatWithOutletRoboot
({
out
letId
:
ret
.
data
[
0
].
outlet_id
})
if
(
ret2
.
code
==
200
)
{
router
.
push
({
name
:
'Chat'
,
query
:
{
target
:
ret2
.
data
.
addr
}
})
}
}
}
...
...
@@ -314,10 +307,10 @@ export default defineComponent({
color: #ffffff;
}
.w-100{
width:100px;
.w-100
{
width:
100px;
}
.w-235{
width:235px;
.w-235
{
width:
235px;
}
</
style
>
\ No newline at end of file
src/views/withMenu/ChatList/index.vue
View file @
e689d495
<
template
>
<Navbar
:title=
"navBarTitle"
:showBackIcon=
"false"
/>
<Navbar
:title=
"navBarTitle"
:showBackIcon=
"false"
/>
<div
class=
"mx-5"
>
<div
v-for=
"(item, index) in cardList"
...
...
@@ -26,7 +23,7 @@
</div>
</div>
<div
v-if=
"isChatListEmpty"
v-if=
"
!cardListLoading &&
isChatListEmpty"
class=
"empty text-center fixed w-full top-1/2 transform -translate-y-1/2 -mt-6"
>
<img
src=
"@/assets/img/empty.png"
class=
"mb-5"
/>
...
...
@@ -47,25 +44,44 @@ import { getUserMsg } from "@/utils/userMsg";
import
{
eRole
}
from
"@/types/roleType"
;
import
ChatMessageDB
from
"@/db/ChatMessageDB"
;
import
router
from
"@/router"
;
import
UserService
from
"@/service/UserService"
;
import
{
getDisplayNamesFromAddress
}
from
"@/utils/displayName"
;
import
{
getDisplayNames
,
getDisplayNamesFromAddress
,
getDisplayNamesFromOutletId
}
from
"@/utils/displayName"
;
const
cardList
=
ref
<
(
iChatListCard
&
{
displayName
?:
string
})[]
>
([]);
const
showList
=
ref
<
boolean
[]
>
([]);
const
selectedIndex
=
ref
<
number
>
()
const
cardListLoading
=
ref
(
false
);
const
renderList
=
async
()
=>
{
cardListLoading
.
value
=
true
;
const
list
=
await
ChatListCardDB
.
getInstance
().
getCardList
(
getFromId
()
as
string
)
const
addressList
=
list
.
map
(
i
=>
i
.
targetId
);
cardList
.
value
=
list
;
const
displayNames
=
await
getDisplayNamesFromAddress
(
addressList
)
const
reqlist
=
list
.
map
(
i
=>
{
if
(
i
.
isRobootCard
)
{
return
{
outletId
:
Number
(
i
.
targetId
),
}
}
else
{
return
{
address
:
i
.
targetId
,
}
}
})
const
displayNames
=
await
getDisplayNames
(
reqlist
)
// const displayNames = await getDisplayNamesFromAddress(addressList)
// await getDisplayNamesFromOutletId(list)
cardList
.
value
=
list
.
map
((
item
,
index
)
=>
{
return
{
...
item
,
displayName
:
displayNames
[
index
]
}
})
cardListLoading
.
value
=
false
;
}
onMounted
(
async
()
=>
{
...
...
@@ -120,6 +136,7 @@ function handleClickItem(index: number, item: iChatListCard) {
name
:
'Chat'
,
query
:
{
targetId
:
item
.
targetId
,
outlet
:
item
.
isRobootCard
?
'true'
:
undefined
}
})
}
...
...
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