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,37 @@
class Collection {
constructor() {
title("我的收藏")
this.likeArr = JSON.stringify(localStorage.getItem("like"))
this.likeArr
}
async getLike() {
var self = this;
if (localStorage.setItem("like") == null) {
var res = await IndexService.classList();
this.likeArr = res.likeArr
localStorage.setItem("like", JSON.stringify(this.likeArr))
}
else {
this.likeArr = JSON.parse(localStorage.setItem("like"))
}
}
renderlikeArr() {
this.likeArr.forEach(v => {
$(".content").innerHTML += `
<li>${v}</li>
`
});
}
}
new Collection()

View File

@@ -0,0 +1,53 @@
class Edit {
constructor() {
title("分类管理")
this.principal = JSON.parse(localStorage.getItem("principal"))
this.additional = JSON.parse(localStorage.getItem("additional"))
this.renderPage()
}
renderPage() {
$(".selected ul").innerHTML = ""
this.principal.forEach(v => {
$(".selected ul").innerHTML += `
<li>${v.title}</li>
`
});
$(".optional ul").innerHTML = ""
this.additional.forEach(v => {
$(".optional ul").innerHTML += `
<li>${v.title}</li>
`
});
click(".selected ul li", (v,i) => {
if (i != 0) {
this.additional.push(this.principal[i])
this.principal = this.principal.filter((val,index) => {
return index != i
});
localStorage.setItem("principal", JSON.stringify(this.principal))
localStorage.setItem("additional", JSON.stringify(this.additional))
this.renderPage()
}
})
click(".optional ul li", (v,i) => {
this.principal.push(this.additional[i])
this.additional = this.additional.filter((val,index) => {
return index != i
});
localStorage.setItem("principal", JSON.stringify(this.principal))
localStorage.setItem("additional", JSON.stringify(this.additional))
this.renderPage()
})
}
}
new Edit()

View File

@@ -0,0 +1,130 @@
class Index {
constructor() {
this.index = 0;
this.principa = []
footer();
this.initSwiper();
this.getType().then(() => this.getIndex());
}
async getType() {
// 本地无数值,那么发送请求
if (localStorage.getItem("principal") == null) {
var { principal, additional } = await indexService.type()
localStorage.setItem("principal", JSON.stringify(principal))
localStorage.setItem("additional", JSON.stringify(additional))
} else {
var principal = JSON.parse(localStorage.getItem("principal"))
var additional = JSON.parse(localStorage.getItem("additional"))
}
this.principal = principal;
console.log(this.principal);
// TODO 改造这个代码,实现下面的作业
this.principal.forEach((v, i) => {
$(".header_menu ul").innerHTML += `<li class="${i == 0 ? 'active' : ''}">${v.title}</li>`;
$(".swiper .swiper-wrapper").innerHTML += `
<div class="swiper-slide">
<div class="list">
</div>
</div>
`;
});
click(".header_menu ul li", (v, i) => {
_(".header_menu ul li").forEach(v => v.classList.remove("active"))
v.classList.add("active")
this.index = i
this.getClassList()
this.mySwiper.slideTo(i)
})
_(".swiper .swiper-wrapper .swiper-slide").forEach((v,i) => {
if (i != 0) {
v.onscroll = () => {
const {clientHeight, scrollHeight, scrollTop} = v;
var distance = scrollHeight- scrollTop - clientHeight;
if (distance <= 0.5) {
this.principal[this.index].page += 1
if (this.principal[this.index].page <= this.principal[this.index].total_page) {
this.getClassList("loadMore")
}
}
}
}
})
// 作业:在utils里面 实现下面这种封装
// principal.html(".header_menu ul", (v,i) => {
// return `<li class="${i == 0 ? 'active' : ''}">${v.title}</li>`
// })
}
async getIndex() {
var res = await indexService.index()
this.principal[this.index].content = res.list
item(
_(".swiper .swiper-wrapper .swiper-slide .list")[this.index],
this.principal[this.index].content
)
}
async getClassList(type = "click") {
var getList = async () => {
var res = await indexService.classList({
page: this.principal[this.index].page,
id: this.principal[this.index].id
});
this.principal[this.index].content = [
...this.principal[this.index].content,
...res.data
]
this.principal[this.index].total_page = res.total_page
console.log("getClassList: ", this.principal);
// 渲染页面(注意:把指定数组下标的content渲染到对应下标的 swiper-slide)
item(
_(".swiper .swiper-wrapper .swiper-slide .list")[this.index],
this.principal[this.index].content
)
}
if (type == "click") {
if (this.principal[this.index].content.length == 0 && this.index != 0) {
getList();
}
} else {
getList();
}
}
initSwiper() {
var self = this;
this.mySwiper = new Swiper('.swiper', {
direction: 'horizontal',
on: {
slideChangeTransitionEnd: function () {
_(".header_menu ul li").forEach(v => v.classList.remove("active"))
_(".header_menu ul li")[this.activeIndex].classList.add("active")
self.index = this.activeIndex
self.getClassList()
},
},
})
}
}
new Index()

View File

