//banner $(function(){ var $firstimg = $('.banner img').eq(0); var img = new image(); img.onload = function () { $('.banner').css({'height':$firstimg.innerheight()}); } img.src = $firstimg.attr("src"); $(window).resize(function () { $('.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; } $(".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 ((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}) } 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}) } } img.src = $thisimg.attr("src"); }); } $(function () { 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(); $adnews.eq(i).find('.news-img .aspectratio').css('padding-bottom', (adimgh * 1.0 / adimgw) * 100 + '%'); } } adimgwh(); imgcount(); var time = 0; var interval = setinterval(function () { imgcount(); if (time++ > 50) { clearinterval(interval); } }, 100); $(window).resize(function () { 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)); } }); } }); //文章广告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"); } }); }) }); //文章广告16移入背景颜色变化 $(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(); }); }); //faq3点击缩放 $(function(){ $('.w-faq-list3 li').eq(0).addclass('open'); $('.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_det').slideup(); if($(this).parents('li').hasclass('open')){ $(this).parents('li').removeclass('open'); $(this).siblings('.faq_det').slideup(); }else{ $(this).parents('li').addclass('open'); $(this).siblings('.faq_det').slidedown(); } }); }); //手机滚动到顶部 $(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($(this).height()<25){ $(this).remove(); } }) $('.product-detail-info .prd_detinfo_con').each(function(){ if($(this).height()<25){ $(this).remove(); } }) })