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,32 @@
var config = {
environment: 'prod', // 当前项目所属的开发环境 dev,test,prod
baseUrl () {
switch (config.environment) {
case "dev":
return config.devbasrUrl;
break;
case "test":
return config.testbasrUrl;
break;
case "prod":
return config.prodbasrUrl;
break;
}
},
devbasrUrl: 'http://127.0.0.1:3000/api/json', // dev 开发阶段
testbasrUrl: 'http://127.0.0.1:3000/test', // test 测试阶段
prodbasrUrl: 'http://47.114.153.249:3000/api/json', // prod 正式阶段
apiList: {
index: '/index', // 获取首页数据,
info: '/info', // 进入详情
type: '/class', // 获取分类接口
mechanism:'/mechanism', // 获取机构接口
mechanismList: '/mechanismList', //获取机构详情接口
search: '/search', // 搜索接口
allModel: '/allModel', // 所有模特
modelList: '/modelList', // 进入模特的个人主页
}
}

View File

@@ -0,0 +1,53 @@
class Api {
constructor() {
this.baseUrl = config.baseUrl();
}
get(option) {
YDUI.dialog.loading.open('很快加载好了');
return new Promise((resolve,reject) => {
$.ajax({
type: "GET",
url: this.baseUrl + option.url,
data: option.data,
success: (res) => {
this.checkStatus(resolve,res)
},
error: (err) => {
reject(err)
}
});
})
}
post(option) {
return new Promise((resolve,reject) => {
$.ajax({
type: "POST",
url: this.baseUrl + option.url,
data: option.data,
success: (res) => {
this.checkStatus(resolve,res)
},
error: (err) => {
reject(err)
}
});
})
}
checkStatus(resolve,res) {
YDUI.dialog.loading.close();
switch (res.status) {
case 200:
resolve(res.result);
break;
case 500:
throw new Error(res.msg);
break;
}
}
}

View File

@@ -0,0 +1,88 @@
class Cation {
constructor() {
this.getCation();
// 这里的俩个数组不能直接为空数组,不然刷新之后就会被立即置空,应该是从本地里面动态的读出来的
this.topList = localStorage.getItem('type')==null?[]:JSON.parse(localStorage.getItem('type'));
this.bottomList = localStorage.getItem('bottom_type')==null?[]:JSON.parse(localStorage.getItem('bottom_type'));
}
getCation() {
//吧type里面的值赋值给空数组topList
this.topList = JSON.parse(localStorage.getItem('type'));
console.log(this.topList);
// 遍历,渲染进上面的页面
$('.top_li').html('');
$(this.topList).each((index,item) => {
$('.top_li').append(`<li>${item.title}</li>`);
})
//调用onclick函数
this.onclick();
//jq情况网页元素使用html
$('.bottom_li').html('');
//从localStorage取出来赋值
this.bottomList=JSON.parse(localStorage.getItem('bottom_type'));
//遍历渲染
$(this.bottomList).each((index,item)=>{
$('.bottom_li').append(`<li>${item.title}</li>`)
})
console.log(this.bottomList);
this.bottomLick();
}
// 点击事件函数
onclick() {
//拿到上面页面的li
$('.top_li li').each((index,item) => {
// 注册点击事件
$(item).click(()=>{
//点谁就把谁追加近bottomList
this.bottomList.push(JSON.parse(localStorage.getItem('type'))[index]);
//存入localStorage
localStorage.setItem('bottom_type',JSON.stringify(this.bottomList))
//过滤好的值查询赋值给res
let res = JSON.parse(localStorage.getItem('type')).filter((i, j) => {
//i。id就是所有的值,JSON.parse(localStorage.getItem('type'))[index].id)是我们点击时的当前值
//这句话的意思就是点击谁就把其他返回出去,点击的过滤掉
if (i.id != JSON.parse(localStorage.getItem('type'))[index].id) {
return i;
}
});
// 然后存入localStorage中,记得使用JSON.stringify()转换
localStorage.setItem('type',JSON.stringify(res));
// 在重新调用上面的方法,遍历渲染进页面,就完成了点谁去除谁的骚操作了
this.getCation();
})
})
}
bottomLick(){
$('.bottom_li li').each((j,i)=>{
$(i).click(()=>{
this.topList.push(JSON.parse(localStorage.getItem('bottom_type'))[j]);
localStorage.setItem('type',JSON.stringify(this.topList))
let msg= JSON.parse(localStorage.getItem('bottom_type')).filter((x,y)=>{
if(x.id != JSON.parse(localStorage.getItem('bottom_type'))[j].id){
return x;
}
});
localStorage.setItem('bottom_type',JSON.stringify(msg));
this.getCation();
})
})
}
}
new Cation();

