Panel.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <main class="panel_main pc_none" ref="panelMainRef">
  3. <div class="panel_head_box">
  4. <span class="panel_head_btn" @click="close_panel_btn_fun"></span>
  5. <h4 class="panel_head_h4">网站地图</h4>
  6. </div>
  7. <section class="panel_long clearfix">
  8. <div class="panel_main_in">
  9. <div class="panel_box panel_box_line">
  10. <div class="panel_a_box ">
  11. <!-- {{navigation1}} -->
  12. <NuxtLink class="panel_a_btn dot1" :to="'/'">首页</NuxtLink>
  13. <NuxtLink class="panel_a_btn dot1" :href="getLinkPath(per_obj)" title="" v-for="(per_obj,per_index) in navigation1" :key="per_obj">
  14. {{per_obj.alias}}
  15. </NuxtLink>
  16. </div>
  17. </div>
  18. <div class="panel_box">
  19. <div class="panel_name_box">
  20. <div class="panel_name">地方频道</div>
  21. </div>
  22. <div class="panel_a_box ">
  23. <NuxtLink class="panel_a_btn_2 dot1" href="" title=""
  24. v-for="(per_obj,per_index) in provinceList" :key="per_obj"
  25. :to="{ path: `/search/${per_obj.id}` }"
  26. >
  27. {{per_obj.abbreviation}}
  28. </NuxtLink>
  29. </div>
  30. </div>
  31. <!-- 行政查询 -->
  32. <div class="select" v-if="false">
  33. <div class="inner">
  34. <div class="role left">
  35. <div class="title">行政职能查询</div>
  36. <div class="searchRole">
  37. <el-select v-model="depValue" placeholder="职能部门" filterable size="large" style="width: 330px">
  38. <el-option v-for="(item, index) in department" :key="index" :label="item.name"
  39. :value="item.id" />
  40. </el-select>
  41. <em @click="goToPrimary"></em>
  42. </div>
  43. </div>
  44. <div class="region left">
  45. <div class="title">行政区划查询</div>
  46. <div class="searchRole" v-if="provinceList.length > 0">
  47. <el-select v-model="province" placeholder="请选择省" size="large" style="width: 80px">
  48. <el-option v-for="item in provinceList" :key="item.id" :label="item.name"
  49. @click="change(item.id)" :value="item.id" />
  50. </el-select>
  51. <i></i>
  52. <el-select v-model="city" placeholder="请选择市" no-data-text="请先选择省份" size="large"
  53. style="width: 80px">
  54. <el-option v-for="(item, index) in cityList" :key="item.id" :label="item.name"
  55. @click="change1(item.id)" :value="item.id" />
  56. </el-select>
  57. <i></i>
  58. <el-select v-model="region" placeholder="请选择区/县" no-data-text="请先选择市" size="large"
  59. style="width: 100px">
  60. <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="item.id" />
  61. </el-select>
  62. <em @click="goToPrimary"></em>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </section>
  69. </main>
  70. </template>
  71. <script setup>
  72. // 注入全局导航数据
  73. // const navigation1 = useState('globalNavData')
  74. const navigation1 = ref("");
  75. async function getPageData2() {
  76. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  77. method: 'GET',
  78. query: {
  79. 'placeid': 1,
  80. 'pid': 0,
  81. 'num': 35
  82. },
  83. });
  84. navigation1.value = mkdata.data;
  85. }
  86. getPageData2()
  87. const panelVisible = useState('panelVisible')
  88. // 关闭面板
  89. const close_panel_btn_fun = () => {
  90. panelVisible.value = false
  91. }
  92. //3.职能部门 start ---------------------------------------->
  93. let department = ref("")
  94. const depValue = ref("")
  95. const typeValue = ref("")
  96. // let departmentList = async () => {
  97. // const mkdata = await requestDataPromise('/web/selectWebsiteDepartment', {
  98. // method: 'GET',
  99. // query: {
  100. // 'keyword': department.value,
  101. // },
  102. // });
  103. // if(mkdata.code == 200){
  104. // department.value = mkdata.data;
  105. // }else{
  106. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  107. // console.log("错误位置:获取职能部门")
  108. // console.log("后端错误反馈:",mkdata.message)
  109. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  110. // }
  111. // }
  112. // //获得所有部门
  113. // departmentList();
  114. //3.职能部门 end ---------------------------------------->
  115. //4.展示行政区划 start ---------------------------------------->
  116. //let areaList = ref("")
  117. //4.1 省
  118. let province = ref("")
  119. let provinceid = ref("")
  120. let provinceList = ref("")
  121. // const provinceList = useState('globalProvinceData')
  122. //4.2 市
  123. let city = ref("")
  124. let cityid = ref("")
  125. let cityList = ref("")
  126. //4.3 县
  127. let region = ref("")
  128. //let regionid = ref("")
  129. let regionList = ref("")
  130. //选择省
  131. // let areaArrList = async () => {
  132. // const mkdata = await requestDataPromise('/web/selectWebsiteArea', {
  133. // method: 'GET',
  134. // query: {},
  135. // });
  136. // if(mkdata.code == 200){
  137. // provinceList.value = mkdata.data;
  138. // }else{
  139. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  140. // console.log("错误位置:获取行政区划")
  141. // console.log("后端错误反馈:",mkdata.message)
  142. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  143. // }
  144. // }
  145. // //一开始只需要获取一下省
  146. // areaArrList();
  147. //选择市
  148. let change = async (id) => {
  149. provinceid.value = id;
  150. const shengData = await requestDataPromise('/web/selectWebsiteArea', {
  151. method: 'GET',
  152. query: {
  153. 'pid': id,
  154. },
  155. });
  156. cityList.value = shengData.data;
  157. }
  158. //选择县
  159. let change1 = async (id) => {
  160. cityid.value = id;
  161. const xianData = await requestDataPromise('/web/selectWebsiteArea', {
  162. method: 'GET',
  163. query: {
  164. 'pid': id,
  165. },
  166. });
  167. regionList.value = xianData.data;
  168. }
  169. //4.展示行政区划 end ---------------------------------------->
  170. //5.执行搜索 start ---------------------------------------->
  171. const getcityid = ref("")
  172. //跳转到搜索页面
  173. // let goToSearch = (id) => {
  174. // console.log(id)
  175. // const route = `/search/search?catids=${id}`;
  176. // window.location.href = route;
  177. // }
  178. //获得cityid和
  179. let goToPrimary = async () => {
  180. if (province.value != "") { getcityid.value = province.value }
  181. if (city.value != "") { getcityid.value = city.value }
  182. if (region.value != "") { getcityid.value = region.value }
  183. if (province.value == "" && city.value == "" && region.value == "" && depValue.value == "") {
  184. ElMessage.error('请选择行政区划或者职能部门!')
  185. } else {
  186. // const responseStatus = await requestDataPromise('/web/selectWebsiteCategory', {
  187. // method: 'GET',
  188. // query: {
  189. // 'cityid': getcityid.value,
  190. // 'department_id': depValue.value
  191. // },
  192. // });
  193. // if (responseStatus.data.catid && responseStatus.data.catid.length > 0) {
  194. // const catids = responseStatus.data.catid.join(',');
  195. // const route = `/search/search?catids=${catids}`;
  196. // window.location.href = route;
  197. // } else {
  198. // // 可以在这里处理数组为空的情况
  199. // console.log('没有可用的分类ID');
  200. // const route = `/search/search`;
  201. // window.location.href = route;
  202. // }
  203. const route = `/search/search?catids=${getcityid.value}&department_id=${depValue.value}`;
  204. window.location.href = route;
  205. }
  206. }
  207. //5.执行搜索 end ---------------------------------------->
  208. onMounted(async () => {
  209. //从客户端获取行政职能部门 加快打开速度
  210. try {
  211. const { $webUrl, $CwebUrl } = useNuxtApp();
  212. const response = await fetch($webUrl + '/web/selectWebsiteDepartment', {
  213. headers: {
  214. 'Content-Type': 'application/json',
  215. 'Userurl': $CwebUrl,
  216. 'Origin': $CwebUrl
  217. }
  218. });
  219. const result = await response.json();
  220. department.value = result.data;
  221. } catch (error) {
  222. console.error('获取部门数据失败:', error);
  223. }
  224. //从客户端获取行政区划
  225. try {
  226. const { $webUrl, $CwebUrl } = useNuxtApp();
  227. const response2 = await fetch($webUrl + '/web/selectWebsiteArea', {
  228. headers: {
  229. 'Content-Type': 'application/json',
  230. 'Userurl': $CwebUrl,
  231. 'Origin': $CwebUrl
  232. }
  233. });
  234. const result2 = await response2.json();
  235. provinceList.value = result2.data;
  236. } catch (error) {
  237. console.error('获取行政区划数据失败:', error);
  238. }
  239. })
  240. const getLinkPath = (item) => {
  241. close_panel_btn_fun()
  242. if (item.is_url == 1) {
  243. return `${item.web_url}`;
  244. } else if (item.children_count == 0) {
  245. //return `/newsList/${item.category_id}?page=1`;
  246. return `/${item.aLIas_pinyin}/list-1.html`;
  247. } else {
  248. //return `/primaryNavigation/${item.aLIas_pinyin}/`;
  249. return `/${item.aLIas_pinyin}/index.html`;
  250. }
  251. }
  252. // 向左滑动事件相关变量
  253. let touchStartX = 0;
  254. let touchEndX = 0;
  255. let panelMainRef = ref(null);
  256. // 监听向左滑动的最小距离(像素)
  257. const MIN_SWIPE_DISTANCE = 33;
  258. // 向左滑动处理函数
  259. const handleSwipeLeft = () => {
  260. return
  261. // 这里可以执行向左滑动后需要的操作,例如关闭面板
  262. close_panel_btn_fun();
  263. };
  264. // 触摸开始事件
  265. const handleTouchStart = (e) => {
  266. touchStartX = e.touches[0].clientX;
  267. };
  268. // 触摸结束事件
  269. const handleTouchEnd = (e) => {
  270. touchEndX = e.changedTouches[0].clientX;
  271. handleSwipe();
  272. };
  273. // 滑动检测逻辑
  274. const handleSwipe = () => {
  275. const swipeDistance = touchEndX - touchStartX;
  276. // 如果向左滑动的距离大于最小阈值(负值表示向左滑动)
  277. if (swipeDistance < -MIN_SWIPE_DISTANCE) {
  278. handleSwipeLeft();
  279. }
  280. };
  281. onMounted(async () => {
  282. // 获取.panel_main元素并添加触摸事件监听
  283. panelMainRef.value = document.querySelector('.panel_main');
  284. if (panelMainRef.value) {
  285. panelMainRef.value.addEventListener('touchstart', handleTouchStart);
  286. panelMainRef.value.addEventListener('touchend', handleTouchEnd);
  287. }
  288. });
  289. onUnmounted(() => {
  290. // 组件卸载时移除事件监听器,防止内存泄漏
  291. if (panelMainRef.value) {
  292. panelMainRef.value.removeEventListener('touchstart', handleTouchStart);
  293. panelMainRef.value.removeEventListener('touchend', handleTouchEnd);
  294. }
  295. });
  296. import { watch } from 'vue'
  297. onMounted(() => {
  298. const delayTimer_hid = ref(null);//延迟器
  299. delayTimer_hid.value = setTimeout(() => {
  300. watch(panelVisible, (newValue, oldValue) => {
  301. // 根据panelVisible的状态执行不同操作
  302. if (newValue) {
  303. document.body.classList.add("body_hid")
  304. } else {
  305. // 面板隐藏时的操作
  306. document.body.classList.remove('body_hid')
  307. }
  308. })
  309. }, 333);
  310. })
  311. </script>
  312. <style lang="less" scoped>
  313. @import url('@/assets/css/nav.less');
  314. </style>
  315. <style lang="less" scoped>
  316. @media screen and (min-width:801px){/*pc*/
  317. .pc_none{display:none;}
  318. }
  319. @media screen and (max-width:800px){/*ipad_phone*/
  320. .dot1{word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  321. }
  322. .select{overflow:hidden;height:auto;line-height:normal;}
  323. .select .inner{width:96%;margin:0px auto;overflow:hidden;height:auto; }
  324. .select .role{padding:0;height:auto;overflow:hidden;float:none;}
  325. .select .role .searchRole{box-sizing:border-box;width:333px; float:left;margin-left:0px;}
  326. .select .el-select{width:230px!important;}
  327. .select .role .searchRole em{margin:4px 10px;float:right;}
  328. .select .role > .title, .select .region > .title{float:none;font-size:18px;}
  329. .select .region{overflow:hidden;height:auto;float:none;}
  330. .select .region .searchRole{float:none;padding:10px 0;width:90%;margin:5px;height:auto;}
  331. .select .region .el-select{margin-left:17px;}
  332. .select .region em{margin-left:22px;}
  333. .panel_main{
  334. position:fixed;
  335. top:0px;
  336. left:0px;
  337. width:100%;
  338. height:100%;
  339. background:#F6F6F6;
  340. z-index:1999;
  341. overflow:hidden;
  342. }
  343. .panel_head_box{
  344. width:97%;margin:0px auto 4px;
  345. height:50px;border-bottom:1px solid #b8b8b8;
  346. text-align:center;position:relative;
  347. }
  348. .panel_long{
  349. height:100%;
  350. overflow:auto;
  351. }
  352. .panel_head_h4{height:50px;line-height:50px;display:inline-block;
  353. font-size:22px;color:#333;text-align:center;}
  354. .panel_head_btn{float:right;width:22px;height:22px; top:12px;
  355. position:absolute;right:0px;
  356. background:url('../../public/image/guanbi1.png') no-repeat center center;
  357. background-size:100% 100%;
  358. }
  359. .panel_main_in{width:96%;margin:0px auto;padding-bottom:66px;}
  360. .panel_box{}
  361. .panel_name_box{
  362. width:100%;
  363. height:44px;
  364. }
  365. .panel_name{
  366. float:left;font-weight:bold;
  367. height:44px;
  368. line-height:44px;
  369. font-size:16px;
  370. color:#333;
  371. // padding-left:20px;
  372. }
  373. .panel_a_box{
  374. width:100%;
  375. overflow:hidden;
  376. margin-bottom:10px;
  377. }
  378. .panel_box_line{
  379. border-bottom:1px solid #ddd;
  380. }
  381. .panel_a_btn{
  382. float:left;
  383. width:23%;margin: 2% 1%;box-sizing:border-box;text-align:center;
  384. height:44px;
  385. line-height:44px;
  386. font-size:12px;
  387. color:#333;
  388. padding:0 6px;background:#F6F6F6;border:solid 1px #ddd;
  389. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  390. }
  391. .panel_a_btn_2{
  392. float:left;
  393. width:14%;margin:4px 1.3%;box-sizing:border-box;text-align:center;
  394. height:33px;
  395. line-height:33px;
  396. font-size:14px;
  397. color:#333;
  398. padding:0 8px;background:#F6F6F6;border:solid 1px #ddd;
  399. }
  400. }
  401. </style>
  402. <style>
  403. .body_hid{
  404. overflow:hidden;
  405. }
  406. </style>