大量修改
This commit is contained in:
80
js/page/index.js
Normal file
80
js/page/index.js
Normal file
@@ -0,0 +1,80 @@
|
||||
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
|
||||
Reference in New Issue
Block a user