Skip to content

Commit 5e7afae

Browse files
author
puhui999
committed
【功能完善】商城: 客服消息JSON 化
1 parent b9e1529 commit 5e7afae

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/views/mall/promotion/kefu/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation'
1616
import { getRefreshToken } from '@/utils/auth'
1717
import { useWebSocket } from '@vueuse/core'
1818
import { useMallKefuStore } from '@/store/modules/mall/kefu'
19+
import { jsonParse } from '@/utils'
1920
2021
defineOptions({ name: 'KeFu' })
2122
@@ -30,6 +31,7 @@ const server = ref(
3031
) // WebSocket 服务地址
3132
3233
/** 发起 WebSocket 连接 */
34+
// TODO puhui999: websocket 连接有点问题收不到消息 🤣
3335
const { data, close, open } = useWebSocket(server.value, {
3436
autoReconnect: true,
3537
heartbeat: true
@@ -45,9 +47,9 @@ watchEffect(() => {
4547
if (data.value === 'pong') {
4648
return
4749
}
48-
4950
// 2.1 解析 type 消息类型
5051
const jsonMessage = JSON.parse(data.value)
52+
console.log(jsonMessage)
5153
const type = jsonMessage.type
5254
if (!type) {
5355
message.error('未知的消息类型:' + data.value)
@@ -65,7 +67,7 @@ watchEffect(() => {
6567
// 2.3 消息类型:KEFU_MESSAGE_ADMIN_READ
6668
if (type === WebSocketMessageTypeConstants.KEFU_MESSAGE_ADMIN_READ) {
6769
// 更新会话已读
68-
kefuStore.updateConversationStatus(JSON.parse(jsonMessage.content))
70+
kefuStore.updateConversationStatus(jsonParse(jsonMessage.content))
6971
}
7072
} catch (error) {
7173
console.error(error)

0 commit comments

Comments
 (0)