pageNavigation.vue 18 KB

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