first commit
This commit is contained in:
79
js/page/index.js
Normal file
79
js/page/index.js
Normal file
@@ -0,0 +1,79 @@
|
||||
class Index {
|
||||
constructor() {
|
||||
|
||||
header(`
|
||||
<div class="search flex1 flex ais">
|
||||
<i class="iconfont icon-sousuo-m"></i>
|
||||
<p>开启精彩搜索..</p>
|
||||
</div>
|
||||
`, '', '')
|
||||
// 虚拟dom(js对象),虚拟dom的数组([{},{}])
|
||||
|
||||
// 数组(不是原生数组,是jq定义的数组)
|
||||
// console.log($("body")[0].innerHTML = ``);
|
||||
// console.log($("body").html(`a`));
|
||||
footer()
|
||||
|
||||
this.getHomeBannerData()
|
||||
this.getHomeHotData()
|
||||
this.getHomeListData()
|
||||
this.getTagRecommendData()
|
||||
|
||||
this.event()
|
||||
}
|
||||
|
||||
event() {
|
||||
$(".search").click(() => {
|
||||
location.href = "./search.html"
|
||||
})
|
||||
}
|
||||
|
||||
async getTagRecommendData() {
|
||||
eachHtml(
|
||||
".recommend-tag",
|
||||
await tagServe.tagRecommend(),
|
||||
(v) => `
|
||||
<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>
|
||||
`
|
||||
)
|
||||
}
|
||||
|
||||
async getHomeBannerData() {
|
||||
eachHtml(
|
||||
".swiper-wrapper",
|
||||
await homeServe.homeBanner(),
|
||||
(v) => `<div class="swiper-slide"><img src="${v.src}" alt=""></div>`
|
||||
)
|
||||
this.initSwiper()
|
||||
}
|
||||
|
||||
async getHomeListData() {
|
||||
eachHtml(
|
||||
".default-model ul",
|
||||
await homeServe.homeList(),
|
||||
(v) => item(v)
|
||||
)
|
||||
}
|
||||
|
||||
async getHomeHotData() {
|
||||
eachHtml(
|
||||
".recommend-horizontally ul",
|
||||
await homeServe.homeHot(),
|
||||
(v) => item(v)
|
||||
)
|
||||
}
|
||||
|
||||
initSwiper() {
|
||||
new Swiper('.banner', {
|
||||
loop: true,
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
new Index
|
||||
Reference in New Issue
Block a user