pageNavigation1.vue 16 KB

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