| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- <template>
- <div class="navigate">
- <div class="partOne">
- <div class="inner">
- <div class="navLeft">
- <div class="navIndex">
- <NuxtLink :to="'/'">首页</NuxtLink>
- </div>
- <div class="navClass">
- <div>主题资讯</div>
- <div>互动资讯</div>
- </div>
- </div>
- <ul class="navigationOne">
- <div class="nav_in clearfix">
- <li v-for="(item, index) in navigation1" :key="index">
- <NuxtLink :href="getLinkPath(item)" :title="item.alias" v-if="index <= 23"
- :target="item.is_url == 1 ? '_blank' : '_self'">
- <span class="active" v-if="item.category_id == routeId">{{ item.alias }}</span>
- <span v-else>{{ item.alias }}</span>
- </NuxtLink>
- </li>
- </div>
- </ul>
- </div>
- </div>
- <!-- 展示地区 -->
- <div class="cityBox">
- <div class="cityMain">
- <div class="cityTitle">地方频道</div>
- <ul class="cityList">
- <li v-for="item in provinceList">
- <NuxtLink :to="{ path: `/search/${item.id}` }">{{ item.abbreviation }}</NuxtLink>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- //1.加载依赖 start ---------------------------------------->
- import { ElMessage } from 'element-plus'
- import { ref, onMounted } from 'vue';
- import { ElSelect, ElOption } from 'element-plus'
- const nuxtApp = useNuxtApp();
- const axios = nuxtApp.$axios;
- const route = useRoute();
- const routeId = route.params.id; //获得该页面的id
- //1.加载依赖 end ---------------------------------------->
- //2.加载模块数据 start ---------------------------------------->
- const navigation1 = ref("");
- async function getPageData2() {
- const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'placeid': 1,
- 'pid': 0,
- 'num': 35
- },
- });
- navigation1.value = mkdata.data;
- }
- getPageData2();
- //格式化跳转路径
- 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`;
- }
- }
- //2.加载模块数据 end ---------------------------------------->
- //3.职能部门 start ---------------------------------------->
- // let department = ref("")
- const depValue = ref("")
- const typeValue = ref("")
- // let departmentList = async () => {
- // const mkdata = await requestDataPromise('/web/selectWebsiteDepartment', {
- // method: 'GET',
- // query: {
- // 'keyword': department.value,
- // },
- // });
- // if(mkdata.code == 200){
- // department.value = mkdata.data;
- // }else{
- // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- // console.log("错误位置:获取职能部门")
- // console.log("后端错误反馈:",mkdata.message)
- // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- // }
- // }
- // //获得所有部门
- // departmentList();
- //3.职能部门 end ---------------------------------------->
- //4.展示行政区划 start ---------------------------------------->
- let areaList = ref("")
- //4.1 省
- let province = ref("")
- let provinceid = ref("")
- let provinceList = ref("")
- //4.2 市
- let city = ref("")
- let cityid = ref("")
- let cityList = ref("")
- //4.3 县
- let region = ref("")
- let regionid = ref("")
- let regionList = ref("")
- //选择省
- // let areaArrList = async () => {
- // const mkdata = await requestDataPromise('/web/selectWebsiteArea', {
- // method: 'GET',
- // query: {},
- // });
- // if(mkdata.code == 200){
- // provinceList.value = mkdata.data;
- // }else{
- // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- // console.log("错误位置:获取行政区划")
- // console.log("后端错误反馈:",mkdata.message)
- // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- // }
- // }
- // //一开始只需要获取一下省
- // areaArrList();
- 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);
- }
- // 设置滚动条初始位置
-
- const parentElement = document.querySelector('.nav_in');
- const targetElement = document.querySelector('.nav_in .router-link-exact-active');
-
- if (targetElement && parentElement) {
- const targetRect = targetElement.getBoundingClientRect();
- const parentRect = parentElement.getBoundingClientRect();
-
- const distanceToParentLeft = targetRect.left - parentRect.left;
-
- const navigationElement = document.querySelector('.partOne .navigationOne');
- if (navigationElement) {
- navigationElement.scrollLeft = distanceToParentLeft - 0;
- }
- }
- })
- //选择市
- let change = async (id) => {
- provinceid.value = id;
- const shengData = await requestDataPromise('/web/selectWebsiteArea', {
- method: 'GET',
- query: {
- 'province': id,
- 'city': 0
- },
- });
- cityList.value = shengData.data.city;
- }
- //选择县
- let change1 = async (id) => {
- cityid.value = id;
- const xianData = await requestDataPromise('/web/selectWebsiteArea', {
- method: 'GET',
- query: {
- 'province': provinceid.value,
- 'city': cityid.value
- },
- });
- regionList.value = xianData.data.region;
- }
- //4.展示行政区划 end ---------------------------------------->
- //5.执行搜索 start ---------------------------------------->
- const getcityid = ref("")
- //跳转到搜索页面
- let goToSearch = (id) => {
- console.log(id)
- const route = `/search/search?catids=${id}`;
- window.open(route, '_blank');
- }
- //获得cityid和
- let goToPrimary = async () => {
- if (province.value != "") { getcityid.value = province.value }
- if (city.value != "") { getcityid.value = city.value }
- if (region.value != "") { getcityid.value = region.value }
- if (province.value == "" && city.value == "" && region.value == "" && depValue.value == "") {
- ElMessage.error('请选择行政区划或者职能部门!')
- } else {
- const responseStatus = await requestDataPromise('/web/selectWebsiteCategory', {
- method: 'GET',
- query: {
- 'cityid': getcityid.value,
- 'department_id': depValue.value
- },
- });
- if (responseStatus.data.catid && responseStatus.data.catid.length > 0) {
- const catids = responseStatus.data.catid.join(',');
- const route = `/search/search?catids=${catids}`;
- window.open(route, '_blank');
- } else {
- // 可以在这里处理数组为空的情况
- console.log('没有可用的分类ID');
- const route = `/search/search`;
- window.open(route, '_blank');
- }
- }
- }
- let searchDepartment = () => {
- //搜索职能部门
- let status = false;
- for (let item of department.value) {
- if (item.name == typeValue.value) {
- //如果有就赋值过去
- depValue.value = item.id
- status = true; //说明有可用的结果
- }
- }
- if (status == true) {
- //弹出提示告诉用户不存在
- }
- }
- //5.执行搜索 end ---------------------------------------->
- </script>
- <style lang="less" scoped>
- @import url('@/assets/css/nav.less');
- </style>
- <style lang="less" scoped>
- @media screen and (min-width:801px){
- .nav_in{ display:flex;
- width:100%;
- flex-wrap: wrap;
-
- }
- .pc_none{display:none;}
- }
- @media screen and (max-width:800px){/*ipad_phone*/
- .partOne{height:33px;background:#49a769;margin-top:11px;padding:6px 0px;}
- .partOne .inner{ overflow: hidden;position:relative;box-sizing:border-box;}
- .partOne .inner .navLeft{display:flex;overflow:hidden;word-break: keep-all; white-space: nowrap;height:33px;text-align:left;
- width:auto;line-height:33px;margin-right:20px;
- }
-
- .partOne .inner .navIndex{ line-height:33px;height:33px;overflow:hidden;width:auto; }
- .partOne .inner .navClass{ line-height:33px;height:33px;padding:0px;word-break: keep-all; white-space: nowrap;overflow:hidden;
- display:none;}
- .partOne .inner .navClass div{margin-left:8px; float:left;}
- .partOne .inner .navClass div:nth-child(2){padding:0px;}
- .partOne .navigationOne{ height:33px; display:block; width:auto;
- line-height:33px;
- flex:1;
- padding:0;margin:0;
- float:right;box-sizing:border-box;
- overflow-y: hidden; // 改为 overlay 模式
- overflow-x: auto; // 改为 overlay 模式
-
- // 隐藏滚动条轨道
- &::-webkit-scrollbar-track {
- background: transparent;
- width: 0;
- height: 0;
- }
-
- // 隐藏滚动条滑块
- &::-webkit-scrollbar-thumb {
- background: transparent;
- }
- /* 新增滚动条样式 */
- &::-webkit-scrollbar {
- width: 0;
- height: 0;
- }
- }
-
-
-
- .nav_in{height:33px;word-break: keep-all; white-space: nowrap; box-sizing:border-box;line-height:33px;}
- .partOne .navigationOne li{width:auto;display:inline-block;font-size:16px;line-height:33px;height:33px; overflow:hidden;}
- .partOne .navigationOne li:nth-of-type(1){margin-left:0px;}
- .partOne .navigationOne li a{display:block;line-height:33px;height:33px; overflow:hidden;}
-
- .cityBox{display: block;overflow:hidden;height:auto;display:none;}
- .cityBox .cityMain{display: block;overflow:hidden;height:auto;width:100%;}
- .cityBox .cityMain .cityTitle{line-height: 22px;padding:0;margin:10px 0px 0px 10px;width:auto;}
- .cityList{overflow:hidden;}
- .cityBox .cityMain .cityList li{line-height:22px;margin:11px;}
- .select{overflow:hidden;height:auto;line-height:normal;}
- .select .inner{width:96%;margin:0px auto;overflow:hidden;height:auto; }
- .select .role{padding:0;height:auto;overflow:hidden;float:none;}
- .select .role .searchRole{box-sizing:border-box;width:333px; float:left;margin-left:0px;}
- .select .el-select{width:230px!important;}
- .select .role .searchRole em{margin:4px 10px;float:right;}
-
- .select .role > .title, .select .region > .title{float:none;font-size:18px;}
- .select .region{overflow:hidden;height:auto;float:none;}
- .select .region .searchRole{float:none;padding:10px 0;width:90%;margin:5px;height:auto;}
- .select .region .el-select{margin-left:17px;}
- .select .region em{margin-left:22px;}
- .navigate_phone{
- }
- .nav_select_btn_box{
- overflow:hidden;padding:5px 0px;
- border-bottom:1px solid #ededed;
- width:92%;margin:0px auto;
- }
- .nav_select_btn{
- height: 33px;
- line-height: 33px;
- color: #333;font-size:16px;
- padding:0px 20px 0px 6px;
- float:left;margin:0px 8px 5px 0px;
- // border:dashed 1px #000;
- background:url(../../public/image/Iconly.png) no-repeat right center;
-
- background-size:auto 20px;
- }
- .nav_select_panel{
- width:100%;background:teal;left:0px;top:0px;
- position:fixed;z-index:999;
- height:100%;
- }
- .partOne .inner .navIndex a{font-size:16px; height:33px;line-height:33px;display:block; }
-
- .partOne .navigationOne li a span{display:block;height:33px;line-height:33px;
- opacity:0.6;
-
- }
- .nav_in .router-link-exact-active span{font-size:16px;font-weight:bold;opacity:1!important;}
- .partOne .inner .navIndex a{font-weight:normal;opacity:.6;}
- .select{display:none;}
- .navigate_phone{display:none;}
- .phone_none{display:none;}
- }
- </style>
|