View File

@@ -0,0 +1,87 @@
class Index {
constructor() {
this.home();
this.getType()
this.initSwiper();
this.initHome();
}
async getType() {
var res = {};
if (localStorage.getItem("type") == null) {
res = await indexService.type();
res.principal.unshift({
id: -1,
page: 0,
title: "首页"
})
localStorage.setItem("type",JSON.stringify(res.principal));
}
res = JSON.parse(localStorage.getItem("type"))
res.forEach((v,i)=> {
$(".menu_list").append(`
<li class="${i == 0 ? 'menu_active' : ''}">${v.title}</li>
`)
});
res.forEach((v,i)=> {
if (i > 0) {
$(".swiper-wrapper").append(`
<div class="swiper-slide">
<h2>${v.title}</h2>
</div>
`)
}
})
console.log(res)
}
async home () {
var res = await indexService.home();
// $(".a").append(item(res.newest.data))
// $(".b").append(item(res.model.data))
console.log()
console.log(res)
}
initHome() {
new Swiper ('#modelSwiper', {
direction: 'horizontal',
// 如果需要分页器
pagination: {
el: '.modelPagination',
},
});
}
initSwiper () {
var mySwiper = new Swiper ('#pageSwiper', {
direction: 'horizontal',
on: {
slideChangeTransitionEnd: function(){
$(".menu_list li").eq(this.activeIndex)
.addClass("menu_active").siblings().removeClass("menu_active")
},
},
});
$(".menu_list li").click(function () {
$(this).addClass("menu_active").siblings().removeClass("menu_active");
mySwiper.slideTo($(this).index(),300)
})
}
}
new Index();

View File

@@ -0,0 +1,110 @@
class infoget {
constructor() {
this.likeList
= localStorage.getItem("list") == null
? []
: JSON.parse(localStorage.getItem("list"));
this.currentifo = {},
this.infoSevice()
}
async infoSevice () {
var res = await infoSevice.infoSevice({
page:1,
id:GetUrlParam("id"),
t:GetUrlParam("name"),
});
this.currentifo = res
$(".action").append(`
<a onclick=window.history.go(-1)> <i class="iconfont icon-back1"></i></a>
<span>写真集详情</span>
`)
res.data.forEach((v) =>{
$(".info").append(`
<figure>
<a href="" data-size="1800x2700">
<img src="${v.src}"
alt="${v.title}">
</a>
</figure>
`)
})
this.like();
}
like() {
var isHave = this.likeList.filter((items,index) => {
// console.log(items)
if (item.data != this.currentifo.data) {
// console.log(this.currentifo.data[0].title)
return items
}
});
isHave.forEach((v,i)=>{
console.log(v.title)
console.log(this.currentifo.data[i].title)
if (v.title = this.currentifo.data[i].title) {
$(".likeicon").removeClass("icon-xin").addClass("icon-aixin");
}
})
// 切换收藏 与 取消收藏
$('.likeicon').on('click', () =>{
// console.log(this.currentifo)
if ($(".likeicon").hasClass("icon-xin")) {
$(".likeicon").removeClass("icon-xin ").addClass("icon-aixin");
this.likeList.push(this.currentifo)
// console.log(this.likeList)
localStorage.setItem("list", JSON.stringify(this.likeList))
} else {
$(".likeicon").removeClass("icon-aixin ").addClass("icon-xin");
this.likeList = this.likeList.filter((item,index) => {
// console.log("item.data",item.data)
// console.log("this.currentifo.data",this.currentifo.data)
if (item.data !== this.currentifo.data) {
return item
}
// console.log(item)
});
localStorage.setItem("list", JSON.stringify(this.likeList))
}
})
}
}
function GetUrlParam(paraName) {
var url = document.location.toString();
var arrObj = url.split("?");
if (arrObj.length > 1) {
var arrPara = arrObj[1].split("&");
var arr;
for (var i = 0; i < arrPara.length; i++) {
arr = arrPara[i].split("=");
if (arr != null && arr[0] == paraName) {
return arr[1];
}
}
return "";
}
else {
return "";
}
}
new infoget();

