pageNavigation_test.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. <template>
  2. <div class="navigate">
  3. <div class="partOne">
  4. <div class="inner">
  5. <div class="navLeft">
  6. <div class="navIndex">
  7. <NuxtLink :to="'/'">首页</NuxtLink>
  8. </div>
  9. <div class="navClass">
  10. <div>主题资讯</div>
  11. <div>互动资讯</div>
  12. </div>
  13. </div>
  14. <ul class="navigationOne">
  15. <div class="nav_in clearfix">
  16. <li v-for="(item, index) in navigation1" :key="index">
  17. <NuxtLink :href="getLinkPath(item)" :title="item.alias" v-if="index <= 23"
  18. :target="item.is_url == 1 ? '_blank' : '_self'">
  19. <span class="active" v-if="item.category_id == routeId">{{ item.alias }}</span>
  20. <span v-else>{{ item.alias }}</span>
  21. </NuxtLink>
  22. </li>
  23. </div>
  24. </ul>
  25. </div>
  26. </div>
  27. <!-- 展示地区 -->
  28. <div class="cityBox">
  29. <div class="cityMain">
  30. <div class="cityTitle">地方频道</div>
  31. <ul class="cityList" v-if="provinceList.length > 0">
  32. <li v-for="item in provinceList">
  33. <NuxtLink :to="{ path: `/search/${item.id}` }">
  34. {{ item.abbreviation }}
  35. </NuxtLink>
  36. </li>
  37. </ul>
  38. </div>
  39. </div>
  40. <!-- 行政查询 -->
  41. <div class="select" >
  42. <div class="inner">
  43. <div class="role left">
  44. <div class="title">行政职能查询 {{ depValue }}</div>
  45. <div class="searchRole">
  46. <el-select v-model="depValue" placeholder="职能部门" filterable size="large" style="width: 330px">
  47. <el-option v-for="(item, index) in department" :key="index" :label="item.name"
  48. :value="item.id" />
  49. </el-select>
  50. <em @click="goToPrimary"></em>
  51. </div>
  52. </div>
  53. <div class="region left">
  54. <div class="title">行政区划查询</div>
  55. <div class="searchRole" v-if="provinceList.length > 0">
  56. <el-select v-model="province" placeholder="请选择省" size="large" style="width: 80px">
  57. <el-option v-for="item in provinceList" :key="item.id" :label="item.name"
  58. @click="change(item.id)" :value="item.id" />
  59. </el-select>
  60. <i></i>
  61. <el-select v-model="city" placeholder="请选择市" no-data-text="请先选择省份" size="large"
  62. style="width: 80px">
  63. <el-option v-for="(item, index) in cityList" :key="item.id" :label="item.name"
  64. @click="change1(item.id)" :value="item.id" />
  65. </el-select>
  66. <i></i>
  67. <el-select v-model="region" placeholder="请选择区/县" no-data-text="请先选择市" size="large"
  68. style="width: 100px">
  69. <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="item.id" />
  70. </el-select>
  71. <em @click="goToPrimary"></em>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <section class="navigate_phone pc_none">
  78. <div class="nav_select_btn_box">
  79. <div class="nav_select_btn nav_department_btn_box" >
  80. 行政职能查询
  81. <div class="nav_department_drop_box">
  82. <a class="nav_department_drop_a" title="" v-for="(per_obj,per_index) in department" :key="per_obj" @click="nav_department_drop_a_fun(per_obj.id)">
  83. {{per_obj.name}}
  84. </a>
  85. </div>
  86. </div>
  87. <div class="nav_select_btn" @click="showZonePanel = true">行政区划查询</div>
  88. </div>
  89. <!-- 行政职能查询 -->
  90. <!-- <div class="nav_department_panel" v-show="true"> -->
  91. <div class="nav_department_panel" v-show="showZonePanel">
  92. <!-- {{ department }} -->
  93. <div class="panel_head_box">
  94. <span class="panel_head_btn nav_department_btn" @click="close_panel_fun"></span>
  95. <h4 class="panel_head_h4">行政区划查询</h4>
  96. </div>
  97. <div class="nav_department_panel_in">
  98. <div class="nav_department_panel_ul">
  99. <a class="nav_department_panel_ul_a" title="" v-for="(per_obj,per_index) in provinceList"
  100. :key="per_obj" @click="change(per_obj.id)"
  101. :class="{'nav_department_panel_ul_a_only':provinceid == per_obj.id}" >
  102. {{ per_obj.name}}
  103. </a>
  104. </div>
  105. <div class="nav_department_panel_ul nav_department_panel_ul_2">
  106. <a class="nav_department_panel_ul_a" title="" v-for="(per_obj,per_index) in cityList" :key="per_obj"
  107. @click="change1(per_obj.id)"
  108. :class="{'nav_department_panel_ul_a_only':cityid == per_obj.id}" >
  109. {{ per_obj.name}}
  110. <!-- {{per_index+1}} b行政区划查询 -->
  111. </a>
  112. </div>
  113. <div class="nav_department_panel_ul nav_department_panel_ul_3">
  114. <a class="nav_department_panel_ul_a" title=""
  115. v-for="(per_obj,per_index) in regionList" :key="per_obj"
  116. @click="change2(per_obj.id)"
  117. :class="{'nav_department_panel_ul_a_only':regionid == per_obj.id}"
  118. >
  119. {{ per_obj.name}}
  120. </a>
  121. </div>
  122. <div class="nav_department_panel_foot clearfix">
  123. <div class="nav_department_panel_foot_btn nav_department_panel_foot_btn_clear" @click="foot_btn_clear_fun">清空</div>
  124. <div class="nav_department_panel_foot_btn nav_department_panel_foot_btn_sure" @click="goToPrimary">确定</div>
  125. </div>
  126. </div>
  127. </div>
  128. </section>
  129. </template>
  130. <script setup>
  131. //1.加载依赖 start ---------------------------------------->
  132. import { ElMessage } from 'element-plus'
  133. import { ref, onMounted } from 'vue';
  134. import { ElSelect, ElOption } from 'element-plus'
  135. const showZonePanel = ref(false)
  136. const nuxtApp = useNuxtApp();
  137. const axios = nuxtApp.$axios;
  138. const route = useRoute();
  139. const routeId = route.params.id; //获得该页面的id
  140. //1.加载依赖 end ---------------------------------------->
  141. //2.加载模块数据 start ---------------------------------------->
  142. // const navigation1 = ref("");
  143. const navigation1 = useState('globalNavData', () => ([]))
  144. async function getPageData2() {
  145. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  146. method: 'GET',
  147. query: {
  148. 'placeid': 1,
  149. 'pid': 0,
  150. 'num': 35
  151. },
  152. });
  153. navigation1.value = mkdata.data;
  154. }
  155. getPageData2();
  156. //格式化跳转路径
  157. // const getLinkPath = (item) => {
  158. // if(item.is_url==1){
  159. // return `${item.web_url}`;
  160. // }else if(item.children_count == 0){
  161. // //return `/${item.aLIas_pinyin}/`;
  162. // return `/newsList/${item.category_id}?page=1`;
  163. // }else{
  164. // //return `/${item.aLIas_pinyin}/`;
  165. // return `/primaryNavigation/${item.category_id}`;
  166. // }
  167. // }
  168. const getLinkPath = (item) => {
  169. console.log('item', item);
  170. if (item.is_url == 1) {
  171. return `${item.web_url}`;
  172. } else if (item.children_count == 0) {
  173. //return `/newsList/${item.category_id}?page=1`;
  174. return `/${item.aLIas_pinyin}/list-1.html`;
  175. } else {
  176. //return `/primaryNavigation/${item.aLIas_pinyin}/`;
  177. return `/${item.aLIas_pinyin}/index.html`;
  178. }
  179. }
  180. //2.加载模块数据 end ---------------------------------------->
  181. //3.职能部门 start ---------------------------------------->
  182. let department = ref("")
  183. const depValue = ref("")
  184. const typeValue = ref("")
  185. // let departmentList = async () => {
  186. // const mkdata = await requestDataPromise('/web/selectWebsiteDepartment', {
  187. // method: 'GET',
  188. // query: {
  189. // 'keyword': department.value,
  190. // },
  191. // });
  192. // if(mkdata.code == 200){
  193. // department.value = mkdata.data;
  194. // }else{
  195. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  196. // console.log("错误位置:获取职能部门")
  197. // console.log("后端错误反馈:",mkdata.message)
  198. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  199. // }
  200. // }
  201. // //获得所有部门
  202. // departmentList();
  203. //3.职能部门 end ---------------------------------------->
  204. //4.展示行政区划 start ---------------------------------------->
  205. //let areaList = ref("")
  206. //4.1 省
  207. let province = ref("")
  208. let provinceid = ref("")
  209. // let provinceList = ref("")
  210. const provinceList = useState('globalProvinceData', () => [])
  211. //4.2 市
  212. let city = ref("")
  213. let cityid = ref("")
  214. let cityList = ref("")
  215. //4.3 县
  216. let region = ref("")
  217. let regionid = ref("")
  218. let regionList = ref("")
  219. //选择省
  220. // let areaArrList = async () => {
  221. // const mkdata = await requestDataPromise('/web/selectWebsiteArea', {
  222. // method: 'GET',
  223. // query: {},
  224. // });
  225. // if(mkdata.code == 200){
  226. // provinceList.value = mkdata.data;
  227. // }else{
  228. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  229. // console.log("错误位置:获取行政区划")
  230. // console.log("后端错误反馈:",mkdata.message)
  231. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  232. // }
  233. // }
  234. // //一开始只需要获取一下省
  235. // areaArrList();
  236. //选择市
  237. let change = async (id) => {
  238. provinceid.value = id;
  239. const shengData = await requestDataPromise('/web/selectWebsiteArea', {
  240. method: 'GET',
  241. query: {
  242. 'pid': id,
  243. },
  244. });
  245. cityList.value = shengData.data;
  246. regionList.value = [];// 清空县
  247. }
  248. //选择县
  249. let change1 = async (id) => {
  250. cityid.value = id;
  251. const xianData = await requestDataPromise('/web/selectWebsiteArea', {
  252. method: 'GET',
  253. query: {
  254. 'pid': id,
  255. },
  256. });
  257. regionList.value = xianData.data;
  258. }
  259. let change2 = async (id) => {
  260. regionid.value = id;
  261. }
  262. //4.展示行政区划 end ---------------------------------------->
  263. //5.执行搜索 start ---------------------------------------->
  264. const getcityid = ref("")
  265. //跳转到搜索页面
  266. // let goToSearch = (id) => {
  267. // console.log(id)
  268. // const route = `/search/search?catids=${id}`;
  269. // window.location.href = route;
  270. // }
  271. //获得cityid和
  272. let goToPrimary = async () => {
  273. // ElMessage.error(province.value)
  274. if (province.value != "") { getcityid.value = province.value }
  275. if (city.value != "") { getcityid.value = city.value }
  276. if (region.value != "") { getcityid.value = region.value }
  277. if (province.value == "" && city.value == "" && region.value == "" && depValue.value == "") {
  278. ElMessage.error('请选择行政区划或者职能部门!')
  279. } else {
  280. const route = `/search/search?catids=${getcityid.value}&department_id=${depValue.value}`;
  281. window.location.href = route;
  282. // const responseStatus = await requestDataPromise('/web/selectWebsiteCategory', {
  283. // method: 'GET',
  284. // query: {
  285. // 'cityid': getcityid.value,
  286. // 'department_id': depValue.value
  287. // },
  288. // });
  289. // if (responseStatus.data.catid && responseStatus.data.catid.length > 0) {
  290. // const catids = responseStatus.data.catid.join(',');
  291. // const route = `/search/search?catids=${catids}`;
  292. // window.location.href = route;
  293. // } else {
  294. // // 可以在这里处理数组为空的情况
  295. // console.log('没有可用的分类ID');
  296. // const route = `/search/search`;
  297. // window.location.href = route;
  298. // }
  299. }
  300. // 行政职能查询
  301. }
  302. const close_panel_fun = () => {
  303. foot_btn_clear_fun();
  304. showZonePanel.value = false;
  305. }
  306. const foot_btn_clear_fun = () => {
  307. regionList.value = [];// 清空县
  308. region.value = "";// 清空县 名称
  309. city.value = "";// 清空市 名称
  310. cityList.value = [];// 清空市
  311. province.value = "";// 清空省 名称
  312. provinceid.value = "";// 清空省 id
  313. }
  314. let shake_bool = true // 声明在组件作用域顶部==防抖
  315. const nav_department_drop_a_fun = (departmentId) => {
  316. if(shake_bool===true){//第1次点击
  317. shake_bool = false;
  318. depValue.value = departmentId;
  319. goToPrimary();
  320. // 行政职能查询
  321. ElMessage({
  322. message: '页面跳转中请稍等',
  323. type: 'success'
  324. });
  325. nav_department_drop_a_fun.timer = setTimeout(() => {
  326. shake_bool = true;
  327. }, 3333);
  328. }else{
  329. ElMessage({
  330. message: '请勿重复点击',
  331. type: 'warning'
  332. });
  333. }
  334. }
  335. //5.执行搜索 end ---------------------------------------->
  336. onMounted(async () => {
  337. //从客户端获取行政职能部门 加快打开速度
  338. try {
  339. const { $webUrl, $CwebUrl } = useNuxtApp();
  340. const response = await fetch($webUrl + '/web/selectWebsiteDepartment', {
  341. headers: {
  342. 'Content-Type': 'application/json',
  343. 'Userurl': $CwebUrl,
  344. 'Origin': $CwebUrl
  345. }
  346. });
  347. const result = await response.json();
  348. department.value = result.data;
  349. } catch (error) {
  350. console.error('获取部门数据失败:', error);
  351. }
  352. //从客户端获取行政区划
  353. try {
  354. const { $webUrl, $CwebUrl } = useNuxtApp();
  355. const response2 = await fetch($webUrl + '/web/selectWebsiteArea', {
  356. headers: {
  357. 'Content-Type': 'application/json',
  358. 'Userurl': $CwebUrl,
  359. 'Origin': $CwebUrl
  360. }
  361. });
  362. const result2 = await response2.json();
  363. provinceList.value = result2.data;
  364. } catch (error) {
  365. console.error('获取行政区划数据失败:', error);
  366. }
  367. })
  368. </script>
  369. <style lang="less" scoped>
  370. @import url('@/assets/css/nav.less');
  371. </style>
  372. <style lang="less" scoped>
  373. @media screen and (min-width:801px){
  374. .nav_in{ display:flex;
  375. width:100%;
  376. flex-wrap: wrap;
  377. }
  378. .pc_none{display:none;}
  379. }
  380. @media screen and (max-width:800px){/*ipad_phone*/
  381. .partOne{height:auto;background:#49a769;}
  382. .partOne .inner{ overflow: hidden;position:relative;}
  383. .partOne .inner .navLeft{display:flex;overflow:hidden;word-break: keep-all; white-space: nowrap;height:33px;text-align:left;
  384. width:auto;float:left;
  385. }
  386. .partOne .inner .navIndex{ line-height:31px;height:33px;overflow:hidden;width:auto; }
  387. .partOne .inner .navClass{ line-height:33px;height:33px;padding:0px;word-break: keep-all; white-space: nowrap;overflow:hidden;
  388. display:none;}
  389. .partOne .inner .navClass div{margin-left:8px; float:left;}
  390. .partOne .inner .navClass div:nth-child(2){padding:0px;}
  391. .partOne .navigationOne{ height:33px; display:block; width:auto;
  392. flex:1;
  393. padding:0;margin:0;
  394. float:right;box-sizing:border-box;
  395. overflow-x: auto; // 改为 overlay 模式
  396. // 隐藏滚动条轨道
  397. &::-webkit-scrollbar-track {
  398. background: transparent;
  399. width: 0;
  400. height: 0;
  401. }
  402. // 隐藏滚动条滑块
  403. &::-webkit-scrollbar-thumb {
  404. background: transparent;
  405. }
  406. /* 新增滚动条样式 */
  407. &::-webkit-scrollbar {
  408. width: 0;
  409. height: 0;
  410. }
  411. }
  412. .nav_in{height:85%;word-break: keep-all; white-space: nowrap; box-sizing:border-box;}
  413. .partOne .navigationOne li{width:auto;display:inline-block;height:88%;line-height:33px; overflow:hidden;}
  414. .cityBox{display: block;overflow:hidden;height:auto;display:none;}
  415. .cityBox .cityMain{display: block;overflow:hidden;height:auto;width:100%;}
  416. .cityBox .cityMain .cityTitle{line-height: 22px;padding:0;margin:10px 0px 0px 10px;width:auto;}
  417. .cityList{overflow:hidden;}
  418. .cityBox .cityMain .cityList li{line-height:22px;margin:11px;}
  419. .select{overflow:hidden;height:auto;line-height:normal;}
  420. .select .inner{width:96%;margin:0px auto;overflow:hidden;height:auto; }
  421. .select .role{padding:0;height:auto;overflow:hidden;float:none;}
  422. .select .role .searchRole{box-sizing:border-box;width:333px; float:left;margin-left:0px;}
  423. .select .el-select{width:230px!important;}
  424. .select .role .searchRole em{margin:4px 10px;float:right;}
  425. .select .role > .title, .select .region > .title{float:none;font-size:18px;}
  426. .select .region{overflow:hidden;height:auto;float:none;}
  427. .select .region .searchRole{float:none;padding:10px 0;width:90%;margin:5px;height:auto;}
  428. .select .region .el-select{margin-left:17px;}
  429. .select .region em{margin-left:22px;}
  430. .navigate_phone{
  431. }
  432. .nav_select_btn_box{
  433. padding:5px 0px;
  434. border-bottom:1px solid #ededed;
  435. width:92%;margin:0px auto;
  436. }
  437. .nav_select_btn_box::after{content: '';display: block;height: 0;visibility: hidden;clear: both;}
  438. .nav_select_btn{
  439. height: 33px;
  440. line-height: 33px;
  441. color: #333;font-size:14px;
  442. padding:0px 30px 0px 6px;
  443. float:left;margin:0px 20px 5px 0px;
  444. background:url(../../public/image/Iconly.png) no-repeat right center;
  445. background-size:auto 20px;
  446. }
  447. .nav_department_btn_box{
  448. position:relative;
  449. .nav_department_select{
  450. width:100%;height:100%;position:absolute;
  451. left:0px;top:0px;border:0;
  452. }
  453. }
  454. .nav_department_drop_box{
  455. position:absolute;left:0px;top:33px;z-index:111;
  456. width:100%;height:333px;border:1px solid #ededed;
  457. background:#fff;overflow:auto;border-radius:6px;
  458. box-sizing:border-box;display:none;
  459. }
  460. .nav_department_btn_box:hover .nav_department_drop_box{
  461. display:block;
  462. }
  463. .nav_department_drop_a{
  464. width:100%;height:44px;line-height:44px;
  465. display:block;
  466. font-size:14px;color:#333;
  467. padding:0px 10px 0px;
  468. box-sizing:border-box;
  469. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  470. }
  471. .partOne .inner .navIndex a{font-size:16px;}
  472. .partOne .navigationOne li{font-size:14px;}
  473. // .select{display:none;}
  474. // .navigate_phone{display:none;}
  475. .nav_department_panel{
  476. width:100%;background:#fff;left:0px;top:0px;
  477. position:fixed;z-index:999;
  478. height:100%;
  479. }
  480. .panel_head_box{
  481. width:97%;margin:0px auto 4px;
  482. height:50px;border-bottom:1px solid #b8b8b8;
  483. text-align:center;position:relative;
  484. }
  485. .panel_head_h4{height:50px;line-height:50px;display:inline-block;
  486. font-size:22px;color:#333;text-align:center;}
  487. .panel_head_btn{float:right;width:22px;height:22px; top:12px;
  488. position:absolute;right:0px;
  489. background:url('../../public/image/guanbi1.png') no-repeat center center;
  490. background-size:100% 100%;
  491. }
  492. .nav_department_panel_in{
  493. width:100%;height:100%; box-sizing:border-box;
  494. overflow:auto;position:relative;
  495. padding-bottom:122px;
  496. }
  497. .nav_department_panel_ul{
  498. width:30%; float:left;
  499. height:100%;box-sizing:border-box;
  500. overflow:auto;
  501. }
  502. .nav_department_panel_ul_2{
  503. width:35%; background:#F2F3F7;
  504. }
  505. .nav_department_panel_ul_3{
  506. width:35%; background:#F2F3F7;
  507. }
  508. .nav_department_panel_ul_a{
  509. width:100%;height:40px;line-height:40px;
  510. display:block;
  511. font-size:16px;color:#333;
  512. padding:0px 10px 0px;
  513. box-sizing:border-box;
  514. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  515. }
  516. .nav_department_panel_ul_a_only{
  517. font-weight:bold; color:#46D333;
  518. }
  519. .nav_department_panel_foot{
  520. width:100%;margin:0px auto;
  521. height:36px;
  522. position:absolute;left:0px;bottom:70px;
  523. background:#fff;text-align:center;
  524. .nav_department_panel_foot_btn{
  525. width:33%;height:36px;line-height:36px; display:inline-block;
  526. text-align:center;
  527. border-radius:16px;font-size:16px;
  528. padding:0px 10px;margin:0px 11px;
  529. }
  530. .nav_department_panel_foot_btn_clear{
  531. background:#abe874;color:#fff;
  532. }
  533. .nav_department_panel_foot_btn_sure{
  534. background:#46D333;color:#fff;
  535. }
  536. }
  537. // .select{display:none;}
  538. .phone_none{display:none;}
  539. }
  540. </style>