(function (doc, win) { var docel = doc.documentelement, resizeevt = "orientationchange" in window ? "orientationchange" : "resize", recalc = function () { var clientwidth = docel.clientwidth; //var foot = document.getelementbyid("foot"); if (!clientwidth) return; if (clientwidth<640){ docel.style.fontsize = 120 * (clientwidth / 640) + "px"; console.log(120 * (clientwidth / 640) + "px"); }else{ docel.style.fontsize = "120px"; } }; if (!doc.addeventlistener) return; win.addeventlistener(resizeevt, recalc, false); doc.addeventlistener('domcontentloaded', recalc, false); })(document, window); $(document).ready(function() { $(".common_news").click(function(event) { //图片加载完获取高度 var t_img1; // 定时器 var isload = false; // 控制变量 // 判断图片加载状况,加载完成后回调 isimgload(function(){ var cclih = $(".common_news li a img").outerheight(); var spanh = $(".common_news li a span").outerheight()*1.3; var maxhh =0; $(".common_news li a img").each(function(index, el) { if(maxhh < $(this).height()){ maxhh = $(this).height() return maxhh; } }); var myheight = math.floor(maxhh+spanh); $(".common_news li").height(myheight); }); // 判断图片加载的函数 function isimgload(callback){ // 注意我的图片类名都是cover,因为我只需要处理cover。其它图片可以不管。 // 查找所有封面图,迭代处理 $(".common_news li img").each(function(){ // 找到为0就将isload设为false,并退出each if(this.height === 0){ isload = false; return false; } }); // 为true,没有发现为0的。加载完毕 if(isload){ cleartimeout(t_img1); // 清除定时器 // 回调函数 callback(); // 为false,因为找到了没有加载完成的图,将调用定时器递归 }else{ console.log(2) isload = true; t_img1 = settimeout(function(){ isimgload(callback); // 递归扫描 },100); // 我这里设置的是500毫秒就扫描一次,可以自己调整 } } //图片加载完获取高度 end }); //图片加载完获取高度 var t_img1; // 定时器 var isload = false; // 控制变量 // 判断图片加载状况,加载完成后回调 isimgload(function(){ var cclih = $(".common_news li a img").outerheight(); var spanh = $(".common_news li a span").outerheight()*1.3; var maxhh =0; $(".common_news li a img").each(function(index, el) { if(maxhh < $(this).height()){ maxhh = $(this).height() return maxhh; } }); var myheight = math.floor(maxhh+spanh); //$(".common_news li").height(myheight); }); // 判断图片加载的函数 function isimgload(callback){ // 注意我的图片类名都是cover,因为我只需要处理cover。其它图片可以不管。 // 查找所有封面图,迭代处理 $(".common_news li img").each(function(){ // 找到为0就将isload设为false,并退出each if(this.height === 0){ isload = false; return false; } }); // 为true,没有发现为0的。加载完毕 if(isload){ cleartimeout(t_img1); // 清除定时器 // 回调函数 callback(); // 为false,因为找到了没有加载完成的图,将调用定时器递归 }else{ isload = true; t_img1 = settimeout(function(){ isimgload(callback); // 递归扫描 },100); // 我这里设置的是500毫秒就扫描一次,可以自己调整 } } var navbtn = $('.nav-btn'); var box = $('.allpage'), blackfixed = $(".black-fixed"); function navshow() { if(box.hasclass('clicked')){ blackfixed.removeclass('black-clicked'); box.removeclass('clicked'); $(".head,.footer,.type").removeclass('clicked'); $(".nav").removeclass('fixed'); }else{ box.addclass('clicked'); $(".head,.footer,.type").addclass('clicked'); $(".nav").addclass('fixed'); blackfixed.addclass('black-clicked'); } }; navbtn.click(navshow); blackfixed.click(navshow); $('.top-search').click(function(){ // 搜索 var search = $(".search"), _this = $(this); if(search.css("display") == "none"){ search.show(); _this.html(""); $(".search-input").focus(); }else{ search.hide(); _this.html(""); $(".search-input").blur(); } }); $('.class-btn').click(function(){ // 分类 $(".type").toggle(); }); $('.common-search-btn').click(function(){ // 分类 $(".common-search").toggle(); }); // 新增 $(".cart-select").click(function(){ $(this).toggleclass("on"); }); $(".cart_order_type span").on("click",function(){ if($(this).hasclass("type_company")){ $(".cart_type_company").show(); $(this).parents(".cart_order_type").find("span").removeclass("on"); $(this).addclass("on"); }else{ $(".cart_type_company").hide(); $(this).parents(".cart_order_type").find("span").removeclass("on"); $(this).addclass("on"); } }); // 星星 var starpf = $(".discuss_list_top_right font"), stararr = {}, starcolor = $(".discuss_list_top_right"); for(var i=0;imath.abs(dy)){dir.horizontal=true;}else{dir.horizontal=false;}} if(dir.horizontal){e.preventdefault();if((cur===0&&x>0)||(cur===length-1&&x<0)){slider.transform(slidecon,((x/6/width-cur)*100/length)+'%');} else{slider.transform(slidecon,((x/width-cur)*100/length)+'%');}}else{isbegin=false;ismove=false;isend=true;delete dir.horizontal;return;}};this.end=function(e){if(!isbegin||!ismove){isbegin=false;ismove=false;isend=true;delete dir.horizontal;autoplay();return;} isend=false;isbegin=false;ismove=false;slider.addclass(slidecon,'transition');temp=cur;if(x>0){cur=cur===0?0:cur-1;}else{cur=cur===length-1?length-1:cur+1;} slider.removeclass(navitem[temp],navcur);slider.addclass(navitem[cur],navcur);slider.transform(slidecon,(-cur*100/length)+'%');settimeout(function(){x=0;slider.removeclass(slidecon,'transition');isend=true;autoplay();},delay);delete dir.horizontal;};slidecon.addeventlistener('touchstart',this.start,false);slidecon.addeventlistener('touchmove',this.move,false);slidecon.addeventlistener('touchend',this.end,false);slidecon.addeventlistener('touchcancel',this.end,false);slidecon.addeventlistener('mousedown',this.start,false);slidecon.addeventlistener('mousemove',this.move,false);slidecon.addeventlistener('mouseup',this.end,false);slidecon.addeventlistener('mouseout',this.end,false);autoplay();} slider.transform=function(element,x,y,z){x=x||0;y=y||0;z=z||0;var style=element.style;if(typeof x==='string'&&(x.indexof('%')||y.indexof('%'||z.indexof('%')))){style.webkittransform='translate3d('+x+', '+y+', '+z+')';style.moztransform='translate('+x+', '+y+')';style.otransform='translate('+x+', '+y+')';style.transform='translate('+x+', '+y+')';}else{style.webkittransform='translate3d('+x+'%, '+y+'%, '+z+'%)';style.moztransform='translate('+x+'%, '+y+'%)';style.otransform='translate('+x+'%, '+y+'%)';style.transform='translate('+x+'%, '+y+'%)';}};slider.addclass=function(element,classname){var temp=element.classname;element.classname=temp+' '+classname;} slider.removeclass=function(element,classname){var temp=element.classname;temp=temp.split(' ');for(var i=0,length=temp.length;i