View File

@@ -0,0 +1,29 @@
class Mechanism {
constructor() {
this.mechanism()
}
async mechanism () {
var res = await mechanismService.mechanism();
console.log(res)
for (let index in res) {
// console.log(index)
// console.log(res[index])
// console.log(res[index].title)
$(".mechanism_list").append(
`
<li>
<a href="./mechanism_info.html?id=${res[index].id}&t=${res[index].title}&type=mechanism">
<p>${res[index].title}</p>
<span>${res[index].quantity}</span>
</a>
</li>
`
)
}
}
}
new Mechanism();

View File

@@ -0,0 +1,37 @@
class MechanismList {
constructor() {
this.mechanList()
// console.log(window.top.document.URL)
}
async mechanList () {
var res = await mechInfoService.mechanismList({
page:0,
id:`${urlId}`
});
console.log(res)
$(".jg_list ul").append(item(res.data))
$(".action").append(`
<i class="iconfont icon-back1"></ihre>
<span>${unit_title}</span>
`)
}
}
var url = document.location.toString();//获取url地址
var urlParmStr = url.slice(url.indexOf('?')+1);//获取问号后所有的字符串
var arr = urlParmStr.split('&');//通过&符号将字符串分割转成数组
var urlId = arr[0].split("=")[1];//获取数组中第一个参数
var unit_title=arr[1].split("=")[1];//第二个参数
unit_title=decodeURI(unit_title);//转码将解码方式unscape换为decodeURI,将中文参数获取
console.log(unit_title)
new MechanismList();

View File

@@ -0,0 +1,59 @@
class Model {
constructor() {
this.GetModelList({});
this.newModelList = []
}
async GetModelList() {
var res = await modelService.Model();
console.log(res);
var hot_models = res.hot_models;
var newest = res.newest;
this.newModelList = [...hot_models, ...newest]
this.RenderModelItem(hot_models, '.hot_models')
this.RenderModelItem(newest, '.newest')
}
RenderModelItem(data, className) {
if (className == ".hot_models") {
$(`${className} .title`).text('热门模特')
} else {
$(`${className} .title`).text('最新模特')
}
data.forEach(v => {
$(`${className} .model_list`).append(
`
<div class="item">
<div class="top">
<img src="${v.preview}" alt="${v.title}">
${
v.total.length == 0
? ''
: `<span>${v.total}</span>`
}
</div>
<p>${v.title}</p>
</div>
`
)
this.BindItemClick();
});
}
BindItemClick() {
var Item = document.querySelectorAll(".item");
Item.forEach((v,i)=>{
v.onclick = () => {
location.href = `model_info.html?id=${this.newModelList[i].id}&t=${this.newModelList[i].title}`
}
})
}
}
new Model();

View File

