/*** * zscms */ var zscms = zscms || {}; ;(function($){ $.OP_URL = ""; $.OP_RTL = ""; $.ROOT = ""; $.DT = ""; // TemplateFace datatype $.catid = "0"; // 鍒嗙被ID $.cid = ""; // 鏂囩珷ID $.siteid = ""; // 绔欑偣ID $.siteno = ""; // 绔欑偣ID /**缁熻*/ $.stat = function(){ try{ var dt = $.DT; var catids = []; var cids = []; if($.catid != "" && $.catid != "0"){ catids.push($.catid); } if($.cid != "" && $.cid != "0"){ cids.push($.cid); } EDom(".statcatid").each(function(o,i){ var id = EDom(o).attr("data-id"); if(id && id !== $.catid){ catids.push(id); } }); EDom(".statcid").each(function(o,i){ var id = EDom(o).attr("data-id"); if(id && id !== $.catid){ cids.push(id); } }); if(catids.length > 0) { zt.post("/cms.oms?omsv=statcat", "id="+ENC(catids.join(","))+"&rd="+Math.random(), function(s){ }); } if(cids.length > 0) { zt.post("/cms.oms?omsv=stathit", "id="+ENC(cids.join(","))+"&rd="+Math.random(), function(s){ }); } var pathname = window.location.pathname; if(pathname === "" || pathname == "/" || pathname == "/index.oms" || pathname == "/index.jsp" || pathname == "/index.html" || pathname == "/index.htm") { if(($.catid === "" || $.catid === "0") && ($.cid === "" || $.cid === "0")){ zt.post("/cms.oms?omsv=statindex", "siteno="+ENC($.siteno)+"&rd="+Math.random(), function(s){ }); } } }catch(Xc){} }; /**鎵撳嵃鍒嗛〉*/ $.printPage = function(tr, curp, ps, cx) { try{ var r = parseInt(tr); var p = parseInt(curp); var s = parseInt(ps); if(isNaN(p))p = 1; if(isNaN(r))r = 0; if(isNaN(s))s = 20; var tp = parseInt(""+(r/s))+(r%s == 0 ? 0 : 1); var str = '<'; var j = 0; var st = p-2; var ed = p+2; if(st < 1)st = 1; if(ed > tp)ed = tp; if(ed < 1)ed = 1; for(var i = st; i <= ed; i++){ str += ''+i+''; } str += '>'; document.write(str); }catch(xcd){} }; /*PC鐗堝鑸爮鍔ㄧ敾鏁堟灉*/ $.bindnav = function(){ var pcnav = EDom(".pcnav .wrap >ul >li"); pcnav.each(function(li,i){ var L = EDom(li); L.addclz("ease"); var submenu = EDom("li > ul", li); submenu.css("visibility", "hidden").css("height", "auto").css("width", "auto").addclz("ease"); var submenuheight = submenu.height(); var submenuwidth = submenu.width(); submenu.css("height", "0px").css("visibility", "visible"); //.css("width", submenuwidth+"px"); if(pcnav.length > 3 && i >= pcnav.length-3){ submenu.css("left", "auto").css("right", "0px"); } L.bind("mouseenter", function(e){ submenu.css("height", submenuheight+"px") }); L.bind("mouseleave", function(e){ submenu.css("height", "0px") }); }); }; /*浠鐨勫昂瀵镐负鍑? 璋冩暣img鐨勪綅缃?璁╁叾灞呬腑,cheight - 琛ㄧず濡傛灉 c鐨勯珮搴︿负绌虹敤杩欎釜鍊?/ $.centerimg = function(img,c,mwidth,mheight,cheight) { try{ img = EDom(img); c = EDom(c); if(img.length == 0)return; var json = c.jsonattr("data-json"); //console.log(c,json); // 棣栧厛澶勪簬姝e父鐘舵€ img.css("width", "auto").css("height", "auto").css("margin-left", "0px").css("margin-top", "0px"); var iw = img.width(); var ih = img.height(); var cw = mwidth || c.width(); var ch = mheight || c.height() || cheight; if(json && json.type === "rate"){ // w/h ch = cw/json.whrate; c.css("height", ch+"px"); } /* if(mwidth && cw > mwidth){ cw = mwidth; } if(mheight && ch > mheight){ ch = mheight; } */ if(iw == cw && ih == ch){ return; } var iwh = iw/ih; var cwh = cw/ch; // 浠ュ涓哄噯 var nw = cw; var nh = nw/iwh; if(nh < ch){ // 灏忎簡!娌℃湁濉弧 nh = ch; nw = nh * iwh; } img.css("width", nw+"px").css("height", nh+"px"); //console.log(iw,ih,"New",nw,nh,cw,ch,"AMX:", mwidth,mheight); if(nw > cw){ img.css("margin-left", ((cw-nw)/2)+"px") } if(nh > ch){ img.css("margin-top", ((ch-nh)/2)+"px") } }catch(Xc){ console.log(Xc); } }; //鏄剧ず鍏ㄩ儴锛岄€傞厤楂樺 $.fullcenterimg = function(img,c,mwidth,mheight,cheight) { try{ img = EDom(img); c = EDom(c); if(img.length == 0)return; var json = c.jsonattr("data-json"); //console.log(c,json); // 棣栧厛澶勪簬姝e父鐘舵€ img.css("width", "auto").css("height", "auto").css("margin-left", "0px").css("margin-top", "0px"); var iw = img.width(); var ih = img.height(); var cw = mwidth || c.width(); var ch = mheight || c.height() || cheight; if(iw == cw && ih == ch){ return; } var iwh = iw/ih; var cwh = cw/ch; // 浠ュ涓哄噯 var nw = cw; var nh = nw/iwh; if(nh > ch){ // 澶т簡锛屼互楂樹负鍑 nh = ch; nw = nh * iwh; } img.css("width", nw+"px").css("height", nh+"px"); }catch(Xc){ console.log(Xc); } }; /** 澶勭悊灞呬腑鍥剧墖 */ $.processCenterImages = function() { var images = EDom(".centerimg > img"); function AlignImage() { images.each(function(I,i){ var img = EDom(I); var P = EDom(I.parentNode); $.centerimg(img, P, P.width(), P.height(), 0); }); }; AlignImage(); images.css("visibility", "visible"); EDom(window).resize(AlignImage); var fimages = EDom(".fullcenterimg > img"); function FAlignImage() { fimages.each(function(I,i){ var img = EDom(I); var P = EDom(I.parentNode); $.fullcenterimg(img, P, P.width(), P.height(), 0); }); }; FAlignImage(); fimages.css("visibility", "visible"); EDom(window).resize(FAlignImage); }; /** * 鍒濆鍖栧姩鐢 */ $.initBannerOrSlider = function(opt, switchFunc, ResizeFunc) { ////opt: {B,curi,timer,o} var B = opt.B; var items = EDom(".item", opt.o); var imgs = EDom(".mainimg img", opt.o); /* var op_pre = opt.op_pre; var op_next = opt.op_next; var op_thumb = opt.op_thumb; */ var op_pre = EDom(".op_pre", opt.o); var op_next = EDom(".op_next", opt.o); var op_thumb = EDom(".op_thumb", opt.o); var inprenext = true; // pre,next鎸夐挳鏄惁涓哄唴閮 var inthumb = true; if(B.attr("data-pre") && B.attr("data-next")){ inprenext = false; //console.log(B.attr("data-pre"),B.attr("data-next")); op_pre = EDom(B.attr("data-pre")); op_next = EDom(B.attr("data-next")); op_pre.css("cursor", "pointer"); op_next.css("cursor", "pointer"); } if(B.attr("data-thumb")){ inthumb = false; op_thumb = EDom(B.attr("data-thumb")); } function switchTo(idx){ clearTimeout(opt.timer); try{ opt.curi = idx; switchFunc(idx); }catch(xc){} try{ if(op_thumb.length == 1) { EDom("span", op_thumb[0]).each(function(TB, TBI){ if(TBI == idx){ EDom(TB).addclz("act"); }else{ EDom(TB).delclz("act"); } }); } }catch(xc){} }; function Run() { clearTimeout(opt.timer); var idx = opt.curi+1; idx = idx % items.length; switchTo(idx); opt.timer = setTimeout(Run, opt.intv); }; function Next() { clearTimeout(opt.timer); var idx = opt.curi+1; idx = idx % items.length; switchTo(idx); opt.timer = setTimeout(Run, opt.intv); }; function Pre() { clearTimeout(opt.timer); var idx = opt.curi-1; if(idx < 0)idx = items.length-1; idx = idx % items.length; switchTo(idx); opt.timer = setTimeout(Run, opt.intv); }; // 鍒濆鍖朤humb try{ if(op_thumb.length == 1){ items.each(function(one, oi){ var curio = EDom(one); op_thumb.append(""); }); EDom("span", op_thumb[0]).each(function(TB,TBI){ EDom(TB).click(function(){ switchTo(TBI); opt.timer = setTimeout(Run, opt.intv); }); }); } }catch(xc){} function ResizeSlider() { clearTimeout(opt.timer); if(ResizeFunc){ ResizeFunc(); } try{ // 鍐呴儴鐨刾re鍜宯ext鎸夐挳浣嶇疆璋冩暣 if(inprenext) { var arrowmargin = B.iattr("data-arrowmargin") || 20; var nw = op_pre.width(); var nh = op_pre.height(); var bw = B.width(); var bh = B.height(); op_pre.css("top", (bh-nh)/2+"px").css("left", arrowmargin+"px"); op_next.css("top", (bh-nh)/2+"px").css("right", arrowmargin+"px"); } }catch(xc){} switchTo(opt.curi); opt.timer = setTimeout(Run, opt.intv); }; // 璋冩暣澶у皬 ResizeSlider(); opt.B.css("visibility", "visible"); if(op_pre && op_pre.length > 0) { op_pre.click(Pre); } if(op_next && op_next.length > 0) { op_next.click(Next); } EDom(window).resize(ResizeSlider); }; /**杩愯Banner*/ $.runBanner = function() { var banners = EDom(".runbanner"); banners.each(function(o,i){ var B = EDom(o); var P = o.parentNode; var intv = B.iattr("data-intv") || 5000; var items = EDom(".item", o); var imgs = EDom(".mainimg img", o); var opt = { "o": o, "B": B, "P": P, "curi": 0, "timer": 0, "intv": intv }; try{ items.each(function(one, oi){ if(oi === 0){ EDom(one).alpha(100).vshow(); }else{ EDom(one).alpha(0).vhide(); } }); }catch(xc){} items.addclz("ease"); if(items.length == 0)return; function switchTo(idx){ try{ items.each(function(one, oi){ if(oi === idx){ EDom(one).vshow().alpha(100); }else{ EDom(one).alpha(0); var timerid = setTimeout(function(){ EDom(one).vhide(); clearTimeout(timerid); }, 500); } }); }catch(xc){} }; // 鍏ㄥ睆鍝嶅簲寮 var fullscreen = B.hasclz("fullwrap"); // 浠ヤ笂灞備负鍑嗙殑鍝嶅簲寮 var parentwrap = B.hasclz("parentwrap"); var isimagelist = imgs.length === items.length; // 璋冩暣澶у皬 function ResizeSlider() { B.css("height", "auto").css("width", "100%"); var BW = B.iattr("data-width") || 1920; var BH = B.iattr("data-height") || 450; var FIXH = B.iattr("data-fixheight") || 0; var minH = B.iattr("data-minheight") || 0; var w = P.clientWidth; if(w >= BW){ BH = w*(BH/BW); }else if(w < BW) { var rbh = w*(BH/BW); if(minH > 1 && rbh < minH){ rbh = minH; } BH = rbh; } if(FIXH > 0){ BH = FIXH; } B.css("height", BH+"px"); items.css("width", B.width()+"px").css("height", "auto"); imgs.css("width", "100%").css("height", "auto").css("margin-left", "0px").css("margin-top", "0px"); var BW = B.width(); var BH = B.height(); //console.log("bBWH:", BW, BH); items.each(function(it,iti){ $.centerimg(EDom(".mainimg img", it), it, B.width(), BH, BH); }); //console.log(BH,FBH,BW,FBW); var iw = 0, ih = 0; var maxh = 0; try{ items.each(function(one, oi){ EDom(one).css("width", BW+"px"); //EDom(one).css("height", BH+"px"); var itemh = EDom(one).height(); iw += EDom(one).width(); ih += itemh; if(itemh > maxh){ maxh = itemh; } }); // 鎵€鏈夊潡楂樺害鐩哥瓑 items.css("height", maxh+"px"); B.css("height", maxh+"px"); }catch(xc){} }; $.initBannerOrSlider(opt, switchTo, ResizeSlider); }); }; /**杩愯Slider*/ $.runSlider = function() { var banners = EDom(".runslider"); banners.each(function(o,i){ var B = EDom(o); var P = EDom(o.parentNode); // 涓婄骇瀹瑰櫒 var intv = B.iattr("data-intv") || 5000; var items = EDom(".item", o); var typev = B.hasclz("v"); // h(姘村钩), v(鍨傜洿) var board = EDom(".mboard", o); // slider涓殑澶у浘 var imgs = EDom(".mainimg img", o); board.addclz("ease"); var opt = { "o": o, "B": B, "P": P, "curi": 0, "timer": 0, "intv": intv }; if(items.length == 0)return; function switchTo(idx){ try{ var iw = 0; items.each(function(one, oi){ var OC = EDom(one); if(oi < idx){ if(typev){ iw += OC.height(); }else{ iw += OC.width(); } } }); if(typev){ board.css("margin-top", (-iw)+"px"); }else{ board.css("margin-left", (-iw)+"px"); } }catch(xc){} }; // 鍏ㄥ睆鍝嶅簲寮 var fullscreen = B.hasclz("fullwrap"); // 浠ヤ笂灞備负鍑嗙殑鍝嶅簲寮 var parentwrap = B.hasclz("parentwrap"); var isimagelist = imgs.length === items.length; // 璋冩暣澶у皬 function ResizeSlider() { board.css("width", "100%").css("height", "auto"); items.css("width", B.width()+"px").css("height", "auto"); imgs.css("width", "100%").css("height", "auto").css("margin-left", "0px").css("margin-top", "0px"); B.css("height", "auto", "width", "auto"); var MH = 0; items.each(function(it,iti){ if(MH < it.clientHeight){ MH = it.clientHeight; } }); //return; var FBW = B.iattr("data-width") || 1920; var FBH = B.iattr("data-height") || 450; // 鍏ㄥ睆鏃惰瀹氭渶澶ч珮搴 if(fullscreen){ if(MH < FBH && zt.w() < FBW){ MH = FBH; } } B.css("height", MH+"px"); var BW = B.width(); var BH = MH; //console.log("BWH:", BW, MH); var w = B.width(); if(w > FBW){ BH = w*(FBH/FBW); } items.each(function(it,iti){ $.centerimg(EDom(".mainimg img", it), it, B.width(), MH, MH); }); //console.log(BH,FBH,BW,FBW); var iw = 0, ih = 0; var maxh = 0; try{ items.each(function(one, oi){ EDom(one).css("width", BW+"px"); //EDom(one).css("height", BH+"px"); var itemh = EDom(one).height(); iw += EDom(one).width(); ih += itemh; if(itemh > maxh){ maxh = itemh; } }); // 鎵€鏈夊潡楂樺害鐩哥瓑 items.css("height", maxh+"px"); // 鍨傜洿 if(typev){ ih = maxh*items.length; } B.css("height", maxh+"px"); }catch(xc){} if(typev === true){ board.css("height", ih+"px"); board.css("width", "100%"); board.css("margin-top", "0px"); }else{ board.css("width", (iw+10)+"px"); board.css("height", "100%"); board.css("margin-left", "0px"); } }; $.initBannerOrSlider(opt, switchTo, ResizeSlider); }); }; $.loadImages = function(){ EDom("img").each(function(o,i){ var img = EDom(o); var url = img.attr("data-orisrc"); if(url !== undefined && url != null && url != ""){ o.src = url; } }); }; /**鍥哄畾婊氬姩鏃剁殑瀵艰埅鍜屽皬灞忓箷瀵艰埅*/ $.bindScrollNav = function() { var snav = EDom(".scrollpcnav"); //if(snav.length == 0)return; var R = document.documentElement; function ProcScrollNav(e) { if(snav.length == 0)return; if(R.scrollTop >= 110){ snav.css("top", "0px"); }else{ snav.css("top", "-80px"); } }; ProcScrollNav(null); EDom(window).bind("scroll", ProcScrollNav); // 绉诲姩绔彍鍗 var mmenus = EDom(".mnav >div >ul >li"); /**鍔ㄧ敾鏄剧ず鎴栭殣钘忕Щ鍔ㄨ彍鍗?/ function hideAllMenu(showidx) { showidx = showidx === undefined ? -1 : showidx; mmenus.each(function(o,i){ var m = EDom("li > ul", o); //console.log(i,showidx); if(i == showidx){ m.delclz("ease"); m.css("visibility", "hidden"); m.css("height", "auto"); var h = m.height(); m.css("height", "0px"); m.css("visibility", "visible"); m.addclz("ease"); setTimeout(function(){ m.css("height", h+"px"); }, 30); }else{ m.delclz("ease"); m.css("height", "0px"); } }); }; mmenus.each(function(o,menui){ ;(function(){ var m = EDom("li.l1 > ul", o); var a = EDom("li.l1 > span", o); if(a.length == 0)return; EDom(a[0]).click(function(){ hideAllMenu(menui); }); })(); }); function getHeight(obj) { var m = EDom(obj); if(m.length == 0)return 0; var curh = m[0].clientHeight; if(curh > 0){ return curh; } m.delclz("ease"); m.css("visibility", "hidden"); m.css("height", "auto"); var h = m.height(); m.css("height", "0px"); m.css("visibility", "visible"); m.addclz("ease"); return h; }; // 鍙敹缂╂垨灞曞紑鑿滃崟 // navexpand > div > ul li (SUB: ul > li) var expmenus = EDom(".navexpand"); expmenus.each(function(eo,eoi){ var EM = EDom(eo); var l1 = EDom("li.l1", eo); //console.log(l1); l1.each(function(l1o, l1i){ var curw = zt.w(); var label = EDom(".l1 > span", l1o); label.css("cursor", "pointer"); var L1 = EDom(l1o); var m = EDom("li > ul", l1o); // submenu var h = getHeight(m); if(L1.hasclz("act")){ m.css("height", h+"px"); } label.click(function(){ if(m.length == 0)return; var curh = m[0].clientHeight; //console.log(curh,h); //if(curh == 0){ if(!L1.hasclz("act")){ m.css("height", h+"px"); L1.addclz("act"); }else{ m.css("height", "0px"); L1.delclz("act"); } }); /**鍝嶅簲寮忕殑鍒楄〃鍙兘鍏堟槸闅愯棌鐨?/ EDom(window).resize(function(){ if(curw != zt.w()) { curw = zt.w(); h = getHeight(m); if(L1.hasclz("act")){ m.css("height", h+"px"); } } }); }); }); /**Product Tree*/ expmenus = EDom(".navproducttree"); expmenus.each(function(eo,eoi){ var EM = EDom(eo); var l1 = EDom("li.p1", eo); //console.log(l1); l1.each(function(l1o, l1i){ var curw = zt.w(); var label = EDom(".p1 > span", l1o); label.css("cursor", "pointer"); var L1 = EDom(l1o); var m = EDom("li > ul", l1o); // submenu var h = getHeight(m); if(L1.hasclz("act")){ m.css("height", h+"px"); } label.click(function(){ if(m.length == 0)return; var curh = m[0].clientHeight; //console.log(curh,h); //if(curh == 0){ if(!L1.hasclz("act")){ m.css("height", h+"px"); L1.addclz("act"); }else{ m.css("height", "0px"); L1.delclz("act"); } }); /**鍝嶅簲寮忕殑鍒楄〃鍙兘鍏堟槸闅愯棌鐨?/ EDom(window).resize(function(){ if(curw != zt.w()) { curw = zt.w(); h = getHeight(m); if(L1.hasclz("act")){ m.css("height", h+"px"); } } }); }); }); /**绉诲姩瀵艰埅鍥炬爣琚偣鍑?/ EDom(".listicon").click(function(){ var mnav = EDom(".mnav"); if(mnav.length > 0){ var h = mnav[0].clientHeight; console.log(h); if(h > 0){ mnav.hide(); EDom(R).css("overflow-y", "scroll"); EDom(".top").delclz("mact"); }else{ EDom(R).css("overflow-y", "hidden"); EDom(".top").addclz("mact"); hideAllMenu(-1); mnav.show(); } } }); /**椤甸潰瀹藉害鍙戠敓鍙樺寲*/ EDom(window).bind("resize", function(){ if(zt.w() >= 1200) { var mnav = EDom(".mnav"); mnav.hide(); EDom(R).css("overflow-y", "scroll"); EDom(".top").delclz("mact"); }else{ // 搴旈噸鏂拌绠楀瓙鑿滃崟鐨勯珮搴 mmenus.each(function(o,i){ var m = EDom("li > ul", o); if(m.length == 0)return; //console.log(i,showidx); if(m[0].clientHeight > 0){ m.css("height", "auto"); var h = m.height(); m.css("height", h+"px"); } }); } }); }; /**鍦╓indows loaded鐨勬椂鍊欏鐞?/ EDom(window).ready(function(e){ $.bindnav(); $.stat(); $.runBanner(); $.runSlider(); $.processCenterImages(); $.bindScrollNav(); $.loadImages(); }); })(zscms); // Video Player EDom(window).ready(function(){ function setVideoPlayer(vd) { if(vd.player){ try{ vd.player.pause(); vd.player.dispose(); vd.player = null; }catch(xc){ } } vd.obj.innerHTML = ""; var pobj = vd.obj.parentNode; var playerid = new Date().getTime(); var fw = pobj.clientWidth || 640; var fh = fw*0.6; vd.obj.style.width = "100%"; vd.obj.style.height = fh+"px"; var vstr = ''; vd.obj.innerHTML = vstr; vd.player = videojs('my-video-'+playerid+'', {autoplay:true}); }; function initVideo(o,i) { var player = null; var id = "autovideoid_"+i; o.id = id; var pc = o; var vd = { "obj" : o, "id" : id, "index": i, "url": "", "player" : null }; vd.url = EDom(".autovideo_obj >div", o).val(); setVideoPlayer(vd); EDom(window).resize(function(){ //setVideoPlayer(vd); var pobj = vd.obj.parentNode; var playerid = new Date().getTime(); var fw = pobj.clientWidth || 640; var fh = fw*0.6; vd.obj.style.width = "100%"; vd.obj.style.height = fh+"px"; vd.obj.style.overflow = "hidden"; //EDom(".autovideo_obj video").css("width", fw+"px").css("height", fh+"px"); EDom(".autovideo_obj >div").css("width", fw+"px").css("height", fh+"px"); }); } EDom(".autovideo_obj").each(initVideo); });