Panel.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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">
  6. 网站地图
  7. </h4>
  8. </div>
  9. <section class="panel_long clearfix">
  10. <div class="panel_main_in">
  11. <!-- 首页 -->
  12. <div class="panel_box">
  13. <div class="panel_a_box ">
  14. <NuxtLink to="/" title="首页" class="panel_a_btn">
  15. 首页
  16. </NuxtLink>
  17. <NuxtLink class="panel_a_btn"
  18. v-for="(item, index) in navigation1" :key="index"
  19. @click="getLinkPath(item)"
  20. :target="item.is_url == 1 ? '_blank' : '_self'"
  21. >
  22. {{ item.alias }}
  23. </NuxtLink>
  24. <!-- <NuxtLink class="panel_a_btn"
  25. v-for="(item, index) in navigation2" :key="index"
  26. @click="getLinkPath(item)"
  27. :target="item.is_url == 1 ? '_blank' : '_self'"
  28. >
  29. {{ item.alias }}
  30. </NuxtLink> -->
  31. </div>
  32. </div>
  33. <!-- 互动版块 -->
  34. <div class="panel_box panel_box_line phone_none" >
  35. <div class="panel_name_box">
  36. <div class="panel_name">互动推荐</div>
  37. </div>
  38. <div class="panel_a_box ">
  39. <NuxtLink class="panel_a_btn"
  40. v-for="(item, index) in navigation2" :key="index"
  41. @click="getLinkPath(item)"
  42. :target="item.is_url == 1 ? '_blank' : '_self'"
  43. >
  44. {{ item.alias }}
  45. </NuxtLink>
  46. </div>
  47. </div>
  48. </div>
  49. </section>
  50. </main>
  51. </template>
  52. <script setup>
  53. //3.获取导航菜单 start ---------------------------------------->
  54. const navigation1 = ref([]);
  55. const navigation2 = ref([]);// 互动推荐
  56. const navigation3 = ref([]);// 深度服务
  57. const province_arr = ref([]);// 省列表
  58. // 引入全局状态
  59. const panelVisible = useState('panelVisible')
  60. //获得详情id
  61. const route = useRoute();
  62. const router = useRouter();
  63. // 关闭面板
  64. const close_panel_btn_fun = () => {
  65. panelVisible.value = false
  66. }
  67. //获取导航菜单1
  68. async function getNavigation1() {
  69. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  70. method: 'GET',
  71. query: {
  72. 'pid': 0,
  73. 'num': 20,
  74. 'placeid': 1
  75. },
  76. });
  77. navigation1.value = mkdata.data;
  78. }
  79. getNavigation1();
  80. //深度服务
  81. async function getNavigation3() {
  82. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  83. method: 'GET',
  84. query: {
  85. 'pid': 0,
  86. 'num': 6,
  87. 'placeid': 33
  88. },
  89. });
  90. navigation3.value = mkdata.data;
  91. }
  92. getNavigation3();
  93. //获取导航菜单4--互动推荐
  94. async function getNavigation2() {
  95. const mkdata = await requestDataPromise('/web/getWebsiteModelCategory', {
  96. method: 'GET',
  97. query: {
  98. 'pid': 0,
  99. 'num': 999,
  100. 'placeid': 11
  101. },
  102. });
  103. navigation2.value = mkdata.data;
  104. }
  105. getNavigation2();
  106. const getLinkPath = (item) => {
  107. close_panel_btn_fun()
  108. let linkPath = ''
  109. if (item.is_url == 1) {
  110. linkPath = `/${item.web_url}`;
  111. } else if (item.children_count == 0) {
  112. //return `/newsList/${item.category_id}?page=1`;
  113. linkPath = `/${item.aLIas_pinyin}/list-1.html`;
  114. } else {
  115. //return `/primaryNavigation/${item.aLIas_pinyin}/`;
  116. linkPath = `/${item.aLIas_pinyin}/index.html`;
  117. }
  118. // router.push(linkPath)
  119. return navigateTo({
  120. path: linkPath,
  121. })
  122. }
  123. import { watch } from 'vue'
  124. onMounted(() => {
  125. const delayTimer_hid = ref(null);//延迟器
  126. delayTimer_hid.value = setTimeout(() => {
  127. watch(panelVisible, (newValue, oldValue) => {
  128. // 根据panelVisible的状态执行不同操作
  129. if (newValue) {
  130. document.body.classList.add("body_hid")
  131. } else {
  132. // 面板隐藏时的操作
  133. document.body.classList.remove('body_hid')
  134. }
  135. })
  136. }, 333);
  137. })
  138. // 向左滑动事件相关变量
  139. let touchStartX = 0;
  140. let touchEndX = 0;
  141. let panelMainRef = ref(null);
  142. // 监听向左滑动的最小距离(像素)
  143. const MIN_SWIPE_DISTANCE = 33;
  144. // 向左滑动处理函数
  145. const handleSwipeLeft = () => {
  146. // 这里可以执行向左滑动后需要的操作,例如关闭面板
  147. return
  148. close_panel_btn_fun();
  149. };
  150. // 触摸开始事件
  151. const handleTouchStart = (e) => {
  152. touchStartX = e.touches[0].clientX;
  153. };
  154. // 触摸结束事件
  155. const handleTouchEnd = (e) => {
  156. touchEndX = e.changedTouches[0].clientX;
  157. handleSwipe();
  158. };
  159. // 滑动检测逻辑
  160. const handleSwipe = () => {
  161. const swipeDistance = touchEndX - touchStartX;
  162. // 如果向左滑动的距离大于最小阈值(负值表示向左滑动)
  163. if (swipeDistance < -MIN_SWIPE_DISTANCE) {
  164. handleSwipeLeft();
  165. }
  166. };
  167. onMounted(async () => {
  168. // 获取.panel_main元素并添加触摸事件监听
  169. panelMainRef.value = document.querySelector('.panel_main');
  170. if (panelMainRef.value) {
  171. panelMainRef.value.addEventListener('touchstart', handleTouchStart);
  172. panelMainRef.value.addEventListener('touchend', handleTouchEnd);
  173. }
  174. });
  175. onUnmounted(() => {
  176. // 组件卸载时移除事件监听器,防止内存泄漏
  177. if (panelMainRef.value) {
  178. panelMainRef.value.removeEventListener('touchstart', handleTouchStart);
  179. panelMainRef.value.removeEventListener('touchend', handleTouchEnd);
  180. }
  181. });
  182. </script>
  183. <style lang="less" scoped>
  184. // @import url('@/assets/css/nav.less');
  185. </style>
  186. <style lang="less" scoped>
  187. @media screen and (max-width:800px){/*ipad_phone*/
  188. .dot1{word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis; }
  189. .panel_main{
  190. position:fixed;
  191. top:0px;
  192. left:0px;
  193. width:100%;
  194. height:100%;
  195. background:#F6F6F6;
  196. z-index:1999;
  197. overflow:hidden;
  198. }
  199. .panel_head_box{
  200. width:97%;margin:0px auto 4px;
  201. height:50px;border-bottom:1px solid #b8b8b8;
  202. text-align:center;position:relative;
  203. }
  204. .panel_long{
  205. height:100%;
  206. overflow:auto;
  207. }
  208. .panel_head_h4{height:50px;line-height:50px;display:inline-block;
  209. font-size:22px;color:#333;text-align:center;}
  210. .panel_head_btn{float:right;width:22px;height:22px; top:12px;
  211. position:absolute;right:0px;
  212. background:url('../../public/image/guanbi 1.png') no-repeat center center;
  213. background-size:100% 100%;
  214. }
  215. .panel_main_in{width:96%;margin:0px auto;padding-bottom:66px;}
  216. .panel_box{}
  217. .panel_name_box{
  218. width:100%;
  219. height:44px;
  220. }
  221. .panel_name{
  222. float:left;font-weight:bold;
  223. height:44px;
  224. line-height:44px;
  225. font-size:16px;
  226. color:#333;
  227. // padding-left:20px;
  228. }
  229. .panel_a_box{
  230. width:100%;
  231. overflow:hidden;
  232. margin-bottom:10px;
  233. }
  234. .panel_box_line{
  235. border-bottom:1px solid #ddd;
  236. }
  237. .panel_a_btn{
  238. float:left;
  239. width:23%;margin: 2% 1%;box-sizing:border-box;text-align:center;
  240. height:44px;
  241. line-height:44px;
  242. font-size:12px;
  243. color:#333;
  244. padding:0 4px;background:#F6F6F6;border:solid 1px #ddd;
  245. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  246. }
  247. .panel_a_btn_2{
  248. float:left;
  249. width:14%;margin:4px 1.3%;box-sizing:border-box;text-align:center;
  250. height:33px;
  251. line-height:33px;
  252. font-size:14px;
  253. color:#333;
  254. padding:0 8px;background:#F6F6F6;border:solid 1px #ddd;
  255. }
  256. }
  257. </style>
  258. <style>
  259. @media screen and (min-width:801px){/*pc*/
  260. }
  261. @media screen and (max-width:800px){/*ipad_phone*/
  262. .body_hid{
  263. overflow:hidden;
  264. }
  265. }
  266. </style>