55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
class search {
|
|
constructor() {
|
|
this.page = 1
|
|
this.scrollLoadData()
|
|
this.search_header()
|
|
|
|
|
|
}
|
|
search_header() {
|
|
$(".header_return").click(function () {
|
|
history.back()
|
|
})
|
|
$(".header_search").click(async () => {
|
|
this.Getser()
|
|
})
|
|
|
|
}
|
|
|
|
async Getser(){
|
|
var res = await indexServe.saerch({
|
|
q: $(".search_input").val(),
|
|
page:this.page
|
|
})
|
|
res.forEach(v => {
|
|
$(".content .content_list").append(`
|
|
<li>
|
|
<a href="../info.html?url=${v.href}">
|
|
<div class="imgs"><img src="${v.img}" alt=""></div>
|
|
<div class="text">
|
|
<h3>${v.title}</h3>
|
|
<p>${v.des}</p>
|
|
</div>
|
|
</a>
|
|
</li>`)
|
|
});
|
|
}
|
|
scrollLoadData() {
|
|
window.onscroll = async ()=>{
|
|
var scrollTop = document.documentElement.scrollTop
|
|
var scrollHeight = document.documentElement.scrollHeight
|
|
var clientHeight = document.documentElement.clientHeight
|
|
if (parseInt(scrollHeight - scrollTop) == clientHeight) {
|
|
this.page++;
|
|
console.log(this.page, "页数");
|
|
await this.Getser();
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
new search()
|