Files
xiezheng_h5/js/page/index.js
2024-11-30 22:40:02 +08:00

80 lines
1.8 KiB
JavaScript

class Index {
constructor() {
util.header(
`
<div class="search flex1 flex ais">
<i class="iconfont icon-sousuo-m"></i>
<p>开启精彩搜索..</p>
</div>
`,
"",
""
)
util.footer()
this.getHomeBanner()
this.getTagRecommend()
this.getHomeHotData()
this.getHomeListData()
this.initSwiper()
this.event()
}
async getHomeListData() {
let res = await homeServe.homeList()
item(".default-model ul", res)
}
// 获取热门推荐的写真
async getHomeHotData() {
let res = await homeServe.homeHot()
item(".recommend-model ul", res)
}
// 请求热门分类
async getTagRecommend() {
let res = await tagServe.tagRecommend()
$(".recommend-tag").innerHTML = res.maps(v => {
return `
<li>
<div class="icon">${v.title.substr(0,1)}</div>
<div class="title">${v.title}</div>
</li>
`
})
}
// 请求banner图
async getHomeBanner() {
let res = await homeServe.homeBanner()
$(".swiper-wrapper").innerHTML = res.maps(v => {
return `
<div class="swiper-slide">
<img src="${v.src}" alt="">
</div>
`
})
}
initSwiper() {
var mySwiper = new Swiper('.banner', {
loop: true, // 循环模式选项
// 如果需要分页器
pagination: {
el: '.swiper-pagination',
},
})
}
event() {
$(".search").onclick = () => {
location.href = "./search.html"
}
}
}
new Index