public.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. $(function(){
  2. $('.index_tt .banner_txt').eq(0).show().siblings().hide();
  3. var $ct=$('.banner_box ul'),
  4. $items=$ct.children(),
  5. $pre=$('.index_pre'),
  6. $next=$('.banner_next'),
  7. imgCount=$items.length,
  8. imgWidth=$items.width();
  9. $ct.append($items.first().clone());
  10. $ct.prepend($items.last().clone());
  11. var newCount=$ct.children().length;
  12. $ct.css({marginLeft:0-imgWidth,width:newCount*imgWidth});
  13. $next.on('click',function(){
  14. playnext();
  15. })
  16. $pre.on('click',function(){
  17. playpre();
  18. })
  19. var curidx =0;
  20. var mov = 1;
  21. function playnext(){
  22. $ct.animate({marginLeft:'-='+mov*imgWidth},1000,function(){
  23. curidx+=mov;
  24. if(curidx===imgCount){
  25. $ct.css({marginLeft:0-imgWidth});
  26. curidx=0;
  27. }
  28. })
  29. $('.index_tt .banner_txt').eq(curidx).show().siblings().hide();
  30. }
  31. function playpre(){
  32. $ct.animate({marginLeft:'+='+mov*imgWidth},1000,function(){
  33. curidx-=mov;
  34. if(curidx<0){
  35. $ct.css({marginLeft:0-imgWidth*imgCount});
  36. curidx=imgCount-1;
  37. }
  38. })
  39. $('.index_tt .banner_txt').eq(curidx).show().siblings().hide();
  40. }
  41. var timer=setInterval(playnext,3000)
  42. $('.banner').mouseenter(function(){
  43. clearInterval(timer)
  44. })
  45. $('.banner').mouseleave(function(){
  46. timer=setInterval(playnext,3000)
  47. })
  48. $('.img_list ol li').hover(function(){
  49. var simg = $(this).children('img').attr('src')
  50. $('.banner_box ul li').eq(curidx+1).find('img').attr('src',simg)
  51. })
  52. //导航
  53. $(window).scroll(function(){
  54. var scrolltop=$(document).scrollTop()
  55. if(scrolltop>400){
  56. $('header').addClass('h_fix')
  57. $('body').css({paddingTop:'74px'})
  58. }else{
  59. $('header').removeClass('h_fix')
  60. $('body').css({paddingTop:0})
  61. }
  62. });
  63. //挂件
  64. $('.pendent_box').click(function(e){
  65. e.preventDefault();
  66. $("body,html").animate({scrollTop:0},1000)
  67. });
  68. //登陆页面
  69. var hht=$(window).height();
  70. $('.login').height(hht);
  71. $('#Lo_user').focus(function(){
  72. var use=$(this).val()
  73. if(use=='用户名/邮箱/手机'){
  74. $(this).val('').css({color:'#333333'})
  75. }
  76. })
  77. $('#Lo_user').blur(function(){
  78. var use=$(this).val();
  79. if(use==''){
  80. $(this).val('用户名/邮箱/手机').css({color:'#cccccc'})
  81. }
  82. })
  83. $('#Lo_pass').focus(function(){
  84. var use=$(this).val()
  85. if(use=='请输入密码'){
  86. $(this).attr('type',"password");
  87. $(this).val('').css({color:'#333333'});
  88. }
  89. });
  90. $('#Lo_pass').blur(function(){
  91. var use=$(this).val();
  92. if(use==''){
  93. $(this).attr('type',"text");
  94. $(this).val('请输入密码').css({color:'#cccccc'})
  95. }
  96. });
  97. $('#checks').attr('checked',true)
  98. $('#checks').click(function(){
  99. var Cheack=$(this).prop('checked')
  100. if(Cheack){
  101. $(this).parent().css({"background":"url(../img/check_lo.png) no-repeat center left","background-size":"34% 40%"})
  102. $('#checkst').prop('checked',false)
  103. $('#checkst').parent().css({"background":"url(../img/check_lono.png) no-repeat center left","background-size":"34% 40%"})
  104. }else{
  105. $('#checkst').prop('checked',true)
  106. $('#checkst').parent().css({"background":"url(../img/check_lo.png) no-repeat center left","background-size":"34% 40%"})
  107. $(this).parent().css({"background":"url(../img/check_lono.png) no-repeat center left","background-size":"34% 40%"})
  108. }
  109. })
  110. $('#checkst').click(function(){
  111. var Cheack_no=$(this).prop('checked')
  112. if(Cheack_no){
  113. $(this).parent().css({"background":"url(../img/check_lo.png) no-repeat center left","background-size":"34% 40%"})
  114. $('#checks').prop('checked',false)
  115. $('#checks').parent().css({"background":"url(../img/check_lono.png) no-repeat center left","background-size":"34% 40%"})
  116. }else{
  117. $('#checks').prop('checked',true)
  118. $('#checks').parent().css({"background":"url(../img/check_lo.png) no-repeat center left","background-size":"34% 40%"})
  119. $(this).parent().css({"background":"url(../img/check_lono.png) no-repeat center left","background-size":"34% 40%"})
  120. }
  121. })
  122. //点击x
  123. $('.log_del').click(function(){
  124. $('#Lo_user').val('');
  125. $('#Lo_user').focus();
  126. $('#Lo_user').css({color:'#333333'});
  127. })
  128. // 登陆事件
  129. $('.login').hide()
  130. $('.head_login').click(function(e){
  131. e.preventDefault();
  132. $('.login').fadeIn(800)
  133. })
  134. $('.login_close').click(function(){
  135. $('.login').fadeOut(800)
  136. })
  137. $('form').submit(function(){
  138. var Suser=$('#Lo_user').val();
  139. var Spass=$('#Lo_pass').val();
  140. if(Suser==''||Spass==''||Suser=='用户名/邮箱/手机'||Spass=='请输入密码'){
  141. return false;
  142. }else{
  143. return true;
  144. }
  145. })
  146. })