Files
xiezheng_jq/js/page/index.js
2024-12-10 12:20:05 +08:00

79 lines
1.9 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 Index {
constructor() {
header(`
<div class="search flex1 flex ais">
<i class="iconfont icon-sousuo-m"></i>
<p>开启精彩搜索..</p>
</div>
`, '', '')
// 虚拟domjs对象虚拟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