| | |
| | | <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> |
| | | |
| | |
| | | </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 |
| | |
| | | |
| | | // 毛玻璃效果 |
| | | 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 |
| | | } |
| | | }) |
| | | |
| | | // 获取屏幕高度 |
| | |
| | | initialPosition.value = 0.95 |
| | | |
| | | if (screenHeight < 500) { |
| | | initialPosition.value = 0.86 |
| | | initialPosition.value = 0.86 |
| | | } |
| | | |
| | | if (screenHeight > 575) { |
| | |
| | | } |
| | | |
| | | if (screenHeight > 642) { |
| | | initialPosition.value = 0.865 |
| | | initialPosition.value = 0.865 |
| | | } |
| | | // #endif |
| | | |
| | |
| | | display: flex; |
| | | flex-direction: column; |
| | | z-index: 997; |
| | | touch-action: none; /* 禁止默认的滚动行为 */ |
| | | touch-action: none; |
| | | /* 禁止默认的滚动行为 */ |
| | | } |
| | | |
| | | .drag-bar { |