pageNavigation.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. <template>
  2. <!-- 导航 -->
  3. <div class="navigate">
  4. <div class="partOne">
  5. <div class="inner">
  6. <!-- 导航一 -->
  7. <div class="navLeft">
  8. <div class="navIndex">
  9. <NuxtLink to="/" target="_blank" title="首页">
  10. 首页
  11. </NuxtLink>
  12. </div>
  13. <div class="navClass">
  14. <div>
  15. <a href="#ztzx" title="主题资讯">主题资讯</a>
  16. </div>
  17. <div>
  18. <a href="#hdzx" title="互动资讯">互动资讯</a>
  19. </div>
  20. </div>
  21. </div>
  22. <ul class="navigationOne">
  23. <li v-for="(item, index) in navigation1" :key="index">
  24. <!-- <NuxtLink :to="`/primaryNavigation/${item.alias}`" target="_blank">{{ item.alias }}</NuxtLink> -->
  25. <!-- <NuxtLink :to="{ path: `/primaryNavigation/${item.category_id}`, query: { name: item.name } }" -->
  26. <NuxtLink :to="{ path: `/primaryNavigation/${item.category_id}`}"
  27. target="_blank" v-if="item.children_count != 0">
  28. <span class="active" v-if="item.category_id == routeId">{{ item.name }}</span>
  29. <span v-else>{{ item.name }}</span>
  30. </NuxtLink>
  31. <!-- <NuxtLink :to="{ path: `/newsList/${item.category_id}`, query: { name: item.name } }" -->
  32. <NuxtLink :to="{ path: `/newsList/${item.category_id}` }"
  33. target="_blank" v-if="item.children_count == 0 && item.is_url != 1">
  34. <span class="active" v-if="item.category_id == routeId">{{ item.name }}</span>
  35. <span v-else>{{ item.name }}</span>
  36. </NuxtLink>
  37. <NuxtLink :to="item.web_url"
  38. target="_blank" v-if="item.children_count == 0 && item.is_url == 1">
  39. <span class="active" v-if="item.category_id == routeId">{{ item.name }}</span>
  40. <span v-else>{{ item.name }}</span>
  41. </NuxtLink>
  42. </li>
  43. </ul>
  44. </div>
  45. </div>
  46. <!-- <div class="partThree">
  47. 地方频道
  48. <div class="inner">
  49. channel 频道
  50. <h5 class="channel">地方频道</h5>
  51. <p class="areaChannel">
  52. <span v-for="(item, index) in areaList" :key="index">
  53. <a href="#">{{ item.name }}</a>
  54. </span>
  55. </p>
  56. </div>
  57. </div> -->
  58. <!-- 导航栏下的大图 -->
  59. <!-- <div class="logo">
  60. <div class="inner">
  61. <img src="../../static/images/banner1.png" alt="">
  62. </div>
  63. </div> -->
  64. <!-- 展示地区 -->
  65. <div class="cityBox">
  66. <div class="cityMain">
  67. <div class="cityTitle">
  68. 地方频道
  69. </div>
  70. <ul class="cityList">
  71. <li v-for="(item, index) in provinceList" :key="index" @click="goToSearch(item.id)">
  72. <!-- <NuxtLink :to="{path:`/search/search?catids=${item.id}`}" target="_blank">
  73. {{item.abbreviation}}
  74. </NuxtLink> -->
  75. {{item.abbreviation}}
  76. </li>
  77. </ul>
  78. </div>
  79. </div>
  80. <!-- 行政查询 -->
  81. <div class="select">
  82. <div class="inner">
  83. <div class="role left">
  84. <div class="title">行政职能查询</div>
  85. <div class="searchRole">
  86. <el-select v-model="depValue" placeholder="职能部门" size="large" style="width: 80px">
  87. <el-option v-for="(item, index) in department" :key="index" :label="item.name"
  88. :value="item.id" />
  89. </el-select>
  90. <i></i>
  91. <input type="text" v-model="typeValue" placeholder="输入关键词" class="ipt">
  92. <em @click="searchDepartment"></em>
  93. </div>
  94. </div>
  95. <div class="region left">
  96. <div class="title">行政区划查询</div>
  97. <div class="searchRole">
  98. <el-select v-model="province" placeholder="请选择省" size="large" style="width: 80px">
  99. <el-option v-for="item in provinceList" :key="item.id" :label="item.name"
  100. @click="change(item.id)" :value="item.id" />
  101. </el-select>
  102. <i></i>
  103. <el-select v-model="city" placeholder="请选择市" no-data-text="请先选择省份" size="large"
  104. style="width: 80px">
  105. <el-option v-for="(item, index) in cityList" :key="item.id" :label="item.name"
  106. @click="change1(item.id)" :value="item.id" />
  107. </el-select>
  108. <i></i>
  109. <el-select v-model="region" placeholder="请选择区/县" no-data-text="请先选择市" size="large"
  110. style="width: 100px">
  111. <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="item.id" />
  112. </el-select>
  113. <em @click="goToPrimary"></em>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. </template>
  120. <script setup>
  121. import { ElMessage } from 'element-plus'
  122. import { ref, onMounted } from 'vue';
  123. import { ElSelect, ElOption } from 'element-plus'
  124. const nuxtApp = useNuxtApp();
  125. const axios = nuxtApp.$axios;
  126. //获得route
  127. const route = useRoute();
  128. const routeId = route.params.id; //获得该页面的id
  129. const pageName = route.query.name;//获得页面名称
  130. //获取导航一的栏目
  131. const navigation1 = ref("");
  132. const navigateList = async () => {
  133. try {
  134. const response = await axios.get(`/web/getWebsiteModelCategory?placeid=${1}&pid=${0}&num=${35}`);
  135. console.log(response.data);
  136. navigation1.value = response.data;
  137. } catch (error) {
  138. console.error(error);
  139. }
  140. }
  141. // const navigateList = async () => {
  142. // try {
  143. // const response = await axios.get(`/web/getWebsiteCategory?pageSize=${24}`);
  144. // console.log(response.data);
  145. // navigation1.value = response.data;
  146. // } catch (error) {
  147. // console.error(error);
  148. // }
  149. // }
  150. //获取导航二的栏目
  151. const navigation2 = ref("");
  152. const navigate2List = async () => {
  153. try {
  154. const response = await axios.get(`/web/getWebsiteModelCategory?placeid=${2}&pid=${1}&num=${13}`);
  155. // console.log(response.data);
  156. navigation2.value = response.data;
  157. } catch (error) {
  158. console.error(error);
  159. }
  160. }
  161. //职能部门 搜索
  162. let department = ref("安全")
  163. const depValue = ref("")
  164. const typeValue = ref("")
  165. let departmentList = async () => {
  166. try {
  167. const response = await axios.get(`/web/selectWebsiteDepartment?keyword=${department.value}`);
  168. // console.log(response.data.department);
  169. department.value = response.data.department
  170. // console.log(department.value);
  171. } catch (error) {
  172. console.error(error);
  173. }
  174. }
  175. //获取地区各省名称
  176. let areaList = ref("")
  177. //获取省名称
  178. let province = useState("province", () => "")
  179. let provinceid = useState("provinceid", () => null)
  180. let provinceList = useState("provinceList", () => "")
  181. let areaArrList = async () => {
  182. try {
  183. const response = await axios.get('/web/getWebsiteDistrit');
  184. console.log(response.data);
  185. areaList.value = response.data;
  186. provinceList.value = response.data
  187. } catch (error) {
  188. console.error(error);
  189. }
  190. }
  191. // 获取城市名称
  192. let city = useState("city", () => "")
  193. let cityid = useState("cityid", () => "")
  194. let cityList = useState("cityList", () => "")
  195. //选择省份后省份的id
  196. let change = (id) => {
  197. console.log(id);
  198. provinceid.value = id
  199. console.log(provinceid.value);
  200. //根据省id获取对应的市名称
  201. axios.get(`web/selectWebsiteArea?province=${provinceid.value}&city=0`).then(response => {
  202. // console.log("response", response.data.city);
  203. cityList.value = response.data.city;
  204. // console.log("cityList", cityList.value);
  205. }).catch(error => {
  206. console.error(error);
  207. })
  208. }
  209. // 获取区/县名称
  210. let region = useState("region", () => "")
  211. let regionid = useState("regionid", () => "")
  212. let regionList = useState("regionList", () => "")
  213. //选择市后市的id
  214. let change1 = (id) => {
  215. console.log(id);
  216. cityid.value = id
  217. console.log(cityid.value);
  218. //根据市id获取对应的区/县名称
  219. axios.get(`web/selectWebsiteArea?province=${provinceid.value}&city=${cityid.value}`).then(response => {
  220. // console.log("response", response.data);
  221. regionList.value = response.data.region;
  222. // console.log("regionList", regionList.value);
  223. }).catch(error => {
  224. console.error(error);
  225. })
  226. }
  227. //depValue.value 行政区划
  228. //二级导航id
  229. //province.value 省id
  230. //city.value 市id
  231. //region.value 县id
  232. const getcityid = ref("")
  233. let goToSearch = (id) => {
  234. console.log(id)
  235. const route = `/search/search?catids=${id}`;
  236. window.open(route, '_blank');
  237. }
  238. //获得cityid和
  239. let goToPrimary = () => {
  240. // console.log(depValue.value)
  241. // console.log(routeId)
  242. if (province.value != "") { getcityid.value = province.value }
  243. if (city.value != "") { getcityid.value = city.value }
  244. if (region.value != "") { getcityid.value = region.value }
  245. console.log(getcityid.value)
  246. //console.log(pageName)
  247. //跳转过去
  248. // navigateTo({
  249. // path: `/primaryNavigation/${routeId}`,
  250. // query: {
  251. // cityid: getcityid.value,
  252. // name: pageName,
  253. // department_id: depValue.value
  254. // }
  255. // })
  256. if (province.value == ""&&city.value == ""&&region.value == ""&&depValue.value=="") {
  257. ElMessage.error('请选择行政区划或者职能部门!')
  258. }else{
  259. //根据市id获取对应的区/县名称
  260. axios.get(`/web/selectWebsiteCategory?cityid=${getcityid.value}&department_id=${depValue.value}`).then(response => {
  261. if (response.data.catid && response.data.catid.length > 0) {
  262. const catids = response.data.catid.join(',');
  263. const route = `/search/search?catids=${catids}`;
  264. window.open(route, '_blank');
  265. } else {
  266. // 可以在这里处理数组为空的情况
  267. console.log('没有可用的分类ID');
  268. const route = `/search/search`;
  269. window.open(route, '_blank');
  270. }
  271. })
  272. }
  273. }
  274. let searchDepartment = () => {
  275. //搜索职能部门
  276. //console.log(typeValue.value)
  277. //console.log(department.value)
  278. let status = false;
  279. for (let item of department.value) {
  280. if (item.name == typeValue.value) {
  281. console.log(item.name)
  282. //如果有就赋值过去
  283. depValue.value = item.id
  284. status = true; //说明有可用的结果
  285. }
  286. }
  287. if (status == true) {
  288. //弹出提示告诉用户不存在
  289. }
  290. }
  291. //挂载成功钩子函数
  292. onMounted(() => {
  293. //导航一栏目
  294. navigateList()
  295. //导航二栏目
  296. navigate2List()
  297. //获取地区各省名称
  298. areaArrList()
  299. //获取职能部门
  300. departmentList()
  301. })
  302. </script>
  303. <style lang="less" scoped>
  304. // 导航部分
  305. .partOne .navigationOne,
  306. .partOne .navigationOne>li,
  307. .partTwo .navigationTwo,
  308. .partTwo .navigationTwo>li {
  309. float: left;
  310. }
  311. .partOne {
  312. width: 100%;
  313. height: 110px;
  314. margin-bottom: 10px;
  315. background-color: #fff;
  316. font-size: 20px;
  317. font-family: PingFang SC-Semibold;
  318. background: url("../../static/head/menubg.png") no-repeat center;
  319. .inner {
  320. display: flex;
  321. justify-content: space-between;
  322. .navLeft {
  323. width:160px;
  324. font-size: 16px;
  325. display: flex;
  326. }
  327. .navIndex {
  328. height: 100px;
  329. line-height: 120px;
  330. a {
  331. font-size: 16px;
  332. color: #fff;
  333. font-weight: bold;
  334. &:hover {
  335. color: #ABE874;
  336. }
  337. }
  338. }
  339. .navClass {
  340. padding-top: 29px;
  341. padding-left: 30px;
  342. font-weight: bold;
  343. color: #fff;
  344. a {
  345. color: #fff;
  346. &:hover {
  347. color: #ABE874;
  348. }
  349. }
  350. div:nth-child(2){
  351. padding-top:20px;
  352. }
  353. }
  354. }
  355. .navigationOne {
  356. width: 1200px;
  357. color: #333;
  358. display: flex;
  359. flex-wrap: wrap;
  360. padding-top: 20px;
  361. //justify-content: space-around;
  362. li {
  363. width: 68px;
  364. font-family: PingFang SC;
  365. height: 40px;
  366. line-height: 40px;
  367. //font-weight: 600;
  368. font-size: 16px;
  369. text-align: left;
  370. font-style: normal;
  371. text-transform: none;
  372. margin: 0 10px;
  373. text-align: center;
  374. // &:nth-last-child(1) {
  375. // margin-right: 0px;
  376. // }
  377. a {
  378. color: #fff;
  379. display: block;
  380. }
  381. }
  382. >li:hover a {
  383. color: #ABE874;
  384. }
  385. .active{
  386. color: #ABE874;
  387. // display: inline-block;
  388. // height: 50px;
  389. // border-bottom: 2px solid #139602
  390. }
  391. }
  392. }
  393. // .partTwo {
  394. // width: 100%;
  395. // height: 57px;
  396. // line-height: 57px;
  397. // border-bottom: 1px solid #e3e3e3;
  398. // .navigationTwo {
  399. // width: 1207px;
  400. // height: 57px;
  401. // color: #333333;
  402. // border-bottom: 1px solid #e3e3e3;
  403. // li {
  404. // font-weight: 600;
  405. // font-size: 20px;
  406. // height: 56px;
  407. // margin-right: 21px;
  408. // &:nth-last-child(1) {
  409. // margin-right: 0px;
  410. // }
  411. // }
  412. // li:hover {
  413. // color: #139602;
  414. // border-bottom: 2px solid #139602;
  415. // }
  416. // }
  417. // }
  418. .partThree {
  419. width: 100%;
  420. height: 105px;
  421. .inner {
  422. margin-bottom: 5px;
  423. display: flex;
  424. }
  425. .channel,
  426. .areaChannel {
  427. float: left;
  428. margin-top: 17px;
  429. }
  430. .channel {
  431. width: 56px;
  432. height: 20px;
  433. font-family: PingFang SC, PingFang SC;
  434. font-weight: 600;
  435. font-size: 14px;
  436. color: #666666;
  437. line-height: 20px;
  438. text-align: left;
  439. font-style: normal;
  440. text-transform: none;
  441. }
  442. .areaChannel {
  443. width: 1122px;
  444. margin-left: 14px;
  445. >span {
  446. display: inline-block;
  447. height: 16px;
  448. line-height: 16px;
  449. margin-bottom: 10px;
  450. padding: 0 8px;
  451. text-align: center;
  452. font-family: PingFang SC, PingFang SC;
  453. font-weight: 400;
  454. font-size: 14px;
  455. text-align: center;
  456. font-style: normal;
  457. text-transform: none;
  458. border-right: 1px solid #e6e6e6;
  459. a {
  460. display: inline-block;
  461. height: 16px;
  462. color: #868686;
  463. }
  464. a:hover {
  465. color: #868686;
  466. }
  467. }
  468. >span:last-child,
  469. >span:nth-child(18),
  470. >span:nth-child(32) {
  471. border-right: none;
  472. }
  473. >span:hover a {
  474. color: #139602;
  475. }
  476. }
  477. }
  478. .logo {
  479. margin-top: 5px;
  480. height: 90px;
  481. img {
  482. width: 1200px;
  483. height: 90px;
  484. }
  485. }
  486. // 行政查询
  487. .select {
  488. width: 100%;
  489. height: 62px;
  490. line-height: 62px;
  491. margin-top: 10px;
  492. .inner {
  493. width: 1200px;
  494. height: 62px;
  495. margin-top: 10px;
  496. background-color: #fafafa;
  497. }
  498. .role,
  499. .region {
  500. float: left;
  501. height: 62px;
  502. .el-select--large::v-deep .el-select__wrapper {
  503. font-size: 14px;
  504. gap: 6px;
  505. line-height: 24px;
  506. min-height: 35px;
  507. padding: 0;
  508. border: none;
  509. box-shadow: none;
  510. }
  511. .el-select__placeholder::v-deep.is-transparent {
  512. color: #999999;
  513. font-weight: 600;
  514. }
  515. >.title {
  516. float: left;
  517. width: 120px;
  518. font-family: PingFang SC, PingFang SC;
  519. font-weight: 600;
  520. font-size: 20px;
  521. color: #666666;
  522. text-align: left;
  523. font-style: normal;
  524. text-transform: none;
  525. }
  526. .searchRole {
  527. float: left;
  528. padding-left: 20px;
  529. box-sizing: border-box;
  530. i {
  531. display: inline-block;
  532. width: 1px;
  533. height: 12px;
  534. background-color: #d9d9d9;
  535. margin: 0 10px;
  536. vertical-align: middle;
  537. }
  538. }
  539. }
  540. .role {
  541. padding-left: 16px;
  542. .searchRole {
  543. width: 440px;
  544. height: 40px;
  545. line-height: 35px;
  546. background-color: #fff;
  547. border: 1px solid #ededed;
  548. margin: 10px 20px 12px 22px;
  549. border-radius: 25px;
  550. em {
  551. display: inline-block;
  552. width: 29px;
  553. height: 29px;
  554. margin: 4px;
  555. margin-right: 25px;
  556. vertical-align: -13px;
  557. background: url('../../static/images/Iconly/Broken/Search.png');
  558. cursor: pointer;
  559. }
  560. >.ipt {
  561. width: 245px;
  562. font-family: PingFang SC, PingFang SC;
  563. font-weight: 600;
  564. font-size: 14px;
  565. color: #666;
  566. line-height: 16px;
  567. padding-left: 22px;
  568. box-sizing: border-box;
  569. text-align: left;
  570. font-style: normal;
  571. text-transform: none;
  572. border: none;
  573. outline: none;
  574. }
  575. >.ipt::placeholder {
  576. color: #cccccc;
  577. }
  578. span {
  579. color: #999999;
  580. }
  581. }
  582. }
  583. .region {
  584. .searchRole {
  585. width: 440px;
  586. height: 40px;
  587. line-height: 35px;
  588. background-color: #fff;
  589. border: 1px solid #ededed;
  590. margin: 10px 0px 12px 16px;
  591. border-radius: 25px;
  592. }
  593. em {
  594. display: inline-block;
  595. width: 29px;
  596. height: 29px;
  597. margin-left: 48px;
  598. vertical-align: middle;
  599. background: url('../../static/images/Iconly/Broken/Search.png');
  600. cursor: pointer;
  601. }
  602. i {
  603. display: inline-block;
  604. width: 24px;
  605. height: 24px;
  606. margin-right: 11px;
  607. vertical-align: middle;
  608. background: url("../../static/images/Iconly/Two-tone/Arrow - Down 3.png");
  609. }
  610. span {
  611. color: #999999;
  612. margin-right: 22px;
  613. }
  614. }
  615. }
  616. .cityBox {
  617. height: 60px;
  618. background: #9CD26B;
  619. display: flex;
  620. margin: 0 auto;
  621. .cityMain {
  622. width: 1200px;
  623. height: 60px;
  624. line-height: 60px;
  625. margin: 0 auto;
  626. display: flex;
  627. justify-content: flex-start;
  628. .cityTitle {
  629. font-size: 16px;
  630. color: #fff;
  631. font-weight: bold;
  632. padding-left: 60px;
  633. margin-right: 30px;
  634. width: 76px;
  635. }
  636. .cityList {
  637. li {
  638. font-size: 16px;
  639. float: left;
  640. color: #fff;
  641. margin-right: 14px;
  642. cursor: pointer;
  643. &:hover {
  644. color: #ABE874;
  645. }
  646. // a {
  647. // color: #fff;
  648. // margin-right: 14px;
  649. // &:hover {
  650. // color: #ABE874;
  651. // }
  652. // }
  653. }
  654. }
  655. }
  656. }
  657. </style>