pageNavigation.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="navigate">
  3. <div class="partOne">
  4. <div class="inner">
  5. <div class="navLeft">
  6. <div class="navClass">
  7. <div>
  8. 资讯信息
  9. </div>
  10. <div>
  11. 网上互动
  12. </div>
  13. </div>
  14. </div>
  15. <ul class="navigationOne">
  16. <li v-for="(item ,per_index) in navigation1"
  17. @mousemove="item.alias == '供求信息' ? showTwo = true : showTwo = false">
  18. <NuxtLink :href="getLinkPath(item)" :title="item.alias"
  19. :target="item.is_url == 1 ? '_blank' : '_self'">
  20. {{ item.alias }}
  21. </NuxtLink>
  22. </li>
  23. </ul>
  24. <ul class="navigationTwo" v-if="showTwo" @mouseleave="showTwo = false">
  25. <li v-for="(item, index) in secNav" :key="index">
  26. <NuxtLink :href="`/gongqiuxinxi/${item.aLIas_pinyin}/index.html`" :title="item.alias"
  27. :target="item.is_url == 1 ? '_blank' : '_self'">
  28. {{ item.alias }}
  29. </NuxtLink>
  30. </li>
  31. </ul>
  32. </div>
  33. </div>
  34. <div class="partTwo">
  35. <div class="inner">
  36. <ul class="part2_left">
  37. <li>农资商城</li>
  38. <li class="part2_navList" v-for="item in navigation2">
  39. <NuxtLink :href="getLinkPath(item)" :title="item.alias"
  40. :target="item.is_url == 1 ? '_blank' : '_self'">
  41. {{ item.alias }}
  42. </NuxtLink>
  43. </li>
  44. </ul>
  45. <ul class="part2_right">
  46. <li class="part2_right_navList" v-for="(item, index) in navigation3">
  47. <NuxtLink :href="getLinkPath(item)" :title="item.alias"
  48. :target="item.is_url == 1 ? '_blank' : '_self'">
  49. {{ item.alias }}
  50. </NuxtLink>
  51. <em v-if="index != 2"></em>
  52. </li>
  53. </ul>
  54. </div>
  55. </div>
  56. <!-- 深度服务 -->
  57. <div class="deepServer">
  58. <div class="inner">
  59. <div class="deepServer_left">
  60. <div class="serverTitle">
  61. <NuxtLink href="/">
  62. 网站首页
  63. </NuxtLink>
  64. </div>
  65. <el-radio-group v-model="checkList">
  66. <el-radio value="1">资讯</el-radio>
  67. <el-radio value="2">商城</el-radio>
  68. <el-radio value="6">企业</el-radio>
  69. <el-radio value="7">项目</el-radio>
  70. </el-radio-group>
  71. <!-- <div class="serverTitle1">
  72. <a href="">
  73. 农资商务中心
  74. </a>
  75. </div> -->
  76. </div>
  77. <div class="deepServer_right">
  78. <div class="searchRole">
  79. <input type="text" v-model="inputValue" placeholder="输入关键词" class="ipt">
  80. <em @click="goToPrimary"></em>
  81. </div>
  82. <!-- <div class="serverTitle_right">
  83. 【高级搜索】
  84. </div> -->
  85. </div>
  86. </div>
  87. </div>
  88. <div class="phone_nav pc_none">
  89. <div class="phone_nav_in">
  90. <NuxtLink
  91. to="/"
  92. class="phone_nav_index"
  93. :class="{ 'phone_nav_index_only': $route.path === '/' }"
  94. >
  95. 首页
  96. </NuxtLink>
  97. <div class="phone_nav_a_box">
  98. <NuxtLink
  99. v-for="(item, index) in navigation1" :key="index"
  100. :to="getLinkPath(item)"
  101. :target="item.is_url == 1 ? '_blank' : '_self'">
  102. {{ item.alias }}
  103. </NuxtLink>
  104. <NuxtLink
  105. v-for="(item, index) in navigation2" :key="index"
  106. :to="getLinkPath(item)"
  107. :target="item.is_url == 1 ? '_blank' : '_self'">
  108. {{ item.alias }}
  109. </NuxtLink>
  110. <NuxtLink
  111. v-for="(item, index) in navigation3" :key="index"
  112. :to="getLinkPath(item)"
  113. :target="item.is_url == 1 ? '_blank' : '_self'">
  114. {{ item.alias }}
  115. </NuxtLink>
  116. <NuxtLink
  117. v-for="(item, index) in navigation4" :key="index"
  118. :to="getLinkPath(item)"
  119. :target="item.is_url == 1 ? '_blank' : '_self'">
  120. {{ item.alias }}
  121. </NuxtLink>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. </template>
  127. <script setup>
  128. //1.获取导航菜单 start ---------------------------------------->
  129. import { ElCheckbox, ElCheckboxGroup, ElMessage, ElRadio, ElRadioGroup } from 'element-plus'
  130. let showTwo = ref(false);
  131. //第一行导航菜单 10个
  132. const navigation1 = ref([]);
  133. //两行的导航菜单 20个
  134. const navigation2 = ref([]);
  135. //三行的导航菜单 3个
  136. const navigation3 = ref([]);
  137. //获取导航菜单1
  138. async function getNavigation1() {
  139. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  140. method: 'GET',
  141. query: {
  142. 'pid': 0,
  143. 'num': 28,
  144. 'placeid': 1
  145. },
  146. });
  147. navigation1.value = mkdata.data;
  148. }
  149. getNavigation1();
  150. //获取导航菜单2
  151. async function getNavigation2() {
  152. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  153. method: 'GET',
  154. query: {
  155. 'pid': 0,
  156. 'num': 10,
  157. 'placeid': 29
  158. },
  159. });
  160. navigation2.value = mkdata.data;
  161. }
  162. getNavigation2();
  163. //获取导航菜单3
  164. async function getNavigation3() {
  165. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  166. method: 'GET',
  167. query: {
  168. 'pid': 0,
  169. 'num': 3,
  170. 'placeid': 39
  171. },
  172. });
  173. navigation3.value = mkdata.data;
  174. }
  175. getNavigation3();
  176. // 1.4 获取供求信息二级导航
  177. //引入导航
  178. const { $pageNav } = useNuxtApp();
  179. const pid = $pageNav[14];
  180. console.log('供求信息二级栏目', pid);
  181. const secNav = ref([]);
  182. async function getNavigation4() {
  183. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  184. method: 'GET',
  185. query: {
  186. 'pid': pid,
  187. 'num': 2,
  188. 'placeid': 1,
  189. 'type': 1
  190. },
  191. });
  192. console.log("供求信息二级栏目", mkdata.data);
  193. secNav.value = mkdata.data;
  194. }
  195. getNavigation4();
  196. //1.获取导航菜单 end ---------------------------------------->
  197. //2.搜索 start ---------------------------------------->
  198. const typeValue = ref("")
  199. const checkList = ref("1");// 单选
  200. const inputValue = ref("") //关键词搜索
  201. //2.1跳转到搜索页面
  202. let goToPrimary = async () => {
  203. if (checkList.value == "") {
  204. ElMessage.error('搜索项类型不能为空!')
  205. } else {
  206. const route = `/search/search?keyword=${inputValue.value}&type=${checkList.value}`;
  207. window.location.href = route;
  208. }
  209. }
  210. onMounted(async () => {
  211. })
  212. //2.搜索 end ---------------------------------------->
  213. const delayTimer = ref(null);
  214. onMounted(() => {
  215. delayTimer.value = setTimeout(() => {
  216. const parentElement = document.querySelector('.phone_nav_a_box');
  217. const targetElement = document.querySelector('.phone_nav_a_box .router-link-exact-active');
  218. if (targetElement) {
  219. const targetRect = targetElement.getBoundingClientRect();
  220. const parentRect = parentElement.getBoundingClientRect();
  221. const distanceToParentLeft = targetRect.left - parentRect.left;
  222. parentElement.scrollLeft = distanceToParentLeft;
  223. }
  224. }, 999);
  225. })
  226. </script>
  227. <style lang="less" scoped>
  228. @import url('@/assets/css/public/nav.less');
  229. </style>
  230. <style lang="less" scoped>
  231. @media screen and (min-width:801px){/*pc*/
  232. .pc_none{display:none;}
  233. }
  234. @media screen and (max-width:800px){/*ipad_phone*/
  235. .phone_nav{
  236. width:100%;margin:10px auto 0;
  237. height:44px;background:#a91b33;
  238. }
  239. .phone_nav_in{height:44px;width:92%;margin:0px auto;}
  240. .phone_nav_index{height:44px;line-height:44px;font-size:16px;float:left;
  241. color:rgba(255, 255, 255,.6);;margin-right:20px;}
  242. .phone_nav_a_box{height:44px;
  243. overflow-x:auto;overflow-y:hidden;word-break: keep-all; white-space: nowrap;
  244. }
  245. .phone_nav_a_box::-webkit-scrollbar{height:0px;}
  246. .phone_nav_a_box a{display:inline-block;height:44px;line-height:44px;font-size:16px;margin:0 10px;
  247. color:rgba(255, 255, 255,.6);}
  248. .phone_nav_index_only{ color:#fff; font-weight:bold;}
  249. .phone_nav_a_box a.router-link-exact-active{color:#fff;font-weight:bold;}
  250. .partOne{display:none;}
  251. .partTwo{display:none;}
  252. .deepServer{display:none;}
  253. .phone_none{display:none;}
  254. }
  255. </style>