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
e8a0eb08
authored
Jul 17, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码优化】MALL:客服聊天
parent
4abd246d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
0 deletions
+14
-0
src/views/mall/promotion/kefu/components/KeFuMessageList.vue
+4
-0
src/views/mall/promotion/kefu/components/history/MemberBrowsingHistory.vue
+6
-0
src/views/mall/promotion/kefu/components/history/OrderBrowsingHistory.vue
+2
-0
src/views/mall/promotion/kefu/components/history/ProductBrowsingHistory.vue
+2
-0
No files found.
src/views/mall/promotion/kefu/components/KeFuMessageList.vue
View file @
e8a0eb08
...
@@ -161,6 +161,7 @@ const queryParams = reactive({
...
@@ -161,6 +161,7 @@ const queryParams = reactive({
})
})
const
total
=
ref
(
0
)
// 消息总条数
const
total
=
ref
(
0
)
// 消息总条数
const
refreshContent
=
ref
(
false
)
// 内容刷新,主要解决会话消息页面高度不一致导致的滚动功能精度失效
const
refreshContent
=
ref
(
false
)
// 内容刷新,主要解决会话消息页面高度不一致导致的滚动功能精度失效
/** 获悉消息内容 */
/** 获悉消息内容 */
const
getMessageContent
=
computed
(()
=>
(
item
:
any
)
=>
jsonParse
(
item
.
content
))
const
getMessageContent
=
computed
(()
=>
(
item
:
any
)
=>
jsonParse
(
item
.
content
))
/** 获得消息列表 */
/** 获得消息列表 */
...
@@ -178,6 +179,7 @@ const getMessageList = async () => {
...
@@ -178,6 +179,7 @@ const getMessageList = async () => {
}
}
refreshContent
.
value
=
true
refreshContent
.
value
=
true
}
}
/** 添加消息 */
/** 添加消息 */
const
pushMessage
=
(
message
:
any
)
=>
{
const
pushMessage
=
(
message
:
any
)
=>
{
if
(
messageList
.
value
.
some
((
val
)
=>
val
.
id
===
message
.
id
))
{
if
(
messageList
.
value
.
some
((
val
)
=>
val
.
id
===
message
.
id
))
{
...
@@ -217,6 +219,7 @@ const refreshMessageList = async (message?: any) => {
...
@@ -217,6 +219,7 @@ const refreshMessageList = async (message?: any) => {
await
handleToNewMessage
()
await
handleToNewMessage
()
}
}
}
}
const
getNewMessageList
=
async
(
val
:
KeFuConversationRespVO
)
=>
{
const
getNewMessageList
=
async
(
val
:
KeFuConversationRespVO
)
=>
{
// 会话切换,重置相关参数
// 会话切换,重置相关参数
queryParams
.
pageNo
=
1
queryParams
.
pageNo
=
1
...
@@ -231,6 +234,7 @@ const getNewMessageList = async (val: KeFuConversationRespVO) => {
...
@@ -231,6 +234,7 @@ const getNewMessageList = async (val: KeFuConversationRespVO) => {
await
refreshMessageList
()
await
refreshMessageList
()
}
}
defineExpose
({
getNewMessageList
,
refreshMessageList
})
defineExpose
({
getNewMessageList
,
refreshMessageList
})
const
showKeFuMessageList
=
computed
(()
=>
!
isEmpty
(
conversation
.
value
))
// 是否显示聊天区域
const
showKeFuMessageList
=
computed
(()
=>
!
isEmpty
(
conversation
.
value
))
// 是否显示聊天区域
const
skipGetMessageList
=
computed
(()
=>
{
const
skipGetMessageList
=
computed
(()
=>
{
// 已加载到最后一页的话则不触发新的消息获取
// 已加载到最后一页的话则不触发新的消息获取
...
...
src/views/mall/promotion/kefu/components/history/MemberBrowsingHistory.vue
View file @
e8a0eb08
<!-- 目录是不是叫 member 好点。然后这个组件是 MemberInfo,里面有浏览足迹 -->
<
template
>
<
template
>
<div
v-show=
"!isEmpty(conversation)"
class=
"kefu"
>
<div
v-show=
"!isEmpty(conversation)"
class=
"kefu"
>
<div
class=
"header-title h-60px flex justify-center items-center"
>
他的足迹
</div>
<div
class=
"header-title h-60px flex justify-center items-center"
>
他的足迹
</div>
...
@@ -29,6 +30,7 @@ import { ElScrollbar as ElScrollbarType } from 'element-plus/es/components/scrol
...
@@ -29,6 +30,7 @@ import { ElScrollbar as ElScrollbarType } from 'element-plus/es/components/scrol
defineOptions
({
name
:
'MemberBrowsingHistory'
})
defineOptions
({
name
:
'MemberBrowsingHistory'
})
const
activeName
=
ref
(
'a'
)
const
activeName
=
ref
(
'a'
)
/** tab 切换 */
/** tab 切换 */
const
productBrowsingHistoryRef
=
ref
<
InstanceType
<
typeof
ProductBrowsingHistory
>>
()
const
productBrowsingHistoryRef
=
ref
<
InstanceType
<
typeof
ProductBrowsingHistory
>>
()
const
orderBrowsingHistoryRef
=
ref
<
InstanceType
<
typeof
OrderBrowsingHistory
>>
()
const
orderBrowsingHistoryRef
=
ref
<
InstanceType
<
typeof
OrderBrowsingHistory
>>
()
...
@@ -37,7 +39,9 @@ const handleClick = async (tab: TabsPaneContext) => {
...
@@ -37,7 +39,9 @@ const handleClick = async (tab: TabsPaneContext) => {
await
nextTick
()
await
nextTick
()
await
getHistoryList
()
await
getHistoryList
()
}
}
/** 获得历史数据 */
/** 获得历史数据 */
// TODO @puhui:不要用 a、b 哈。就订单列表、浏览列表这种噶
const
getHistoryList
=
async
()
=>
{
const
getHistoryList
=
async
()
=>
{
switch
(
activeName
.
value
)
{
switch
(
activeName
.
value
)
{
case
'a'
:
case
'a'
:
...
@@ -50,6 +54,7 @@ const getHistoryList = async () => {
...
@@ -50,6 +54,7 @@ const getHistoryList = async () => {
break
break
}
}
}
}
/** 加载下一页数据 */
/** 加载下一页数据 */
const
loadMore
=
async
()
=>
{
const
loadMore
=
async
()
=>
{
switch
(
activeName
.
value
)
{
switch
(
activeName
.
value
)
{
...
@@ -63,6 +68,7 @@ const loadMore = async () => {
...
@@ -63,6 +68,7 @@ const loadMore = async () => {
break
break
}
}
}
}
/** 浏览历史初始化 */
/** 浏览历史初始化 */
const
conversation
=
ref
<
KeFuConversationRespVO
>
({}
as
KeFuConversationRespVO
)
// 用户会话
const
conversation
=
ref
<
KeFuConversationRespVO
>
({}
as
KeFuConversationRespVO
)
// 用户会话
const
initHistory
=
async
(
val
:
KeFuConversationRespVO
)
=>
{
const
initHistory
=
async
(
val
:
KeFuConversationRespVO
)
=>
{
...
...
src/views/mall/promotion/kefu/components/history/OrderBrowsingHistory.vue
View file @
e8a0eb08
...
@@ -21,6 +21,7 @@ const skipGetMessageList = computed(() => {
...
@@ -21,6 +21,7 @@ const skipGetMessageList = computed(() => {
// 已加载到最后一页的话则不触发新的消息获取
// 已加载到最后一页的话则不触发新的消息获取
return
total
.
value
>
0
&&
Math
.
ceil
(
total
.
value
/
queryParams
.
pageSize
)
===
queryParams
.
pageNo
return
total
.
value
>
0
&&
Math
.
ceil
(
total
.
value
/
queryParams
.
pageSize
)
===
queryParams
.
pageNo
})
// 跳过消息获取
})
// 跳过消息获取
/** 获得浏览记录 */
/** 获得浏览记录 */
const
getHistoryList
=
async
(
val
:
KeFuConversationRespVO
)
=>
{
const
getHistoryList
=
async
(
val
:
KeFuConversationRespVO
)
=>
{
queryParams
.
userId
=
val
.
userId
queryParams
.
userId
=
val
.
userId
...
@@ -28,6 +29,7 @@ const getHistoryList = async (val: KeFuConversationRespVO) => {
...
@@ -28,6 +29,7 @@ const getHistoryList = async (val: KeFuConversationRespVO) => {
total
.
value
=
res
.
total
total
.
value
=
res
.
total
list
.
value
=
res
.
list
list
.
value
=
res
.
list
}
}
/** 加载下一页数据 */
/** 加载下一页数据 */
const
loadMore
=
async
()
=>
{
const
loadMore
=
async
()
=>
{
if
(
skipGetMessageList
.
value
)
{
if
(
skipGetMessageList
.
value
)
{
...
...
src/views/mall/promotion/kefu/components/history/ProductBrowsingHistory.vue
View file @
e8a0eb08
...
@@ -32,6 +32,7 @@ const skipGetMessageList = computed(() => {
...
@@ -32,6 +32,7 @@ const skipGetMessageList = computed(() => {
// 已加载到最后一页的话则不触发新的消息获取
// 已加载到最后一页的话则不触发新的消息获取
return
total
.
value
>
0
&&
Math
.
ceil
(
total
.
value
/
queryParams
.
pageSize
)
===
queryParams
.
pageNo
return
total
.
value
>
0
&&
Math
.
ceil
(
total
.
value
/
queryParams
.
pageSize
)
===
queryParams
.
pageNo
})
// 跳过消息获取
})
// 跳过消息获取
/** 获得浏览记录 */
/** 获得浏览记录 */
const
getHistoryList
=
async
(
val
:
KeFuConversationRespVO
)
=>
{
const
getHistoryList
=
async
(
val
:
KeFuConversationRespVO
)
=>
{
queryParams
.
userId
=
val
.
userId
queryParams
.
userId
=
val
.
userId
...
@@ -39,6 +40,7 @@ const getHistoryList = async (val: KeFuConversationRespVO) => {
...
@@ -39,6 +40,7 @@ const getHistoryList = async (val: KeFuConversationRespVO) => {
total
.
value
=
res
.
total
total
.
value
=
res
.
total
list
.
value
=
res
.
list
list
.
value
=
res
.
list
}
}
/** 加载下一页数据 */
/** 加载下一页数据 */
const
loadMore
=
async
()
=>
{
const
loadMore
=
async
()
=>
{
if
(
skipGetMessageList
.
value
)
{
if
(
skipGetMessageList
.
value
)
{
...
...
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