hjyd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
3.0 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div
  3. :class="
  4. [0, 15].includes(activeIndex)
  5. ? 'header_container'
  6. : 'header_container not_first'
  7. "
  8. >
  9. <img v-lazy="logo()" alt="logo" class="logo" @click="scrollToPage(0)" />
  10. <ul :class="fontColor()">
  11. <li :class="getActiveClass([0])" @click="scrollToPage(0)">首页</li>
  12. <li :class="getActiveClass([3, 4])" @click="scrollToPage(3)">工业设计</li>
  13. <li :class="getActiveClass([5, 6, 7, 8])" @click="scrollToPage(5)">
  14. 软硬件研发
  15. </li>
  16. <li :class="getActiveClass([11])" @click="scrollToPage(11)">结构开发</li>
  17. <li :class="getActiveClass([13])" @click="scrollToPage(13)">企业文化</li>
  18. <li :class="getActiveClass([14])" @click="scrollToPage(14)">加入我们</li>
  19. <li :class="getActiveClass([16])" @click="scrollToPage(16)">联系我们</li>
  20. </ul>
  21. </div>
  22. </template>
  23. <script setup>
  24. import Logo1 from '@/assets/img/banner/logo1.png'
  25. import Logo from '@/assets/img/banner/logo.png'
  26. import LogoWhite from '@/assets/img/banner/logo3.png'
  27. import { useSwiperStore, useCountStore } from '@/store'
  28. import { onMounted, ref, watch } from 'vue'
  29. import { storeToRefs } from 'pinia'
  30. const swiperStore = useSwiperStore()
  31. const countStore = useCountStore()
  32. const { activeIndex } = storeToRefs(swiperStore)
  33. const getActiveClass = index => {
  34. if (index.includes(swiperStore.activeIndex)) {
  35. return 'active'
  36. }
  37. return ''
  38. }
  39. const scrollToPage = index => {
  40. // 让数字动
  41. swiperStore.swiper.slideTo(index, 0, false)
  42. if (index == 3) {
  43. setTimeout(() => {
  44. countStore.countAdd()
  45. })
  46. }
  47. if (index == 5) {
  48. setTimeout(() => {
  49. countStore.countAddI()
  50. })
  51. }
  52. }
  53. const logo = () => {
  54. if (swiperStore.activeIndex == 0) {
  55. if ([4].includes(swiperStore.headerIndex)) return LogoWhite
  56. }
  57. return Logo
  58. }
  59. const fontColor = () => {
  60. if (swiperStore.activeIndex == 0) {
  61. if ([2, 3, 4].includes(swiperStore.headerIndex)) {
  62. return 'flex_center white'
  63. }
  64. }
  65. if (swiperStore.activeIndex == 15) {
  66. return 'flex_center white'
  67. }
  68. return 'flex_center font_change'
  69. }
  70. </script>
  71. <style scoped lang="scss">
  72. .header_container {
  73. position: fixed;
  74. top: 0;
  75. left: 0;
  76. right: 0;
  77. width: 100%;
  78. z-index: 999;
  79. background: none;
  80. padding: 0 87px;
  81. height: $header_height;
  82. min-height: $header_height;
  83. white-space: nowrap;
  84. display: flex;
  85. align-items: center;
  86. justify-content: space-between;
  87. box-sizing: border-box;
  88. font-size: 18px;
  89. li {
  90. margin: 0 30px;
  91. transition-property: all;
  92. transition-duration: 0.3s;
  93. animation-fill-mode: forwards;
  94. }
  95. li:hover {
  96. transform: scale(1.1);
  97. color: rgb(40, 63, 231, 0.6);
  98. }
  99. .logo {
  100. height: 40px;
  101. width: auto;
  102. cursor: pointer;
  103. }
  104. }
  105. .flex_center {
  106. display: flex;
  107. align-items: center;
  108. justify-content: center;
  109. color: $default_color;
  110. li {
  111. cursor: pointer;
  112. }
  113. .active {
  114. color: $theme_color;
  115. }
  116. .white {
  117. color: #fff;
  118. }
  119. }
  120. .font_change {
  121. li {
  122. color: $point_default;
  123. }
  124. }
  125. .not_first {
  126. background: #fff;
  127. }
  128. </style>