$(function(){ $('.index_tt .banner_txt').eq(0).show().siblings().hide(); var $ct=$('.banner_box ul'), $items=$ct.children(), $pre=$('.index_pre'), $next=$('.banner_next'), imgCount=$items.length, imgWidth=$items.width(); $ct.append($items.first().clone()); $ct.prepend($items.last().clone()); var newCount=$ct.children().length; $ct.css({marginLeft:0-imgWidth,width:newCount*imgWidth}); $next.on('click',function(){ playnext(); }) $pre.on('click',function(){ playpre(); }) var curidx =0; var mov = 1; function playnext(){ $ct.animate({marginLeft:'-='+mov*imgWidth},1000,function(){ curidx+=mov; if(curidx===imgCount){ $ct.css({marginLeft:0-imgWidth}); curidx=0; } }) $('.index_tt .banner_txt').eq(curidx).show().siblings().hide(); } function playpre(){ $ct.animate({marginLeft:'+='+mov*imgWidth},1000,function(){ curidx-=mov; if(curidx<0){ $ct.css({marginLeft:0-imgWidth*imgCount}); curidx=imgCount-1; } }) $('.index_tt .banner_txt').eq(curidx).show().siblings().hide(); } var timer=setInterval(playnext,3000) $('.banner').mouseenter(function(){ clearInterval(timer) }) $('.banner').mouseleave(function(){ timer=setInterval(playnext,3000) }) $('.img_list ol li').hover(function(){ var simg = $(this).children('img').attr('src') $('.banner_box ul li').eq(curidx+1).find('img').attr('src',simg) }) //导航 var headt=$('header').clone(); $(window).scroll(function(){ var scrolltop=$(document).scrollTop() if(scrolltop>600){ headt.addClass('h_fix'); $('body').append(headt) $('.h_fix').slideDown(200) }else{ $('.h_fix').slideUp(200) } }); //挂件 $('.pendent_box').click(function(e){ e.preventDefault(); $("body,html").animate({scrollTop:0},1000) }); //登陆页面 var hht=$(window).height(); $('.login').height(hht); $('#Lo_user').focus(function(){ var use=$(this).val() if(use=='用户名/邮箱/手机'){ $(this).val('').css({color:'#333333'}) } }) $('#Lo_user').blur(function(){ var use=$(this).val(); if(use==''){ $(this).val('用户名/邮箱/手机').css({color:'#cccccc'}) } }) $('#Lo_pass').focus(function(){ var use=$(this).val() if(use=='请输入密码'){ $(this).attr('type',"password"); $(this).val('').css({color:'#333333'}); } }); $('#Lo_pass').blur(function(){ var use=$(this).val(); if(use==''){ $(this).attr('type',"text"); $(this).val('请输入密码').css({color:'#cccccc'}) } }); $('#checks').attr('checked',true) $('#checks').click(function(){ var Cheack=$(this).prop('checked') if(Cheack){ $(this).parent().css({"background":"url(../img/check_lo.png) no-repeat center left","background-size":"34% 40%"}) $('#checkst').prop('checked',false) $('#checkst').parent().css({"background":"url(../img/check_lono.png) no-repeat center left","background-size":"34% 40%"}) }else{ $('#checkst').prop('checked',true) $('#checkst').parent().css({"background":"url(../img/check_lo.png) no-repeat center left","background-size":"34% 40%"}) $(this).parent().css({"background":"url(../img/check_lono.png) no-repeat center left","background-size":"34% 40%"}) } }) $('#checkst').click(function(){ var Cheack_no=$(this).prop('checked') if(Cheack_no){ $(this).parent().css({"background":"url(../img/check_lo.png) no-repeat center left","background-size":"34% 40%"}) $('#checks').prop('checked',false) $('#checks').parent().css({"background":"url(../img/check_lono.png) no-repeat center left","background-size":"34% 40%"}) }else{ $('#checks').prop('checked',true) $('#checks').parent().css({"background":"url(../img/check_lo.png) no-repeat center left","background-size":"34% 40%"}) $(this).parent().css({"background":"url(../img/check_lono.png) no-repeat center left","background-size":"34% 40%"}) } }) //点击x $('.log_del').click(function(){ $('#Lo_user').val(''); $('#Lo_user').focus(); $('#Lo_user').css({color:'#333333'}); }) // 登陆事件 $('.login').hide() $('.head_login').click(function(e){ e.preventDefault(); $('.login').fadeIn(800) }) $('.login_close').click(function(){ $('.login').fadeOut(800) }) $('form').submit(function(){ var Suser=$('#Lo_user').val(); var Spass=$('#Lo_pass').val(); var check_experts=$('#checks').prop('checked'); var experts=check_experts?0:1; console.log(Suser,Spass,experts) if(Suser==''||Spass==''||Suser=='用户名/邮箱/手机'||Spass=='请输入密码'){ return false; }else{ $.ajax({ method: "POST", dataType: "json", url: globalConfig.context + "/signin", data: { "mobile": Suser, "password": Spass, "type": experts, "remember": false, }, success: function (rest) { if (rest.error && rest.error.length) { message.warning(rest.error[0].message); } else { var data = rest.data; if (data && data.requestURI) { var path = globalConfig.context + data.requestURI if (data.queryString) { path += '?' + data.queryString; } if (window.location.hash) { path += window.location.hash; } window.location.href = path; } else { window.location.href = globalConfig.context + "/user/account/index.html"; } return true; } } }) } }) })