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.

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