@@ -0,0 +1,72 @@
class Info {
constructor() {
this.infoArr = []
this.likeArr = JSON.parse(localStorage.getItem("like")) == null
? []
: JSON.parse(localStorage.getItem("like"))
title(query("title"), `<i class="like iconfont icon-xin"></i>`)
this.getInfo()
this.like()
}
async getInfo() {
this.infoArr = await indexService.info({
id: query("id"),
quantity: query("quantity")
});
this.infoArr.forEach((v,i) => {
var img = document.createElement("img")
img.src = v;
img.onload = () => {
$(".imgList").innerHTML += `
<figure>
<a href="${v}" data-size="${img.width}x${img.height}">
<img src="${v}" alt="${v}" />
</a>
<figcaption itemprop="caption description">${query("title")} ${i+1}P</figcaption>
</figure>
`
}
});
initPhotoSwipeFromDOM('.imgList');
}
like() {
var res = this.likeArr.filter((v,i) => {
return query("id") == v.id
});
if (res.length != 0) {
$(".like").classList.replace("icon-xin", "icon-aixin")
}
click(".like", () => {
// 空心 未收藏 去收藏
if ($(".like").classList.contains("icon-xin")) {
$(".like").classList.replace("icon-xin", "icon-aixin")
this.likeArr.push({
id: query("id"),
quantity: query("quantity"),
img: this.infoArr[0]
});
} else {
$(".like").classList.replace("icon-aixin", "icon-xin")
this.likeArr = this.likeArr.filter((v,i) => {
return query("id") != v.id
});
}
localStorage.setItem("like", JSON.stringify(this.likeArr))
})
}
}
new Info();

View File

@@ -0,0 +1,10 @@
class Me {
constructor() {
footer()
title("我的收藏")
}
}
new Me()

View File

@@ -0,0 +1,24 @@
class Mechanism {
constructor () {
footer()
title('机构')
this.getmechanism()
}
async getmechanism() {
var res = await indexService.mechanism({ });
console.log("test:",res)
res.forEach((v) => {
$(".list").innerHTML += `
<a href="./mechanisminfo.html?id=${v.id}&title=${v.title}" class="shuliang">
<div class="title">${v.title}</div>
<div class="number">${v.id}套</div>
</a>
`
})
}
}
new Mechanism()

View File

@@ -0,0 +1,35 @@
// class Model {
// constructor () {
// footer()
// }
// }
// new Model()
class Model {
constructor() {
footer()
title("模特")
this.getModel()
//this.renderModelPage()
}
async getModel() {
var res = await modelService.model();
console.log("list接口数据",res);
res.forEach((v => {
$(".model_list").innerHTML += `
<a href="./modelinfo.html?id=${v.id}&title=${v.title}">
<i>44张</i>
<img src="${v.img}" alt="">
<span class="ellipsis">${v.title}</span>
</a>
`
}))
}
}
new Model()

View File

@@ -0,0 +1,53 @@
class Modelinfo {
constructor() {
this.list = [];
title(query("title"))
this.appear = true
this.page = 1
this.getmodelList();
}
async getmodelList() {
var self = this;
var res = await indexService.modelList({
id: query("id"),
page: this.page
})
//每次请求接口得到结果,把数组累加
res.data.forEach(element => {
this.list.push(element)
});
//判断是否第一次请求,是 === 渲染简介 否 === 不渲染
if (this.appear) {this.modelList($('.title'),res) }
this.testModelList($('.test'), this.list)
}
modelList(father, data) {
father.innerHTML +=`
<img src="${data.model_info.portrait}" alt="">
<div class="name">
<p>${data.model_info.name}</p>
<p>${data.model_info.explain} </p>
</div>
`
}
testModelList(father, data) {
data.forEach((value, index) => {
father.innerHTML +=
`
<img src="${value.img_src}" alt="">
`
})
}
}
new Modelinfo();

View File

@@ -0,0 +1,67 @@
class Search {
constructor() {
footer()
this.getSearch()
this.seek()
}
async seek(newKey) {
var res = await indexService.search({
keyword: newKey,
page: 1
});
item($(".recommend .list"), res)
}
hidden (){
$(".suggest").style.display = "none"
$(".recommend").style.display = "block"
}
show (){
$(".suggest").style.display = "block"
$(".recommend").style.display = "none"
}
async getSearch() {
var res = await indexService.search({
keyword: "长裙",
page: 1
});
res.forEach(v => {
$(".suggest_list").innerHTML += `
<li class="ellipsis">${v.biaoqianlist[0].name}</li>
`
});
// item($(".recommend .list"), res)
//获取输入框值
$(".search_box").oninput = () => {
if ($(".search_box").value.length > 0) {
this.seek($(".search_box").value)
}
}
//input获得焦点
$(".search_box").onfocus = () => {
this.show()
}
$(".content").onclick = () => {
this.hidden()
}
//标签绑定点击事件
click(".suggest_list li", (v, i) => {
$(".search_box").value = v.innerText
this.seek($(".search_box").value)
this.hidden()
})
//绑定搜索按钮
click(".icon-search", async (v, i) => {
this.seek($(".search_box").value)
this.hidden()
})
click(".icon-back1", () => {
history.back()
})
}
}
new Search()

View File

@@ -0,0 +1,21 @@
class Tags {
constructor() {
title(query("name"))
footer()
this.getTags()
}
async getTags() {
this.res = await indexService.classList({
id: query("id"),
page: 1,
});
this.res.data.forEach((v, i) => {
item($(".swiper-slide .list"),this.res.data)
});
}
}
new Tags()