$(function () { var $doc = $(document), obj = { init: function () { this.event(); this.form(); proNav(); /*this.banner();*/ this.nav(); }, event: function () { $('.year-collapse li').click(function () { $(this).addClass('active').siblings().removeClass('active'); }) }, banner: function () { }, form: function () { //v-radio $doc.on('click', '.v-radio', function () { var _ = $(this), $value = _.data('value'); active(_, -1, 'checked'); _.siblings('input').val($value); }); //v-select $('.wsc-select .select-panel').click(function () { $(this).siblings('.select-menu').slideToggle(100); }); $('.v-select').blur(function () { $(this).children('.select-menu').slideUp(100); }); //同意发送广告 $doc.on('click', '.fill .agree', function () { $(this).toggleClass('unchecked') }); $('.select-menu li').click(function (e) { var $this = $(this), $menu = $this.parent(), $input = $menu.siblings('input'), $panel = $menu.siblings('.select-panel'); $input.val($this.data('value')); $panel.text($this.text()); $menu.slideUp(100); }); //验证项 $('.m-apply-form').validator({ fields: { firstname: { rule: 'required', msg: { required: '请输入您的称呼' } }, company: { rule: 'required', msg: { required: '请输入您的单位名称' } }, phone: { rule: 'required', msg: { required: '请输入您的联系方式', } }, } }); $('.async').on('valid.form', function (e) { e.preventDefault(); var $form = $(this); var url = $form.attr('action'); var data = $form.serialize(); $.ajax({ //防止服务器拿不到数据 headers: { "Content-Type": "application/x-www-form-urlencoded" }, url: url, data: data, type: 'POST', success: function (res) { if (res.status) { /* $.dialog({ title: 'SUCCESS', msg: 'We will contact you within 24 hours' });*/ $('.async input[type="text"]').val(''); $('.async textarea').val(''); window.location.href="/addes/" } else { //提交失败处理 alert('FAIL!'); } //更新表单token var $token = $form.find('#token'); $token.attr('name', res.token.key); $token.val(res.token.value); } }) }); }, /*proNav: function () { //不知名BUG DEL长度为8 略过第一个 var $del = $('.Del-main'); var $nav = $('.ue-nav_t6'); var $navLis = $('.nav-list li'); var axis = []; function active(index) { var index = index; $('.nav-list li').eq(index).addClass('current').siblings().removeClass('current'); } for (var i = 0; i < $del.length; i++) { axis.push($del.eq(i).offset().top-100); } $doc.on('click', '.table-open', function () { axis = []; for (var i = 0; i < $del.length; i++) { axis.push($('.Del-main').eq(i).offset().top-80); } }); $doc.scroll(function () { var dis = $(this).scrollTop() + $('.header').height() + $('.ue-nav_t6').height() + 100; if (dis < axis[0]) { $nav.removeClass('nav-fixed') } if (dis >= axis[0] && dis < axis[1]) { $nav.addClass('nav-fixed'); active(0); } if (dis >= axis[1] && dis < axis[2]) { active(1); } if (dis >= axis[2] && dis < axis[3]) { active(2); } if (dis >= axis[3] && dis < axis[4]) { active(3); } if (dis >= axis[4] && dis < axis[5]) { active(4); } if (dis >= axis[5] && dis < axis[6]) { active(5); } if (dis >= axis[6]) { active(6); } }); $doc.on('click', '.screen-term', function (e) { var $this = $(this); $this.siblings().find('.inner-mask-two').hide(); $this.find('.inner-mask-two').toggle(); }); },*/ nav: function () { //导航显示隐藏 $('.js-menu_t2').click(function (e) { e.preventDefault(); $('.m-header_t2').toggleClass('nav--show'); }); //搜索菜单 var $search = $('.m-search_t2'); $('.js-search-trigger_t2').click(function () { $search.addClass('search--show'); $('.search__input').focus(); }); $search.on('click', '.js-search-close_t2', function () { $search.removeClass('search--show'); }); $doc.on('click', 'footer li', function () { $(this).toggleClass('active') }) }, } ; obj.init(); if ($('.ue-nav_t3').length) { window.scroll1 = new IScroll('.ue-nav_t3', { scrollX: true, scrollY: false, click: true, preventDefault: false }); } if ($('.ue-nav_t8').length) { window.scroll1 = new IScroll('.ue-nav_t8', { scrollX: true, scrollY: false, click: true, preventDefault: false }); } if ($('.ue-nav_t9').length) { window.scroll1 = new IScroll('.ue-nav_t9', { scrollX: true, scrollY: false, click: true, preventDefault: false }); } if ($('.ue-nav_t7').length) { window.scroll2 = new IScroll('.ue-nav_t7', { scrollX: true, scrollY: false, click: true, preventDefault: false }); } if ($('.ue-nav_t1').length) { window.scroll2 = new IScroll('.ue-nav_t1', { scrollX: true, scrollY: false, click: true, preventDefault: false }); } if ($('.ue-nav_t6').length) { window.scroll2 = new IScroll('.ue-nav_t6', { scrollX: true, scrollY: false, click: true, preventDefault: false }); } if ($('.ue-nav_t5').length) { window.scroll2 = new IScroll('.ue-nav_t5', { scrollX: true, scrollY: false, click: true, preventDefault: false }); } $doc.on('click', '.js-collapse', function (event) { if ($('.search-box').css('display') == 'block') { $('.search-box').hide(); $('.mask-alls').show(); } $('nav').addClass('nav-show'); $('body').addClass('alpha'); event.preventDefault(); $('.mask-alls').show(); } ); $doc.on('click', '.js-close', function () { $('nav').removeClass('nav-show'); $('body').removeClass('alpha'); $('.mask-alls').hide(); }); $doc.on('click', '.mask-alls', function () { $('nav').removeClass('nav-show'); $('body').removeClass('alpha'); $('.mask-alls').hide(); }); $doc.on('click', '.f-nav li', function () { $(this).toggleClass('nav-open').siblings().removeClass('nav-open'); }); $doc.on('click', '.partsDetail-ps', function () { $('.partsDetail-tex').css('height', 'auto'); $('.modelHead-js').css("height", "auto"); $('.partsDetail-ps').hide(); }); /*这里*/ $doc.on('click', '.nav-list .sub1-menu', function () { $(this).find('.sub2-menu').toggle(); $(this).toggleClass('nav-open'); }); $doc.on('click', '.inner-nav', function () { $('.inner-nav-menus').slideToggle('fast'); $('.inner-nav').toggleClass('inner-show'); }); $doc.on('click', '.js-search', function () { if ($('.nav-show').length) { $('nav').removeClass('nav-show'); } $('.nav-search').show(); $('html').css("overflow", "hidden"); }); $doc.on('click', '.search-close', function () { $('.nav-search').hide(); $('html').css("overflow", "auto"); }); $doc.on('click touchstart', '.proLet-del', function (e) { e.preventDefault(); $('.proLet-tex').css({'height': 'auto', 'display': 'block'}); $('.proLet-del').remove(); }); $doc.on('click', '.proDetail-but', function () { $('.proDetail-cls table').css("height", "auto"); $('.proDetail-but').remove(); }); function active(ele, index, className) { var className = className || 'active'; if (index == -1) { ele.addClass(className).siblings().removeClass(className); } else { ele.eq(index).addClass(className).siblings().removeClass(className); } } $('.detail-nav-tab li').click(function () { var $this = $(this); active($this, -1); active($('.detail-tabs .detail-tab'), $('.detail-nav-tab li').index($this)); }); $('.pro-detail-faq li').click(function () { // obj.active($(this),-1) $(this).toggleClass('active') }); $doc.on('touchstart', '.caseDetail-nav-cls', function () { var $this = $(this); var index = $('.caseDetail-nav-cls').index($(this)); active($('.caseDetail-als'), index); active($this, -1); }); }); $(document).on('click touchstart','.ue-nav_t8 .nl-item',function () { var $this=$(this); var index=$('.ue-nav_t8 .nl-item').index($this)%12; $(this).find('a').addClass('current'); $this.siblings().find('a').removeClass('current'); $('.case-list').eq(index).addClass('active').siblings().removeClass('active'); }); $(".select-area .select-value").each(function(){ /* if( $(this).next("select").find("option:selected").length != 0 ){ $(this).text( $(this).next("select").find("option:selected").text() ); }*/ }); $(".select-area select").change(function(){ var value = $(this).find("option:selected").text(); var vls = $(this).find("option:selected").val(); $(this).parent(".select-area").find(".select-value").text(value); $('#Prod').val(vls); }); // 点击 // $('.nav-list li').click(function () { // var $this = $(this); // $this.addClass('current').siblings().removeClass('current'); // var offset = $('.header').height() + $('.ue-nav_t6').height(); // var index = $('.nav-list li').index($this); //找到序号 // var ids = $('.proDetail-cell').eq(index); //拿到对应的标题 // var axis = ids.offset().top; //找到对应标题的坐标 // $('html,body').animate({ 'scrollTop':axis - offset },2000); //滚动到标题位置 // }); // 滚动监听 // $(window).scroll(function() { // // $('.proDetail-cell').each(function(i){ // // //获取当前下标 // // var _index = $(this).index(); // // var _top = $(window).scrollTop(); // // var _height = $(this).offset().top;//获取上偏移值 // // if(_height >= _top){ // // $('.nav_list .nl-item').eq(_index).addClass('current').siblings().removeClass('current'); // // return false;//跳出遍历 // // }; // // }); // $.each($('.proDetail-cell'), function(i) { // //获取当前下标 // var _index = $(this).index(); // var _top = $(window).scrollTop(); // var _hei = $(this).offset().top;//获取上偏移值 // if(_hei <= _top){ // $('.nav_list .nl-item').eq(_index).addClass('current').siblings().removeClass('current'); // return false;//跳出遍历 // }; // }); // }) var proNavCon = $('.ue-nav_t5'); if (proNavCon.length) { $(document).scroll(function() { var $this = $(this); var scrollTop = $this.scrollTop(); var proNav=$('.proDetail-nav'); var proNavTop = proNav.offset().top; var $proLi = $('.nav-list li'); if(scrollTop >= proNavTop) { proNavCon.addClass('pro-fixed'); } else { proNavCon.removeClass('pro-fixed'); } /* var dis = scrollTop; var axis2 = []; var $mark = $('.detailNew-title'); for (var i = 0; i < $mark.length; i++) { axis2.push($mark.eq(i).offset().top - 75); } if (dis <= axis2[1]) { active($proLi, 0, 'select'); } else if (dis > axis2[1] && dis <= axis2[2]) { active($proLi, 1, 'select'); } else if (dis > axis2[2] && dis <= axis2[3]) { active($proLi, 2, 'select'); } else if (dis > axis2[3] && dis <= axis2[4]) { active($proLi, 3, 'select'); } else if (dis > axis2[4]) { active($proLi, 4, 'select'); } var $main=$('.detailNew-main'); var $mainHeight=$main.height(); var $mainTop=$main.offset().top; if(scrollTop+40>=($mainHeight+$mainTop)) { console.log('导航要跑了') // proNavCon.removeClass('pro-fixed'); // proNavCon.css({position:'absolute',bottom:0}) }*/ // else{ // proNavCon.addClass('pro-fixed'); // proNavCon.css({position:'static',bottom:'auto'}) // } });} // function active (ele, index, className) { // var className = className || 'active'; // if (index == -1) { // ele.addClass(className).siblings().removeClass(className); // } // else { // ele.eq(index).addClass(className).siblings().removeClass(className); // } // } /** * * 页面的滚动高度 >= 模块的高度+模块的offset().top * 当导航条 到达 模块底部的时候 把 导航条的定位 改成 absolute,bottom0/ *否则 还原成 fixed * * */ function proNav() { var $doc = $(document); var $del = $('.proDetail-cell'); var $nav = $('.ue-nav_t5'); var $navLis = $('.nav-list li'); var axis = []; if ($del.length) { function active(index) { var index = index; $('.nav-list li').eq(index).addClass('current').siblings().removeClass('current'); } for (var i = 0; i < $del.length; i++) { axis.push($del.eq(i).offset().top + $del.eq(i).height()); } // 滚动 $doc.scroll(function () { var dis = $(this).scrollTop() + 120; if (dis < axis[0]) { active(0); } if (dis >= axis[0] && dis < axis[1]) { active(1); } if (dis >= axis[1] && dis < axis[2]) { active(2); } if (dis >= axis[2] && dis < axis[3]) { active(3); } if (dis >= axis[3] && dis < axis[4]) { active(4); } if (dis >= axis[4] && dis < axis[5]) { active(5); } if (dis >= axis[5]) { active(6); } }); // 点击 $navLis.click(function () { var offSet = $('.header').height() + $('.ue-nav_t5').height(); var index = $('.nav-list .nl-item').index(this); $('html,body').animate({'scrollTop': axis[index] - $del.eq(index).height() - 140}, 200); }); } } $('.proDetail-nav a').click(function () { var $this = $(this); var index = $('.proDetail-nav a').index($this); //找到序号 var ids = $('.pd-edit').eq(index); //拿到对应的标题 var axis = ids.offset().top; //找到对应标题的坐标 $('html,body').animate({'scrollTop':axis-99},200) //滚动到标题位置 }); var proNavCon = $('.proDetail-nav'); if (proNavCon.length) { $(document).scroll(function() { var $this = $(this); var scrollTop = $this.scrollTop(); var proNav=$('.pat-box'); var proNavTop = proNav.offset().top; var $proLi = $('.proDetail-nav a'); if(scrollTop >= proNavTop) { proNavCon.addClass('pro-fixed'); } else { proNavCon.removeClass('pro-fixed'); } var dis = scrollTop; var axis2 = []; var $mark = $('.pd-edit'); for (var i = 0; i < $mark.length; i++) { axis2.push($mark.eq(i).offset().top - 175); } if (dis <= axis2[1]) { active($proLi, 0, 'active'); } else if (dis > axis2[1] && dis <= axis2[2]) { active($proLi, 1, 'active'); } else if (dis > axis2[2]) { active($proLi, 2, 'active'); } var $main=$('.footServ'); var $mainHeight=$main.height(); var $mainTop=$main.offset().top; if (scrollTop + 64 >= $mainTop) { proNavCon.removeClass('pro-fixeds'); proNavCon.addClass('pro-end') } else{ proNavCon.addClass('pro-fixeds'); proNavCon.removeClass('pro-end') } });} function active (ele, index, className) { var className = className || 'active'; if (index == -1) { ele.addClass(className).siblings().removeClass(className); } else { ele.eq(index).addClass(className).siblings().removeClass(className); } }