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,139 @@
class Index {
constructor() {
this.getBanner();
this.getType();
this.getThreeMeals();
}
async getIndexClass() {
var res = await indexService.indexClass({type:1,page:1});
}
//轮播图
async getBanner() {
var res = await indexService.banner();
let banners=document.querySelector('.swiper-wrapper');
res.forEach((item,index) => {
banners.innerHTML+=`
<li>
<a href="./bannerInfo.html?id=${item.url}">
<img src="${item.img}" alt="">
</a>
</li>
`;
});
new Swiper(".swiper",{
time: 1000,
initialSlide: 0,
loop: false,
speed: 300,
autoplay: false,
grabCursor: true,
});
}
//轮播图下面的九宫格
async getType() {
var res = await indexService.type();
let jiugong=document.querySelector('.jiu ul');
res.forEach((item,index)=>{
jiugong.innerHTML+=`
<li>
<a href="./jiugongInfo.html?id=${item.href}">
<img src="${item.img}" alt="">
<span>${item.title}</span>
</a>
</li>
`;
})
}
//每日三餐
async getThreeMeals() {
var res = await indexService.threeMeals();
let sancan=document.querySelector('.sancan_ul');
let three=document.querySelector('.wrapper_list');
res.forEach((item,index)=>{
sancan.innerHTML+=`
<li class='${index==0?'activesan':''}'>${item.title}</li>
`;
});
res.forEach((item,index)=>{
three.innerHTML+=`
<li class="three_meals_list">
${
( item.content.map((a,b)=>{
return ` <div class="three_meals_item">
<img src="${a.img}" alt="">
<div class="text">${a.title}</div>
<div class="yang"></div>
<div class="desc">${a.des}</div>
</div>`
})).join('')
}
</li>
`;
});
var thress=document.querySelectorAll('.sancan_ul li');
var threeSwiper= new Swiper(".swiper_list",{
time: 1000,
initialSlide: 0,
loop: false,
speed: 300,
autoplay: false,
grabCursor: true,
swiperWrapper: '.wrapper_list',
pagination: {
el: '.pagination'
},
on:{
slideChange:function (index) {
thress.forEach((q,w)=>{
q.className='';
thress[index].className='activesan';
})
}
}
});
thress.forEach((item,index)=>{
item.onclick=()=>{
thress.forEach((i,j)=>{
i.className='';
})
item.className='activesan';
threeSwiper.slideTo(index)
}
})
}
initSwiper(){
// 初始banner轮播
}
}
new Index();

View File

@@ -0,0 +1,41 @@
class Search{
constructor(){
this.page=1;
this.getSearch();
}
async getSearch() {
// var res = await indexService.search();
let div=document.querySelector('.header div');
let input=document.querySelector('.header input');
let conn=document.querySelector('.content');
input.onfocus=()=>{
input.value='';
};
div.onclick=async()=>{
let ser= await indexService.search({
q:input.value,
page:'1',
});
ser.forEach((item,index)=>{
conn.innerHTML+=`
<a href=''>
<div class="three_meals_item">
<img src="${item.img}" alt="">
<div class="text">${item.title}</div>
<div class="desc">${item.des}</div>
</div>
</a>
`;
})
};
}
}
new Search();

View File

@@ -0,0 +1,66 @@
class Video{
constructor(){
this.page = 0;
this.getVoid();
this.scrolles();
}
async getVoid(){
let connt=document.querySelector('.content');
var res = await indexService.video();
console.log(res.items);
connt.innerHTML+='';
res.items.forEach((item,index) => {
connt.innerHTML+=`
<a class="tuitupian" href="./voidInfo.html?vid=${item.xhz_video_url}&tid=${item.seo_title}&inif=${item.intro}">
<img src="${item.bd_photo}" alt="">
<i class="iconfont icon-shipin"></i>
<span>${item.seo_title}</span>
<div class="yonghu">
<div>
<img src="https://st-cn.meishij.net/user/68/143/ns13598318_155093722619492.jpg" alt="">
<span>阿青美食</span>
</div>
<div>
<i class="iconfont icon-yanjing"></i>
<span>${item.click_num}</span>
</div>
</div>
</a>
`;
});
this.scrolles(()=>{
this.page+=1;
this.getVoid();
})
}
scrolles(callback) {
let body=document.querySelector('body');
body.onscroll = () => {
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
let clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
if(scrollHeight > clientHeight && scrollTop + clientHeight === scrollHeight) {
callback();
}
}
}
}
new Video();

View File

@@ -0,0 +1,28 @@
class VoidInfo{
constructor(){
this.getVoidInfo();
}
async getVoidInfo(){
let video=document.querySelector('.header video');
let h2=document.querySelector('.content h2');
let p=document.querySelector('.content p');
video.src=getUrlSearch('vid');
h2.innerHTML=getUrlSearch('tid');
p.innerHTML=getUrlSearch('inif');
}
}
new VoidInfo();
function getUrlSearch(name) {
        if (!name) return null;
        var after = window.location.search;
        after = after.substr(1) || window.location.hash.split('?')[1];
        if (!after) return null;
        if (after.indexOf(name) === -1) return null;
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
        var r = decodeURI(after).match(reg);
        if (!r) return null;
        return r[2];
    }