Panel.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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">
  10. <div class="panel_a_box ">
  11. <!-- {{navigation1}} -->
  12. <NuxtLink class="panel_a_btn dot1" :to="'/'">首页</NuxtLink>
  13. <NuxtLink class="panel_a_btn dot1"
  14. v-for="(per_obj,per_index) in navigation1"
  15. @click="getLinkPath(per_obj)"
  16. :key="per_obj">
  17. {{per_obj.alias}}
  18. </NuxtLink>
  19. </div>
  20. </div>
  21. <div class="panel_box panel_box_line" v-if="false">
  22. <div class="panel_name_box">
  23. <div class="panel_name">地方频道</div>
  24. </div>
  25. <div class="panel_a_box ">
  26. <NuxtLink class="panel_a_btn_2 dot1" href="" title=""
  27. v-for="(per_obj,per_index) in provinceList" :key="per_obj"
  28. :to="{ path: `/search/${per_obj.id}` }"
  29. >
  30. {{per_obj.abbreviation}}
  31. </NuxtLink>
  32. </div>
  33. </div>
  34. <div class="panel_box panel_box_line" v-if="if_shop_s">
  35. <div class="panel_name_box">
  36. <div class="panel_name">地方频道</div>
  37. </div>
  38. <div class="panel_a_box ">
  39. <NuxtLink :to="`/${targetSegment}/${shopNavOnePinyin}/list-1.html?cityid=${item.id}`"
  40. v-for="item in provinceList1"
  41. :class="['panel_a_btn_2', { 'shop_name_a_only': item.id == cityId }]">
  42. {{ item.abbreviation }}
  43. </NuxtLink>
  44. <NuxtLink :class="['panel_a_btn_2', { 'shop_name_a_only': item.id == cityId }]"
  45. :to="`/${targetSegment}/${shopNavOnePinyin}/list-1.html?cityid=${item.id}`"
  46. v-for="item in provinceList2">
  47. {{ item.abbreviation }}
  48. </NuxtLink>
  49. <NuxtLink :class="['panel_a_btn_2', { 'shop_name_a_only': item.id == cityId }]"
  50. :to="`/${targetSegment}/${shopNavOnePinyin}/list-1.html?cityid=${item.id}`"
  51. v-for="item in provinceList3">
  52. {{ item.abbreviation }}
  53. </NuxtLink>
  54. </div>
  55. </div>
  56. <div class="panel_box panel_box_line" v-if="if_shop_1">
  57. <div class="panel_name_box">
  58. <div class="panel_name">地方频道</div>
  59. </div>
  60. <div class="panel_a_box ">
  61. <NuxtLink :to="`/${targetSegment}/${targetSegment1}/list-1.html?cityid=${item.id}`"
  62. :title="item.name" v-for="item in provinceList1"
  63. :class="['panel_a_btn_2', { 'shop_name_a_only': item.id == cityId }]">
  64. {{ item.abbreviation }}
  65. </NuxtLink>
  66. <NuxtLink :class="['panel_a_btn_2', { 'shop_name_a_only': item.id == cityId }]"
  67. :to="`/${targetSegment}/${targetSegment1}/list-1.html?cityid=${item.id}`"
  68. :title="item.name" v-for="item in provinceList2">
  69. {{ item.abbreviation }}
  70. </NuxtLink>
  71. <NuxtLink :class="['panel_a_btn_2', { 'shop_name_a_only': item.id == cityId }]"
  72. :to="`/${targetSegment}/${targetSegment1}/list-1.html?cityid=${item.id}`"
  73. :title="item.name" v-for="item in provinceList3">
  74. {{ item.abbreviation }}
  75. </NuxtLink>
  76. </div>
  77. </div>
  78. <!-- 行政查询 -->
  79. <div class="select panel_box_line" v-if="false">
  80. <div class="inner">
  81. <div class="role left">
  82. <div class="title">行政职能查询</div>
  83. <div class="searchRole">
  84. <el-select v-model="depValue" placeholder="职能部门" filterable size="large" style="width: 330px">
  85. <el-option v-for="(item, index) in department" :key="index" :label="item.name"
  86. :value="item.id" />
  87. </el-select>
  88. <em @click="goToPrimary"></em>
  89. </div>
  90. </div>
  91. <div class="region left">
  92. <div class="title">行政区划查询</div>
  93. <div class="searchRole" v-if="provinceList.length > 0">
  94. <el-select v-model="province" placeholder="请选择省" size="large" style="width: 80px">
  95. <el-option v-for="item in provinceList" :key="item.id" :label="item.name"
  96. @click="change(item.id)" :value="item.id" />
  97. </el-select>
  98. <i></i>
  99. <el-select v-model="city" placeholder="请选择市" no-data-text="请先选择省份" size="large"
  100. style="width: 80px">
  101. <el-option v-for="(item, index) in cityList" :key="item.id" :label="item.name"
  102. @click="change1(item.id)" :value="item.id" />
  103. </el-select>
  104. <i></i>
  105. <el-select v-model="region" placeholder="请选择区/县" no-data-text="请先选择市" size="large"
  106. style="width: 100px">
  107. <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="item.id" />
  108. </el-select>
  109. <em @click="goToPrimary"></em>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </section>
  116. </main>
  117. </template>
  118. <script setup>
  119. const if_shop_s = ref(false)
  120. // components\goods\subMenu.vue
  121. const if_shop_1 = ref(false)
  122. // components\goods\subMenu1.vue
  123. //判断是否是商城站type=2是商城
  124. const targetSegment = getRoutePath(1);//地址栏名字
  125. const targetSegment1 = getRoutePath(2);
  126. const navId = ref(0)//当前导航标记哪个
  127. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  128. method: 'GET',
  129. query: {
  130. 'pinyin': targetSegment,
  131. },
  132. });
  133. if (getRouteId.code == 200) {
  134. navId.value = parseInt(getRouteId.data.category_id)
  135. } else {
  136. console.log("错误位置:通过url路径查询导航池id")
  137. }
  138. const the_path = (useRoute()).path
  139. const the_path_arr = the_path.split("/")
  140. //判断是否是商城站type=2是商城
  141. if (getRouteId.data.type == 2 && the_path_arr.length == 3) {
  142. if_shop_s.value = true
  143. }
  144. if (getRouteId.data.type == 2 && the_path_arr.length == 4 && the_path_arr[the_path_arr.length-1].startsWith('list')) {
  145. if_shop_1.value = true
  146. }
  147. // 注入全局导航数据
  148. // const navigation1 = useState('globalNavData')
  149. const navigation1 = ref("");
  150. //1.2 获得商城导航
  151. const shopNav = ref("")
  152. const shopNavOnePinyin = ref("")//获得商城导航的第一个 作为默认的跳转链接
  153. let getShowNav = async () => {
  154. const responseStatus = await requestDataPromise('/web/getWebsiteModelCategory', {
  155. method: 'GET',
  156. query: {
  157. placeid: 0,
  158. pid: navId.value,
  159. num: 8,
  160. type: 1
  161. },
  162. });
  163. shopNav.value = responseStatus.data
  164. shopNavOnePinyin.value = responseStatus.data[0].aLIas_pinyin
  165. }
  166. getShowNav();
  167. //1.3 标记当前选择的地区
  168. const route = useRoute();
  169. //获得详情id
  170. const cityId = ref(route.query.cityid)
  171. watch(route, () => {
  172. cityId.value = route.query.cityid
  173. })
  174. async function getPageData2() {
  175. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  176. method: 'GET',
  177. query: {
  178. 'placeid': 1,
  179. 'pid': 0,
  180. 'num': 999
  181. },
  182. });
  183. navigation1.value = mkdata.data;
  184. }
  185. getPageData2()
  186. const panelVisible = useState('panelVisible')
  187. // 关闭面板
  188. const close_panel_btn_fun = () => {
  189. panelVisible.value = false
  190. }
  191. //3.职能部门 start ---------------------------------------->
  192. let department = ref("")
  193. const depValue = ref("")
  194. // let departmentList = async () => {
  195. // const mkdata = await requestDataPromise('/web/selectWebsiteDepartment', {
  196. // method: 'GET',
  197. // query: {
  198. // 'keyword': department.value,
  199. // },
  200. // });
  201. // if(mkdata.code == 200){
  202. // department.value = mkdata.data;
  203. // }else{
  204. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  205. // console.log("错误位置:获取职能部门")
  206. // console.log("后端错误反馈:",mkdata.message)
  207. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  208. // }
  209. // }
  210. // //获得所有部门
  211. // departmentList();
  212. //3.职能部门 end ---------------------------------------->
  213. //4.展示行政区划 start ---------------------------------------->
  214. //let areaList = ref("")
  215. //4.1 省
  216. let province = ref("")
  217. let provinceid = ref("")
  218. let provinceList = ref("")
  219. // const provinceList = useState('globalProvinceData')
  220. //4.2 市
  221. let city = ref("")
  222. let cityid = ref("")
  223. let cityList = ref("")
  224. //4.3 县
  225. let region = ref("")
  226. //let regionid = ref("")
  227. let regionList = ref("")
  228. //选择省
  229. // let areaArrList = async () => {
  230. // const mkdata = await requestDataPromise('/web/selectWebsiteArea', {
  231. // method: 'GET',
  232. // query: {},
  233. // });
  234. // if(mkdata.code == 200){
  235. // provinceList.value = mkdata.data;
  236. // }else{
  237. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  238. // console.log("错误位置:获取行政区划")
  239. // console.log("后端错误反馈:",mkdata.message)
  240. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  241. // }
  242. // }
  243. // //一开始只需要获取一下省
  244. // areaArrList();
  245. //选择市
  246. let change = async (id) => {
  247. provinceid.value = id;
  248. const shengData = await requestDataPromise('/web/selectWebsiteArea', {
  249. method: 'GET',
  250. query: {
  251. 'pid': id,
  252. },
  253. });
  254. cityList.value = shengData.data;
  255. }
  256. //选择县
  257. let change1 = async (id) => {
  258. cityid.value = id;
  259. const xianData = await requestDataPromise('/web/selectWebsiteArea', {
  260. method: 'GET',
  261. query: {
  262. 'pid': id,
  263. },
  264. });
  265. regionList.value = xianData.data;
  266. }
  267. //4.展示行政区划 end ---------------------------------------->
  268. //5.执行搜索 start ---------------------------------------->
  269. const getcityid = ref("")
  270. //跳转到搜索页面
  271. // let goToSearch = (id) => {
  272. // console.log(id)
  273. // const route = `/search/search?catids=${id}`;
  274. // window.location.href = route;
  275. // }
  276. //获得cityid和
  277. let goToPrimary = async () => {
  278. if (province.value != "") { getcityid.value = province.value }
  279. if (city.value != "") { getcityid.value = city.value }
  280. if (region.value != "") { getcityid.value = region.value }
  281. if (province.value == "" && city.value == "" && region.value == "" && depValue.value == "") {
  282. ElMessage.error('请选择行政区划或者职能部门!')
  283. } else {
  284. // const responseStatus = await requestDataPromise('/web/selectWebsiteCategory', {
  285. // method: 'GET',
  286. // query: {
  287. // 'cityid': getcityid.value,
  288. // 'department_id': depValue.value
  289. // },
  290. // });
  291. // if (responseStatus.data.catid && responseStatus.data.catid.length > 0) {
  292. // const catids = responseStatus.data.catid.join(',');
  293. // const route = `/search/search?catids=${catids}`;
  294. // window.location.href = route;
  295. // } else {
  296. // // 可以在这里处理数组为空的情况
  297. // console.log('没有可用的分类ID');
  298. // const route = `/search/search`;
  299. // window.location.href = route;
  300. // }
  301. const route = `/search/search?catids=${getcityid.value}&department_id=${depValue.value}`;
  302. window.location.href = route;
  303. }
  304. }
  305. //5.执行搜索 end ---------------------------------------->
  306. //2.获得省列表 start ---------------------------------------->
  307. const provinceList1 = ref([]);//省列表1
  308. const provinceList2 = ref([]);//省列表2
  309. const provinceList3 = ref([]);//省列表3
  310. onMounted(async () => {
  311. //获得所有的省
  312. try {
  313. const { $webUrl, $CwebUrl } = useNuxtApp();
  314. const response = await fetch($webUrl + '/web/selectWebsiteArea', {
  315. headers: {
  316. 'Content-Type': 'application/json',
  317. 'Userurl': $CwebUrl,
  318. 'Origin': $CwebUrl
  319. }
  320. });
  321. const result = await response.json();
  322. for (let index in result.data) {
  323. if (index < 15) {
  324. provinceList1.value.push(result.data[index])
  325. } else if (index > 14 && index < 30) {
  326. provinceList2.value.push(result.data[index])
  327. } else if (index > 29) {
  328. provinceList3.value.push(result.data[index])
  329. }
  330. }
  331. } catch (error) {
  332. console.error('获取行政区划数据失败:', error);
  333. }
  334. //从客户端获取行政职能部门 加快打开速度
  335. try {
  336. const { $webUrl, $CwebUrl } = useNuxtApp();
  337. const response = await fetch($webUrl + '/web/selectWebsiteDepartment', {
  338. headers: {
  339. 'Content-Type': 'application/json',
  340. 'Userurl': $CwebUrl,
  341. 'Origin': $CwebUrl
  342. }
  343. });
  344. const result = await response.json();
  345. department.value = result.data;
  346. } catch (error) {
  347. console.error('获取部门数据失败:', error);
  348. }
  349. //从客户端获取行政区划
  350. try {
  351. const { $webUrl, $CwebUrl } = useNuxtApp();
  352. const response2 = await fetch($webUrl + '/web/selectWebsiteArea', {
  353. headers: {
  354. 'Content-Type': 'application/json',
  355. 'Userurl': $CwebUrl,
  356. 'Origin': $CwebUrl
  357. }
  358. });
  359. const result2 = await response2.json();
  360. provinceList.value = result2.data;
  361. } catch (error) {
  362. console.error('获取行政区划数据失败:', error);
  363. }
  364. })
  365. const getLinkPath = (item) => {
  366. panelVisible.value = false
  367. let the_path;
  368. if (item.is_url == 1) {
  369. the_path = `${item.web_url}`;
  370. // return `${item.web_url}`;
  371. } else if (item.children_count == 0) {
  372. the_path = `/${item.aLIas_pinyin}/list-1.html`;
  373. // return `/${item.aLIas_pinyin}/list-1.html`;
  374. } else {
  375. the_path = `/${item.aLIas_pinyin}/index.html`;
  376. // return `/${item.aLIas_pinyin}/index.html`;
  377. }
  378. const { $router } = useNuxtApp();
  379. $router.push(the_path);
  380. }
  381. import { watch } from 'vue'
  382. onMounted(() => {
  383. const delayTimer_hid = ref(null);//延迟器
  384. delayTimer_hid.value = setTimeout(() => {
  385. watch(panelVisible, (newValue, oldValue) => {
  386. // 根据panelVisible的状态执行不同操作
  387. if (newValue) {
  388. document.body.classList.add("body_hid")
  389. } else {
  390. // 面板隐藏时的操作
  391. document.body.classList.remove('body_hid')
  392. }
  393. })
  394. }, 333);
  395. })
  396. // 向左滑动事件相关变量
  397. let touchStartX = 0;
  398. let touchEndX = 0;
  399. let panelMainRef = ref(null);
  400. // 监听向左滑动的最小距离(像素)
  401. const MIN_SWIPE_DISTANCE = 33;
  402. // 向左滑动处理函数
  403. const handleSwipeLeft = () => {
  404. // 这里可以执行向左滑动后需要的操作,例如关闭面板
  405. return
  406. close_panel_btn_fun();
  407. };
  408. // 触摸开始事件
  409. const handleTouchStart = (e) => {
  410. touchStartX = e.touches[0].clientX;
  411. };
  412. // 触摸结束事件
  413. const handleTouchEnd = (e) => {
  414. touchEndX = e.changedTouches[0].clientX;
  415. handleSwipe();
  416. };
  417. // 滑动检测逻辑
  418. const handleSwipe = () => {
  419. const swipeDistance = touchEndX - touchStartX;
  420. // 如果向左滑动的距离大于最小阈值(负值表示向左滑动)
  421. if (swipeDistance < -MIN_SWIPE_DISTANCE) {
  422. handleSwipeLeft();
  423. }
  424. };
  425. onMounted(async () => {
  426. // 获取.panel_main元素并添加触摸事件监听
  427. panelMainRef.value = document.querySelector('.panel_main');
  428. if (panelMainRef.value) {
  429. panelMainRef.value.addEventListener('touchstart', handleTouchStart);
  430. panelMainRef.value.addEventListener('touchend', handleTouchEnd);
  431. }
  432. });
  433. onUnmounted(() => {
  434. // 组件卸载时移除事件监听器,防止内存泄漏
  435. if (panelMainRef.value) {
  436. panelMainRef.value.removeEventListener('touchstart', handleTouchStart);
  437. panelMainRef.value.removeEventListener('touchend', handleTouchEnd);
  438. }
  439. });
  440. </script>
  441. <style lang="less" scoped>
  442. @import url('@/assets/css/public/nav.less');
  443. </style>
  444. <style lang="less" scoped>
  445. @media screen and (max-width:800px){/*ipad_phone*/
  446. .dot1{word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  447. }
  448. .select{overflow:hidden;height:auto;line-height:normal;}
  449. .select .inner{width:96%;margin:0px auto;overflow:hidden;height:auto; }
  450. .select .role{padding:0;height:auto;overflow:hidden;float:none;}
  451. .select .role .searchRole{box-sizing:border-box;width:333px; float:left;margin-left:0px;}
  452. .select .el-select{width:230px!important;}
  453. .select .role .searchRole em{margin:4px 10px;float:right;}
  454. .select .role > .title, .select .region > .title{float:none;font-size:18px;}
  455. .select .region{overflow:hidden;height:auto;float:none;}
  456. .select .region .searchRole{float:none;padding:10px 0;width:90%;margin:5px;height:auto;}
  457. .select .region .el-select{margin-left:17px;}
  458. .select .region em{margin-left:22px;}
  459. .panel_main{
  460. position:fixed;
  461. top:0px;
  462. left:0px;
  463. width:100%;
  464. height:100%;
  465. background:#F6F6F6;
  466. z-index:1999;
  467. overflow:hidden;
  468. }
  469. .panel_head_box{
  470. width:97%;margin:0px auto 4px;
  471. height:50px;border-bottom:1px solid #b8b8b8;
  472. text-align:center;position:relative;
  473. }
  474. .panel_long{
  475. height:100%;
  476. overflow:auto;
  477. }
  478. .panel_head_h4{height:50px;line-height:50px;display:inline-block;
  479. font-size:22px;color:#333;text-align:center;}
  480. .panel_head_btn{float:right;width:22px;height:22px; top:12px;
  481. position:absolute;right:0px;
  482. background:url('../../public/image/guanbi1.png') no-repeat center center;
  483. background-size:100% 100%;
  484. }
  485. .panel_main_in{width:96%;margin:0px auto;padding-bottom:66px;}
  486. .panel_box{}
  487. .panel_name_box{
  488. width:100%;
  489. height:44px;
  490. }
  491. .panel_name{
  492. float:left;font-weight:bold;
  493. height:44px;
  494. line-height:44px;
  495. font-size:16px;
  496. color:#333;
  497. // padding-left:20px;
  498. }
  499. .panel_a_box{
  500. width:100%;
  501. overflow:hidden;
  502. margin-bottom:10px;
  503. }
  504. .panel_box_line{
  505. border-top:1px solid #ddd;
  506. }
  507. .panel_a_btn{
  508. float:left;
  509. width:23%;margin: 2% 1%;box-sizing:border-box;text-align:center;
  510. height:44px;
  511. line-height:44px;
  512. font-size:12px;
  513. color:#333;
  514. padding:0 4px;background:#F6F6F6;border:solid 1px #ddd;
  515. }
  516. .panel_a_btn_2{
  517. float:left;
  518. width:14%;margin:4px 1.3%;box-sizing:border-box;text-align:center;
  519. height:33px;
  520. line-height:33px;
  521. font-size:14px;
  522. color:#333;
  523. padding:0 8px;background:#F6F6F6;border:solid 1px #ddd;
  524. }
  525. .panel_a_btn_2.shop_name_a_only{
  526. background:#004564;color:#fff;
  527. }
  528. }
  529. </style>
  530. <style >
  531. @media screen and (min-width:801px){/*pc*/
  532. }
  533. @media screen and (max-width:800px){/*ipad_phone*/
  534. .body_hid{
  535. overflow:hidden;
  536. }
  537. }
  538. </style>