pageNavigation.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="navigate">
  3. <div class="partOne">
  4. <div class="inner">
  5. <div class="navLeft">
  6. <div class="navIndex">
  7. <NuxtLink :to="'/'">首页</NuxtLink>
  8. </div>
  9. <div class="navClass">
  10. <div>主题资讯</div>
  11. <div>互动资讯</div>
  12. </div>
  13. </div>
  14. <ul class="navigationOne">
  15. <li v-for="(item, index) in navigation1" :key="index">
  16. <NuxtLink :href="getLinkPath(item)" :title="item.alias" v-if="index <= 23"
  17. :target="item.is_url == 1 ? '_blank' : '_self'">
  18. <span class="active" v-if="item.category_id == routeId">{{ item.alias }}</span>
  19. <span v-else>{{ item.alias }}</span>
  20. </NuxtLink>
  21. </li>
  22. </ul>
  23. </div>
  24. </div>
  25. <!-- 展示地区 -->
  26. <div class="cityBox">
  27. <div class="cityMain">
  28. <div class="cityTitle">地方频道</div>
  29. <ul class="cityList" v-if="provinceList.length > 0">
  30. <li v-for="item in provinceList">
  31. <NuxtLink :to="{ path: `/search/${item.id}` }">{{ item.abbreviation }}</NuxtLink>
  32. </li>
  33. </ul>
  34. </div>
  35. </div>
  36. <!-- 行政查询 -->
  37. <div class="select">
  38. <div class="inner">
  39. <div class="role left">
  40. <div class="title">行政职能查询</div>
  41. <div class="searchRole">
  42. <el-select v-model="depValue" placeholder="职能部门" filterable size="large" style="width: 330px">
  43. <el-option v-for="(item, index) in department" :key="index" :label="item.name"
  44. :value="item.id" />
  45. </el-select>
  46. <em @click="goToPrimary"></em>
  47. </div>
  48. </div>
  49. <div class="region left">
  50. <div class="title">行政区划查询</div>
  51. <div class="searchRole" v-if="provinceList.length > 0">
  52. <el-select v-model="province" placeholder="请选择省" size="large" style="width: 80px">
  53. <el-option v-for="item in provinceList" :key="item.id" :label="item.name"
  54. @click="change(item.id)" :value="item.id" />
  55. </el-select>
  56. <i></i>
  57. <el-select v-model="city" placeholder="请选择市" no-data-text="请先选择省份" size="large"
  58. style="width: 80px">
  59. <el-option v-for="(item, index) in cityList" :key="item.id" :label="item.name"
  60. @click="change1(item.id)" :value="item.id" />
  61. </el-select>
  62. <i></i>
  63. <el-select v-model="region" placeholder="请选择区/县" no-data-text="请先选择市" size="large"
  64. style="width: 100px">
  65. <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="item.id" />
  66. </el-select>
  67. <em @click="goToPrimary"></em>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </template>
  74. <script setup>
  75. //1.加载依赖 start ---------------------------------------->
  76. import { ElMessage } from 'element-plus'
  77. import { ref, onMounted } from 'vue';
  78. import { ElSelect, ElOption } from 'element-plus'
  79. const nuxtApp = useNuxtApp();
  80. const axios = nuxtApp.$axios;
  81. const route = useRoute();
  82. const routeId = route.params.id; //获得该页面的id
  83. //1.加载依赖 end ---------------------------------------->
  84. //2.加载模块数据 start ---------------------------------------->
  85. const navigation1 = ref("");
  86. async function getPageData2() {
  87. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  88. method: 'GET',
  89. query: {
  90. 'placeid': 1,
  91. 'pid': 0,
  92. 'num': 35
  93. },
  94. });
  95. navigation1.value = mkdata.data;
  96. }
  97. getPageData2();
  98. //格式化跳转路径
  99. // const getLinkPath = (item) => {
  100. // if(item.is_url==1){
  101. // return `${item.web_url}`;
  102. // }else if(item.children_count == 0){
  103. // //return `/${item.aLIas_pinyin}/`;
  104. // return `/newsList/${item.category_id}?page=1`;
  105. // }else{
  106. // //return `/${item.aLIas_pinyin}/`;
  107. // return `/primaryNavigation/${item.category_id}`;
  108. // }
  109. // }
  110. const getLinkPath = (item) => {
  111. console.log('item', item);
  112. if (item.is_url == 1) {
  113. return `${item.web_url}`;
  114. } else if (item.children_count == 0) {
  115. //return `/newsList/${item.category_id}?page=1`;
  116. return `/${item.aLIas_pinyin}/list-1.html`;
  117. } else {
  118. //return `/primaryNavigation/${item.aLIas_pinyin}/`;
  119. return `/${item.aLIas_pinyin}/index.html`;
  120. }
  121. }
  122. //2.加载模块数据 end ---------------------------------------->
  123. //3.职能部门 start ---------------------------------------->
  124. let department = ref("")
  125. const depValue = ref("")
  126. const typeValue = ref("")
  127. // let departmentList = async () => {
  128. // const mkdata = await requestDataPromise('/web/selectWebsiteDepartment', {
  129. // method: 'GET',
  130. // query: {
  131. // 'keyword': department.value,
  132. // },
  133. // });
  134. // if(mkdata.code == 200){
  135. // department.value = mkdata.data;
  136. // }else{
  137. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  138. // console.log("错误位置:获取职能部门")
  139. // console.log("后端错误反馈:",mkdata.message)
  140. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  141. // }
  142. // }
  143. // //获得所有部门
  144. // departmentList();
  145. //3.职能部门 end ---------------------------------------->
  146. //4.展示行政区划 start ---------------------------------------->
  147. //let areaList = ref("")
  148. //4.1 省
  149. let province = ref("")
  150. let provinceid = ref("")
  151. let provinceList = ref("")
  152. //4.2 市
  153. let city = ref("")
  154. let cityid = ref("")
  155. let cityList = ref("")
  156. //4.3 县
  157. let region = ref("")
  158. //let regionid = ref("")
  159. let regionList = ref("")
  160. //选择省
  161. // let areaArrList = async () => {
  162. // const mkdata = await requestDataPromise('/web/selectWebsiteArea', {
  163. // method: 'GET',
  164. // query: {},
  165. // });
  166. // if(mkdata.code == 200){
  167. // provinceList.value = mkdata.data;
  168. // }else{
  169. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  170. // console.log("错误位置:获取行政区划")
  171. // console.log("后端错误反馈:",mkdata.message)
  172. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  173. // }
  174. // }
  175. // //一开始只需要获取一下省
  176. // areaArrList();
  177. //选择市
  178. let change = async (id) => {
  179. provinceid.value = id;
  180. const shengData = await requestDataPromise('/web/selectWebsiteArea', {
  181. method: 'GET',
  182. query: {
  183. 'pid': id,
  184. },
  185. });
  186. cityList.value = shengData.data;
  187. }
  188. //选择县
  189. let change1 = async (id) => {
  190. cityid.value = id;
  191. const xianData = await requestDataPromise('/web/selectWebsiteArea', {
  192. method: 'GET',
  193. query: {
  194. 'pid': id,
  195. },
  196. });
  197. regionList.value = xianData.data;
  198. }
  199. //4.展示行政区划 end ---------------------------------------->
  200. //5.执行搜索 start ---------------------------------------->
  201. const getcityid = ref("")
  202. //跳转到搜索页面
  203. // let goToSearch = (id) => {
  204. // console.log(id)
  205. // const route = `/search/search?catids=${id}`;
  206. // window.location.href = route;
  207. // }
  208. //获得cityid和
  209. let goToPrimary = async () => {
  210. if (province.value != "") { getcityid.value = province.value }
  211. if (city.value != "") { getcityid.value = city.value }
  212. if (region.value != "") { getcityid.value = region.value }
  213. if (province.value == "" && city.value == "" && region.value == "" && depValue.value == "") {
  214. ElMessage.error('请选择行政区划或者职能部门!')
  215. } else {
  216. // const responseStatus = await requestDataPromise('/web/selectWebsiteCategory', {
  217. // method: 'GET',
  218. // query: {
  219. // 'cityid': getcityid.value,
  220. // 'department_id': depValue.value
  221. // },
  222. // });
  223. // if (responseStatus.data.catid && responseStatus.data.catid.length > 0) {
  224. // const catids = responseStatus.data.catid.join(',');
  225. // const route = `/search/search?catids=${catids}`;
  226. // window.location.href = route;
  227. // } else {
  228. // // 可以在这里处理数组为空的情况
  229. // console.log('没有可用的分类ID');
  230. // const route = `/search/search`;
  231. // window.location.href = route;
  232. // }
  233. const route = `/search/search?catids=${getcityid.value}&department_id=${depValue.value}`;
  234. window.location.href = route;
  235. }
  236. }
  237. //5.执行搜索 end ---------------------------------------->
  238. onMounted(async () => {
  239. //从客户端获取行政职能部门 加快打开速度
  240. try {
  241. const { $webUrl, $CwebUrl } = useNuxtApp();
  242. const response = await fetch($webUrl + '/web/selectWebsiteDepartment', {
  243. headers: {
  244. 'Content-Type': 'application/json',
  245. 'Userurl': $CwebUrl,
  246. 'Origin': $CwebUrl
  247. }
  248. });
  249. const result = await response.json();
  250. department.value = result.data;
  251. } catch (error) {
  252. console.error('获取部门数据失败:', error);
  253. }
  254. //从客户端获取行政区划
  255. try {
  256. const { $webUrl, $CwebUrl } = useNuxtApp();
  257. const response2 = await fetch($webUrl + '/web/selectWebsiteArea', {
  258. headers: {
  259. 'Content-Type': 'application/json',
  260. 'Userurl': $CwebUrl,
  261. 'Origin': $CwebUrl
  262. }
  263. });
  264. const result2 = await response2.json();
  265. provinceList.value = result2.data;
  266. } catch (error) {
  267. console.error('获取行政区划数据失败:', error);
  268. }
  269. })
  270. </script>
  271. <style lang="less" scoped>
  272. @import url('@/assets/css/nav.less');
  273. </style>