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,69 @@
class Edit {
constructor() {
pHeader("分类编辑")
// 已选
this.principal = get_storage("principal")
// 待选
this.additional = get_storage("additional")
this.yx();
}
yx () {
$(".yx").empty()
this.principal.forEach(v => {
$(".yx").append(`
<li>${v.title}</li>
`)
});
var self = this
$(".yx li").click(function () {
self.additional.push(self.principal[$(this).index()])
self.principal = self.principal.filter((v,i) => {
if (i != $(this).index()) {
return v
}
});
set_storage("principal", self.principal)
set_storage("additional", self.additional)
self.yx()
})
$(".dx").empty()
this.additional.forEach(v => {
$(".dx").append(`
<li>${v.title}</li>
`)
})
var self = this
$(".dx li").click(function () {
self.principal.push(self.additional[$(this).index()])
self.additional = self.additional.filter((v,i) => {
if (i != $(this).index()) {
return v
}
});
set_storage("principal", self.principal)
set_storage("additional", self.additional)
self.yx()
})
}
}
new Edit()

View File

@@ -0,0 +1,142 @@
class Index {
constructor() {
this.currentIndex = 0;
this.classData = []
this.geIndex();
this.GetType();
footer()
lui.scrollToBottom('.swiper-slide-active',function(){
console.log("11")
})
}
async GetType() {
var principal = [], additional = []
if (localStorage.getItem("principal") == null) {
let res = await indexServe.type();
principal = res.principal
additional = res.additional
localStorage.setItem("principal", JSON.stringify(principal))
localStorage.setItem("additional", JSON.stringify(additional))
} else {
principal = get_storage("principal")
additional = get_storage("additional")
}
var self = this;
principal.unshift({
title: '首页',
id: -1,
page: 0,
content: []
})
this.classData = principal
principal.forEach((v,i) => {
$(".header_menu ul").append(`
<li class="${i == 0 ? 'active': ''}">${v.title}</li>
`)
if (i > 0) {
$(".page-wrapper").append(`
<div class="swiper-slide eee list_fa padding_16 top"></div>
`)
}
});
var page = new Swiper ('.page-container', {
direction: 'horizontal',
on:{
slideChange: function (){
self.currentIndex = this.activeIndex;
$(".header_menu ul li").eq(this.activeIndex).addClass("active").siblings().removeClass("active")
self.getClassList();
},
},
})
$(".header_menu ul li").click(function () {
self.currentIndex = $(this).index()
$(this).addClass("active").siblings().removeClass("active")
page.slideTo($(this).index())
})
}
async getClassList() {
if (this.classData[this.currentIndex].id != -1) {
if (this.classData[this.currentIndex].content.length == 0) {
let res = await indexServe.classList({
page: this.classData[this.currentIndex].page,
id: this.classData[this.currentIndex].id
});
this.classData[this.currentIndex].total_page = res.total_page
this.classData[this.currentIndex].content = [
...this.classData[this.currentIndex].content,
...res.data
]
item($(".page-wrapper .eee").eq(this.currentIndex -1),
this.classData[this.currentIndex].content)
}
}
}
async geIndex() {
let data = await indexServe.index()
console.log(data)
var modelArr = [ { content: [] }, { content: [] } ]
data.model.res.forEach((v,i) => {
if (i<4) {
modelArr[0].content.push(v)
} else {
modelArr[1].content.push(v)
}
})
modelArr.forEach(v=> {
$(".model-wrapper").append(`
<ul class="swiper-slide">
${
v.content.map(item => {
return ` <li>
<a href="">
<div class="top">
<img src="${item.preview}" alt="">
<span>${item.total}</span>
</div>
<p>${item.title}</p>
</a>
</li>`
}).toString().replaceAll(",","")
}
</ul>
`)
})
item(".news", data.newest.data)
item(".remm", data.recommended.data)
new Swiper ('.model-container', {
direction: 'horizontal',
})
}
}
new Index()

View File

@@ -0,0 +1,119 @@
class Info {
constructor() {
this.res = {}
this.like = {}
this.likeArr =
localStorage.getItem("like") == null
? []
: JSON.parse(localStorage.getItem("like"))
this.page = 1;
this.total_page = 0;
this.pswpElement = $(".pswp")[0]
this.getInfo()
.then(() => this.renderInfo())
}
async getInfo() {
this.res = await indexServe.info({
page: this.page,
id: query("id")
});
this.total_page = this.res.total_page
// this.total_page = 3
// 详情页
this.res.data.forEach(v => {
var image = new Image();
image.src = v.src
image.onload = () => {
if (image.width < image.height) {
this.like.preview = v.src
}
$(".info_img").append(`
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<a href="${v.src}" itemprop="contentUrl" data-size="${image.width}x${image.height}">
<img src="${v.src}" itemprop="thumbnail" alt="${v.title}" />
</a>
<figcaption itemprop="caption description">${v.title}</figcaption>
</figure>
`)
}
})
initPhotoSwipeFromDOM(".info_img")
$(".tuijian").empty()
$(".xianguan").empty()
item(".tuijian", this.res.recommend)
item(".xianguan", this.res.relevant)
}
renderInfo() {
console.log(this.res)
pHeader(this.res.title, `
<i class="iconfont like icon-xin"></i>
<i class="iconfont icon-home"></i>
`);
this.like = {
id: query("id"),
title: this.res.title,
total: this.res.total,
preview: ''
}
var isHave = this.likeArr.filter((v,i) => {
if (v.id == query("id")) {
return v
}
})
// 本地收藏过了
if (isHave.length != 0) {
$(".like").removeClass("icon-xin")
$(".like").addClass("icon-aixin")
} else {
$(".like").removeClass("icon-aixin")
$(".like").addClass("icon-xin")
}
$(".like").click(() => {
// 如果空心,表示未收藏,改成实心 收藏
if ($(".like").hasClass("icon-xin")) {
$(".like").removeClass("icon-xin")
$(".like").addClass("icon-aixin")
this.likeArr.push(this.like)
localStorage.setItem("like",JSON.stringify(this.likeArr))
// 取消收藏
} else {
$(".like").removeClass("icon-aixin")
$(".like").addClass("icon-xin")
this.likeArr = this.likeArr.filter((v,i) => {
if (v.id != query("id")) {
return v
}
})
localStorage.setItem("like",JSON.stringify(this.likeArr))
}
})
$(".icon-xiangxia").click(() => {
this.page+=1
if (this.page == this.total_page) {
$(".icon-xiangxia").hide()
}
this.getInfo()
})
}
}
new Info();

View File

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