pageNavigation.vue 17 KB

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