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,65 @@
(function() {
var pn = 0;
function getClassInfoData() {
$('.g-scrollview').infiniteScroll({
pageSize: 10,
initLoad: true,
loadingHtml: '<strong>加载中...</strong>',
loadListFn: function () {
var def = $.Deferred();
get({
url: '/index',
data: {
cid: returnId(),
pn: pn
},
callback: function(res) {
RenderList(res.data)
def.resolve(res.data);
++pn;
}
})
return def.promise();
}
})
}
function RenderList (data) {
data.forEach(val => {
$('article').append(`<a class="list-item">
<div class="list-img">
<img src="${val.albums[0]}">
</div>
<div class="list-mes">
<h3 class="list-title">${val.title}</h3>
<div class="list-mes-item">
<div>
<span class="list-del-price">${val.tags.substring(0,20)}..</span>
</div>
</div>
</div>
</a>`)
})
bindClick(data)
}
function bindClick (data) {
$("article a").on('click', function() {
localStorage.setItem("info", JSON.stringify(data[$(this).index()]))
location.href="info.html"
})
}
getClassInfoData()
})()

View File

@@ -0,0 +1,53 @@
(function() {
$('#J_Slider').slider({
speed: 300,
autoplay: 2000,
lazyLoad: true
});
var MenuList = ['西红柿','猪蹄','红烧肉','蛋炒饭','黄瓜']
function getData() {
get({
url: '/query',
data: {
menu: MenuList[Math.floor(Math.random()*5)]
},
callback: function(res) {
renderList(res)
}
})
}
function renderList (list) {
list.data.forEach(val => {
$('article').append(`<a class="list-item">
<div class="list-img">
<img src="${val.albums[0]}">
</div>
<div class="list-mes">
<h3 class="list-title">${val.title}</h3>
<div class="list-mes-item">
<div>
<span class="list-del-price">${val.ingredients.substring(0,17)}...</span>
</div>
</div>
</div>
</a>`)
});
bindClick(list.data)
}
function bindClick (data) {
$("article a").on('click', function() {
localStorage.setItem("info", JSON.stringify(data[$(this).index()]))
location.href="info.html"
})
}
getData()
})()

View File

@@ -0,0 +1,54 @@
(function(){
var InfoData = JSON.parse(localStorage.getItem("info"));
var LikeData = localStorage.getItem("like") == null
? []
: JSON.parse(localStorage.getItem("like"));
var status = true;
$(".info-header").css({
'background': `url(${InfoData.albums[0]}) no-repeat center center`,
'background-size': 'cover'
})
$('.info-title h3').text(InfoData.title)
$('.info-title p').text(InfoData.tags)
$('.item1 p').text(InfoData.ingredients)
$('.item2 p').text(InfoData.burden)
InfoData.steps.forEach((val,index) => {
$('.list-item ul').append(`<li>
<h2>${index == 0 ? InfoData.title+'步骤'+(index+1) : '步骤'+(index+1)}</h2>
<img src="${val.img}" alt="">
<p class="padding20">${val.step}</p>
</li>`)
});
$("#likefood").on('click', function () {
changeStatus()
if(status) {
LikeData.push(JSON.parse(localStorage.getItem("info")))
localStorage.setItem("like", JSON.stringify(LikeData))
$("#likefood").removeClass("icon-star-outline").addClass("icon-star")
} else {
YDUI.dialog.toast('您已经收藏过了', 'error', 1000);
}
});
function checkIsLike() {
changeStatus()
if(!status) {
$("#likefood").removeClass("icon-star-outline").addClass("icon-star")
}
}
function changeStatus () {
LikeData.forEach( val => val.id == InfoData.id ? status = false : status = true);
}
checkIsLike()
})()

View File

