first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
class Edit {
constructor() {
header("分类编辑")
// additional 可选菜单
// principal 已选菜单
this.renderList()
}
renderList() {
$(".principal").html()
$(".additional").html()
$(".principal").html(getItem("principal").map(v => `<li>${v.title}</li>`))
$(".additional").html(getItem("additional").map(v => `<li>${v.title}</li>`))
_(".principal li").tap(({v,i}) => i != 0 ? this.clickEvent("principal", "additional", {v,i}) : null )
_(".additional li").tap(({v,i}) => this.clickEvent("additional", "principal", {v,i}))
}
clickEvent(principal, additional, item) {
let {v,i} = item;
// 先把数据添加到 可选菜单 中
let getAdditional = getItem(additional)
getAdditional.push(getItem(principal)[i])
setItem(additional,getAdditional)
setItem(principal,getItem(principal).filter(item => v.innerText != item.title))
this.renderList()
}
}
new Edit()

View File

@@ -0,0 +1,121 @@
class Index {
constructor() {
// console.log(config.getBaseUrl());
// this.getClassList()
this.index = 0;
this.principal = [];
this.GetType()
this.initSwiper()
footer()
}
initSwiper() {
var self = this;
this.swiper = new Swiper('.swiper', {
direction: 'horizontal',
on: {
slideChangeTransitionStart: function () {
_(".header_menu ul li")[this.activeIndex].addClass("active")
.siblings().removeClass("active");
self.index = this.activeIndex
if (this.activeIndex != 0) {
self.getClassList()
}
},
},
})
}
async GetType() {
// 第一次访问网页获取分类
if (!getItem("principal")) {
let { principal, additional } = await indexServe.type();
this.principal = principal
setItem("principal", principal)
setItem("additional", additional)
} else {
this.principal = getItem("principal")
}
this.principal.forEach((v, i) => {
$(".header_menu ul").html(`
<li class="${i == 0 ? 'active' : ''}">${v.title}</li>
`);
$(".swiper-wrapper").html(`
<div class="swiper-slide">
<ul></ul>
</div>
`)
});
_(".swiper-wrapper .swiper-slide").forEach(v => {
v.onscroll = () => {
const {clientHeight, scrollHeight, scrollTop} = v;
const distance = scrollHeight- scrollTop - clientHeight;
if(distance <= 0) {
if (this.index != 0) {
this.principal[this.index].page += 1;
if (this.principal[this.index].page <= this.principal[this.index].total_page) {
this.getClassList('load_more')
} else {
// 暂无数据的样式
}
}
}
}
})
_(".header_menu ul li").tap(( { v, i }) => {
// 链式调用
this.swiper.slideTo(i)
})
this.getIndex();
}
async getClassList(type = 'click') {
let loadData = async () => {
let res = await indexServe.classList({
id: this.principal[this.index].id,
page: this.principal[this.index].page
});
this.principal[this.index].content = res.data;
this.principal[this.index].total_page = res.total_page
console.log(this.principal);
item(
_(".swiper-wrapper .swiper-slide ul")[this.index],
this.principal[this.index].content
)
}
this.principal=getItem("principal")
console.log(getItem("principal"))
if (type == 'click') {
if (this.principal[this.index].content.length == 0) {
loadData()
}
} else {
loadData()
}
}
async getIndex() {
let res = await indexServe.index();
console.log("index: ",res);
item(_(".swiper-wrapper .swiper-slide ul")[0],res.list)
}
}
new Index()

View File

@@ -0,0 +1,33 @@
class Info {
constructor() {
this.page = 0;
this.pageRes = []
header(
query("title"),
'<i class="iconfont icon-xin"></i>'
)
this.getInfo()
}
async getInfo() {
let res = await indexServe.info({
id: query("id"),
// quantity: parseInt(query("quantity") / 20)
quantity: query("quantity")
});
for (let i = 0; i < res.length; i+=10) {
this.pageRes.push(res.slice(i, i + 10))
}
this.renderPage()
}
renderPage() {
$(".content").html(
this.pageRes[this.page].map(v => {
return `<img src="${v}" alt="">`
})
)
}
}
new Info()

View File

@@ -0,0 +1,7 @@
class Institution {
constructor() {
footer()
}
}
new Institution()

View File

@@ -0,0 +1,7 @@
class Model {
constructor() {
footer()
}
}
new Model()

View File

@@ -0,0 +1,7 @@
class My {
constructor() {
footer()
}
}
new My()