pageNavigation1.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <!-- 导航 -->
  3. <div class="navigate">
  4. <div class="partOne">
  5. <div class="inner">
  6. <div class="home">
  7. <em></em>
  8. <NuxtLink :to="'/'">首页</NuxtLink>
  9. </div>
  10. <ul class="partOneTitle">
  11. <li class="titleList1">
  12. <NuxtLink to="/">深度服务</NuxtLink>
  13. </li>
  14. <li class="titleList111" v-for="(item, index) in navigation1" :key="index">
  15. <NuxtLink :href="getLinkPath(item)" :title="item.alias" :target="item.is_url == 1 ? '_blank' : '_self'">
  16. {{ item.alias }}
  17. </NuxtLink>
  18. </li>
  19. </ul>
  20. </div>
  21. </div>
  22. <div class="partTwo">
  23. <div class="inner">
  24. <div class="navleft">
  25. <div> 互动版块 </div>
  26. <div> 推荐版块 </div>
  27. </div>
  28. <ul class="navlist">
  29. <li class="navListItem" v-for="(item,index) in navigation2" :key="index">
  30. <NuxtLink :href="getLinkPath(item)" :title="item.alias" :target="item.is_url == 1 ? '_blank' : '_self'">
  31. {{ item.alias }}
  32. </NuxtLink>
  33. </li>
  34. </ul>
  35. <div class="navright">
  36. <div class="nav111" v-for="(item, index) in navigation3" :key="index">
  37. <NuxtLink :href="getLinkPath(item)" :title="item.alias"
  38. :target="item.is_url == 1 ? '_blank' : '_self'">
  39. {{ item.alias }}
  40. </NuxtLink>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="phone_nav pc_none">
  46. <div class="phone_nav_in">
  47. <NuxtLink
  48. to="/" title="首页"
  49. class="phone_nav_index"
  50. :class="{ 'phone_nav_index_only': $route.path === '/' }"
  51. >
  52. 首页
  53. </NuxtLink>
  54. <div class="phone_nav_a_box">
  55. <NuxtLink
  56. v-for="(item, index) in navigation1" :key="index"
  57. :href="getLinkPath(item)"
  58. :title="item.alias"
  59. :target="item.is_url == 1 ? '_blank' : '_self'">
  60. {{ item.alias }}
  61. </NuxtLink>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. <script setup>
  68. //1.获取导航菜单 start ---------------------------------------->
  69. //第一行导航菜单 10个
  70. const navigation1 = ref([]);
  71. //两行的导航菜单 20个
  72. const navigation2 = ref([]);
  73. //边边上的导航菜单 2个
  74. const navigation3 = ref([]);
  75. //获取导航菜单1
  76. async function getNavigation1() {
  77. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  78. method: 'GET',
  79. query: {
  80. 'pid': 0,
  81. 'num': 10,
  82. 'placeid': 1
  83. },
  84. });
  85. navigation1.value = mkdata.data;
  86. }
  87. getNavigation1();
  88. //获取导航菜单2
  89. async function getNavigation2() {
  90. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  91. method: 'GET',
  92. query: {
  93. 'pid': 0,
  94. 'num': 20,
  95. 'placeid': 11
  96. },
  97. });
  98. navigation2.value = mkdata.data;
  99. }
  100. getNavigation2();
  101. //获取导航菜单3
  102. async function getNavigation3() {
  103. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  104. method: 'GET',
  105. query: {
  106. 'pid': 0,
  107. 'num': 2,
  108. 'placeid': 31
  109. },
  110. });
  111. navigation3.value = mkdata.data;
  112. }
  113. getNavigation3();
  114. //1.获取导航菜单 end ---------------------------------------->
  115. //格式化跳转路径
  116. const getLinkPath = (item) => {
  117. if(item.is_url==1){
  118. return `${item.web_url}`;
  119. }else if(item.children_count == 0){
  120. //return `/newsList/${item.category_id}?page=1`;
  121. return `/${item.aLIas_pinyin}/list-1.html`;
  122. }else{
  123. //return `/primaryNavigation/${item.aLIas_pinyin}/`;
  124. return `/${item.aLIas_pinyin}/index.html`;
  125. }
  126. }
  127. const delayTimer = ref(null);
  128. onMounted(() => {
  129. delayTimer.value = setTimeout(() => {
  130. const parentElement = document.querySelector('.phone_nav_a_box');
  131. const targetElement = document.querySelector('.phone_nav_a_box .router-link-exact-active');
  132. if (targetElement) {
  133. const targetRect = targetElement.getBoundingClientRect();
  134. const parentRect = parentElement.getBoundingClientRect();
  135. const distanceToParentLeft = targetRect.left - parentRect.left;
  136. parentElement.scrollLeft = distanceToParentLeft;
  137. }
  138. }, 999);
  139. })
  140. </script>
  141. <style lang="less" scoped>
  142. @import url('@/assets/css/public/nav.less');
  143. </style>
  144. <style lang="less" scoped>
  145. @media screen and (min-width:801px){/*pc*/
  146. .pc_none{display:none;}
  147. }
  148. @media screen and (max-width:800px){/*ipad_phone*/
  149. .phone_nav{
  150. width:100%;margin:10px auto 0;
  151. height:44px;background:#dd7d18;
  152. }
  153. .phone_nav_in{height:44px;width:92%;margin:0px auto;}
  154. .phone_nav_index{height:44px;line-height:44px;font-size:16px;float:left;
  155. color:rgba(255, 255, 255,.6);;margin-right:20px;}
  156. .phone_nav_a_box{height:44px;
  157. overflow-x:auto;overflow-y:hidden;word-break: keep-all; white-space: nowrap;
  158. }
  159. .phone_nav_a_box::-webkit-scrollbar{height:0px;}
  160. .phone_nav_a_box a{display:inline-block;height:44px;line-height:44px;font-size:16px;margin:0 10px;
  161. color:rgba(255, 255, 255,.6);}
  162. .phone_nav_a_box a:nth-of-type(1){margin-left:0px;}
  163. .phone_nav_index_only{ color:#fff; font-weight:bold;}
  164. .phone_nav_a_box a.router-link-exact-active{color:#fff;font-weight:bold;}
  165. .partOne{display:none;}
  166. .partTwo{display:none;}
  167. .phone_none{display:none;}
  168. }
  169. </style>