pageNavigation.vue 17 KB

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