// 判断是否为手机 function ismobile() { var useragentinfo = navigator.useragent; var mobileagents = [ "android", "iphone", "symbianos", "windows phone", "ipad","ipod"]; var mobile_flag = false; //根据useragent判断是否是手机 for (var v = 0; v < mobileagents.length; v++) { if (useragentinfo.indexof(mobileagents[v]) > 0) { mobile_flag = true; break; } } var screen_width = window.screen.width; var screen_height = window.screen.height; //根据屏幕分辨率判断是否是手机 if(screen_width < 500 && screen_height < 800){ mobile_flag = true; } return mobile_flag; } $(document).ready(function(){ initmenu(); initfloatbtns(); $('#needfloat #productnameinput').click(function(){ showfloat('#productnamefloat'); }); $('.floatpage .close').click(function(){ hidefloat($(this).attr('floatid')); }); }); function showfloat(pageid){ $(pageid).show(); tweenmax.to(pageid + " .bg", 0.3, {opacity:1}); tweenmax.to(pageid + " .floatinfo", 0.5, {top:'50%', opacity:1, ease:back.easeout}); } function hidefloat(pageid){ tweenmax.to(pageid + " .bg", 0.3, {delay:0.2, opacity:0}); tweenmax.to(pageid + " .floatinfo", 0.5, {top:'70%', opacity:0, ease:back.easein, oncomplete:function(){ $(pageid + '').hide(); }}); } // 初始化右侧悬浮按钮 var needformtype = 'company'; //nom || company function initfloatbtns(){ $('.floatbtnbox .need').click(function(){ showneedfloat(); }); $('#needfloat .bg, #needfloat .floatclose').click(function(){ hideneedfloat(); }); $('#needfloat .tabbtn').click(function(){ var id = $(this).index(); if(id == 0){ needformtype = 'company'; $('#needfloat .copies').show(); $('#needfloat .company').show(); }else{ needformtype = 'nom'; $('#needfloat .copies').hide(); $('#needfloat .company').hide(); } $('#needfloat .tabbtn').removeclass('curr'); $(this).addclass('curr'); console.log(needformtype); }); function showneedfloat(){ $('#needfloat').show(); tweenmax.to("#needfloat .bg", 0.3, {opacity:1}); tweenmax.to("#needfloat .floatinfo", 0.5, {top:'50%', opacity:1, ease:back.easeout}); } function hideneedfloat(){ tweenmax.to("#needfloat .bg", 0.3, {delay:0.2, opacity:0}); tweenmax.to("#needfloat .floatinfo", 0.5, {top:'70%', opacity:0, ease:back.easein, oncomplete:function(){ $('#needfloat').hide(); }}); } } // 初始化导航组件 var isshowregion = false; var isshowsearch = false; var isshowmenuhover = false; var isshowmobildmenu = false; function initmenu(){ $("#menu .menulist").mouseover(function(){ showmenuhover(); hideregion(); }); $("#menu .menulist").mouseout(function(){ hidemenuhover(); }); $("#menu .region").click(function(){ if(isshowregion){ hideregion(); }else{ showregion(); hidemobilemenu(); } }); $("#menu .search").click(function(){ if(isshowsearch){ hidesearch(); }else{ showsearch(); } }); $("#menu .openmenu").click(function(){ showmobilemenu(); hideregion(); }); $("#menu .closemenu").click(function(){ hidemobilemenu(); }); $(".menudown .bg").click(function(){ hidemenuhover(); hideregion(); hidesearch(); }); function showmenuhover(){ isshowmenuhover = true; $(".menudown").show(); $(".menudown .region").hide(); tweenmax.to(".menudown .bg", 0.3, {opacity:1}); tweenmax.to(".menuhover", 0.3, {height:'380px', opacity:1, ease:power1.easeout}); } function hidemenuhover(){ isshowmenuhover = false; if(!isshowmenuhover && !isshowregion && !isshowsearch){ tweenmax.to(".menudown .bg", 0.3, {opacity:0}); } tweenmax.to(".menuhover", 0.3, {height:'0px', opacity:0, ease:power1.easein, oncomplete:function(){ if(!isshowmenuhover && !isshowregion && !isshowsearch){ $(".menudown").hide(); } }}); } function showregion(){ isshowregion = true; $(".menudown").show(); $(".menudown .region").css({ display: "block", height: "0" }); tweenmax.to(".menudown .bg", 0.3, {opacity:1}); if(ismobile()){ tweenmax.to(".menudown .infobox", 0.3, {height:'100%', opacity:1, ease:power1.easeout}); tweenmax.to(".menudown .region", 0.3, {height:'100%', opacity:1, ease:power1.easeout}); }else{ tweenmax.to(".menudown .region", 0.3, {height:'493px', opacity:1, ease:power1.easeout}); } } function hideregion(){ isshowregion = false; if(!isshowmenuhover && !isshowregion && !isshowsearch){ tweenmax.to(".menudown .bg", 0.3, {opacity:0}); } tweenmax.to(".menudown .region", 0.3, {height:'0px', opacity:0, ease:power1.easein, oncomplete:function(){ if(!isshowmenuhover && !isshowregion && !isshowsearch && !isshowmobildmenu){ $(".menudown").hide(); } if(ismobile()){ $(".menudown .region").css({ height: "auto" }); } $(".menudown .region").css({ display: "none" }); }}); } function showsearch(){ console.log('b'); isshowsearch = true; $(".menudown").show(); tweenmax.to(".menudown .bg", 0.3, {opacity:1}); tweenmax.to(".menudown .search", 0.3, {height:'180px', opacity:1, ease:power1.easeout}); } function hidesearch(){ isshowsearch = false; if(!isshowmenuhover && !isshowregion && !isshowsearch){ tweenmax.to(".menudown .bg", 0.3, {opacity:0}); } tweenmax.to(".menudown .search", 0.3, {height:'0px', opacity:0, ease:power1.easein, oncomplete:function(){ if(!isshowmenuhover && !isshowregion && !isshowsearch){ $(".menudown").hide(); } }}); } function showmobilemenu(){ isshowmobildmenu = true; $('.menudown').show(); $('#menu .openmenu').hide(); $('#menu .closemenu').show(); tweenmax.to(".menudown .mobilemenu", 0.3, {height:'100%', opacity:1, ease:power1.easeout}); } function hidemobilemenu(){ isshowmobildmenu = false; $('#menu .openmenu').show(); $('#menu .closemenu').hide(); tweenmax.to(".menudown .mobilemenu", 0.3, {height:'0', opacity:0, ease:power1.easein, oncomplete:function(){ if(!isshowmenuhover && !isshowregion && !isshowsearch){ $(".menudown").hide(); } }}); } }