@@ -0,0 +1,95 @@
class Model_infoList{
constructor() {
this.GetModel_Info();
}
async GetModel_Info() {
var res = await model_InfoService.ModelList({
page:0,
id:`${urlId}`
}
);
console.log(res)
$(".action").append(`
<i class="iconfont icon-back1"></i>
<span>${res.model_info.name}</span>
`)
$(".model_info_header").append(
`
<img src="${res.model_info.portrait}" alt="${res.model_info.name}">
<div class="right_text">
<p>${res.model_info.name}</p>
<span>${res.model_info.explain}</span>
</div>
`
)
// 遍历模特的作品
$(".tazuop .title").text('她的作品')
res.data.forEach(v => {
$(".tazuop ul").append(
`
<li>
<div class="newest_img">
<a href="./info.html?id=${v.id}">
<img src="${v.preview}" alt="${v.title}">
</a>
<span>${v.total}P</span>
</div>
<div class="newest_text">
<a href="./info.html?id=${v.id}">
<p class="t">${v.title}</p>
<p class="source">${v.source}</p>
</a>
<div class="tags">
${
(v.tags.map((t) => {
return `<div class="tags_item"><a href="./mechanism_info.html?id=${t.id}&type=tags&t=${t.title}">${t.title}</a></div>`
})).toString().replace(/,/ig, " ")
}
</div>
</div>
</li>
`
)
});
// 遍历类似模特
$(".similar .title").text('类似模特')
res.similar.forEach((v)=>{
$(".similar .model_list").append(
`
<div class="item">
<div class="top">
<img src="${v.preview}" alt="${v.title}">
<span>${v.total}</span>
</div>
<p>${v.title}</p>
</div>
`
)
})
var items = document.querySelectorAll(".similar .model_list .item")
items.forEach((v,i)=>{
v.onclick = function () {
location.href = `model_info.html?id=${res.similar[i].id}&t=${res.similar[i].title}`
}
})
}
}
var url = document.location.toString();//获取url地址
var urlParmStr = url.slice(url.indexOf('?')+1);//获取问号后所有的字符串
var arr = urlParmStr.split('&');//通过&符号将字符串分割转成数组
var urlId = arr[0].split("=")[1];//获取数组中第一个参数
var unit_title=arr[1].split("=")[1];//第二个参数
new Model_infoList();

View File

@@ -0,0 +1,70 @@
class Search {
constructor() {
this.getSearch();
//判断标准位
this.coke = true;
}
async getSearch() {
//输入框注册点击事件
$('input').on('input', () => {
//输入框的内容发生改变就为true
this.coke = true;
//判断输入框里面的value值是否为空,为空就情况页面
if ($('input').val()) {
$('.coontent').html('');
}
})
//输入框注册点击事件
$('.icon-search').on('click', async () => {
//判断输入框value值是否为0,不为0执行下面条件,为0不执行下面条件
if ($('input').val().length != 0) {
if (this.coke) {
//先置空
$('.coontent').html('');
var res = await indexService.search({
keyword: $('input').val(),
page: this.page
});
//标志位
this.coke=false;
//遍历,渲染页面
$(res).each((index,item) => {
$('.coontent').append(`
<a href="./info.html?id=${item.id}">
<img src="${item.preview}" alt="">
<p>${item.title}</p>
</a>
`)
});
console.log(res.length);
//res。length是用户搜索内容,返回的内容长度,等于0就说明没有搜索到内容
if (res.length == 0) {
$('.coontent').append(`<p>没有关于这方面的奇怪内容哦</p>`);
}
}
}
})
}
}
new Search();
// 思考?重复点击会一直发送请求,改如何取消重复发送请求?
// 办法:设置一个标准位,默认为true,为true可以点击搜索,
// 搜索完毕不管结果怎么样,吧标准位改为false,当用户输入内容发送改变(使用oninput事件监听输入框的值是否发送改变)的时候再把标准位改为true

View File

