Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5e7afae9
authored
Nov 10, 2024
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【功能完善】商城: 客服消息JSON 化
parent
b9e15296
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
src/views/mall/promotion/kefu/index.vue
+4
-2
No files found.
src/views/mall/promotion/kefu/index.vue
View file @
5e7afae9
...
@@ -16,6 +16,7 @@ import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
...
@@ -16,6 +16,7 @@ import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
import
{
getRefreshToken
}
from
'@/utils/auth'
import
{
getRefreshToken
}
from
'@/utils/auth'
import
{
useWebSocket
}
from
'@vueuse/core'
import
{
useWebSocket
}
from
'@vueuse/core'
import
{
useMallKefuStore
}
from
'@/store/modules/mall/kefu'
import
{
useMallKefuStore
}
from
'@/store/modules/mall/kefu'
import
{
jsonParse
}
from
'@/utils'
defineOptions
({
name
:
'KeFu'
})
defineOptions
({
name
:
'KeFu'
})
...
@@ -30,6 +31,7 @@ const server = ref(
...
@@ -30,6 +31,7 @@ const server = ref(
)
// WebSocket 服务地址
)
// WebSocket 服务地址
/** 发起 WebSocket 连接 */
/** 发起 WebSocket 连接 */
// TODO puhui999: websocket 连接有点问题收不到消息 🤣
const
{
data
,
close
,
open
}
=
useWebSocket
(
server
.
value
,
{
const
{
data
,
close
,
open
}
=
useWebSocket
(
server
.
value
,
{
autoReconnect
:
true
,
autoReconnect
:
true
,
heartbeat
:
true
heartbeat
:
true
...
@@ -45,9 +47,9 @@ watchEffect(() => {
...
@@ -45,9 +47,9 @@ watchEffect(() => {
if
(
data
.
value
===
'pong'
)
{
if
(
data
.
value
===
'pong'
)
{
return
return
}
}
// 2.1 解析 type 消息类型
// 2.1 解析 type 消息类型
const
jsonMessage
=
JSON
.
parse
(
data
.
value
)
const
jsonMessage
=
JSON
.
parse
(
data
.
value
)
console
.
log
(
jsonMessage
)
const
type
=
jsonMessage
.
type
const
type
=
jsonMessage
.
type
if
(
!
type
)
{
if
(
!
type
)
{
message
.
error
(
'未知的消息类型:'
+
data
.
value
)
message
.
error
(
'未知的消息类型:'
+
data
.
value
)
...
@@ -65,7 +67,7 @@ watchEffect(() => {
...
@@ -65,7 +67,7 @@ watchEffect(() => {
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_ADMIN_READ
)
{
if
(
type
===
WebSocketMessageTypeConstants
.
KEFU_MESSAGE_ADMIN_READ
)
{
// 更新会话已读
// 更新会话已读
kefuStore
.
updateConversationStatus
(
JSON
.
p
arse
(
jsonMessage
.
content
))
kefuStore
.
updateConversationStatus
(
jsonP
arse
(
jsonMessage
.
content
))
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
)
console
.
error
(
error
)
...
...
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