app.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //行业菜单
  2. $('.hangye-has-arrow').click(function () {
  3. $(this).toggleClass('hangye-open');
  4. });
  5. $('.navbar-toggle').click(function () {
  6. var y = $(window).scrollTop();
  7. $('.navbar-toggle .icon-bar').toggleClass('hidden');
  8. $('.navbar-toggle .icon-close-bar').toggleClass('hidden');
  9. if (y == 0) {
  10. $('.site-header').toggleClass('new-face');
  11. }
  12. });
  13. //header tab的选中样式
  14. let pathName = window.location.pathname;
  15. $('#headerNav a').each(function (index, item) {
  16. if ($(item).attr('href') == pathName) {
  17. $(item).addClass('nav-active');
  18. }
  19. if ($(item).attr('href') == '/cases/' && /^(\/cases\/)/.test(pathName)) {
  20. $(item).addClass('nav-active');
  21. }
  22. });
  23. $('#header-solution a').each(function (index, item) {
  24. if ($(item).attr('href') == pathName) {
  25. $('#header-solution-title').addClass('nav-active');
  26. }
  27. });
  28. //案例部分LOGO切换
  29. $('#case-logo-div .case-logo-item').hover(function(){
  30. var index = $(this).index();
  31. $('#case-logo-dec .case-logo-dec-item').eq(index).show();
  32. },function(){
  33. $('#case-logo-dec .case-logo-dec-item').hide();
  34. });
  35. $('#case-logo-dec .case-logo-dec-item').hover(function(){
  36. var index = $(this).index();
  37. $('#case-logo-dec .case-logo-dec-item').hide();
  38. $('#case-logo-dec .case-logo-dec-item').eq(index).show();
  39. },function(){
  40. $('#case-logo-dec .case-logo-dec-item').hide();
  41. });
  42. //切换地址
  43. function onChangeAddress(){
  44. $('#address-tab li').on('click',function () {
  45. var index = $(this).index();
  46. $('#address-tab li').removeClass('active');
  47. $(this).addClass('active');
  48. $('#address-tab .address-info').hide();
  49. $('#address-tab .address-info').eq(index).show();
  50. if(index === 0) {
  51. $('#address-tab .shanghai-bg').stop().animate({opacity: '0'},100);
  52. $('#address-tab .beijing-bg').stop().animate({opacity: '1'},400);
  53. }
  54. if(index === 1){
  55. $('#address-tab .shanghai-bg').stop().animate({opacity: '1'},400);
  56. $('#address-tab .beijing-bg').stop().animate({opacity: '0'},100);
  57. }
  58. })
  59. }
  60. onChangeAddress();
  61. //移动端 tab切换
  62. function onChangeTab() {
  63. $('#tab-box .tab').on('click',function(){
  64. var index = $(this).index();
  65. $('#tab-box .tab').removeClass('active');
  66. $(this).addClass('active');
  67. $('#content-div .content').hide();
  68. $('#content-div .content').eq(index).show();
  69. })
  70. }
  71. onChangeTab();
  72. //案例切换 自动切换
  73. var activeIndex = 0;
  74. var interVal = null;
  75. function onChangeCases(index){
  76. activeIndex = index;
  77. $('#case-logo-nav .case-logo-item').removeClass('active');
  78. $('#case-logo-nav .case-logo-item').eq(index).addClass('active');
  79. $('#case-logo-content .case-logo-item').hide();
  80. $('#case-logo-content .case-logo-item').eq(index).show();
  81. }
  82. function setInter(){
  83. interVal = setInterval(function(){
  84. activeIndex++;
  85. if(activeIndex > $('#case-logo-nav .case-logo-item').length - 1){
  86. activeIndex = 0;
  87. }
  88. onChangeCases(activeIndex);
  89. },3000);
  90. }
  91. setInter();
  92. var timer = null;
  93. $('#case-logo-nav .case-logo-item').on('click',function(){
  94. var index = $(this).index();
  95. onChangeCases(index);
  96. clearInterval(interVal);
  97. if(!timer) {
  98. // clearTimeout(timer);
  99. timer = setTimeout(function () {
  100. setInter();
  101. }, 5000);
  102. }
  103. });