123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <template>
- <div class="headerSection">
- <div class="header-container width1200">
- <router-link :to="{ path: '/' }" class="logo">
- <img src="../assets/images/logoWhile.png" width="100%" alt="" />
- </router-link>
- <div class="menu">
- <a
- :class="checkActive == 1 ? 'active' : ''"
- @click="change(1, 'banner')"
- >产品服务</a
- >
- <a :class="checkActive == 2 ? 'active' : ''" @click="change(2, 'infos')"
- >成功案例</a
- >
- <a
- :class="checkActive == 3 ? 'active' : ''"
- @click="change(3, 'detail')"
- >关于我们</a
- >
- <div class="bandBtn" @click="goKu">机构入驻</div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Bus from "../views/index/blocks/eventBus";
- import { scrollAnimation } from "@/util/scroll";
- export default {
- name: "headerSection",
- props: ["name"],
- data() {
- return {
- checkActive: 1,
- topList: [],
- };
- },
- created() {},
- mounted() {
- scrollTo(0, 0);
- let url = this.$route;
- if (url.path.indexOf("detile") != -1) {
- this.checkActive = 5;
- }
- this.$nextTick((res) => {
- this.topList = this.getTop([
- "banner",
- "infos",
- "detail",
- "videoList",
- "consult",
- "aboutUs",
- ]);
- });
- window.addEventListener(
- "scroll",
- this.onContentScroll,
- true
- );
- Bus.$on("gotoDetail", (res) => {
- // 控制页面滚动
- this.change(3, "detail");
- });
- },
- methods: {
- getTop(nameList) {
- let arr = [];
- nameList.forEach((item) => {
- let top = document.getElementById(item).offsetTop - 78;
- arr.push(top);
- });
- arr.sort(function (a, b) {
- return a - b;
- });
- return arr;
- },
- change(num, name) {
- let url = this.$route.path;
- let top = document.getElementById(name).offsetTop - 76;
- const currentY =
- document.documentElement.scrollTop || document.body.scrollTop;
- if (url != "/") {
- this.$router.push("/");
- this.checkActive = num;
- scrollAnimation(currentY, top);
- // scrollTo(0, top);
- } else {
- this.checkActive = num;
- scrollAnimation(currentY, top);
- // scrollTo(0, top);
- }
- },
- goKu() {
- window.open("https://kj.colexiu.com/#/login?returnUrl=%2F", "_blank");
- },
- onContentScroll(e) {
- // this.topList = this.getTop(['banner', 'infos', 'detail', 'videoList', 'consult', 'aboutUs'])
- let target = e.target || e.srcElement;
- if (target&&target.scrollingElement) {
- this.scrollTop = target.scrollingElement.scrollTop;
- if (this.scrollTop < this.topList[1]) {
- this.checkActive = 1;
- } else if (
- this.scrollTop >= this.topList[1] &&
- this.scrollTop < this.topList[2]
- ) {
- this.checkActive = 2;
- } else if (
- this.scrollTop >= this.topList[2] &&
- this.scrollTop < this.topList[3]
- ) {
- this.checkActive = 3;
- } else if (
- this.scrollTop >= this.topList[3] &&
- this.scrollTop < this.topList[4]
- ) {
- this.checkActive = 4;
- } else if (
- this.scrollTop >= this.topList[4] &&
- this.scrollTop < this.topList[5]
- ) {
- this.checkActive = 5;
- } else if (this.scrollTop >= this.topList[5]) {
- this.checkActive = 6;
- }
- }
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .bandBtn {
- width: 112px;
- height: 30px;
- background: #2dc7aa;
- // border-radius: 4px;
- color: #fff;
- margin-left: 70px;
- line-height: 30px;
- cursor: pointer;
- position: relative;
- &:hover {
- background-color: #2ac0a3;
- }
- }
- .wall {
- height: 82px;
- }
- .headerSection {
- background-color: rgba(0,0,0,.4);
- position: fixed;
- width: 100%;
- top: 0px;
- z-index: 1000;
- // backdrop-filter: saturate(180%) blur(20px);
- .header-container {
- margin: 0 auto;
- // overflow: hidden;
- display: flex;
- align-items: center;
- flex-direction: row;
- justify-content: space-between;
- height: 70px;
- border-bottom: 1px solid rgba(255,255,255,.2);
- }
- .logo {
- // float: left;
- width: 159px;
- height: 48px;
- }
- .menu {
- display: flex;
- flex-direction: row;
- font-size: 16px;
- align-items: center;
- a {
- cursor: pointer;
- margin-left: 44px;
- color: #fff;
- text-decoration: none;
- position: relative;
- // display: block;
- text-decoration: none;
- text-transform: uppercase;
- transition: 0.5s;
- &::after {
- position: absolute;
- content: "";
- top: 180%;
- left: 25%;
- width: 50%;
- height: 3px;
- background-color: #2dc7aa;
- z-index: 100;
- transform: scaleX(0);
- transform-origin: right;
- transition: transform 0.5s;
- }
- &:hover,
- &.hover {
- color: #2dc7aa;
- font-weight: 600;
- }
- &:hover::after {
- transform: scaleX(1);
- transform-origin: left;
- }
- }
- }
- a.active {
- color: #2dc7aa !important;
- font-weight: 600;
- // &::after {
- // position: absolute;
- // content: "";
- // top: 180%;
- // left: 25%;
- // width: 50%;
- // height: 3px;
- // background-color: #2dc7aa;
- // z-index: 100;
- // transform: scaleX(1);
- // transform-origin: left;
- // }
- }
- }
- </style>
|