You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
4.7 KiB
JavaScript
152 lines
4.7 KiB
JavaScript
const active = document.getElementById("activeUl");
|
|
const liElements = active.children;
|
|
// const api1 = "https://www.keephappy.love/pychr/pubGoodsShow/getGoodsShowList";
|
|
// const api2 = "https://www.keephappy.love/pychr/pubGoodsShow/findGoodsShow?ID=1";
|
|
const api1 = "https://www.pychr.com/pychr/pubGoodsShow/getGoodsShowList";
|
|
// const api2 = "https://www.pychr.com/pychr/pubGoodsShow/findGoodsShow?ID=1";
|
|
const fullURL = window.location.href;
|
|
const url = new URL(fullURL);
|
|
const param = url.searchParams.get("param");
|
|
const param1 = url.searchParams.get("param1");
|
|
const type = url.searchParams.get("type");
|
|
const langType = url.searchParams.get("langType");
|
|
const params = {
|
|
langType: langType,
|
|
page: 1,
|
|
pageSize: 5000,
|
|
type: type,
|
|
};
|
|
const lm = document.getElementById("load-more");
|
|
|
|
function HrefL() {
|
|
if (param == null) return;
|
|
liElements[Number(param)].classList.add("current-menu");
|
|
liElements[Number(param)].classList.add("current-menu-item");
|
|
liElements[Number(param)].classList.add("current-menu-ancestor");
|
|
if (liElements[Number(param)].children.length >= 2) {
|
|
liElements[Number(param)].children[1].children[
|
|
Number(param1)
|
|
].classList.add("current-menu-item");
|
|
}
|
|
const url = api1 + "?" + new URLSearchParams(params).toString();
|
|
getData(url);
|
|
}
|
|
|
|
// 获取数据
|
|
function getData(api) {
|
|
fetch(api)
|
|
.then((response) => response.json())
|
|
.then((res) => {
|
|
tabs(res.data.list);
|
|
// genSwiper(res.data.list[0].otherPic);
|
|
});
|
|
}
|
|
// tab数据
|
|
function tabs(data) {
|
|
const flatTabs = document.querySelectorAll(".tabs-case-study");
|
|
data.forEach((element) => {
|
|
const url =
|
|
"study-details.html?param=" + element.ID + "&langType=" + langType;
|
|
const nodes = generateProfolioHtml(
|
|
element.goodsMainPic,
|
|
element.name,
|
|
element.briefIntroduction.split('\n')[0],
|
|
url
|
|
);
|
|
flatTabs[0].appendChild(nodes);
|
|
});
|
|
}
|
|
|
|
// 生成html
|
|
function generateProfolioHtml(imageSrc, titleText, linkText, linkUrl) {
|
|
// 创建父容器
|
|
const container = document.createElement("div");
|
|
container.className = "image-profolio image-profolio-style2";
|
|
|
|
// 创建图片容器
|
|
const imageContainer = document.createElement("div");
|
|
imageContainer.className = "image";
|
|
|
|
// 创建图片元素
|
|
const image = document.createElement("img");
|
|
image.src = imageSrc == "" ? "../static/picture/imgworkman.jpg" : imageSrc;
|
|
image.alt = "images";
|
|
image.className = "MyImge";
|
|
// 将图片添加到图片容器
|
|
imageContainer.appendChild(image);
|
|
|
|
// 创建作品展示容器
|
|
const profolioShowContainer = document.createElement("div");
|
|
profolioShowContainer.className = "profolio-show";
|
|
|
|
// 创建内容标题容器
|
|
const contentTitleContainer = document.createElement("div");
|
|
contentTitleContainer.className = "content-title text-left tf-text-hv";
|
|
|
|
// 创建标题元素
|
|
const title = document.createElement("h4");
|
|
title.textContent = titleText;
|
|
|
|
// 创建链接元素
|
|
const link = document.createElement("a");
|
|
link.href = linkUrl;
|
|
link.className = "tftitle-style2";
|
|
link.textContent = linkText;
|
|
link.style.whiteSpace = "nowrap";
|
|
link.style.overflow = "hidden";
|
|
link.style.textOverflow = "ellipsis";
|
|
link.style.width = "200px";
|
|
link.style.display = "block";
|
|
|
|
// 将标题和链接添加到内容标题容器
|
|
contentTitleContainer.appendChild(title);
|
|
contentTitleContainer.appendChild(link);
|
|
// 创建按钮标签容器
|
|
const btnTabContainer = document.createElement("div");
|
|
btnTabContainer.className = "btn-tab";
|
|
|
|
// 创建链接按钮元素
|
|
const linkBtn = document.createElement("a");
|
|
linkBtn.href = linkUrl;
|
|
|
|
// 创建箭头图标元素
|
|
const arrowIcon = document.createElement("i");
|
|
arrowIcon.className = "fas fa-arrow-right";
|
|
|
|
// 将箭头图标添加到链接按钮
|
|
linkBtn.appendChild(arrowIcon);
|
|
|
|
// 将链接按钮添加到按钮标签容器
|
|
btnTabContainer.appendChild(linkBtn);
|
|
|
|
// 将内容标题容器和按钮标签容器添加到作品展示容器
|
|
profolioShowContainer.appendChild(contentTitleContainer);
|
|
profolioShowContainer.appendChild(btnTabContainer);
|
|
// 将图片容器和作品展示容器添加到父容器
|
|
container.appendChild(imageContainer);
|
|
container.appendChild(profolioShowContainer);
|
|
// 返回创建的 HTML 元素
|
|
return container;
|
|
}
|
|
|
|
// 加载更多
|
|
// function loadMore() {
|
|
// if (lm) {
|
|
// lm.addEventListener("click", function (event) {
|
|
// event.preventDefault();
|
|
// params.page++;
|
|
// HrefL();
|
|
// });
|
|
// }
|
|
// }
|
|
|
|
HrefL();
|
|
// getData();
|
|
|
|
// loadMore();
|
|
const adress = document.querySelector(".adress");
|
|
adress.addEventListener("click", function () {
|
|
if(adress.innerHTML.indexOf('Dafu Road') !== -1){
|
|
alert('Dafu Road,Ronggui town, Shunde District, Foshan City, Guangdong Province, China')
|
|
}
|
|
}) |