$(function () { $.ajax({ url: "jsons/salary.json", success: (res) => { const { features, program, industries, priceList } = res; // 功能点 $("#salary_features").append(renderFeatrues(features)); $("#salary_features_mobile").append(renderFeatruesMobile(features)); // 全场景人事解决方案 $("#salary_program").append(renderProgram(program)); const programMobile_1 = []; const programMobile_2 = []; program.forEach((item, i) => { if (i > 3) { programMobile_2.push(item); } else { programMobile_1.push(item); } }); $("#salary_program_mobile_1").append( renderProgram(programMobile_1, "mobile_1") ); $("#salary_program_mobile_2").append( renderProgram(programMobile_2, "mobile_2") ); /* // 智能薪酬 行业版 industries.forEach((item, ) => { $("#salary_industries").append(renderIndustries(item)) $("#salary_industries_mobile").append(renderIndustriesMobile(item)) }); */ // 行业版移动端 轮播 swiperSalary("features_swiper", 0); // 解决方案 轮播 swiperSalary("program_swiper"); // 解决方案移动端 轮播 swiperSalary("mobile_1_swiper"); swiperSalary("mobile_2_swiper"); // 产品价格渲染,PC端 // priceList.forEach(item => { // $("#salaryPriceList").append(renderPriceList(item)); // $("#salaryPriceListMobile").append(renderPriceListMobile(item)); // }) // 其他行业模板渲染 // $("#otherContent").html(template("other-content-temp", res)); // 其他行业轮播事件 // $("#otherContent .swiper-container").each(function (i, val) { // if ($(val).attr("data-slide-length") > 1) { // new Swiper(val, { // loop: true, // autoplay: { // delay: 4000, // disableOnInteraction: false, // }, // on: { // slideChange: function () { // const prev = $(val).prev(); // const ul = prev[0]; // if (ul) { // setTimeout(() => { // var index = // $(val) // .find(".outer-slide.swiper-slide-active") // .eq(0) // .attr("data-swiper-slide-index") || 0; // $(ul) // .find("li") // .removeClass("active") // .eq(+index) // .addClass("active"); // }, 0); // } // }, // }, // }); // } // }); // 其他行业tab切换事件 // $("#otherContent .tabs li").click(function () { // var s = $(this).parent().next()[0].swiper; // s.slideTo($(this).index() + 1, 300, false); // s.autoplay.stop(); // }); }, }); /** * id 轮播节点 * speed 播放速度 */ swiperSalary = (id, speed) => { const el = `#${id}`; const nav = `#${id}_tabs_nav`; var salarySwiper = new Swiper(el, { loop: true, autoplay: { delay: 4000, delay: 4000000, disableOnInteraction: false, }, on: { slideChange: function () { setTimeout(() => { var index = $(`${el} .swiper-slide-active`) .eq(0) .attr("data-swiper-slide-index") || 0; $(`${nav} li`).removeClass("active").eq(+index).addClass("active"); }, 0); }, }, }); if (speed) { salarySwiper.speed = speed; } $(`${nav} li`).click(function () { salarySwiper.slideTo($(this).index() + 1, 300, false); salarySwiper.autoplay.stop(); }); $(`${nav} li`).hover( function () { if ($(this).hasClass("active")) { salarySwiper.autoplay.stop(); } }, function () { salarySwiper.autoplay.start(); } ); $(`${el}`).hover( function () { salarySwiper.autoplay.stop(); }, function () { salarySwiper.autoplay.start(); } ); }; // 功能点节点渲染 renderFeatrues = (features) => { return `
${renderFeatrueContent(features)}
`; }; // 功能点导航 renderFeatureNav = (features = []) => { let featureNav = ""; features.forEach((item, i) => { featureNav += `
  • ${item.id} ${item.title}

    ${item.subTitle}

  • `; }); return featureNav; }; // 功能点内容 renderFeatrueContent = (features = []) => { let featrueContent = ""; features.forEach((item, i) => { featrueContent += `
    `; }); return featrueContent; }; renderFeatruesMobile = (features) => { let accordion = ""; features.forEach((item, i) => { accordion += ` ${i === 0 ? '
    ' : ""}

    ${item.id} ${item.title}

    ${item.subTitle}

    `; }); return accordion; }; // 功能点list renderFeatureList = (items = []) => { let list = ""; items.forEach((item) => { list += `
  • ${item}
  • `; }); return list; }; // 产品价值点 list renderProductValue = (items = []) => { let list = ""; items.forEach((item) => { list += `
  • ${item.data}:${item.value}
  • `; }); return list; }; /** * 解决方案 * source 来源,不传值时默认PC端, 有值表移动端。 */ renderProgram = (program, source = "") => { return `
    ${renderProgramPlan(program, source)}
    `; }; // 解决方案Tab导航 renderProgramNav = (program = []) => { let nav = ""; program.forEach((item, i) => { nav += `
  • ${item.title}
  • `; }); return nav; }; /** * 解决方案Tab内容 * source 来源,不传值时默认PC端, 有值表移动端。 */ renderProgramPlan = (program = [], source = "") => { let plan = ""; program.forEach((item, i) => { plan += `
    ${renderProgramDesc( item.desc )}
    `; }); return plan; }; // 解决方案Tab内容说明文案 renderProgramDesc = (items = []) => { let desc = ""; items.forEach((item) => { desc += `

    ${item}

    `; }); return desc; }; /** // 行业版 renderIndustries = item => { return `
    ${item.title}
    ` } // 行业版移动端 renderIndustriesMobile = item => { return `
    ${item.title}
    ` } **/ // 产品价格 PC端 renderPriceList = (item) => { return `
    `; }; // 产品价格 移动端 renderPriceListMobile = (item) => { return `
    `; }; $(".salary-video img").click(function () { $(this).css("display", "none"); $(".salary-video video").css("visibility", "visible").trigger("play"); }); (function () { var $tabItems = $(".salary-tab-item"); var $tabPanels = $(".salary-tab-panel"); var currentIndex = 0; var timer = null; var interval = 5000; function switchTab(index, immediate) { if (index === currentIndex) return; $tabItems.removeClass("active"); $tabItems.eq(index).addClass("active"); $tabPanels.removeClass("active"); $tabPanels.eq(index).addClass("active"); currentIndex = index; } function startAutoSwitch() { if (timer) return; timer = setInterval(function () { var nextIndex = (currentIndex + 1) % $tabItems.length; switchTab(nextIndex, false); }, interval); } function stopAutoSwitch() { clearInterval(timer); timer = null; } $tabItems.each(function (index) { $(this).on("mouseenter", function () { stopAutoSwitch(); switchTab(index, true); }); $(this).on("mouseleave", function () { startAutoSwitch(); }); }); startAutoSwitch(); })(); (function () { var $mobileNav = $(".salary-tabs-mobile-nav"); var $mobileItems = $(".salary-tabs-mobile-item"); var $mobilePanels = $(".salary-tabs-mobile-panel"); var currentIndex = 0; var touchStartX = 0; var touchEndX = 0; var isAnimating = false; function switchMobileTab(index) { if (isAnimating) return; if (index < 0) index = $mobileItems.length - 1; if (index >= $mobileItems.length) index = 0; if (index === currentIndex) return; isAnimating = true; $mobileItems.removeClass("active").eq(index).addClass("active"); $mobilePanels.eq(currentIndex).fadeOut(200, function () { $mobilePanels.eq(index).fadeIn(200, function () { isAnimating = false; }); }); currentIndex = index; var activeItem = $mobileItems.eq(index)[0]; if (activeItem && $mobileNav.length) { var navRect = $mobileNav[0].getBoundingClientRect(); var itemRect = activeItem.getBoundingClientRect(); var scrollLeft = $mobileNav[0].scrollLeft + itemRect.left - navRect.left - (navRect.width - itemRect.width) / 2; $mobileNav[0].scrollTo({ left: scrollLeft, behavior: "smooth" }); } } $mobileItems.on("click", function () { var index = $(this).index(); switchMobileTab(index); }); var $mobileContent = $(".salary-tabs-mobile-content"); if ($mobileContent.length) { $mobileContent[0].addEventListener("touchstart", function (e) { touchStartX = e.changedTouches[0].screenX; }); $mobileContent[0].addEventListener("touchend", function (e) { touchEndX = e.changedTouches[0].screenX; var diff = touchStartX - touchEndX; if (Math.abs(diff) > 50) { if (diff > 0) { switchMobileTab(currentIndex + 1); } else { switchMobileTab(currentIndex - 1); } } }); } })(); (function () { var url = "https://h5.dingtalk.com/org-center/index.html?showmenu=false&dd_share=false&goodsCode=FW_GOODS-1000933561&fromQrCode=1&channelCode=official_salary&sig=4f11020aa759c295bd15292e97bb0df72636525a&funnelsource=goodsOfflineQrcode&leadsFrom=401"; var containers = ["salary-header-qrcode", "salary-footer-qrcode"]; containers.forEach(function(id) { var container = document.getElementById(id); if (container) { QRCode.toDataURL(url, { errorCorrectionLevel: "H", width: 200, margin: 1 }, function(err, qrCode) { if (!err) { var img = document.createElement("img"); img.src = qrCode; img.style.width = "100%"; img.style.height = "100%"; container.appendChild(img); } }); } }); })(); });