Commit 3c7733aa authored by KesaubeEire's avatar KesaubeEire

fix: 瀑布流细节改进

parent a068678a
......@@ -174,8 +174,12 @@
}
isSearching = true;
globalPageLimit = limit;
// globalPageLimit = limit;
nextPage = page;
// 是否两次搜索参数相同
let sameSearch = lastSearchParam == searchParam && lastSearchType == searchType;
lastSearchType = searchType;
lastSearchParam = searchParam;
......@@ -199,12 +203,20 @@
createFetch(requestType(searchParam), data => {
if (process.env.APP_ENV === 'dev') console.log(data);
page == 1 ? showList(data) : appendList(data);
if (data.length != 0) {
page == 1 ? showList(data) : appendList(data);
} else {
toast.push('没有搜索到数据捏~');
return;
}
if (data.length < globalPageLimit) {
console.log(data.length);
isEnd = true;
toast.push('没有更多数据了捏~');
if (sameSearch) isEnd = true;
toast.push('加载完成了捏~');
return;
}
......@@ -296,12 +308,22 @@
//拉动到页面底部则更新数据
window.addEventListener('scroll', () => {
// 加载下一页: page + 1 重复上次搜
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
let clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
if (clientHeight > 0 && scrollTop > 0 && scrollTop + clientHeight > scrollHeight - 10.0) {
// 加载下一页: page + 1 重复上次搜
// continueLastSearch();
// PC 端
// if (clientHeight > 0 && scrollTop > 0 && scrollTop + clientHeight > scrollHeight - 10.0) debouncedContinue();
// 手机端
// if (window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 10.0) debouncedContinue();
let pc_debounced = clientHeight > 0 && scrollTop > 0 && scrollTop + clientHeight > scrollHeight - 10.0;
let phone_debounced = window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 10.0;
if (pc_debounced || phone_debounced) {
// toast.push(pc_debounced ? 'pc' : 'phone');
debouncedContinue();
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment