var $window = $(window), flexslider = { vars:{} }, flexslider1 = { vars:{} }; $(function(){ // $('.product-list-b li').eq(1).addClass("newss"); $('.news-page a').each(function(index, el) { if ($(el).attr('href') != "#") { el.href += location.search; } }); function getGridSize() { return (window.innerWidth >= 1025) ? "fade" : "slide"; } function getGridSize1() { return (window.innerWidth < 480) ? 1 : (window.innerWidth < 1025) ? 2 : 4; } getwidth() winsize() $(window).resize(function(){ flexslider.vars.animation = getGridSize(); getwidth() winsize() flexslider1.vars.minItems = getGridSize1(); flexslider1.vars.maxItems = getGridSize1(); }) //首页banner图 function winsize(){ var winw = $(window).width(); if (winw > 1025) { $('.wel-banner .slides li').each(function(){ var wb = $(this).attr('data-pc'); $(this).find(".pic").attr('src',wb); }) var hs = $('.wel-case .slides li').width(); $('.wel-case .slides li').hover(function(){ var h = $(this).find('img').width(); $(this).stop().animate({width:h},500); },function(){ $(this).stop().animate({width:hs},500); }) }else{ $('.wel-banner .slides li').each(function(){ var wb = $(this).attr('data-mobile'); $(this).find(".pic").attr('src',wb); }) } } var size = $('.wel-case .slides li').size(); if (size > 1) { $('.wel-banner').flexslider({ animation: 'slide', slideshowSpeed: 4000, animationSpeed: 1000, touch: true, slideshow: true, start: function(slider){ flexslider = slider; $('.wel-banner .loader').hide(); $('.flex-direction-nav a').text(""); } }); }; $('.product-list-b li').each(function(){ var index = $(this).index(); if (index % 3 == 2) { $(this).addClass("on"); } if(index % 2 == 1){ $(this).addClass("cur"); } }) $('.product-list .text').focus(function(){ $(this).parents('.form').addClass('on'); }) $('.product-list .text').blur(function(){ $(this).parents('.form').removeClass('on'); }) function getwidth(){ var winw = $(window).width(), w14 = $('.w1400').width(), nw = (winw - w14)/2 $('.product-nav').css('left',-nw); } $('.product-nav .link-box .link-tit').on('click',function(e){ if ($(this).hasClass("cur")) { $(this).removeClass("cur"); $(this).next('.link-box-b').slideUp(); }else{ $(this).addClass("cur").siblings('.link-tit').removeClass("cur"); $(this).next('.link-box-b').slideDown().siblings(".link-box-b").slideUp(); } e.preventDefault(); var _this = $(this); var link = _this.attr('href'); console.log(link); if (link == "javascript:;") { return false; }else{ var html = ''; $('.product-list-b li.but').each(function (i){ var othis = $(this); if(i){ html += '-'+othis.attr('data-id'); }else{ html += othis.attr('data-id'); } }); _this.attr("href",link+'&var='+html) var windows = _this.attr('href'); console.log(windows); window.location.href = windows; } }) $('.product-nav .link-box-tit').on('click',function(e){ if ($(this).hasClass("into")) { $(this).removeClass("into"); $(this).next('.link-box-con').slideUp(); }else{ $(this).addClass("into").siblings('.link-box-tit').removeClass("into"); $(this).next('.link-box-con').slideDown().siblings(".link-box-con").slideUp(); } e.preventDefault(); var _this = $(this); var link = _this.attr('href'); console.log(link); if (link == "javascript:;") { return false; }else{ var html = ''; $('.product-list-b li.but').each(function (i){ var othis = $(this); if(i){ html += '-'+othis.attr('data-id'); }else{ html += othis.attr('data-id'); } }); _this.attr("href",link+'&var='+html) var windows = _this.attr('href'); console.log(windows); window.location.href = windows; } }) $('.product-nav .tit').on('click',function(e){ // if ($(this).hasClass("on")) { // $(this).removeClass("on"); // $('.product-nav .tit-box').slideUp(); // }else{ // $(this).addClass("on"); // $('.product-nav .tit-box').slideDown(); // } e.preventDefault(); var _this = $(this); var link = _this.attr('href'); console.log(link); if (link == "javascript:;") { return false; }else{ var html = ''; $('.product-list-b li.but').each(function (i){ var othis = $(this); if(i){ html += '-'+othis.attr('data-id'); }else{ html += othis.attr('data-id'); } }); _this.attr("href",link+'&var='+html) var windows = _this.attr('href'); console.log(windows); window.location.href = windows; } }) $('.product-nav .tit').hover(function(){ $(this).addClass("on"); $('.product-nav .tit-box').slideDown(200); },function(){ $(this).removeClass("on"); $('.product-nav .tit-box').slideUp(200); }) $('.product-nav .nav-link').on('click',function(){ if ($(this).hasClass("on")) { $(this).removeClass("on"); $(this).next('.link-box').slideUp(); }else{ $(this).addClass("on"); $(this).next('.link-box').slideDown(); } }) //产品导航 //初始 // $('.pn-list li').eq(0).find('.pn-tit-one').next('.pn-con-one').slideDown(); // $('.pn-list li').eq(0).find('.pn-tit-two').eq(0).addClass('cur').next('.pn-con-two').slideDown().find('.pn-tit-three').eq(0).addClass('cut ').next('.pn-con-three').slideDown().find(".pn-tit-four").eq(0).addClass("cur").next(".pn-con-four").slideDown().find(".pn-tit-five").eq(0).addClass("cur"); $('.pn-list .pn-tit.cursleect').parents('.pn-content').slideDown().prev('.pn-tit').addClass('cur cut'); var retractLeft = $(".pn-list").width(); $('.pn-box').hover(function(){ $('.pn-list').addClass('on') $('.pn-retract').css("left",retractLeft) },function(){ $('.pn-list').removeClass('on') $('.pn-retract').css("left",-retractLeft) }) // 收起箭头 $('.pn-retract').hover(function() { $('.pn-list').removeClass('on'); $('.pn-retract').css("left",-retractLeft) },function(){ $('.pn-list').addClass('on') $('.pn-retract').css("left",retractLeft) }) $('.pn-list li .pn-tit-one').on('click',function(){ var sss = $(this).parent('li').index(); var len = $('.pn-list li').length-1; if (sss == len) { var off = $(this).offset().top - ($('.pn-list').height()/2); $('.pn-list').stop().animate({'scrollTop':off},500); }; if (!$(this).hasClass('cut')) { $(this).addClass('cut').parents('li').siblings('li').find('.pn-tit-one').removeClass('cut'); $(this).next('.pn-con-one').slideDown().parents('li').siblings('li').find('.pn-con-one').slideUp() }else{ $(this).removeClass('cut') $(this).next('.pn-con-one').slideUp() } }) $('.pn-list li .pn-tit-two').on('click',function(){ if (!$(this).hasClass('cur')) { $(this).addClass('cur').siblings('.pn-tit-two').removeClass('cur').parents('li').siblings('li').find('.pn-tit-two').removeClass('cur'); $(this).next('.pn-con-two').slideDown().siblings('.pn-con-two').slideUp().parents('li').siblings('li').find('.pn-con-two').slideUp() }else{ $(this).removeClass('cur') $(this).next('.pn-con-two').slideUp() } }) $('.pn-list li .pn-tit-three').on('click',function(){ if (!$(this).hasClass('cur')) { $(this).addClass('cur').siblings('.pn-tit-three').removeClass('cur').parents('li').siblings('li').find('.pn-tit-three').removeClass('cur'); $(this).next('.pn-con-three').slideDown().siblings('.pn-con-three').slideUp().parents('li').siblings('li').find('.pn-con-three').slideUp() }else{ $(this).removeClass('cur') $(this).next('.pn-con-three').slideUp() } }) $('.pn-list li .pn-tit-four').on('click',function(){ if (!$(this).hasClass('cur')) { $(this).addClass('cur').siblings('.pn-tit-four').removeClass('cur').parents('li').siblings('li').find('.pn-tit-four').removeClass('cur'); $(this).next('.pn-con-four').slideDown().siblings('.pn-con-four').slideUp().parents('li').siblings('li').find('.pn-con-four').slideUp() }else{ $(this).removeClass('cur') $(this).next('.pn-con-four').slideUp() } }) //产品对比 /* $('.product-contrast .contrast-list').flexslider({ animation: 'slide', animationLoop: false, slideshow: false, itemWidth: 310, itemMargin: 4, move:1, minItems: getGridSize1(), maxItems: getGridSize1(), start: function(slider){ flexslider1 = slider; $('.flex-direction-nav a').text(""); } })*/ $('.product-list-b li .add').on('click',function(){ var part = $(this).parents("li"); var SPEARTER = "-"; var sku = $(this).data('sku'); var id = part.data('id'); var hre = part.find('.link').attr('href'); var src = part.find('img').attr('src'); var tit = part.find('h3').data('title'); var font = part.find('.font').data('font'); $('.product-contrast').height('auto'); match = true; if(!part.hasClass("but")){ var ajaxUrl = "https://www.dahuatech.com/product/addcompare.html"; $.ajax({ url: ajaxUrl, async:false, type: 'POST', dataType: 'json', data: {'ci_csrf_token':'',id:id }, }) .done(function(data) { if(data.status==2){ alert(data.msg); }else if(data.status==1){ part.addClass("but"); $('.product-contrast .contrast-list .slides li').each(function (i){ var othis = $(this); if(!othis.attr("data-id")&&match){ match = false; othis.attr('data-id',id); othis.attr('data-sku',id); othis.find('a').attr('href',hre).html('
'+font+'
').after(''); inVal(); $(".product-contrast .title span b").html(data.count) // if(othis.index()>2 && othis.index()<8){ // $(".flex-next").click(); // return false // } } }); } }) }else{ part.removeClass("but"); $('.product-contrast .contrast-list .slides li').each(function (i){ var othis = $(this); var sid = othis.data('id'); if(id==sid){ othis.attr('data-id',''); othis.attr('data-sku',''); othis.find("a").attr('href','javascript:;').html('您还可以继续添加
') order_state(); inVal(); // if(1您还可以继续添加
') othis.attr('data-id','') othis.attr('data-sku','') } }); var ajaxUrl = "https://www.dahuatech.com/product/delcompareall.html"; $.ajax({ url: ajaxUrl, async:false, type: 'POST', dataType: 'json', data: {'ci_csrf_token':''}, }) .done(function(data) { if(data.status==1){ $(".product-contrast .title span b").html(data.count) } }) $('.product-contrast .contrast-btn.on').removeClass("on").attr("href","javascript:;"); $('.product-list-b li').removeClass('but'); }); //调整位置 function order_state(){ var htmlArr = []; $('.product-contrast .contrast-list .slides li').each(function (i){ var othis = $(this); if(othis.attr("data-id")){ htmlArr.push({ all:othis.find("a").html(), id:othis.attr('data-id'), sku:othis.attr('data-sku') }); othis.find("a").attr('href','javascript:;').html('您还可以继续添加
') othis.attr('data-id','') othis.attr('data-sku','') } }); $('.product-contrast .contrast-list .slides li').each(function (i){ var othis = $(this); if(i