pageNavigation.vue 20 KB

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