Files
ClassContent/项目合集/菜谱App/fontend/js/page/search.js
2024-09-27 02:06:13 +08:00

50 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class search {
constructor() {
this.page = 1
this.searchfunction();
this.scrollLoadData()
}
searchfunction(){
var dd = this;
$(".header p").on('click',()=>{
this.searchss()
})
}
async searchss(){
var dd=this,
value =$(".header input").val();
console.log($(".header input").val());
let res = await SearchService.search({
q:value,
page:this.page
});
res.forEach((v,i)=>{
$(".content ul").append(`
<li>
<a href="./info.html?url=${v.href}">
<div class="img">
<img src="${v.img}" alt="">
</div>
<div class="name">
<h3>${v.title}</h3>
<p>${v.des}</p>
</div>
</a>
</li>
`)
})
}
scrollLoadData() {
var scroll = new auiScroll({
listen: true,
distance: 10 //判断到达底部的距离isToBottom为true
}, (ret) => {
if(ret.isToBottom){
this.page += 1;
this.searchss()
}
});
}
}
new search()