// =============================================================
// =============================================================
//全局变量
var globalVals = {
// 顶部导航高度 用于导航滚动状态下合理active
topBannerHeight: null,
//配合topbannerheight 根据每个页面不同进行补偿 默认100
topBHeightMP: 280,
};
// =============================================================
// =============================================================
// =============================================================
// =============================================================
//全局方法
var handleEvns = {
setHeaderState: function () {
if ($(document).scrollTop() + globalVals.topBHeightMP >= globalVals.topBannerHeight) {
$('header').addClass('active');
} else {
$('header').removeClass('active');
}
},
// 为banner高度这个全局变量设置高度 传入banner对象筛选
setTBHeight: function (str) {
globalVals.topBannerHeight = $(str).height();
handleEvns.setHeaderState();
$(window).resize(function () {
globalVals.topBannerHeight = $(str).height();
handleEvns.setHeaderState();
})
},
getQueryVariable (variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) { return pair[1]; }
}
return (false);
},
// 页面全局方法
pageLayoutFunc: function () {
$(document).scroll(function () {
handleEvns.setHeaderState();
})
$(".public-open-contact").click(function (e) {
e.stopPropagation()
$('.contact-box').removeClass('hide')
})
$(".contact-box").click(function (e) {
e.stopPropagation()
})
$('.close-contact').click(function () {
$('.contact-box').addClass('hide')
})
$('body,html').click(function () {
$('.contact-box').addClass('hide')
})
},
// 导航处理
handleNavs: function () {
$('body header .my-container .right-nav').on('mouseenter', '.item', function () {
if ($(this).has('ul').length > 0) {
var height = $(this).children('ul').height();
console.log(height);
$('header .mask').show().height(height);
} else {
$('header .mask').hide();
}
});
$('body header .my-container .right-nav').on('mouseleave', '.item', function () {
if ($(this).has('ul').length > 0) {
$('header .mask').hide();
}
});
},
// 点击百度商桥
clickBaidu () {
$(".open_shangqiao").click(function (event) {
if ($('#nb_invite_ok').length > 0) {
$('#nb_invite_ok').click();
}
});
}
};
// =============================================================
// =============================================================
// =============================================================
// =============================================================
// 异步方法请写在这个全局变量中
var MyApi = {
}
// =============================================================
// =============================================================
// =============================================================
// =============================================================
// 页面管理
var PageManage = {
// 首页
homeIndex: function () {
handleEvns.setTBHeight('.home-banner');
handleEvns.pageLayoutFunc();
// banner 轮播
var swiper = new Swiper('.home-banner .swiper-container', {
loop: true,
autoplay: {
delay: 5000,
disableOnInteraction: false,
},
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.home-banner .swiper-button-next',
prevEl: '.home-banner .swiper-button-prev',
},
});
// 解决方案 点击效果
$(".part-two .tab-group .item").each(function (index, val) {
$(this).click(function () {
if ($(this).hasClass("active")) {
} else {
$(this).addClass("active")
$(this).siblings().removeClass("active")
$(".content-group .item").eq(index).addClass("show")
$(".content-group .item").eq(index).siblings().removeClass("show")
}
})
})
$(".part-two .tab-group .item").eq(0).addClass("active")
$(".part-two .content-group .item").eq(0).addClass("show")
// 产品tab 点击效果
$(".part-three .tab-group .item").each(function (index, val) {
$(this).click(function () {
var typeId = $(this).attr("data-id");
if ($(this).hasClass("active")) {
} else {
$(this).addClass("active")
$(this).siblings().removeClass("active")
$(".carousel-group .carousel-item").eq(index).addClass("show")
$(".carousel-group .carousel-item").eq(index).siblings().removeClass("show")
getProductList(typeId)
}
})
function getProductList (typeId) {
$.ajax({
url: '/api/homed/productlist',
data: {
"typeId": typeId
},
type: 'get',
dataType: 'json',
success: function (data) {
if (data.errcode == 0) {
$('.carousel-item .swiper-wrapper').html("")
var str = '';
for (var i = 0; i < data.list.length; i++) {
str += '';
if (data.list[i].PropId == 1) {
str += ' ' + data.list[i].Introduction + ' ' + data.list[i].Introduction + '' + data.list[i].MainTitle + '
';
str += '' + data.list[i].MainTitle + '
';
str += '
' + data.infomodel.MainTitle + '
'; if (data.infomodel.Salary != null) { strs += '' + data.infomodel.Salary + ''; } else { strs += ''; } strs += '' + data.infomodel.Introduction + '
'; } else { strs += ''; } strs += '' + data.infomodel.ResponsibilityFamil + '
'; } else { strs += ''; } strs += '' + data.infomodel.QualificationFamil + '
'; } else { strs += ''; } strs += ''; strs += '请将简历发送至:info@china-shjy.com'; strs += '
'; //} $('.mask-popup').html(''); $('.mask-popup').append(strs); } else { alert(data.errmsg); } $(".mask-popup .close").click(function () { $('.talent-main table .talent-list').removeClass('tr-active') $('body').removeClass("no-scroll") $(window).scrollTop(top) $(".mask").hide(); $(".mask-popup").hide(); }) } }); }) $(document).keydown(function (e) { if (e.keyCode == 13) { $('#page .page-box .page-sure').click(); } }) }, // 业务中心-固废处理 businessIndex () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); // 点击切换页面类型 $('.procedure-list .procedure-item').click(function () { var index = $(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.procedure-detail').find('.detail-item').eq(index).show().siblings().hide(); }); }, // 业务中心-物料解析 businessMaterial () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); $(document).keydown(function (e) { if (e.keyCode == 13) { $('#page .page-box .page-sure').click(); } }) }, // 业务中心-物料解析-详情 businessMaterialDetail () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); var produceSwiper = new Swiper('.material-detail-box .produce-swiper', { navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, }); }, // 业务中心-零配件专区 businessComponent () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); if (handleEvns.getQueryVariable('type')) { var top = $('.title-container').eq(0).offset().top; $('html,body').animate({ 'scrollTop': top - 120 }, 0); } $(document).keydown(function (e) { if (e.keyCode == 13) { $('#page .page-box .page-sure').click(); } }) }, // 业务中心-设备专区 businessEquipment () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); for (var i = 0; i < 4; i++) { var equipmentSwiper = new Swiper('.right-bottom .swiper-container-' + i, { slidesPerView: 3, observer: true, observeSlideChildren: true, navigation: { prevEl: '.right-bottom .prev-' + i, nextEl: '.right-bottom .next-' + i, }, }); } // 有参数就滚动 if (handleEvns.getQueryVariable('type')) { var typeVal = handleEvns.getQueryVariable('type'); // var topHeight=$('.business-equipment .equipment-type-list .type-list-box ul.type-list li.type-item .type-left .type-name').scrollTop(); var topHeight = $('.business-equipment .equipment-type-list .type-list-box ul.type-list li.type-item .type-left .type-name[data-type=' + typeVal + ']').offset().top; $('html,body').animate({ 'scrollTop': topHeight }, 1000); } }, // 业务中心-设备专区详情 businessEquipmentDetail () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); var galleryThumbs = new Swiper('.equipment-detail-container .gallery-thumbs', { spaceBetween: 10, slidesPerView: 5, loop: false, freeMode: false, watchSlidesVisibility: true, watchSlidesProgress: true, }); var galleryTop = new Swiper('.equipment-detail-container .gallery-top', { // spaceBetween: 10, loop: false, navigation: { nextEl: '.equipment-detail-container .gallery-top .swiper-button-next', prevEl: '.equipment-detail-container .gallery-top .swiper-button-prev', }, thumbs: { swiper: galleryThumbs, }, }); }, // 解决方案 businessSolution () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); if (handleEvns.getQueryVariable('type')) { var topVal = $('.solution-container .title-container').eq(0).offset().top; $('body,html').animate({ scrollTop: topVal - 150 }, 0); // console.log(topVal); } $(document).keydown(function (e) { if (e.keyCode == 13) { $('#page .page-box .page-sure').click(); } }) }, // 解决方案详情 businessSolutionDetail () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); var galleryThumbs = new Swiper('.params-gallery-box .gallery-thumbs', { spaceBetween: 10, slidesPerView: 5, loop: false, freeMode: false, watchSlidesVisibility: true, watchSlidesProgress: true, }); var galleryTop = new Swiper('.material-produce .gallery-top', { // spaceBetween: 10, loop: false, navigation: { nextEl: '.material-produce .gallery-top .swiper-button-next', prevEl: '.material-produce .gallery-top .swiper-button-prev', }, thumbs: { swiper: galleryThumbs, }, }); }, // 服务与支持 businessService () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); $('body .question-list').on('click', '.question-text', function () { // $('.question-list .question-item').removeClass('active'); // $('.question-list .question-item .question-text p').text('+'); // $('.question-list .question-item .question-answer').slideUp(500); if ($(this).parent().hasClass('active')) { $(this).parent().removeClass('active').siblings().removeClass('active'); $(this).parent().children('.question-answer').slideUp(500); $(this).parent().siblings().children('.question-answer').slideUp(500); $(this).parent().children('.question-text').find('p').text('+'); $(this).parent().siblings().children('.question-text').find('p').text('+') } else { $(this).parent().addClass('active').siblings().removeClass('active'); $(this).parent().children('.question-text').find('p').text('-'); $(this).parent().siblings().children('.question-text').find('p').text('+'); $(this).parent().children('.question-answer').slideDown(500); $(this).parent().siblings().children('.question-answer').slideUp(500) } }); // map/index页面进入锚点到具体位置 if (handleEvns.getQueryVariable('mapgo')) { var map = handleEvns.getQueryVariable('mapgo'); var top = 0; switch (map) { case '1': { //服务与支持 top = $('.title-container').eq(0).offset().top; break; } case '2': { //常见问答 top = $('.title-container').eq(1).offset().top; break; } } $('body,html').animate({ scrollTop: top - 120 }, 0) } }, //资讯 newsIndex: function () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); $(document).keydown(function (e) { if (e.keyCode == 13) { $('#page .page-box .page-sure').click(); } }) }, //资讯 webMap: function () { handleEvns.setTBHeight('.banner'); handleEvns.pageLayoutFunc(); }, // // 产品详情 // productDetail: function () { // handleEvns.pageLayoutFunc(); // }, // // 联系信息 // contactIndex: function () { // handleEvns.pageLayoutFunc(); // }, // // 留言 // contactMessage: function () { // handleEvns.pageLayoutFunc(); // }, // // 行业 // industryIndex: function () { // handleEvns.pageLayoutFunc(); // }, // //资讯 // newsIndex: function () { // handleEvns.pageLayoutFunc(); // }, // // 资讯详情 // newsDetail: function () { // handleEvns.pageLayoutFunc(); // } } // ============================================================= // ============================================================= // 路由设置 $(function () { var pathname = window.location.pathname; var r_base = pathname.split('/')[1]; var r_page = pathname.split('/')[2]; // home if (r_base == '/' || r_base == "") { PageManage.homeIndex(); console.log("首页"); } // about if (r_base == 'about') { if (r_page == 'develop') { PageManage.aboutDevelop(); console.log("走进星空足球app-发展历程"); return false; } if (r_page == 'global') { PageManage.aboutGlobal(); console.log("走进星空足球app-全球"); return false; } // index页面放在最底 if (r_page == 'index' || typeof (r_page === 'undefined')) { PageManage.aboutIndex(); console.log("走进星空足球app-我们的优势"); } } // business if (r_base == 'business') { if (r_page == 'material') { PageManage.businessMaterial(); console.log("业务中心-物料解析"); return false; } if (r_page == 'materialdetail') { PageManage.businessMaterialDetail(); console.log("业务中心-物料解析-详情"); return false; } if (r_page == 'component') { PageManage.businessComponent(); console.log("业务中心-零配件专区"); return false; } if (r_page == 'equipment') { PageManage.businessEquipment(); console.log("业务中心-设备专区"); return false; } if (r_page == 'equipmentdetail') { PageManage.businessEquipmentDetail(); console.log("业务中心-设备专区-详情"); return false; } if (r_page == 'solution') { PageManage.businessSolution(); console.log("业务中心-解决方案"); return false; } if (r_page == 'solutiondetail') { PageManage.businessSolutionDetail(); console.log("业务中心-解决方案-详情"); return false; } if (r_page == 'service') { PageManage.businessService(); console.log("业务中心-服务与支持"); return false; } // index页面放在最底 if (r_page == 'index' || typeof (r_page === 'undefined')) { PageManage.businessIndex(); console.log("业务中心-固废处理"); } } // contact if (r_base == 'contact') { PageManage.contactIndex(); console.log("联系我们"); } // news if (r_base == 'news') { PageManage.newsIndex(); console.log("新闻资讯"); } // map if (r_base == 'map') { PageManage.webMap(); console.log("网站地图"); } });