scripts.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!-- Le javascript
  2. ================================================== -->
  3. <!-- Placed at the end of the document so the pages load faster -->
  4. <script src="__TMPL__/public/assets/simpleboot3/bootstrap/js/bootstrap.min.js"></script>
  5. <script src="__STATIC__/js/frontend.js"></script>
  6. <script>
  7. $(function(){
  8. $("#main-menu li.dropdown").hover(function(){
  9. $(this).addClass("open");
  10. },function(){
  11. $(this).removeClass("open");
  12. });
  13. $("#main-menu a").each(function() {
  14. if ($(this)[0].href == String(window.location)) {
  15. $(this).parentsUntil("#main-menu>ul>li").addClass("active");
  16. }
  17. });
  18. $.post("{:url('user/index/isLogin')}",{},function(data){
  19. if(data.code==1){
  20. if(data.data.user.avatar){
  21. }
  22. $("#main-menu-user span.user-nickname").text(data.data.user.user_nickname?data.data.user.user_nickname:data.data.user.user_login);
  23. $("#main-menu-user li.login").show();
  24. $("#main-menu-user li.offline").hide();
  25. }
  26. if(data.code==0){
  27. $("#main-menu-user li.login").hide();
  28. $("#main-menu-user li.offline").show();
  29. }
  30. });
  31. ;(function($){
  32. $.fn.totop=function(opt){
  33. var scrolling=false;
  34. return this.each(function(){
  35. var $this=$(this);
  36. $(window).scroll(function(){
  37. if(!scrolling){
  38. var sd=$(window).scrollTop();
  39. if(sd>100){
  40. $this.fadeIn();
  41. }else{
  42. $this.fadeOut();
  43. }
  44. }
  45. });
  46. $this.click(function(){
  47. scrolling=true;
  48. $('html, body').animate({
  49. scrollTop : 0
  50. }, 500,function(){
  51. scrolling=false;
  52. $this.fadeOut();
  53. });
  54. });
  55. });
  56. };
  57. })(jQuery);
  58. $("#backtotop").totop();
  59. });
  60. </script>