pageNavigation.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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="'/'">
  8. 首页
  9. </NuxtLink>
  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. <!-- 有外链优先显示外链接 没有外链 优先显示二级分类 否则进入列表 -->
  23. <NuxtLink :to="item.web_url" v-if="item.is_url == 1 && index<=23" :title="item.alias" target="_blank">
  24. <span class="active" v-if="item.category_id == routeId">{{ item.alias }}</span>
  25. <span v-else>{{ item.alias }}</span>
  26. </NuxtLink>
  27. <NuxtLink :to="'/primaryNavigation/' + item.category_id" v-if="item.is_url != 1 && item.children_count !=0 && index<=23" :title="item.alias">
  28. <span class="active" v-if="item.category_id == routeId">{{ item.alias }}</span>
  29. <span v-else>{{ item.alias }}</span>
  30. </NuxtLink>
  31. <NuxtLink :to="'/newsList/' + item.category_id" v-if="item.is_url != 1 && item.children_count == 0 && index<=23" :title="item.alias">
  32. <span class="active" v-if="item.category_id == routeId">{{ item.alias }}</span>
  33. <span v-else>{{ item.alias }}</span>
  34. </NuxtLink>
  35. </li>
  36. </ul>
  37. </div>
  38. </div>
  39. <!-- 展示地区 -->
  40. <div class="cityBox">
  41. <div class="cityMain">
  42. <div class="cityTitle">
  43. 地方频道
  44. </div>
  45. <ul class="cityList">
  46. <li v-for="item in provinceList">
  47. <NuxtLink :to="{ path: `/search/search`,query:{catids:item.id}}">{{item.abbreviation}}</NuxtLink>
  48. </li>
  49. </ul>
  50. </div>
  51. </div>
  52. <!-- 行政查询 -->
  53. <div class="select">
  54. <div class="inner">
  55. <div class="role left">
  56. <div class="title">行政职能查询</div>
  57. <div class="searchRole" v-if="department.length > 0">
  58. <el-select v-model="depValue" placeholder="职能部门" filterable size="large" style="width: 330px">
  59. <el-option v-for="(item, index) in department" :key="index" :label="item.name" :value="item.id" />
  60. </el-select>
  61. <em @click="goToPrimary"></em>
  62. </div>
  63. </div>
  64. <div class="region left">
  65. <div class="title">行政区划查询</div>
  66. <div class="searchRole" v-if="provinceList.length > 0">
  67. <el-select v-model="province" placeholder="请选择省" size="large" style="width: 80px">
  68. <el-option v-for="item in provinceList" :key="item.id" :label="item.name" @click="change(item.id)" :value="item.id" />
  69. </el-select>
  70. <i></i>
  71. <el-select v-model="city" placeholder="请选择市" no-data-text="请先选择省份" size="large" style="width: 80px">
  72. <el-option v-for="(item, index) in cityList" :key="item.id" :label="item.name" @click="change1(item.id)" :value="item.id" />
  73. </el-select>
  74. <i></i>
  75. <el-select v-model="region" placeholder="请选择区/县" no-data-text="请先选择市" size="large" style="width: 100px">
  76. <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="item.id" />
  77. </el-select>
  78. <em @click="goToPrimary"></em>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </template>
  85. <script setup>
  86. //1.加载依赖 start ---------------------------------------->
  87. import { ElMessage } from 'element-plus'
  88. import { ref, onMounted } from 'vue';
  89. import { ElSelect, ElOption } from 'element-plus'
  90. const nuxtApp = useNuxtApp();
  91. const axios = nuxtApp.$axios;
  92. const route = useRoute();
  93. const routeId = route.params.id; //获得该页面的id
  94. //1.加载依赖 end ---------------------------------------->
  95. //2.加载模块数据 start ---------------------------------------->
  96. const navigation1 = ref("");
  97. async function getPageData2() {
  98. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  99. method: 'GET',
  100. query: {
  101. 'placeid': 1,
  102. 'pid': 0,
  103. 'num': 35
  104. },
  105. });
  106. navigation1.value = mkdata.data;
  107. }
  108. getPageData2();
  109. //2.加载模块数据 end ---------------------------------------->
  110. //3.职能部门 start ---------------------------------------->
  111. let department = ref("安全")
  112. const depValue = ref("")
  113. const typeValue = ref("")
  114. let departmentList = async () => {
  115. const mkdata = await requestDataPromise('/web/selectWebsiteDepartment', {
  116. method: 'GET',
  117. query: {
  118. 'keyword': department.value,
  119. },
  120. });
  121. if(mkdata.code == 200){
  122. department.value = mkdata.data;
  123. }else{
  124. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  125. console.log("错误位置:获取职能部门")
  126. console.log("后端错误反馈:",mkdata.message)
  127. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  128. }
  129. }
  130. //获得所有部门
  131. departmentList();
  132. //3.职能部门 end ---------------------------------------->
  133. //4.展示行政区划 start ---------------------------------------->
  134. //let areaList = ref("")
  135. //4.1 省
  136. let province = ref("")
  137. let provinceid = ref("")
  138. let provinceList = ref("")
  139. //4.2 市
  140. let city = ref("")
  141. let cityid = ref("")
  142. let cityList = ref("")
  143. //4.3 县
  144. let region = ref("")
  145. //let regionid = ref("")
  146. let regionList = ref("")
  147. //选择省
  148. let areaArrList = async () => {
  149. const mkdata = await requestDataPromise('/web/selectWebsiteArea', {
  150. method: 'GET',
  151. query: {},
  152. });
  153. if(mkdata.code == 200){
  154. provinceList.value = mkdata.data;
  155. }else{
  156. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  157. console.log("错误位置:获取行政区划")
  158. console.log("后端错误反馈:",mkdata.message)
  159. console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  160. }
  161. }
  162. //一开始只需要获取一下省
  163. areaArrList();
  164. //选择市
  165. let change = async (id) => {
  166. provinceid.value = id;
  167. const shengData = await requestDataPromise('/web/selectWebsiteArea', {
  168. method: 'GET',
  169. query: {
  170. 'province': id,
  171. 'city': 0
  172. },
  173. });
  174. cityList.value = shengData.data.city;
  175. }
  176. //选择县
  177. let change1 = async (id) => {
  178. cityid.value = id;
  179. const xianData = await requestDataPromise('/web/selectWebsiteArea', {
  180. method: 'GET',
  181. query: {
  182. 'province': provinceid.value,
  183. 'city': cityid.value
  184. },
  185. });
  186. regionList.value = xianData.data.region;
  187. }
  188. //4.展示行政区划 end ---------------------------------------->
  189. //5.执行搜索 start ---------------------------------------->
  190. const getcityid = ref("")
  191. //跳转到搜索页面
  192. // let goToSearch = (id) => {
  193. // console.log(id)
  194. // const route = `/search/search?catids=${id}`;
  195. // window.location.href = route;
  196. // }
  197. //获得cityid和
  198. let goToPrimary = async () => {
  199. if (province.value != "") { getcityid.value = province.value }
  200. if (city.value != "") { getcityid.value = city.value }
  201. if (region.value != "") { getcityid.value = region.value }
  202. if (province.value == ""&&city.value == ""&&region.value == ""&&depValue.value=="") {
  203. ElMessage.error('请选择行政区划或者职能部门!')
  204. }else{
  205. // const responseStatus = await requestDataPromise('/web/selectWebsiteCategory', {
  206. // method: 'GET',
  207. // query: {
  208. // 'cityid': getcityid.value,
  209. // 'department_id': depValue.value
  210. // },
  211. // });
  212. // if (responseStatus.data.catid && responseStatus.data.catid.length > 0) {
  213. // const catids = responseStatus.data.catid.join(',');
  214. // const route = `/search/search?catids=${catids}`;
  215. // window.location.href = route;
  216. // } else {
  217. // // 可以在这里处理数组为空的情况
  218. // console.log('没有可用的分类ID');
  219. // const route = `/search/search`;
  220. // window.location.href = route;
  221. // }
  222. const route = `/search/search?catids=${getcityid.value}&department_id=${depValue.value}`;
  223. window.location.href = route;
  224. }
  225. }
  226. //5.执行搜索 end ---------------------------------------->
  227. </script>
  228. <style lang="less" scoped>
  229. @import url('@/assets/css/nav.less');
  230. </style>