@@ -0,0 +1,63 @@
(function(){
var LikeData = localStorage.getItem("like") == null
? []
: JSON.parse(localStorage.getItem("like"));
function renderLike () {
if(LikeData.length == 0) {
$(".list-theme1").append("<p class='error'>没有收藏</p>")
} else {
LikeData.forEach(val => {
$(".list-theme1").append(`<a href="#" class="list-item">
<div class="list-img">
<img src="${val.albums[0]}">
</div>
<div class="list-mes">
<h3 class="list-title">${val.title}</h3>
</div>
</a>`)
});
}
}
function BindTagaClick() {
$("article a").on('click', function() {
localStorage.setItem("info", JSON.stringify(LikeData[$(this).index()]))
location.href="info.html"
});
var $as = $('#J_ActionSheet'), index = null;
$(".list-theme1 .list-item").on({
touchstart: function(e){
index = $(this).index()
setTimeout(function(){
$as.actionSheet('open');
},500);
}
});
$('.delete-like').on("click",function() {
LikeData.splice(index,1);
localStorage.setItem("like", JSON.stringify(LikeData));
$("article a").eq(index).remove();
$as.actionSheet('close');
if(LikeData.length == 0) {
$(".list-theme1").append("<p class='error'>没有收藏</p>")
}
})
$("#J_Cancel").on("click",function() {
$as.actionSheet('close');
})
}
renderLike()
BindTagaClick()
})()

View File

@@ -0,0 +1,12 @@
(function(){
$('.update').on('click', function () {
YDUI.dialog.loading.open('正在检查..');
setTimeout(function () {
YDUI.dialog.loading.close();
YDUI.dialog.toast('已经是最新版本', 'success', 1000);
}, 2000);
});
$('.contact').on('click', function () {
YDUI.dialog.toast('客服微信号cxy-monkey', 'success', 3000);
});
})()

View File

@@ -0,0 +1,37 @@
(function () {
var result = typeData.result;
console.log(result)
function renderLeft () {
result.forEach(function(val,index){
$(".type-left ul").append(` <li class="${ index == 0 ? 'active' : ''}">${val.name}</li>`)
});
}
function renderRight(index) {
$(".type-right ul").empty()
result[index].list.forEach(function(val){
$(".type-right ul").append(`<li> <a href="./classinfo.html?id=${val.id}">${val.name}</a> </li>`)
})
}
function bindLeftLiClick() {
if (returnId() != undefined) {
$(".type-left ul li").eq(returnId()).addClass("active").siblings().removeClass("active")
renderRight(returnId())
}
$(".type-left ul li").on('click',function(){
$(this).addClass("active").siblings().removeClass("active")
renderRight($(this).index())
})
}
renderLeft()
renderRight(0)
bindLeftLiClick()
})()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,24 @@
function get (params) {
YDUI.dialog.loading.open('正在请求数据...');
$.ajax({
url: `http://127.0.0.1:3000${params.url}`,
type: 'GET',
data: params.data,
success: function (res) {
YDUI.dialog.loading.close();
if(res.resultcode == "200") {
params.callback(res.result)
} else {
YDUI.dialog.toast(res.reason, 'error', 3000);
}
},
error: function(err) {
YDUI.dialog.loading.close();
YDUI.dialog.toast('抱歉,请求失败,请稍后重试', 'error', 3000);
}
})
}
function returnId() {
return location.search.split("=")[1]
}

View File

@@ -0,0 +1,38 @@
/**
* YDUI 可伸缩布局方案
* rem计算方式设计图尺寸px / 100 = 实际rem 例: 100px = 1rem
*/
!function (window) {
/* 设计图文档宽度 */
var docWidth = 750;
var doc = window.document,
docEl = doc.documentElement,
resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
var recalc = (function refreshRem () {
var clientWidth = docEl.getBoundingClientRect().width;
/* 8.55小于320px不再缩小11.2大于420px不再放大 */
docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / docWidth), 11.2), 8.55) * 5 + 'px';
return refreshRem;
})();
/* 添加倍屏标识安卓倍屏为1 */
docEl.setAttribute('data-dpr', window.navigator.appVersion.match(/iphone/gi) ? window.devicePixelRatio : 1);
if (/iP(hone|od|ad)/.test(window.navigator.userAgent)) {
/* 添加IOS标识 */
doc.documentElement.classList.add('ios');
/* IOS8以上给html添加hairline样式以便特殊处理 */
if (parseInt(window.navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/)[1], 10) >= 8)
doc.documentElement.classList.add('hairline');
}
if (!doc.addEventListener) return;
window.addEventListener(resizeEvt, recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
}(window);

File diff suppressed because it is too large Load Diff