$(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"); }); });