From eb740db87c90b4e6d1060f862c5408fa482bd981 Mon Sep 17 00:00:00 2001 From: jscyl13849007907 <13849007907@163.com> Date: Wed, 22 Jan 2025 10:20:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/FirstJob/joblist.vue | 79 ++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/src/components/FirstJob/joblist.vue b/src/components/FirstJob/joblist.vue index 4d45778..f738406 100644 --- a/src/components/FirstJob/joblist.vue +++ b/src/components/FirstJob/joblist.vue @@ -884,6 +884,7 @@
= scrollHeight - 100 && !this.isFetching && !this.isStop) { // 100 是一个阈值,可以根据需要调整 - this.isFetching = true; - setTimeout(() => { - this.speed = 1; - this.loadMoreData(); - }, 300); - } - }, - loadMoreData() { - this.formvalue.pageNum += 1; // 增加页码 - if (this.signType != 0) { - this.getJobList({isScroll:1}).then(() => { - this.isFetching = false; - }); - } else { - this.getJobList({isScroll:1}).then(() => { - this.isFetching = false; - }); - } - }, + const scrollTop = document.documentElement.scrollTop || document.body.scrollTop; + const windowHeight = document.documentElement.clientHeight; + const scrollHeight = document.documentElement.scrollHeight; + + const threshold = windowHeight * 0.4; + + if (scrollTop + windowHeight >= scrollHeight - 100 && !this.isFetching && !this.isStop) { // 100 是一个阈值,可以根据需要调整 + this.isFetching = true; + setTimeout(() => { + this.speed = 1; + this.loadMoreData(); + }, 300); + } + if (scrollTop >= threshold) { + this.$refs.backToTop.style.opacity = 1; + this.$refs.backToTop.style.pointerEvents = 'auto'; + } else { + this.$refs.backToTop.style.opacity = 0; + this.$refs.backToTop.style.pointerEvents = 'none'; + } + }, + loadMoreData() { + this.formvalue.pageNum += 1; // 增加页码 + if (this.signType != 0) { + this.getJobList({isScroll:1}).then(() => { + this.isFetching = false; + }); + } else { + this.getJobList({isScroll:1}).then(() => { + this.isFetching = false; + }); + } + }, removePageInfo() { sessionStorage.removeItem("PAGE_TYPE"); }, @@ -3760,4 +3770,25 @@ p { .stoggle{ transform: rotate(90deg); } + .top-obj { + width: 40px; + height: 40px; + background-color: #fff; + border-radius: 50%; + position: fixed; + bottom: 100px; + right: calc(50vw - 470px); + cursor: pointer; + transition: opacity 0.3s ease; + opacity: 0; + pointer-events: none; + } + + .top-obj:hover { + background-color: #1890ffdd; + } + + .top-obj:active { + background-color: #1890ffdd; + }