headerSection.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div class="headerSection">
  3. <div class="header-container width1200">
  4. <router-link :to="{ path: '/' }" class="logo">
  5. <img src="../assets/images/logoWhile.png" width="100%" alt="" />
  6. </router-link>
  7. <div class="menu">
  8. <a
  9. :class="checkActive == 1 ? 'active' : ''"
  10. @click="change(1, 'banner')"
  11. >产品服务</a
  12. >
  13. <a :class="checkActive == 2 ? 'active' : ''" @click="change(2, 'infos')"
  14. >成功案例</a
  15. >
  16. <a
  17. :class="checkActive == 3 ? 'active' : ''"
  18. @click="change(3, 'detail')"
  19. >关于我们</a
  20. >
  21. <div class="bandBtn" @click="goKu">机构入驻</div>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import Bus from "../views/index/blocks/eventBus";
  28. import { scrollAnimation } from "@/util/scroll";
  29. export default {
  30. name: "headerSection",
  31. props: ["name"],
  32. data() {
  33. return {
  34. checkActive: 1,
  35. topList: [],
  36. };
  37. },
  38. created() {},
  39. mounted() {
  40. scrollTo(0, 0);
  41. let url = this.$route;
  42. if (url.path.indexOf("detile") != -1) {
  43. this.checkActive = 5;
  44. }
  45. this.$nextTick((res) => {
  46. this.topList = this.getTop([
  47. "banner",
  48. "infos",
  49. "detail",
  50. "videoList",
  51. "consult",
  52. "aboutUs",
  53. ]);
  54. });
  55. window.addEventListener(
  56. "scroll",
  57. this.onContentScroll,
  58. true
  59. );
  60. Bus.$on("gotoDetail", (res) => {
  61. // 控制页面滚动
  62. this.change(3, "detail");
  63. });
  64. },
  65. methods: {
  66. getTop(nameList) {
  67. let arr = [];
  68. nameList.forEach((item) => {
  69. let top = document.getElementById(item).offsetTop - 78;
  70. arr.push(top);
  71. });
  72. arr.sort(function (a, b) {
  73. return a - b;
  74. });
  75. return arr;
  76. },
  77. change(num, name) {
  78. let url = this.$route.path;
  79. let top = document.getElementById(name).offsetTop - 76;
  80. const currentY =
  81. document.documentElement.scrollTop || document.body.scrollTop;
  82. if (url != "/") {
  83. this.$router.push("/");
  84. this.checkActive = num;
  85. scrollAnimation(currentY, top);
  86. // scrollTo(0, top);
  87. } else {
  88. this.checkActive = num;
  89. scrollAnimation(currentY, top);
  90. // scrollTo(0, top);
  91. }
  92. },
  93. goKu() {
  94. window.open("https://kj.colexiu.com/#/login?returnUrl=%2F", "_blank");
  95. },
  96. onContentScroll(e) {
  97. // this.topList = this.getTop(['banner', 'infos', 'detail', 'videoList', 'consult', 'aboutUs'])
  98. let target = e.target || e.srcElement;
  99. if (target&&target.scrollingElement) {
  100. this.scrollTop = target.scrollingElement.scrollTop;
  101. if (this.scrollTop < this.topList[1]) {
  102. this.checkActive = 1;
  103. } else if (
  104. this.scrollTop >= this.topList[1] &&
  105. this.scrollTop < this.topList[2]
  106. ) {
  107. this.checkActive = 2;
  108. } else if (
  109. this.scrollTop >= this.topList[2] &&
  110. this.scrollTop < this.topList[3]
  111. ) {
  112. this.checkActive = 3;
  113. } else if (
  114. this.scrollTop >= this.topList[3] &&
  115. this.scrollTop < this.topList[4]
  116. ) {
  117. this.checkActive = 4;
  118. } else if (
  119. this.scrollTop >= this.topList[4] &&
  120. this.scrollTop < this.topList[5]
  121. ) {
  122. this.checkActive = 5;
  123. } else if (this.scrollTop >= this.topList[5]) {
  124. this.checkActive = 6;
  125. }
  126. }
  127. },
  128. },
  129. };
  130. </script>
  131. <style lang="less" scoped>
  132. .bandBtn {
  133. width: 112px;
  134. height: 30px;
  135. background: #2dc7aa;
  136. // border-radius: 4px;
  137. color: #fff;
  138. margin-left: 70px;
  139. line-height: 30px;
  140. cursor: pointer;
  141. position: relative;
  142. &:hover {
  143. background-color: #2ac0a3;
  144. }
  145. }
  146. .wall {
  147. height: 82px;
  148. }
  149. .headerSection {
  150. background-color: rgba(0,0,0,.4);
  151. position: fixed;
  152. width: 100%;
  153. top: 0px;
  154. z-index: 1000;
  155. // backdrop-filter: saturate(180%) blur(20px);
  156. .header-container {
  157. margin: 0 auto;
  158. // overflow: hidden;
  159. display: flex;
  160. align-items: center;
  161. flex-direction: row;
  162. justify-content: space-between;
  163. height: 70px;
  164. border-bottom: 1px solid rgba(255,255,255,.2);
  165. }
  166. .logo {
  167. // float: left;
  168. width: 159px;
  169. height: 48px;
  170. }
  171. .menu {
  172. display: flex;
  173. flex-direction: row;
  174. font-size: 16px;
  175. align-items: center;
  176. a {
  177. cursor: pointer;
  178. margin-left: 44px;
  179. color: #fff;
  180. text-decoration: none;
  181. position: relative;
  182. // display: block;
  183. text-decoration: none;
  184. text-transform: uppercase;
  185. transition: 0.5s;
  186. &::after {
  187. position: absolute;
  188. content: "";
  189. top: 180%;
  190. left: 25%;
  191. width: 50%;
  192. height: 3px;
  193. background-color: #2dc7aa;
  194. z-index: 100;
  195. transform: scaleX(0);
  196. transform-origin: right;
  197. transition: transform 0.5s;
  198. }
  199. &:hover,
  200. &.hover {
  201. color: #2dc7aa;
  202. font-weight: 600;
  203. }
  204. &:hover::after {
  205. transform: scaleX(1);
  206. transform-origin: left;
  207. }
  208. }
  209. }
  210. a.active {
  211. color: #2dc7aa !important;
  212. font-weight: 600;
  213. // &::after {
  214. // position: absolute;
  215. // content: "";
  216. // top: 180%;
  217. // left: 25%;
  218. // width: 50%;
  219. // height: 3px;
  220. // background-color: #2dc7aa;
  221. // z-index: 100;
  222. // transform: scaleX(1);
  223. // transform-origin: left;
  224. // }
  225. }
  226. }
  227. </style>