$(function () { window.spm(window.isMobile() ? "288.3" : "288.1"); var nowDateTime = new Date().getTime(); var isProd = window.isProd; var url = window.reqHost; var hash = nowDateTime + "5839606a1e964e5b8464539e7ca419cf"; const industryMap = { id_ygq: "央国企", id_fwy: "服务业", id_zzy: "制造业", id_ithlw: "IT互联网", id_cyy: "餐饮业", id_xfls: "消费零售", id_swyl: "生物医疗", id_jrbx: "金融保险", id_qt: "其他", }; let targetIndustryIndexList = []; function getIndustryName(industry) { if (!industry) return ""; const industryList = industry.split(","); const industryNameList = industryList.map( (item) => industryMap[item] || "" ); if (industryNameList.length) { return industryNameList.join("/"); } else { return ""; } } const curSearch = window.location.search.slice(1); const curRes = {}; curSearch.split("&").forEach((v) => { const [key, value] = v.split("="); curRes[key] = value; }); // 行业案例=>入参0 人力知识=>入参1 媒体报道=>入参2 const articleType = (curRes && curRes.articleType) || ""; if (articleType !== "0") { $(".cc-container").css("display", "none"); $(".cc-related-article").css("margin-top", 0); } if (window.isMobile()) { $(".cc-swiper ").css("height", ((window.innerWidth - 32) * 171) / 358); } // 最新文章 $.ajax({ url: `${url}/home/open/articleList?articleType=&industry=&pageSize=4&page=1×tamp=${nowDateTime}&signature=${SparkMD5.hash( hash )}`, success: function (res) { if (res.success) { var latestArticles = (res.result.articleList || []).map((item) => { const industryName = getIndustryName(item.industry); return { ...item, industryName }; }); var html = template("customer-case-right-temp", { data: latestArticles, isProd, }); $("#caseRightContent").html(html); if (!!latestArticles.length) { $(".cc-detail-right-container h2").css("opacity", 1); } } }, }); // banner+广告位 $.ajax({ url: "https://rlj-f2e-assets.oss-cn-hangzhou.aliyuncs.com/config/f409c1ba-1206-43d8-ae11-57f23593ef24.json", success: function (res) { let { banner, advertising } = res || {}; banner = banner.filter((item) => { if (window.isMobile()) { return !!item.imgMobile; } else { return !!item.imgWeb; } }); $(".cc-advertise").html( template("customer-case-right-advertising", { data: { isProd, list: advertising }, }) ); $(".cc-advertise-image-container").click(function (e) { const index = e.currentTarget.dataset.index; const curData = advertising[+index]; if (curData.type === "video" || curData.type === "videoNoTag") { const targetUrl = isProd ? curData.publishUrl : curData.previewUrl; $("#detailVideoPlayer").attr("src", targetUrl); $(".detail-player-modal").modal("show"); } }); $(".detail-player-modal").on("hidden.bs.modal", function (e) { $("#detailVideoPlayer").trigger("pause"); }); $(".swiper-wrapper").html( template("customer-case-right-banner", { data: { isProd, isMobile: window.isMobile(), list: banner, }, }) ); new Swiper(".cc-swiper", { loop: true, autoplay: banner.length > 1, //只有一张图片的时候不轮播 pagination: { el: ".cc-swiper-pagination", clickable: true, }, }); setTimeout(() => { $(".getLeadsForWhitePaperInCustomerCase").click(function () { window.spm("288.1.0.1"); }); }); }, }); // 页面滚动,控制case-nav-tabs[最新文章+客户案例+人力知识...]条的显示 $(window).scroll(function () { var mobile = isMobile(); var isTop = $(".cc-container").offset().top > (mobile ? 272 : 522); $(".cc-container").css( isTop ? { background: "#ffffff", "box-shadow": "0 0 6px rgb(0 0 0 / 10%)", zIndex: 12, } : { background: "rgba(0, 0, 0, 0)", "box-shadow": "none", zIndex: 10, } ); $(".navbar").css( isTop ? { "box-shadow": "none", "border-bottom": "1px solid #ebebeb" } : { "box-shadow": "0 0 6px rgb(0 0 0 / 10%)", "border-bottom": "0" } ); if (mobile) { $(".cc-container").css({ top: "46px" }); } else { $(".cc-container").css({ top: "60px" }); } }); // 控制分页器 function getArticle() { const industry = Object.keys(industryMap) .filter((_, index) => targetIndustryIndexList.includes(index + 1)) .join(","); $("#cc-pagination").pagination({ dataSource: `${url}/home/open/articleList?articleType=${articleType}&industry=${industry}`, ajax: { beforeSend: (_, a) => { nowDateTime = new Date().getTime(); hash = nowDateTime + "5839606a1e964e5b8464539e7ca419cf"; a.url += `×tamp=${nowDateTime}&signature=${SparkMD5.hash(hash)}`; }, }, alias: { pageNumber: "page", }, totalNumberLocator: function (res) { if (res.success) { return res.result.query.totalCount; } return 0; }, locator: "result.articleList", pageSize: 12, callback: function (articleList, pagination) { $("#cc-pagination").css({ display: pagination.totalNumber <= pagination.pageSize ? "none" : "block", }); var article = articleList.map(function (item) { return { id: item.articleId, title: item.articleTitle, type: item.articleType, content: item.articleDesc, img: item.showImg, content: item.articleContent, publishDate: item.publishDate, industryName: getIndustryName(item.industry), url: location.port === "3003" ? "customer-case-detail" : isProd ? item.publishUrl : item.previewUrl, }; }); var articleHtml = template("case-lists-temp", { data: article, }); $("#caseContent").html(articleHtml); }, }); } getArticle(); $("#case-nav-tabs") .find("li") .each((index, item) => { $(item).click(function () { if (index === 0) { targetIndustryIndexList = []; } else { // 多选的逻辑 // if (targetIndustryIndexList.includes(index)) { // targetIndustryIndexList = targetIndustryIndexList.filter( // (item) => item !== index // ); // } else { // targetIndustryIndexList.push(index); // } // 单选的逻辑 targetIndustryIndexList = [index]; } $("#case-nav-tabs").find("li").removeClass("active"); setTimeout(() => { $("#case-nav-tabs") .find("li") .each((index, item) => { if (targetIndustryIndexList.length === 0 && index === 0) { $(item).addClass("active"); } else if (targetIndustryIndexList.includes(index)) { $(item).addClass("active"); } else { $(item).removeClass("active"); } }); }); getArticle(); }); }); });