shuishen
2025-10-11 db554162f109e9bdaacf6f88f96ec68dc98fca20
src/pages/map/drag.vue
@@ -1,14 +1,8 @@
<template>
  <view
    class="panel-container"
    :style="{
  <view class="panel-container" :style="{
      transform: `translateY(${translateY}px)`,
      transition: isDragging ? 'none' : 'transform 0.3s ease',
    }"
    @touchstart="onTouchStart"
    @touchmove="onTouchMove"
    @touchend="onTouchEnd"
  >
    }" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd">
    <!-- 顶部拖拽提示条 -->
    <view class="drag-bar"></view>
@@ -27,7 +21,23 @@
</template>
<script setup>
  import { ref, computed, onMounted } from 'vue'
  import {
    ref,
    computed,
    onMounted,
    watch
  } from 'vue'
  const props = defineProps({
    isSelectInput: {
      type: Boolean,
      default: false
    },
    searchVal: {
      type: String,
      default: ''
    },
  })
  // 获取屏幕高度
  let screenHeight = 0
@@ -44,14 +54,27 @@
  // 毛玻璃效果
  const searchBoxStyle = computed(() => {
    return translateY.value <= screenHeight * oneSlidePosition.value
      ? {
          backdropFilter: 'blur(10px)',
          background: 'rgba(255, 255, 255, 0.7)',
        }
      : {
          background: '#fff',
        }
    return translateY.value <= screenHeight * oneSlidePosition.value ?
      {
        backdropFilter: 'blur(10px)',
        background: 'rgba(255, 255, 255, 0.7)',
      } :
      {
        background: '#fff',
      }
  })
  watch([
    () => props.isSelectInput,
    () => props.searchVal,
  ], ([newIsSelectInput, newSearchVal]) => {
    if (newIsSelectInput) {
       translateY.value = screenHeight * twoSlidePosition.value
    }
    if (!newIsSelectInput && !newSearchVal) {
      translateY.value = screenHeight * initialPosition.value
    }
  })
  // 获取屏幕高度
@@ -67,7 +90,7 @@
    initialPosition.value = 0.95
    if (screenHeight < 500) {
       initialPosition.value = 0.86
      initialPosition.value = 0.86
    }
    if (screenHeight > 575) {
@@ -75,7 +98,7 @@
    }
    if (screenHeight > 642) {
       initialPosition.value = 0.865
      initialPosition.value = 0.865
    }
    // #endif
@@ -134,7 +157,8 @@
    display: flex;
    flex-direction: column;
    z-index: 997;
    touch-action: none; /* 禁止默认的滚动行为 */
    touch-action: none;
    /* 禁止默认的滚动行为 */
  }
  .drag-bar {