$(function () { layui.use(['carousel','element'], function () { var carousel = layui.carousel; carousel.render({ elem: "#prodpage_yj" , width: '100%' //设置容器宽度 , height: '100%' , arrow: 'always' , interval:10000 , "indicator": "none" , "autoplay": true }); carousel.render({ elem: "#prodpage_rj" , width: '100%' //设置容器宽度 , height: '100%' , arrow: 'always' , interval:10000 , "indicator": "none" , "autoplay": true }); bindevent(); domevent(); }); }); function bindevent() { var fixthesolutioncontentmain=function(){ var parentwidth=$(".the-solution-content").width(); var scale=parentwidth/1980; var left = 22*scale; var top = -40*scale; $(".the-solution-content-main").attr("style", "-webkit-transform:scale(" + scale + ") !important;left:"+left+"px;top:"+top+"px"); } //搞定产品中心的高度问题 var fixproductcentercarouselhight=function(){ $("[name='product-center']").find(".product-center-prodinfo").height($("[name='product-center']").find(".product-center-prodinfo").find('.layui-row').height()); } //搞定移动端产品分页的宽度 var fixmobileprodpagewidth=function(){ $("[name='product-center']").find(".mobile-page").find(".contaner").each(function(){ var count = $(this).find(".proditem").length; var width=$(this).find(".proditem").width(); var allw= count * width; $(this).width(allw); }) } $(document).on("onresize",function(event,resizedwinwidth, resizedwinheight, scale){ fixthesolutioncontentmain(); fixproductcentercarouselhight(); fixmobileprodpagewidth(); }); fixproductcentercarouselhight(); fixthesolutioncontentmain(); fixmobileprodpagewidth(); return{ fixmobileprodpagewidth:fixmobileprodpagewidth } } function domevent(){ $("[name='prod-center-label-btn']").click(function(){ $("[name='prod-center-label-btn']").removeclass("active"); $(this).addclass("active"); var curselectprodlabel=$(this).attr("data-label"); var winwidth = $(window).width(); if(winwidth>768){ $("[name^='prodpage_']").hide(); $("[name='prodpage_"+curselectprodlabel+"']").show(); }else{ $("[name^='mobileprodpage_']").hide(); $("[name='mobileprodpage_"+curselectprodlabel+"']").show(); var count = $("[name='mobileprodpage_"+curselectprodlabel+"']").find(".proditem").length; var width=$("[name='mobileprodpage_"+curselectprodlabel+"']").find(".proditem").width(); var allw= count * width; $("[name='mobileprodpage_"+curselectprodlabel+"']").width(allw); } }); $("[name='product-center']").find(".proditem").find(".item-content").on("click",function(){ $("[name='product-center']").find(".proditem").find(".item-content").css("bordercolor","#c0c0c0"); $(this).css("bordercolor","#3ab7ff"); var prod_id=$(this).attr("data-id"); var prod_label = $(this).attr('data-label'); var prod_title = $(this).attr('data-title'); var prod_url = $(this).attr('data-url'); var prod_info = $(this).attr('data-info'); var prod_img = $(this).attr('data-img'); $("[name='product-center-prodinfo']").find("[name='bigimg']").attr("src",prod_img); $("[name='product-center-prodinfo']").find("[name='title']").text(prod_title); $("[name='product-center-prodinfo']").find("[name='info']").html(prod_info); $("[name='product-center-prodinfo']").find("[name='url']").attr("href",prod_url); }) }