Files
xiezheng_h5/js/page/index.js
bmy 4991b3686c
All checks were successful
continuous-integration/drone/push Build is passing
hahah
2024-12-03 11:18:07 +08:00

80 lines
1.9 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.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>
<a class="icon" href="./tagListInfo.html?url=${v.url}&title=${v.title}">${v.title.substr(0,1)}</a>
<a class="title" href="./tagListInfo.html?url=${v.url}&title=${v.title}">${v.title}</a>
</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>
`
})
this.initSwiper()
}
initSwiper() {
var mySwiper = new Swiper('.banner', {
loop: true,
pagination: {
el: '.swiper-pagination',
},
})
}
event() {
$(".search").onclick = () => {
location.href = "./search.html"
}
}
}
new Index