//banner $(function () { var $firstimg = $('.banner img').eq(0); if ($firstimg.length) { var img = new image(); img.onload = function () { if ($firstimg.innerheight() < 1) { $('.banner').css({'height': 'auto'}); } else { $('.banner').css({'height': $firstimg.innerheight()}); } } img.src = $firstimg.attr("src"); settimeout(function () { $('.banner').css({'height': 'auto'}); }, 8000); $(window).resize(function () { $('.banner').css({'height': 'auto'}); }); }else{ $('.banner').css({'height': 'auto'}); } }); /*单选框*/ $(function () { $('.w-option').click(function () { $(this).siblings('.w-option').children('input').removeclass('checked'); $(this).children('input').addclass('checked'); }); }); /*复选框*/ $(function () { $('input[type="checkbox"]').on('change', function () { $(this)[$(this).prop('checked') ? 'addclass' : 'removeclass']('checked'); }); }); /*选择下拉框*/ $(function () { var selects = $(".w-select-box"); var i; for (i = 0; i < selects.length; i++) { selects.eq(i).parent().parent().css({'z-index': 100 - i}); selects.eq(i).css({'z-index': 100 - i, 'position': 'relative'}); } $('.w-select-option').hide(); $('.w-select-box .w-select-dt').bind('click', function (e) { if ($(this).children('.select-icon').hasclass('select-down')) { $(this).children('.select-icon').removeclass('select-down'); $(this).parent().find('.w-select-option').slideup(); e.stoppropagation(); } else { $(this).children('.select-icon').addclass('select-down'); $(this).parent().find('.w-select-option').slidedown(); e.stoppropagation(); } }) $("body").bind("click", function (e) { e = window.event || e; // 兼容ie7 obj = $(e.srcelement || e.target); if ($(obj).is(".w-select-box *")) { } else { $('.w-select-option').slideup(); $('.w-select-dt').children('.select-icon').removeclass('select-down'); } }); $('.w-select-option div').click(function () { var itemcontent = $(this).html(); $(this).parents('.w-select-dl').find('.w-select-dt .selected').html(itemcontent).trigger("contentchanged"); $(this).parents('.w-select-dl').find('.w-select-option').slideup(); $(this).parents('.w-select-dl').find('.w-select-dt').children('.select-icon').removeclass('select-down'); }); }); /*会员选择下拉框*/ $(function () { var selects = $(".select-box-gw"); var i; for (i = 0; i < selects.length; i++) { selects.eq(i).parent().parent().css({'z-index': 100 - i}); selects.eq(i).css({'z-index': 100 - i, 'position': 'relative'}); } $('.select-option-gw').hide(); $('.select-box-gw .select-dt-gw').bind('click', function (e) { if ($(this).data("select") === false) { return ''; } $(this).parent().find('.select-option-gw').slidedown(); e.stoppropagation(); $(this).parents('.select-dl-gw').find('.select-option-gw div').click(function () { var itemcontent = $(this).html(); $(this).parents('.select-dl-gw').find('.select-dt-gw .selected').html(itemcontent); $(this).parents('.select-dl-gw').find('.select-option-gw').slideup(); }); }) $("body").bind("click", function (e) { e = window.event || e; // 兼容ie7 obj = $(e.srcelement || e.target); if ($(obj).is(".select-box-gw *")) { } else { $('.select-option-gw').slideup(); } }); }); /*tab切换*/ $(function () { $(".info_tab li[data-tab]").click(function () { $(this).siblings().removeclass('cur_tab'); $(this).addclass('cur_tab'); var data = $(this).attr('data-tab'); $("div[id^='tabitem']").hide(); $("#tabitem" + data).show(); }); }); /*收藏滚动*/ $(function () { var conboxchild = $('.collect_lista').html(); var slidec = function () { var visc; if ($(window).width() > 960) { visc = 5; } else if ($(window).width() > 767) { visc = 4; } else { visc = 3; } if($(".mycollecta").is(':visible')){ $(".mycollecta").slidenew({ maincell: ".collect_lista ul", autopage: false, effect: "leftloop", autoplay: true, scroll: 1, vis: visc, prevcell: ".slide_la", nextcell: ".slide_ra" }); } } slidec(); var widthold=$(window).width(); var widthnew; $(window).resize(function () { widthnew=$(window).width(); if(widthold > 960){ if(widthnew < 960){ $('.collect_lista').html(conboxchild); slidec(); } }else if(widthold > 768){ if(widthnew < 768){ $('.collect_lista').html(conboxchild); slidec(); }else if(widthnew > 960){ $('.collect_lista').html(conboxchild); slidec(); } }else{ if(widthnew > 768){ $('.collect_lista').html(conboxchild); slidec(); } } widthold=$(window).width(); }); }); /*新闻组件3的右边图片大小自适应*/ /*图片位置计算*/ var imgcount = function () { $('.img-count').each(function (index, element) { var imgh = $(this).height(); var imgw = $(this).width(); var $thisimg = $(this).find('img'); var img = new image(); img.onload = function () { if ($thisimg.data("img") === false) { return ''; } if ($thisimg.data("img") === 'autoimagesize') { $.autoimagesize($thisimg); return ''; } if ($thisimg.data("img") === 'autoproductimgsize') { $.autoproductimgsize($thisimg); return ''; } var imgwidth = img.width; var imgheight = img.height; if ($thisimg.data("img") === 'allimgsize') { if (imgwidth <= imgw && imgheight <= imgh) { widththan = 'auto'; heightthan = 'auto'; leftthan = (((imgw - imgwidth) / 2) / imgw) * 100; topthan = (((imgh - imgheight) / 2) / imgh) * 100; } else { if (imgheight > imgh) { imgwidth = (imgh / imgheight) * imgwidth; imgheight = imgh; } if (imgwidth > imgw) { imgheight = (imgw / imgwidth) * imgheight; imgwidth = imgw; } widththan = ((imgwidth / imgw) * 100) + '%'; heightthan = ((imgheight / imgh) * 100) + '%'; leftthan = (((imgw - imgwidth) / 2) / imgw) * 100; topthan = (((imgh - imgheight) / 2) / imgh) * 100; } $thisimg.css({'position':'absolute', 'width': widththan, 'height': heightthan, 'left': leftthan + '%', 'top': topthan + '%' }); return ''; } if ((imgwidth / imgheight) < (imgw / imgh)) { $thisimg.css({'height': (imgw / imgh) * ((imgheight * 1.00) / imgwidth) * imgh, 'max-height': (imgw / imgh) * ((imgheight * 1.00) / imgwidth) * imgh, 'top': -((imgw / imgh) * ((imgheight * 1.00) / imgwidth) - 1) / 2 * imgh, 'width': '100%', 'max-width': '100%', 'left': 0}) } else { $thisimg.css({'width': (imgh / imgw) * ((imgwidth * 1.00) / imgheight) * imgw, 'max-width': (imgh / imgw) * ((imgwidth * 1.00) / imgheight) * imgw, 'left': -((imgh / imgw) * ((imgwidth * 1.00) / imgheight) - 1) / 2 * imgw, 'height': '', 'max-height': '', 'top': 0}) } } var thisimg_src = $thisimg.attr("src"); if(typeof(thisimg_src) != 'undefined'){ img.src = $thisimg.attr("src"); } }); } var imgcount1 = function (dom) { var imgh = dom.height(); var imgw = dom.width(); var $thisimg = dom.find('img'); var img = new image(); img.onload = function () { if ($thisimg.data("img") === false) { return ''; } if ($thisimg.data("img") === 'autoimagesize') { $.autoimagesize($thisimg); return ''; } if ($thisimg.data("img") === 'autoproductimgsize') { $.autoproductimgsize($thisimg); return ''; } var imgwidth = img.width; var imgheight = img.height; if ($thisimg.data("img") === 'allimgsize') { if (imgwidth <= imgw && imgheight <= imgh) { widththan = 'auto'; heightthan = 'auto'; leftthan = (((imgw - imgwidth) / 2) / imgw) * 100; topthan = (((imgh - imgheight) / 2) / imgh) * 100; } else { if (imgheight > imgh) { imgwidth = (imgh / imgheight) * imgwidth; imgheight = imgh; } if (imgwidth > imgw) { imgheight = (imgw / imgwidth) * imgheight; imgwidth = imgw; } widththan = ((imgwidth / imgw) * 100) + '%'; heightthan = ((imgheight / imgh) * 100) + '%'; leftthan = (((imgw - imgwidth) / 2) / imgw) * 100; topthan = (((imgh - imgheight) / 2) / imgh) * 100; } $thisimg.css({'position':'absolute', 'width': widththan, 'height': heightthan, 'left': leftthan + '%', 'top': topthan + '%' }); return ''; } if ((imgwidth / imgheight) < (imgw / imgh)) { $thisimg.css({'height': (imgw / imgh) * ((imgheight * 1.00) / imgwidth) * imgh, 'max-height': (imgw / imgh) * ((imgheight * 1.00) / imgwidth) * imgh, 'top': -((imgw / imgh) * ((imgheight * 1.00) / imgwidth) - 1) / 2 * imgh, 'width': '100%', 'max-width': '100%', 'left': 0}) } else { $thisimg.css({'width': (imgh / imgw) * ((imgwidth * 1.00) / imgheight) * imgw, 'max-width': (imgh / imgw) * ((imgwidth * 1.00) / imgheight) * imgw, 'left': -((imgh / imgw) * ((imgwidth * 1.00) / imgheight) - 1) / 2 * imgw, 'height': '', 'max-height': '', 'top': 0}) } } var thisimg_src = $thisimg.attr("src"); if(typeof(thisimg_src) != 'undefined'){ img.src = $thisimg.attr("src"); } } $(function () { var xxh = false; var adimgwh = function () { var $adnews = $('.w-adnews3'); for (var i = 0; i < $adnews.length; i++) { var adimgw = $adnews.eq(i).find('.w-adnews-imgs').width(); var adimgh = $adnews.eq(i).find('.w-adnews-texts').height(); if($adnews.eq(i).find('.news-img .aspectratio').attr('style')==null || xxh){ $adnews.eq(i).find('.news-img .aspectratio').css('padding-bottom', (adimgh * 1.0 / adimgw) * 100 + '%'); xxh = true; } } } adimgwh(); imgcount(); var time = 0; var interval = setinterval(function () { imgcount(); if (time++ > 50) { clearinterval(interval); } }, 100); $(window).resize(function () { if(xxh){adimgwh();} imgcount(); }); }); //palceholder $(function () { // 判断浏览器是否是ie7 if (navigator.appname == "microsoft internet explorer" && navigator.appversion.split(";")[1].replace(/[ ]/g, "") == "msie7.0") { if ($(".w-prd-imgbox>a").length > 0 && $(".w-prd-imgbox>a").find("img").length > 0) { $(".w-prd-imgbox>a").find("img").css("cursor", "pointer").click(function () { $(this).parents("a").children().click(); }); } if ($(".news-imgbox>a").length > 0 && $(".news-imgbox>a").find("img").length > 0) { $(".news-imgbox>a").find("img").css("cursor", "pointer").click(function () { $(this).parents("a").children().click(); }); } } //判断浏览器是否支持placeholder属性 supportplaceholder = 'placeholder'in document.createelement('input'), placeholder = function (input) { var text = input.attr('placeholder'); var defaultvalue = input.val(); if (!defaultvalue) { if ($.trim(input.attr("type")) === "password") { input.hide(); var inputpasshtml = ''; input.parent("div").append(inputpasshtml); input.parent().children(".g-text-password").focus(function () { $(this).hide(); input.show().focus(); }); input.blur(function () { if ($.trim($(this).val()) == text || $.trim($(this).val()) == "") { $(this).hide(); input.parent().children(".g-text-password").show(); } }); } else { input.val(text).addclass("phcolor"); input.focus(function () { if (input.val() == text) { $(this).val(""); } }); input.blur(function () { if (input.val() == "") { $(this).val(text).addclass("phcolor"); } }); //输入的字符不为灰色 input.keydown(function () { $(this).removeclass("phcolor"); }); } } }; //当浏览器不支持placeholder属性时,调用placeholder函数 if (!supportplaceholder) { $('input').each(function () { text = $(this).attr("placeholder"); if ($(this).attr("type") == "text" || $(this).attr("type") == "tel" || $(this).attr("type") == "email" || $(this).attr("type") == "password") { placeholder($(this)); } }); } }); $(function () { $('.w-adnews4').each(function(index, element) { if($(this).find('.date').is(':visible')){ }else{ $(this).addclass('w-adnews4-nodate'); } }); }); //文章广告7移入背景颜色变化 $(function () { var adnewslh; $('.w-adnews7 .adnewsl li').hover(function () { $(this).find('.date').addclass('bg_main'); $(this).find('.triangle-bottomright').addclass('border_colorbottom_main'); }, function () { $(this).find('.date').removeclass('bg_main'); $(this).find('.triangle-bottomright').removeclass('border_colorbottom_main'); }); $('.w-adnews7').each(function (index, element) { adnewslh = $(this).find('.adnewsl').height() - parseint($(this).find('.adnewsl li').css('margin-bottom')); if ($(window).width() > 767) { $(this).find('.adnewsr').css({"min-height": adnewslh}); } }); $(window).resize(function () { $('.w-adnews7').each(function (index, element) { if ($(window).width() > 767) { adnewslh = $(this).find('.adnewsl').height() - parseint($(this).find('.adnewsl li').css('margin-bottom')); $(this).find('.adnewsr').css({"min-height": adnewslh}); } else { $(this).find('.adnewsr').removeattr("style"); } }); }) }); //文章广告移入背景颜色变化 $(function () { $('.w-adnews16 li .news-item').hover(function () { $(this).find('.adnew_mask').addclass('bg_main'); }, function () { $(this).find('.adnew_mask').removeclass('bg_main'); }); }); //系统菜单导航手机显示隐藏 $(function(){ if($(window).width()<768){ $('.systitle').bind('click',function(){ if($(this).hasclass('open')){ $(this).removeclass('open'); $(this).siblings('.ul-parent').slideup(); $(this).siblings('.ul-parent').find('.ul-submenu').slideup(); $(this).siblings('.ul-parent').find('.open').removeclass('open'); }else{ $(this).addclass('open'); $(this).siblings('.ul-parent').slidedown(); } }); } var oldwidth=$(window).width(); $(window).resize(function(){ var newwidth=$(window).width(); if(oldwidth>767){ if(newwidth<768){ $('.systitle').siblings('.ul-parent').slideup(); $('.systitle').bind('click',function(){ if($(this).hasclass('open')){ $(this).removeclass('open'); $(this).siblings('.ul-parent').slideup(); $(this).siblings('.ul-parent').find('.ul-submenu').slideup(); $(this).siblings('.ul-parent').find('.open').removeclass('open'); }else{ $(this).addclass('open'); $(this).siblings('.ul-parent').slidedown(); } }); } }else{ if(newwidth>768){ $('.systitle').unbind('click'); $('.systitle').removeclass('open'); $('.systitle').siblings('.ul-parent').slidedown(); $('.systitle').siblings('.ul-parent').find('.ul-submenu').removeattr('style'); $('.systitle').siblings('.ul-parent').find('.open').removeclass('open'); } } oldwidth=$(window).width(); }); }); //系统分类3二级 $(function(){ var mlw=0; var mlc=function(){ $('.w-com-menu-h2 > .w-com-menu-in > .ul-parent > .li-parent > .div-parent').each(function(index, element) { if($(this).innerwidth()>mlw){ mlw=$(this).innerwidth(); } }); } $('.w-com-menu-h2 a').each(function(index, element) { if($(this).closest('li').hasclass('cur')){ $(this).addclass('colorbg_main'); }else{ $(this).hover(function(){ $(this).addclass('colorbg_main'); },function(){ $(this).removeclass('colorbg_main'); }); } }); if($(window).width()>767){ mlc(); $('.w-com-menu-h2 > .w-com-menu-in > .ul-parent > .li-parent > .div-parent').css({'width':mlw+3}); $('.w-com-menu-h2 .ul-submenu').css({'margin-left':mlw+20}); } var oldwidth=$(window).width(); $(window).resize(function(){ var newwidth=$(window).innerwidth(); if(oldwidth>767){ if(newwidth<768){ $('.w-com-menu-h2 > .w-com-menu-in > .ul-parent > .li-parent > .div-parent').removeattr("style"); $('.w-com-menu-h2 .ul-submenu').removeattr("style"); } }else{ if(newwidth>768){ mlw=0; mlc(); $('.w-com-menu-h2 > .w-com-menu-in > .ul-parent > .li-parent > .div-parent').css({'width':mlw+3}); var mull=function(){ $('.w-com-menu-h2 .ul-submenu').css({'margin-left':mlw+20}); } settimeout(mull,500); } } oldwidth=$(window).width(); }); }); //faq3点击缩放 $(function(){ $('.w-faq-list3 li .faq_tit').addclass('faq_tit3bg'); $('.w-faq-list3 li').eq(0).addclass('open'); $('.w-faq-list3 li').eq(0).find('.faq_tit').addclass('bg_main'); $('.w-faq-list3 li').eq(0).find('.faq_det').slidedown(); $('.w-faq-list3 li .faq_tit').click(function(){ $(this).parents('li').siblings('li').removeclass('open'); $(this).parents('li').siblings('li').find('.faq_tit').removeclass('bg_main'); $(this).parents('li').siblings('li').find('.faq_det').slideup(); if($(this).parents('li').hasclass('open')){ $(this).parents('li').removeclass('open'); $(this).siblings('.faq_det').slideup(); $(this).removeclass('bg_main'); }else{ $(this).parents('li').addclass('open'); $(this).siblings('.faq_det').slidedown(); $(this).addclass('bg_main'); } }); }); //手机滚动到顶部 $(function(){ if($(window).scrolltop()>10){ if($(window).width()<960){ $('.toptel').show(); } } $(window).scroll(function(){ if($(window).width()<960){ if($(window).scrolltop()>10){ $('.toptel').show(); }else{ $('.toptel').hide(); } } }) }); //产品详情 $(function(){ $('.product-detail-info .product-short-sum').each(function(){ if($.trim($(this).html()) === ''){ $(this).remove(); }else{ if($(this).innerheight()<25){ $(this).remove(); } } }) $('.product-detail-info .prd_detinfo_con').each(function(){ if($.trim($(this).html()) === ''){ $(this).remove(); }else{ if($(this).height()<16){ $(this).remove(); } } }) }) $(function () { $('.w-button25 .btn-w').on('mouseenter', function (e) { var parentoffset = $(this).offset(), relx = e.pagex - parentoffset.left, rely = e.pagey - parentoffset.top; $(this).find('.bgsqr1').css({ top: rely, left: relx }); }).on('mouseout', function (e) { var parentoffset = $(this).offset(), relx = e.pagex - parentoffset.left, rely = e.pagey - parentoffset.top; $(this).find('.bgsqr1').css({ top: rely, left: relx }); }); }); // 语言下拉 $(function () { let firstclick = true; var langposition = function(){ $('.w-languege-dropdown').each(function () { let leftlang = $(this).offset().left; let toplang = $(this).offset().top - $(window).scrolltop(); let $selectlang = $(this).find('.select-lang'); let widlang = $selectlang.innerwidth(); let widwindow = $(window).innerwidth(); let hghlang = $selectlang.innerheight(); let hghwindow = $(window).innerheight(); if (leftlang && widlang && leftlang + widlang + 20 > widwindow) { $selectlang.css({'right':'-15px', 'left':'auto'}) } if (toplang && hghlang && toplang + hghlang + 30 > hghwindow) { $selectlang.css({'top':'auto', 'bottom': '100%'}) } }) } langposition(); $('.mobile-nav-toggle').click(function () { let settimeoutlang; if (firstclick) { settimeoutlang = settimeout(function () { langposition(); }, 1000); firstclick = false; } else { if (settimeoutlang) { cleartimeout(settimeoutlang) } } }) })