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,192 @@
class Index {
constructor() {
this.currentIndex = 0;
this.classArr = [
{ id: 1, title: '推荐', page: 1, total_page: 0, content: [] },
{ id: 2, title: '时令', page: 1, total_page: 0, content: [] },
{ id: 3, title: '食肉', page: 1, total_page: 0, content: [] },
{ id: 4, title: '素食', page: 1, total_page: 0, content: [] },
{ id: 5, title: '烘焙', page: 1, total_page: 0, content: [] },
]
this.getIndex();
this.getBanner();
this.getType();
this.renderLi()
footer()
}
renderLi() {
this.classArr.forEach((v,i) => {
$(".djdzz ul").append(`
<li class="${i == 0 ? 'active' : ''}">${v.title}</li>
`);
$(".djdzz-container .swiper-wrapper").append(`
<div class="swiper-slide ${i == 0 ? '' : 'ai'}">
<div class="mrsc_list cj-item"></div>
</div>
`);
});
var li_arr = $(".djdzz ul li");
var swiperSlide = $(".djdzz-container .swiper-slide")
var self = this;
var djdzz = new Swiper('.djdzz-container', {
on: {
slideChangeTransitionStart: function () {
self.currentIndex = this.activeIndex;
swiperSlide.eq(this.activeIndex).removeClass("ai").siblings().addClass("ai")
li_arr.eq(this.activeIndex).addClass("active").siblings().removeClass("active")
// self.getClassList()
},
},
});
li_arr.click(function() {
djdzz.slideTo($(this).index())
});
this.getClassList();
var abc = () => {
console.log(this)
this.classArr[this.currentIndex].page += 1;
this.getClassList("more");
}
var throttleFun = throttle(abc, 1000);
new auiScroll({ listen:true, distance: 200 },(ret) => {
if(ret.isToBottom){
throttleFun()
}
});
}
async getClassList(type = "click") {
var getData = async () => {
var res = await indexServe.classList({
type: this.classArr[this.currentIndex].id,
page: this.classArr[this.currentIndex].page
});
this.classArr[this.currentIndex].content = [
...this.classArr[this.currentIndex].content,
...res.items
]
var mrsc_list = $(".djdzz-container .mrsc_list")
mrsc_list.eq(this.currentIndex).empty()
this.classArr[this.currentIndex].content.forEach((v,i) => {
mrsc_list.eq(this.currentIndex).append(`
<a href="">
<div class="mrsc_list_item">
<img src="${Array.isArray(v.img) ? v.img[0] : v.img}" alt="">
<p class="tips_titles">${v.title}</p>
<span class="tips_text">养</span>
${
typeof v.label == "string" ||
v.label == null
? ''
: `<p class="tips">${v.label.desc}</p>`
}
</div>
</a>
`)
})
}
if (type == "click") {
if (this.classArr[this.currentIndex].content.length == 0) {
getData()
}
} else {
getData()
}
}
async getIndex() {
var res = await indexServe.threeMeals();
console.log(res);
res.forEach((v, i) => {
$(".dddd ul").append(`
<li class="${i == 0 ? 'active' : ''}">${v.title}</li>
`);
$(".mrsc-container .swiper-wrapper").append(`
<div class="swiper-slide">
<div class="mrsc_list">
${v.content.map(item => {
return `<a href="./info.html?url=${item.url}">
<div class="mrsc_list_item">
<img src="${item.img}" alt="">
<p class="tips_titles">${item.title}</p>
<span class="tips_text">养</span>
<p class="tips">${item.des}</p>
</div>
</a>`
}).toString().replaceAll(",", "")
}
</div>
</div>
`)
});
var li = $(".dddd ul li")
li.click(function() {
mySwiper.slideTo($(this).index())
})
var mySwiper = new Swiper('.mrsc-container', {
on: {
slideChangeTransitionStart: function () {
li.eq(this.activeIndex).addClass("active").siblings().removeClass("active")
},
},
})
}
async getType() {
let res = await indexServe.type();
res.forEach(v => {
$(".menu .aui-row").append(`
<div class="aui-col-5">
<img src="${v.img}" alt="">
<div class="aui-grid-label">${v.title}</div>
</div>
`)
});
}
async getBanner() {
var res = await indexServe.banner();
res.forEach(v => {
$(".banner-container .swiper-wrapper").append(`
<div class="swiper-slide">
<a href="">
<img src="${v.img}" alt="">
</a>
</div>
`)
});
var mySwiper = new Swiper('.banner-container', {
loop: true,
pagination: {
el: '.swiper-pagination',
},
})
}
}
new Index()

View File

@@ -0,0 +1,105 @@
class Info {
constructor() {
this.getInfo();
}
async getInfo() {
var res = await indexServe.info({
url: query("url")
});
$(".cpc_c1 h2").text(res.title)
$(".cpc_c1 .time").text(res.posttime)
res.Statistics.forEach(v => {
$(".yyinfos").append(`
<li>
<span>${v.title}</span>
<div class="jdw">
<div class="jd" style="${v.proportion}"></div>
</div>
</li>
`)
});
res.stepInfo.arr.forEach(v => {
$(".cpargsw").append(`
<li>
<div class="i" style="background-position: 0px ${v.position}px;"></div>
<span>${v.title}</span>
</li>
`)
});
$(".show_more .text").text(res.stepInfo.message)
$(".more span").click(function () {
$(".show_more").css({
height: 'auto'
})
$(".more").css({
display: 'none'
})
});
res.material.main.forEach(v => {
$(".zhuliao .list").append(`
<li>
<div class="list_title">${v.title}</div>
<div class="list_nums">${v.nums}</div>
</li>
`)
})
res.material.accessories.forEach(v => {
$(".fuliao .list").append(`
<li>
<div class="list_title">${v.title}</div>
<div class="list_nums">${v.nums}</div>
</li>
`)
});
res.DetailedSteps.forEach(v => {
$(".info_list").append(`
<li>
${
v.step_img == null
? `<div class="dddd">${v.step_title}</div>`
: `<div class="info_top ${Array.isArray(v.step_img)? 'aa':''}">
<img src="${Array.isArray(v.step_img) ? v.step_img[0] : v.step_img}" alt="">
<div class="setp">${v.step_title}</div>
</div>`
}
${
Array.isArray(v.step_img)
? `<div class="change_list">
${
v.step_img.map((v,i) => {
return `<img src="${v}" alt="" style="opacity: ${i == 0 ? 1 : 0.5}">`
}).toString().replaceAll(",","")
}
</div>`
: `<p>${v.step_text}</p>`
}
</li>
`)
})
$(".change_list img").click(function () {
$(this).css({
opacity: 1
}).siblings().css({
opacity: 0.5
})
$(".aa img").attr({
src: $(this).attr("src")
})
})
}
}
new Info()

View File

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