@@ -0,0 +1,40 @@
class IndexService {
constructor() { }
async home(data = {}) {
var api = new Api();
var res = await api.get({
url: config.apiList.index,
data: data
});
api = null;
return res;
}
async type(data = {}) {
var api = new Api();
var res = await api.get({
url: config.apiList.type,
data: data
});
api = null;
return res;
}
// 搜索接口
async search(data = {}) {
var api = new Api();
var res = await api.get({
url: config.apiList.search,
data: data
});
api = null;
return res;
}
}
var indexService = new IndexService();

View File

@@ -0,0 +1,20 @@
class InfoSevice{
constructor() {}
async infoSevice(data = {}) {
var api = new Api();
var res = await api.get({
url: config.apiList.info,
data: data
});
api = null;
return res;
}
}
var infoSevice = new InfoSevice();

View File

@@ -0,0 +1,23 @@
class MechInfoService {
constructor() {
}
async mechanismList(data = {}) {
var api = new Api();
var res = await api.get({
url: config.apiList.mechanismList,
data: data
});
api = null;
return res;
}
}
var mechInfoService = new MechInfoService();

View File

@@ -0,0 +1,20 @@
class MechanismService {
constructor() {}
async mechanism(data = {}) {
var api = new Api();
var res = await api.get({
url: config.apiList.mechanism,
data: data
});
api = null;
return res;
}
}
var mechanismService = new MechanismService();

View File

@@ -0,0 +1,17 @@
class ModelService {
constructor() {
}
async Model (data = {}) {
var api = new Api();
var res = await api.get({
url: config.apiList.allModel,
data: data
});
api = null;
return res;
}
}
var modelService = new ModelService();

View File

@@ -0,0 +1,17 @@
class Model_infoService {
constructor() {
}
async ModelList (data = {}) {
var api = new Api();
var res = await api.get({
url: config.apiList.modelList,
data: data
});
api = null;
return res;
}
}
var model_InfoService = new Model_infoService();

View File

@@ -0,0 +1,25 @@
class TypeService {
constructor() {}
async leftMenu(data = {}) {
var api = new Api();
return await api.get({
url: config.apiList.leftMenu,
data: data
});
api = null;
}
async rightMenu(data = {}) {
var api = new Api();
return await api.get({
url: config.apiList.rightMenu,
data: data
});
api = null;
}
}
var typeService = new TypeService();

View File

@@ -0,0 +1,45 @@
function query(name) {
const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
const r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
function item (arr) {
var html = "";
arr.forEach((v, i) => {
html += `
<a href="./page/info.html?id={v,id}">
<li>
<div class="newest_img">
<a href="./info.html?id=${v.id}">
<!--图片地址-->
<img src="${v.preview || v.img}" alt="${v.title}">
</a>
<span>${v.total}套</span>
</div>
<div class="newest_text">
<a href="./info.html?id=${v.id}">
<p class="t">${v.title}</p>
<p class="source">${v.user}</p>
<p class="source">${ v.source.length > 5 ? '' :`${v.source}`}</p>
</a>
<div class="tags">
${(v.tags.map((item,index)=>{
return `<div class="tags_item">
<a href="./mechanism_info.html?id=${v.id}&amp;type=tags&amp;t=${v.title}">
${item.title}
</a>
</div> `
})).toString().replace(/,/g,"")}
</div>
</div>
</li>
</a>
`
})
return html;
}

View File

@@ -0,0 +1,20 @@
!(function(win, doc) {
function setFontSize() {
var winWidth = window.innerWidth;
doc.documentElement.style.fontSize = (winWidth / 375) * 100 + 'px';
}
var evt = 'onorientationchange' in win ? 'orientationchange' : 'resize';
var timer = null;
win.addEventListener(evt, function() {
clearTimeout(timer);
timer = setTimeout(setFontSize, 300);
}, false);
win.addEventListener("pageshow", function(e) {
if (e.persisted) {
clearTimeout(timer);
timer = setTimeout(setFontSize, 300);
}
}, false);
//初始化
setFontSize();
}(window, document));