| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <template>
- <!-- 导航 -->
- <div class="navigate">
- <div class="partOne">
- <div class="inner">
- <div class="home">
- <em></em>
- <NuxtLink :to="'/'">首页</NuxtLink>
- </div>
- <ul class="partOneTitle">
- <li class="titleList1">
- <NuxtLink to="/">深度服务</NuxtLink>
- </li>
- <li class="titleList111" v-for="(item, index) in navigation1" :key="index">
- <NuxtLink :href="getLinkPath(item)" :title="item.alias" :target="item.is_url == 1 ? '_blank' : '_self'">
- {{ item.alias }}
- </NuxtLink>
- </li>
- </ul>
- </div>
- </div>
- <div class="partTwo">
- <div class="inner">
- <div class="navleft">
- <div> 互动版块 </div>
- <div> 推荐版块 </div>
- </div>
- <ul class="navlist">
- <li class="navListItem" v-for="(item,index) in navigation2" :key="index">
- <NuxtLink :href="getLinkPath(item)" :title="item.alias" :target="item.is_url == 1 ? '_blank' : '_self'">
- {{ item.alias }}
- </NuxtLink>
- </li>
- </ul>
- <div class="navright">
- <div class="nav111" v-for="(item, index) in navigation3" :key="index">
- <NuxtLink :href="getLinkPath(item)" :title="item.alias"
- :target="item.is_url == 1 ? '_blank' : '_self'">
- {{ item.alias }}
- </NuxtLink>
- </div>
- </div>
- </div>
- </div>
-
- <div class="phone_nav pc_none">
- <div class="phone_nav_in">
- <NuxtLink
- to="/" title="首页"
- class="phone_nav_index"
- :class="{ 'phone_nav_index_only': $route.path === '/' }"
- >
- 首页
- </NuxtLink>
-
- <div class="phone_nav_a_box">
- <NuxtLink
- v-for="(item, index) in navigation1" :key="index"
- :href="getLinkPath(item)"
- :title="item.alias"
- :target="item.is_url == 1 ? '_blank' : '_self'">
- {{ item.alias }}
- </NuxtLink>
- </div>
-
- </div>
- </div>
- </div>
- </template>
- <script setup>
- //1.获取导航菜单 start ---------------------------------------->
- //第一行导航菜单 10个
- const navigation1 = ref([]);
- //两行的导航菜单 20个
- const navigation2 = ref([]);
- //边边上的导航菜单 2个
- const navigation3 = ref([]);
- //获取导航菜单1
- async function getNavigation1() {
- const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'pid': 0,
- 'num': 10,
- 'placeid': 1
- },
- });
- navigation1.value = mkdata.data;
- }
- getNavigation1();
- //获取导航菜单2
- async function getNavigation2() {
- const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'pid': 0,
- 'num': 20,
- 'placeid': 11
- },
- });
- navigation2.value = mkdata.data;
- }
- getNavigation2();
- //获取导航菜单3
- async function getNavigation3() {
- const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'pid': 0,
- 'num': 2,
- 'placeid': 31
- },
- });
- navigation3.value = mkdata.data;
- }
- getNavigation3();
- //1.获取导航菜单 end ---------------------------------------->
- //格式化跳转路径
- const getLinkPath = (item) => {
- if(item.is_url==1){
- return `${item.web_url}`;
- }else if(item.children_count == 0){
- //return `/newsList/${item.category_id}?page=1`;
- return `/${item.aLIas_pinyin}/list-1.html`;
- }else{
- //return `/primaryNavigation/${item.aLIas_pinyin}/`;
- return `/${item.aLIas_pinyin}/index.html`;
- }
- }
- const delayTimer = ref(null);
- onMounted(() => {
- delayTimer.value = setTimeout(() => {
- const parentElement = document.querySelector('.phone_nav_a_box');
- const targetElement = document.querySelector('.phone_nav_a_box .router-link-exact-active');
-
- if (targetElement) {
-
- const targetRect = targetElement.getBoundingClientRect();
- const parentRect = parentElement.getBoundingClientRect();
-
- const distanceToParentLeft = targetRect.left - parentRect.left;
-
- parentElement.scrollLeft = distanceToParentLeft;
-
- }
-
- }, 999);
- })
- </script>
- <style lang="less" scoped>
- @import url('@/assets/css/public/nav.less');
- </style>
- <style lang="less" scoped>
-
- @media screen and (min-width:801px){/*pc*/
-
-
- .pc_none{display:none;}
- }
- @media screen and (max-width:800px){/*ipad_phone*/
- .phone_nav{
- width:100%;margin:10px auto 0;
- height:44px;background:#dd7d18;
- }
-
- .phone_nav_in{height:44px;width:92%;margin:0px auto;}
- .phone_nav_index{height:44px;line-height:44px;font-size:16px;float:left;
- color:rgba(255, 255, 255,.6);;margin-right:20px;}
- .phone_nav_a_box{height:44px;
- overflow-x:auto;overflow-y:hidden;word-break: keep-all; white-space: nowrap;
- }
- .phone_nav_a_box::-webkit-scrollbar{height:0px;}
- .phone_nav_a_box a{display:inline-block;height:44px;line-height:44px;font-size:16px;margin:0 10px;
- color:rgba(255, 255, 255,.6);}
- .phone_nav_a_box a:nth-of-type(1){margin-left:0px;}
- .phone_nav_index_only{ color:#fff; font-weight:bold;}
- .phone_nav_a_box a.router-link-exact-active{color:#fff;font-weight:bold;}
- .partOne{display:none;}
- .partTwo{display:none;}
- .phone_none{display:none;}
- }
- </style>
|