/** * Created by Administrator on 2016/12/1. */ // 判断pc function IsPC() { var flag = true; if (/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))) { flag = false; } return flag; } var version3 = function () { var IsPcFlag = IsPC(); // 重载设置 function reload(){ // pc 改变宽度时 if(IsPcFlag){ window.oldWidth=parseInt(document.documentElement.clientWidth||document.body.clientWidth); $(window).resize(function(){ window.nowWidth=parseInt(document.documentElement.clientWidth||document.body.clientWidth); if(window.nowWidth-window.oldWidth>=50)location.reload(); window.oldWidth=window.nowWidth; }); return; } // 移动端 // 查看横竖屏 function HengShuPing(){ if("onorientationchange" in window){ var orientation=window.orientation; switch(orientation){ // 竖屏 case 90: case -90: return "h"; break; // 横屏 180 0 default: return "v"; break; } }else{ if(window.innerWidth 1) { for (var i = 0; i < row; i++) { var index = null, last, first, _first, _first2; for (var k = 0; k < num; k++) { index = i * num + k; last = (i + 1) * num - 1; first = (i + 1) * num; _first = 2 * num - 1; _first2 = 2 * num; if (index >= len) { return } if (first < len) { $(".presI").eq(first).find(".line").css({ "width": "50%" }); } if (last < len) { $(".presI").eq(last).find(".line").css({ "width": "50%" }); } if (_first < len) { $(".presI").eq(_first).find(".line").css({ "left": "50%" }); } if (_first2 < len) { $(".presI").eq(_first2).find(".line").css({ "left": "50%" }); } if (i % 2 == 1) { $(".presI").eq(index).css({ "float": "right" }); } else { $(".presI").eq(index).css({ "float": "left" }) } } } } return; } setPri(lineNum); $(".presI").each(function (i) { var that = $(this); that.tips({dir: 6}); }); } // 热门图片 function hotImg() { $("#blc_hots").find(".imgBox").hover(function () { $(this).find(".img_alt").stop(true, true).animate({ "height": "100%" }, 300, function () { $(this).animate({ padding: "54px 10px 0" }, 200); }); }, function () { var h = IsPC() ? "36px" : "1rem"; $(this).find(".img_alt").stop(true, true).animate({ "height": h }, 300, function () { $(this).animate({ padding: "0 10px 0" }, 400); }); } ); } //关于我们幻灯片 function aboutSlide() { var next = $("#aboutPrev"); var prev = $("#aboutNext"); var oArr = $("#aboutPics li").toArray(); var clientNum = 3; function up(n) { $("#aboutPics").append(oArr); $("#aboutPics .psi").each(function (i) { if (i >= clientNum) { $(this).removeAttr("style") } else { $(this).css({ "animation-delay": "" + i * 300 + "ms", "animation-timing-function": "ease", "animation-name": function () { return n == 1 ? "rightRotate" : "leftRotate"; }, "animation-duration": "300ms", "-webkit-animation-delay": "" + i * 300 + "ms", "webkit-animation-timing-function": "ease", "-webkit-animation-name": function () { return n == 1 ? "rightRotate" : "leftRotate"; }, "-webkit-animation-duration": "300ms" }); } }); } prev.bind("click", function (e) { e.preventDefault(); oArr.push(oArr[0]); oArr.shift(oArr[0]); up(-1); }); next.bind("click", function (e) { e.preventDefault(); oArr.unshift(oArr[oArr.length - 1]); oArr.pop(oArr[oArr.length - 1]); up(1); }) } // 二级页切换 $.fn.nav=function(opt){ var defaults={ type:"click", target:".vi", toToggle:".ci", delay:0, tClass:"active" }; var opts=$.extend({},defaults,opt); $(this).find(opts.target)[opts.type](function(){ var i=$(this).index(); $(this).stop(true,true).delay(opts.delay).addClass(opts.tClass).siblings().removeClass(opts.tClass); $(opts.choseBox).find(opts.toToggle).eq(i).stop(true,true).delay(opts.delay).addClass(opts.tClass).siblings().removeClass(opts.tClass); }); }; // 二级页切换 function twoNav() { $(".verticalNav").nav({choseBox: ".choseBox", type: "mouseover"}); } function init() { process(); hotImg(); aboutSlide(); twoNav(); reload(); if(IsPcFlag){ // 只在pc }else{ // 只在移动端 headDown(); } } return { init: init } }(); $(function () { version3.init(); });