$(document).ready(function() { // 返回头部 $(function() { $(".return").click(function() { $("html,body").animate({ scrolltop: 0 }, 500); }); }); $(function () { $(".scroll_bottom").click(function () { $("html,body").animate({scrolltop: $('.footer').offset().top}, 500); }); }); //顶部浮动 mh = $('body').height(); fh = $('.header').height(); $(window).scroll(function (e) { s = $(document).scrolltop(); if (s > fh) { $('.header').addclass('fixed-head'); } else { $('.header').removeclass('fixed-head'); } }); //导航下拉 $(function() { $(".nav li").hover(function() { $(this).children(".navbox").stop(true, true).slidedown(500); }, function() { $(this).children(".navbox").stop(true, true).slideup(0); }) }); //通用切换 $('.tabswitch').each(function(index, element) { var obj = $(this); obj.find('.tabtit').children().on('click tab',function(){ $(this).addclass('cur').siblings().removeclass('cur'); if (obj.find('.tabbox').children().eq($(this).index()).length > 0) obj.find('.tabbox').children().hide().eq($(this).index()).show(); if (obj.find('.tabbox2').children().eq($(this).index()).length > 0) obj.find('.tabbox2').children().hide().eq($(this).index()).show(); return false; }); obj.find('.tabtit .cur').trigger('tab'); }); $('.tabswitchhover').each(function(index, element) { var obj = $(this); obj.find('.tabtit').children().on('mouseover tab',function(){ $(this).addclass('cur').siblings().removeclass('cur'); if (obj.find('.tabbox').children().eq($(this).index()).length > 0) obj.find('.tabbox').children().hide().eq($(this).index()).show(); if (obj.find('.tabbox2').children().eq($(this).index()).length > 0) obj.find('.tabbox2').children().hide().eq($(this).index()).show(); //return false; }); obj.find('.tabtit .cur').trigger('tab'); }); }); $(document).ready(function() { // phone nav = $(".navbtn").click(function (e) { $(".nav_box").animate({ left: "0" }); $("body").bind("touchmove", function (event) { event.preventdefault(), event.stoppropagation(); }); e.stoppropagation(); }); $(".nav_box .navclose").click(function () { $(".nav_box").animate({ left: "-100%" }); $("body").unbind("touchmove"); }); }); //session.js (function($){ var cookieexpiretime = 1209600; // cookie项过期时间 2周 $.session = { _id: null, _cookiecache: undefined, _init: function() { //if (!window.name) { // window.name = math.random(); //} //this._id = window.name; // 如果id设置为动态,会导致浏览器不断生成cookie,进而导致取值有问题 this._id = 'sessionid'; this._initcache(); // see if we've changed protcols var matches = (new regexp(this._generateprefix() + "=([^;]+);")).exec(document.cookie); if (matches && document.location.protocol !== matches[1]) { this._clearsession(); for (var key in this._cookiecache) { try { window.sessionstorage.setitem(key, this._cookiecache[key]); } catch (e) {}; } } document.cookie = this._generateprefix() + "=" + document.location.protocol + ';path=/;expires=' + (new date((new date).gettime() + 28800000 + cookieexpiretime)).toutcstring(); // 28800000 含义:世界时间+8天=北京时间 }, _generateprefix: function() { return '__session:' + this._id + ':'; }, _initcache: function() { var cookies = document.cookie.split(';'); this._cookiecache = {}; for (var i in cookies) { var kv = cookies[i].split('='); if ((new regexp(this._generateprefix() + '.+')).test(kv[0]) && kv[1]) { this._cookiecache[kv[0].split(':', 3)[2]] = kv[1]; } } }, _setfallback: function(key, value, onceonly) { var cookie = this._generateprefix() + key + "=" + value + ";path=/"; if (onceonly) { // 只一次设置项,为其添加过期时间,过期自动删除 cookie += ";expires=" + (new date(date.now() + 28800000 + cookieexpiretime)).toutcstring(); } document.cookie = cookie; this._cookiecache[key] = value; return this; }, _getfallback: function(key) { if (!this._cookiecache) { this._initcache(); } return this._cookiecache[key]; }, _clearfallback: function() { for (var i in this._cookiecache) { document.cookie = this._generateprefix() + i + '=;path=/;expires=thu, 01 jan 1970 00:00:01 gmt;'; } this._cookiecache = {}; }, _deletefallback: function(key) { document.cookie = this._generateprefix() + key + '=;path=/;expires=thu, 01 jan 1970 00:00:01 gmt;'; // 把有效时间设置为过期 delete this._cookiecache[key]; }, get: function(key) { return window.sessionstorage.getitem(key) || this._getfallback(key); }, set: function(key, value, onceonly) { try { window.sessionstorage.setitem(key, value); } catch (e) {} this._setfallback(key, value, onceonly || false); return this; }, 'delete': function(key){ return this.remove(key); }, remove: function(key) { try { window.sessionstorage.removeitem(key); } catch (e) {}; this._deletefallback(key); return this; }, _clearsession: function() { try { window.sessionstorage.clear(); } catch (e) { for (var i in window.sessionstorage) { window.sessionstorage.removeitem(i); } } }, clear: function() { this._clearsession(); this._clearfallback(); return this; } }; $.session._init(); })(jquery); // 动画开始 $(document).ready(function () { npos = $(window).scrolltop(); sw = $(window).width(); sh = $(window).height(); ieflag = (navigator.appversion.indexof("msie 7") > -1 || navigator.appversion.indexof("msie 8") > -1) ? true : false; lnbflag = false; var isrun = false; if ($('.banner img').length) { $(".banner img:eq(0)").one('load', function () { isrun = true; coninit(); }).each(function () { if (this.complete) { $(this).load(); return false; } }); } else { isrun = true; coninit(); } }); $(window).scroll(function () { npos = $(window).scrolltop(); sw = $(window).width(); sh = $(window).height(); }); //chd scroll $(window).resize(function () { sw = $(window).width(); sh = $(window).height(); }); //chd resize function coninit() { var actions, event, total; var cur = 0; var ncur = 0; var ctarget = $('body'); var item = []; if (ctarget.find('.maxbox').length == 0) { return false; } init = { _start: function () { //$('#main_nav ul').css('margin-top',(($('#main_nav ul').height()/2)+120)*-1); /************* / variable add *************/ total = ctarget.find('.maxbox').length; //$('body,html').animate({scrolltop:0},300,'easeoutexpo') /************* / event add *************/ /************* / item add *************/ var _i = 0; ctarget.find('.maxbox').each(function ($index) { var _t = $(this); item[$index] = { _data: _i, _target: _t, _moveflag: true, _play: function (_posy) { var target = this._target; var f_t = target.position().top; var f_b = f_t + 600; var p_y = _posy - f_t; var d_y; var target_w = target.width(); var target_h = target.height(); if (item[cur]._moveflag) { var __i = 0; target.find('.tweentodelayup').each(function () { var _d = __i * 0.15 tweenmax.to($(this), 0.8, { y: 0, alpha: 1, delay: _d, ease: quad.easeout }); __i++ }); target.find('.tweentodelayupchildren').children().each(function () { var _d = __i * 0.15 tweenmax.to($(this), 0.8, { y: 0, alpha: 1, delay: _d, ease: quad.easeout }); __i++ }); target.find('.tweentodelaydown').each(function () { var _d = __i * 0.15 tweenmax.to($(this), 0.8, { y: 0, alpha: 1, delay: _d, ease: quad.easeout }); __i++ }); target.find('.tweentoshow').each(function () { var _d = __i * 0.15; tweenmax.to($(this), 1.5, { y: 0, alpha: 1, delay: 0, ease: quad.easeout }); __i++ }); target.find('.tweentoshowchildren').children().each(function () { var _d = __i * 0.15; tweenmax.to($(this), 1.5, { y: 0, alpha: 1, delay: 0, ease: quad.easeout }); __i++ }); target.find('.tweentodelayshow').each(function () { var _d = __i * 0.15; tweenmax.to($(this), 1.5, { y: 0, alpha: 1, delay: _d, ease: quad.easeout }); __i++ }); target.find('.tweentodelayshowchildren').children().each(function () { var _d = __i * 0.15; tweenmax.to($(this), 1.5, { y: 0, alpha: 1, delay: _d, ease: quad.easeout }); __i++ }); target.find('.tweentoleft, .tweentoright').each(function () { var _d = __i * 0.15; tweenmax.to($(this), 1.5, { x: 0, alpha: 1, delay: 0, ease: quad.easeout }); __i++ }); target.find('.tweentoleftchildren, .tweentorightchildren').children().each(function () { var _d = __i * 0.15; tweenmax.to($(this), 1.5, { x: 0, alpha: 1, delay: 0, ease: quad.easeout }); __i++ }); target.find('.tweentodelayleftchildren, .tweentodelayrightchildren').children().each(function () { var _d = __i * 0.4; //console.log(__i); if (target.hasclass('oymc_div')) { if (__i % 2 > 0) { _d = old_d; } } else if (target.hasclass('tweentoup')) { _d = 1.0; } tweenmax.to($(this), 1.0, { x: 0, alpha: 1, delay: _d, ease: quad.easeout }); old_d = _d; __i++ }); target.find('.tweenscale').each(function () { var _d = __i * 0.15; tweenmax.to($(this), 1.5, { scale: 1.1, alpha: 1, delay: 0, ease: quad.easeout }); __i++ }); } this._moveflag = false; }, _reset: function () { var target = this._target; var target_w = target.width(); var target_h = target.height(); this._moveflag = true target.find('.tweentodelayup').each(function () { tweenmax.set($(this), { y: 50, alpha: 0 }); }); target.find('.tweentodelayupchildren').children().each(function () { tweenmax.set($(this), { y: 50, alpha: 0 }); }); target.find('.tweentodelaydown').each(function () { tweenmax.set($(this), { y: -50, alpha: 0 }); }); target.find('.tweentoshow, .tweentodelayshow').each(function () { tweenmax.set($(this), { alpha: 0 }); }); target.find('.tweentoshowchildren, .tweentodelayshowchildren').children().each(function () { tweenmax.set($(this), { alpha: 0 }); }); target.find('.tweentoleft, .tweentodelayleft').each(function () { tweenmax.set($(this), { x: 200, alpha: 0 }); }); target.find('.tweentoright, .tweentodelayright').each(function () { tweenmax.set($(this), { x: -200, alpha: 0 }); }); target.find('.tweentoleftchildren, .tweentodelayleftchildren').children().each(function () { tweenmax.set($(this), { x: 200, alpha: 0 }); }); target.find('.tweentorightchildren, .tweentodelayrightchildren').children().each(function () { tweenmax.set($(this), { x: -200, alpha: 0 }); }); } } item[$index]._reset(); _i++ }); item[cur]._play(npos); } } //init end actions = { _pagemove: function (targety) { $('html,body').stop().animate({ scrolltop: targety }, 1200) }, _pagehandler: function (_posy) { item[cur]._play(_posy); if (_posy == 0) { ctarget.find('.maxbox').each(function ($index) { //item[$index]._reset(); }); //item[cur]._play(_posy); } }, _pageresize: function () { ctarget.find('.maxbox').each(function ($index) { //item[$index]._reset(); }); } } //actions end event = { _activehandler: function (index) { var _mb = sh - (sh / 4) ctarget.find('.maxbox').each(function (vi) { //console.log($(this).index('.maxbox')); if (vi != total - 1) { if (index >= $(this).offset().top - _mb && index <= $(this).next().offset().top - _mb) { cur = vi; } if (index >= $(this).offset().top && index <= $(this).next().offset().top) { ncur = vi; } } else { if (index >= $(this).offset().top - _mb) { cur = vi; } if (index >= $(this).offset().top) { ncur = vi; } } }); } } //event end $(window).scroll(function () { npos = $(window).scrolltop(); sw = $(window).width(); sh = $(window).height(); event._activehandler(npos); actions._pagehandler(npos); }); //chd scroll $(window).resize(function () { sw = $(window).width(); sh = $(window).height(); actions._pageresize(); }); //chd resize init._start(); event._activehandler(npos); actions._pagehandler(npos); } //coninit end // 动画结束 // $(".contactus1 .ygrdflj .rdfxll .xll").click(function(){ // $(".contactus1 .ygrdflj .rdfxll .xll dl").show(); // }); $(document).on("click",".contactus1 .ygrdflj .rdfxll .xll",function(){ $(".contactus1 .ygrdflj .rdfxll .xll dl").show(); }); $(document).on("click",".navlist ul li.ssub",function(){ $(this).find(".navlist2").stop().slidetoggle(); $(this).siblings().find(".navlist2").stop().slideup(); }); var lastnum = $(".cqxwmppds ul li:last-child").index(); if(lastnum <= 0){ $(".cqxwmppds").hide(); }