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.

114 lines
2.6 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
  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 LogoWhite from '@/assets/img/banner/logo3.png'
  23. import { useSwiperStore, useCountStore } from '@/store'
  24. import { onMounted, ref, watch } from 'vue'
  25. import { storeToRefs } from 'pinia'
  26. const swiperStore = useSwiperStore()
  27. const countStore = useCountStore()
  28. const { activeIndex } = storeToRefs(swiperStore)
  29. const getActiveClass = index => {
  30. if (swiperStore.activeIndex == index) {
  31. return 'active'
  32. }
  33. return ''
  34. }
  35. const scrollToPage = index => {
  36. // 让数字动
  37. swiperStore.swiper.slideTo(index, 1000, false)
  38. if (index == 3) {
  39. setTimeout(() => {
  40. countStore.countAdd()
  41. })
  42. }
  43. if (index == 5) {
  44. setTimeout(() => {
  45. countStore.countAddI()
  46. })
  47. }
  48. }
  49. const logo = () => {
  50. if (swiperStore.activeIndex == 0) {
  51. if ([4].includes(swiperStore.headerIndex)) return LogoWhite
  52. }
  53. return Logo
  54. }
  55. const fontColor = () => {
  56. if (swiperStore.activeIndex == 0) {
  57. if ([2, 3, 4].includes(swiperStore.headerIndex)) {
  58. return 'flex_center white'
  59. }
  60. }
  61. return 'flex_center font_change'
  62. }
  63. </script>
  64. <style scoped lang="scss">
  65. .header_container {
  66. position: fixed;
  67. top: 0;
  68. left: 0;
  69. right: 0;
  70. width: 100%;
  71. z-index: 999;
  72. background: none;
  73. padding: 0 87px;
  74. height: $header_height;
  75. white-space: nowrap;
  76. display: flex;
  77. align-items: center;
  78. justify-content: space-between;
  79. box-sizing: border-box;
  80. font-size: 18px;
  81. li {
  82. margin: 0 30px;
  83. }
  84. }
  85. .flex_center {
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. color: $default_color;
  90. li {
  91. cursor: pointer;
  92. }
  93. .active {
  94. color: $theme_color;
  95. }
  96. .white {
  97. color: #fff;
  98. }
  99. }
  100. .font_change {
  101. li {
  102. color: $point_default;
  103. }
  104. }
  105. .not_first {
  106. background: #fff;
  107. }
  108. </style>