| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- <template>
- <div class="navigate">
- <!-- 第一部分导航 start -->
- <div class="partOne">
- <div class="inner">
-
- <div class="navigationOneTitle">
- 资讯信息
- </div>
- <ul class="navigationOne">
- <li 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>
- <em class="line"></em>
- <em class="line1"></em>
- <div class="navigationOneTitle">
- 农副商城
- </div>
- <ul class="navigationOne">
- <li 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>
- <em class="line"></em>
- <em class="line1"></em>
- <div class="navigationOneTitle">
- 网上互动
- </div>
- <ul class="navigationOne">
- <li 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>
- </li>
- </ul>
- </div>
- </div>
- <!-- 第一部分导航 end -->
-
- <!-- 第二部分导航 start -->
- <div class="partTwo">
- <div class="inner">
- <ul class="nav2">
- <li>
- <NuxtLink to="/">首页</NuxtLink>
- </li>
- <li>
- <NuxtLink to="/">农副商业中心</NuxtLink>
- </li>
- <li class="navList" v-for="(item, index) in navigation4" :key="index">
- <NuxtLink :href="getLinkPath(item)" :title="item.alias" :target="item.is_url == 1 ? '_blank' : '_self'">
- {{ item.alias }}
- </NuxtLink>
- </li>
- </ul>
- </div>
- </div>
- <!-- 第二部分导航 end -->
-
- <!-- 第三部分导航 start-->
- <div class="deepServer">
- <div class="inner">
- <div class="deepServer_right">
- <div class="serverTitle_right">
- 站内搜索:
- </div>
- <div class="searchRole">
- <input type="text" v-model="inputValue" placeholder="输入关键词" class="ipt">
- <em @click="goToPrimary"></em>
- </div>
- </div>
- <div class="deepServer_left">
- <div class="serverTitle">
- <!-- 供应信息 -->
- </div>
- <ul class="contentList">
- <!-- <li>地区搜索:</li> -->
- <li v-for="item in provinceList">
- <NuxtLink :to="{ path: `/search/${item.id}`}">{{item.abbreviation}}</NuxtLink>
- </li>
- </ul>
- </div>
- </div>
- </div>
- <!-- 第三部分导航 end-->
-
- <div class="phone_nav pc_none">
- <div class="phone_nav_in">
- <NuxtLink
- to="/"
- 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"
- :to="getLinkPath(item)"
- :target="item.is_url == 1 ? '_blank' : '_self'">
- {{ item.alias }}
- </NuxtLink>
-
- <NuxtLink
- v-for="(item, index) in navigation2" :key="index"
- :to="getLinkPath(item)"
- :target="item.is_url == 1 ? '_blank' : '_self'">
- {{ item.alias }}
- </NuxtLink>
-
- <NuxtLink
- v-for="(item, index) in navigation3" :key="index"
- :to="getLinkPath(item)"
- :target="item.is_url == 1 ? '_blank' : '_self'">
- {{ item.alias }}
- </NuxtLink>
-
- <NuxtLink
- v-for="(item, index) in navigation4" :key="index"
- :to="getLinkPath(item)"
- :target="item.is_url == 1 ? '_blank' : '_self'">
- {{ item.alias }}
- </NuxtLink>
-
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- //1.获取导航菜单 start ---------------------------------------->
- //三行导航菜单第一个 12个
- const navigation1 = ref([]);
- //三行导航菜单第二个 12个
- const navigation2 = ref([]);
- //三行导航菜单第三个 12个
- const navigation3 = ref([]);
- //第二行的导航菜单 9个
- const navigation4 = ref([]);
- //获取导航菜单1
- async function getNavigation1() {
- const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'pid': 0,
- 'num': 12,
- 'placeid': 1
- },
- });
- navigation1.value = mkdata.data;
- }
- getNavigation1();
- //获取导航菜单2
- async function getNavigation2() {
- const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'pid': 0,
- 'num': 12,
- 'placeid': 13
- },
- });
- navigation2.value = mkdata.data;
- }
- getNavigation2();
- //获取导航菜单3
- async function getNavigation3() {
- const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'pid': 0,
- 'num': 12,
- 'placeid': 25
- },
- });
- navigation3.value = mkdata.data;
- }
- getNavigation3();
- //获取导航菜单4
- async function getNavigation4() {
- const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'pid': 0,
- 'num': 9,
- 'placeid': 37
- },
- });
- navigation4.value = mkdata.data;
- }
- getNavigation4();
- //1.获取导航菜单 end ---------------------------------------->
- //2.搜索 start ---------------------------------------->
- const inputValue = ref("") //关键词搜索
- //2.1跳转到搜索页面
- let goToPrimary = async () => {
- if (inputValue.value=="") {
- ElMessage.error('搜索项不能为空!')
- }else{
- const route = `/search/search?keyword=${inputValue.value}`;
- window.location.href = route;
- }
- }
- const provinceList = ref([]);//省列表
- onMounted(async () => {
- //获得所有的省
- try {
- const { $webUrl, $CwebUrl } = useNuxtApp();
- const response2 = await fetch($webUrl + '/web/selectWebsiteArea', {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const result2 = await response2.json();
- provinceList.value = result2.data;
- } catch (error) {
- console.error('获取行政区划数据失败:', error);
- }
- })
- //2.搜索 end ---------------------------------------->
- 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:#004564;
- }
- .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_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;}
- .deepServer{display:none;}
- .phone_none{display:none;}
- }
- </style>
|