滚动加载

cyl/dev
jscyl13849007907 1 year ago
parent 6ef277b998
commit bad88e38c0

@ -1,5 +1,6 @@
<template> <template>
<div class="joblist-container"> <div class="joblist-container"
>
<!-- 城市的弹出框 --> <!-- 城市的弹出框 -->
<a-modal class="cityModal" transitionName v-model="visible" width="680px" @cancel="cityModalClose" title="请选择城市" :footer="null"> <a-modal class="cityModal" transitionName v-model="visible" width="680px" @cancel="cityModalClose" title="请选择城市" :footer="null">
<div class="inputBox"> <div class="inputBox">
@ -22,6 +23,7 @@
</li> </li>
</ul> </ul>
</a-modal> </a-modal>
<div class="main-page-obj">
<!-- 筛选导航 --> <!-- 筛选导航 -->
<div class="navigation"> <div class="navigation">
<div class="w" id="navigation"> <div class="w" id="navigation">
@ -480,7 +482,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="pagecontainer f40"> <div class="pagecontainer f40" v-if="false">
<a-pagination :current="+formvalue.pageNum" :default-current="1" :defaultPageSize="8" :total="formvalue.total" @change="pageChange" /> <a-pagination :current="+formvalue.pageNum" :default-current="1" :defaultPageSize="8" :total="formvalue.total" @change="pageChange" />
<div class="ant-pagination-options-quick-jumper"> <div class="ant-pagination-options-quick-jumper">
跳至 跳至
@ -531,6 +533,7 @@
<recommend /> <recommend />
</div> </div>
</div> </div>
</div>
<recordModal :show.sync="recordShow" :jobDetail="currentInfo"></recordModal> <recordModal :show.sync="recordShow" :jobDetail="currentInfo"></recordModal>
</div> </div>
</template> </template>
@ -589,6 +592,7 @@ export default {
// //
data() { data() {
return { return {
isFetching: false, //
jobMainList: [], // jobMainList: [], //
jobNum:0, jobNum:0,
recordShow: false, recordShow: false,
@ -883,10 +887,12 @@ export default {
mounted() { mounted() {
this.loginValue = localStorage.getItem("LOGIN_DATA") !== null ? JSON.parse(localStorage.getItem("LOGIN_DATA")) : { tel: "" }; this.loginValue = localStorage.getItem("LOGIN_DATA") !== null ? JSON.parse(localStorage.getItem("LOGIN_DATA")) : { tel: "" };
console.log(this.loginValue); console.log(this.loginValue);
window.addEventListener('scroll', this.handleScroll);
}, },
beforeDestroy() { beforeDestroy() {
console.log("beforeDestroy"); console.log("beforeDestroy");
// sessionStorage.removeItem("PAGE_TYPE") // sessionStorage.removeItem("PAGE_TYPE")
window.removeEventListener('scroll', this.handleScroll);
}, },
destroyed() { destroyed() {
@ -894,6 +900,29 @@ export default {
}, },
// //
methods: { methods: {
// ...
handleScroll() {
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
const windowHeight = document.documentElement.clientHeight;
const scrollHeight = document.documentElement.scrollHeight;
if (scrollTop + windowHeight >= scrollHeight - 100 && !this.isFetching) { // 100
this.isFetching = true;
this.loadMoreData();
}
},
loadMoreData() {
this.formvalue.pageNum += 1; //
if (this.signType != 0) {
this.getJobListYicai().then(() => {
this.isFetching = false;
});
} else {
this.getJobList().then(() => {
this.isFetching = false;
});
}
},
removePageInfo() { removePageInfo() {
sessionStorage.removeItem("PAGE_TYPE"); sessionStorage.removeItem("PAGE_TYPE");
}, },
@ -934,9 +963,8 @@ export default {
} }
this.isspinning = false; this.isspinning = false;
}, },
//
async getJobList(newdata) { async getJobList(newdata) {
this.isspinning = true; // this.isspinning = true;
console.log("this.formvalue", this.formvalue); console.log("this.formvalue", this.formvalue);
try { try {
newdata = { newdata = {
@ -945,83 +973,61 @@ export default {
ageStr: "", ageStr: "",
jobRequestLabelIds: "", jobRequestLabelIds: "",
aliasName: "", aliasName: "",
pageNum: 1, pageNum: this.formvalue.pageNum, // 使
pageSize: 8, pageSize: 8,
total: null, // total: null, //
}; };
for (var k in this.formvalue) { for (var k in this.formvalue) {
// console.log(this.formvalue[k]);
if (Array.isArray(this.formvalue[k])) { if (Array.isArray(this.formvalue[k])) {
newdata[k] = this.formvalue[k].length > 0 ? this.formvalue[k].join() : ""; newdata[k] = this.formvalue[k].length > 0 ? this.formvalue[k].join() : "";
} else { } else {
newdata[k] = this.formvalue[k]; newdata[k] = this.formvalue[k];
} }
} }
// console.log(newdata);
// debugger;
// console.log(this.isLogin);
if (this.isLogin) { if (this.isLogin) {
const { data } = await JobListApi(newdata); const { data } = await JobListApi(newdata);
console.log("data", data);
if (data.status === 200) { if (data.status === 200) {
this.jobMainList = disposeJobListData(data.data.recordList); this.jobMainList = this.jobMainList.concat(disposeJobListData(data.data.recordList)); //
this.formvalue.total = data.data.recordCount; this.formvalue.total = data.data.recordCount;
console.log(this.jobMainList);
} else { } else {
this.$message.info("数据获取失败"); this.$message.info("数据获取失败");
} }
} }
this.totop(); // this.totop();
// = data.data.recordList;
// console.log(this.formvalue);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
this.isspinning = false; this.isspinning = false;
}, },
async getJobNum() {
const { data } = await getJobNumApi();
this.jobNum = data.data;
console.log('getJobNum',data);
},
//
async getJobListYicai(newdata) { async getJobListYicai(newdata) {
return; // this.isspinning = true;
this.isspinning = true;
console.log(this.formvalue); console.log(this.formvalue);
try { try {
let aId = ""; let aId = "";
if (window.location.origin.indexOf("localhost:") > -1 || window.location.origin.indexOf("test.") > -1) { if (window.location.origin.indexOf("localhost:") > -1 || window.location.origin.indexOf("test.") > -1) {
aId = "2743"; aId = "2743";
} else { } else {
aId = "3087"; aId = "3087";
} }
newdata = { newdata = {
agencyId: aId, // agencyId: aId,
recruitment: "1", recruitment: "1",
keys: "", keys: "",
pageNum: 1, pageNum: this.formvalue.pageNum, // 使
pageSize: 8, pageSize: 8,
total: null, // total: null, //
}; };
for (var k in this.formvalue) { for (var k in this.formvalue) {
// console.log(this.formvalue[k]);
if (Array.isArray(this.formvalue[k])) { if (Array.isArray(this.formvalue[k])) {
newdata[k] = this.formvalue[k].length > 0 ? this.formvalue[k].join() : ""; newdata[k] = this.formvalue[k].length > 0 ? this.formvalue[k].join() : "";
} else { } else {
newdata[k] = this.formvalue[k]; newdata[k] = this.formvalue[k];
} }
} }
// console.log(newdata);
// debugger;
// console.log(this.isLogin);
if (this.isLogin) { if (this.isLogin) {
const { data } = await JobListApiYicai(newdata); const { data } = await JobListApiYicai(newdata);
// console.log(data);
if (data.status === 200) { if (data.status === 200) {
this.jobMainList = disposeJobListData(data.data.recordList); this.jobMainList = this.jobMainList.concat(disposeJobListData(data.data.recordList)); //
this.jobMainList.forEach((item, index) => { this.jobMainList.forEach((item, index) => {
if (item.jobType == 2) { if (item.jobType == 2) {
item["servetype"] = setReturnFee(item.agencyReturnFee, item.agencyReturnFeeType); item["servetype"] = setReturnFee(item.agencyReturnFee, item.agencyReturnFeeType);
@ -1030,19 +1036,21 @@ export default {
} }
}); });
this.formvalue.total = data.data.recordCount; this.formvalue.total = data.data.recordCount;
console.log(this.jobMainList);
} else { } else {
this.$message.info("数据获取失败"); this.$message.info("数据获取失败");
} }
} }
this.totop(); // this.totop();
// = data.data.recordList;
// console.log(this.formvalue);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
this.isspinning = false; this.isspinning = false;
}, },
async getJobNum() {
const { data } = await getJobNumApi();
this.jobNum = data.data;
console.log('getJobNum',data);
},
// //
onSearch() { onSearch() {
@ -1404,8 +1412,8 @@ export default {
}, },
totop() { totop() {
// console.log(window); // console.log(window);
document.body.scrollTop = 0; // document.body.scrollTop = 0;
document.documentElement.scrollTop = 0; // document.documentElement.scrollTop = 0;
// window.body.scrollY = 0; // window.body.scrollY = 0;
}, },
moneyToFixed(value) { moneyToFixed(value) {

@ -705,7 +705,7 @@ export default {
showfooter() { showfooter() {
const path = this.$route.fullPath; const path = this.$route.fullPath;
if (path.indexOf("main") > -1) { if (path.indexOf("main") > -1 || this.pagrTitle == 'list') {
this.isbannershow = false; this.isbannershow = false;
this.isfootershow = false; this.isfootershow = false;
} else { } else {

Loading…
Cancel
Save