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
993d0705
authored
Jul 10, 2024
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【优化】mall 客服触顶自动加载下一页数据
parent
fa089298
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
23 deletions
+4
-23
src/views/mall/promotion/kefu/components/KeFuMessageList.vue
+4
-23
No files found.
src/views/mall/promotion/kefu/components/KeFuMessageList.vue
View file @
993d0705
...
@@ -2,14 +2,6 @@
...
@@ -2,14 +2,6 @@
<el-container
v-if=
"showKeFuMessageList"
class=
"kefu"
>
<el-container
v-if=
"showKeFuMessageList"
class=
"kefu"
>
<el-header>
<el-header>
<div
class=
"kefu-title"
>
{{
conversation
.
userNickname
}}
</div>
<div
class=
"kefu-title"
>
{{
conversation
.
userNickname
}}
</div>
<!-- 加载历史消息 -->
<div
v-show=
"loadingMore"
class=
"loadingMore flex justify-center items-center cursor-pointer"
@
click=
"handleOldMessage"
>
加载更多
</div>
</el-header>
</el-header>
<el-main
class=
"kefu-content overflow-visible"
>
<el-main
class=
"kefu-content overflow-visible"
>
<el-scrollbar
ref=
"scrollbarRef"
always
height=
"calc(100vh - 495px)"
@
scroll=
"handleScroll"
>
<el-scrollbar
ref=
"scrollbarRef"
always
height=
"calc(100vh - 495px)"
@
scroll=
"handleScroll"
>
...
@@ -248,15 +240,16 @@ const handleToNewMessage = async () => {
...
@@ -248,15 +240,16 @@ const handleToNewMessage = async () => {
}
}
/** 加载历史消息 */
/** 加载历史消息 */
const
loadingMore
=
ref
(
false
)
// 滚动到顶部加载更多
const
loadHistory
=
ref
(
false
)
// 加载历史消息
const
loadHistory
=
ref
(
false
)
// 加载历史消息
const
handleScroll
=
async
({
scrollTop
})
=>
{
const
handleScroll
=
async
({
scrollTop
})
=>
{
const
messageTotal
=
messageList
.
value
.
length
const
messageTotal
=
messageList
.
value
.
length
if
(
total
.
value
>
0
&&
messageTotal
>
0
&&
messageTotal
===
total
.
value
)
{
if
(
total
.
value
>
0
&&
messageTotal
>
0
&&
messageTotal
===
total
.
value
)
{
return
return
}
}
// 距顶 20 加载下一页数据
// 触顶自动加载下一页数据
loadingMore
.
value
=
scrollTop
<
20
if
(
scrollTop
===
0
)
{
await
handleOldMessage
()
}
}
}
const
handleOldMessage
=
async
()
=>
{
const
handleOldMessage
=
async
()
=>
{
// 记录已有页面高度
// 记录已有页面高度
...
@@ -265,7 +258,6 @@ const handleOldMessage = async () => {
...
@@ -265,7 +258,6 @@ const handleOldMessage = async () => {
// 加载消息列表
// 加载消息列表
queryParams
.
pageNo
+=
1
queryParams
.
pageNo
+=
1
await
getMessageList
(
conversation
.
value
)
await
getMessageList
(
conversation
.
value
)
loadingMore
.
value
=
false
// 等页面加载完后,获得上一页最后一条消息的位置,控制滚动到它所在位置
// 等页面加载完后,获得上一页最后一条消息的位置,控制滚动到它所在位置
scrollbarRef
.
value
!
.
setScrollTop
(
innerRef
.
value
!
.
clientHeight
-
oldPageHeight
)
scrollbarRef
.
value
!
.
setScrollTop
(
innerRef
.
value
!
.
clientHeight
-
oldPageHeight
)
}
}
...
@@ -293,17 +285,6 @@ const showTime = computed(() => (item: KeFuMessageRespVO, index: number) => {
...
@@ -293,17 +285,6 @@ const showTime = computed(() => (item: KeFuMessageRespVO, index: number) => {
line-height
:
60px
;
line-height
:
60px
;
}
}
.loadingMore
{
width
:
100%
;
height
:
50px
;
background-color
:
#eee
;
color
:
#666
;
text-align
:
center
;
line-height
:
50px
;
transform
:
translateY
(
-100%
);
transition
:
transform
0.3s
ease-in-out
;
}
&
-content
{
&
-content
{
.newMessageTip
{
.newMessageTip
{
position
:
absolute
;
position
:
absolute
;
...
...
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