From e07f2ad2d1b0940efa56f2466a861fedc0246463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AD=B1=E9=87=8E?= Date: Sat, 7 Feb 2026 23:37:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=8C=89=E9=92=AE=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=B8=8E=E9=94=AE=E7=9B=98=E5=BC=B9=E5=87=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CustomPopup/CustomPopup.tsx | 33 +++++++++++++++++-- src/components/CustomPopup/index.module.scss | 10 +++--- src/components/TextareaTag/TextareaTag.tsx | 1 + .../SelectStadium/StadiumDetail.tsx | 19 +++++++---- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/components/CustomPopup/CustomPopup.tsx b/src/components/CustomPopup/CustomPopup.tsx index 2841d24..002c658 100644 --- a/src/components/CustomPopup/CustomPopup.tsx +++ b/src/components/CustomPopup/CustomPopup.tsx @@ -1,7 +1,8 @@ -import React, { useRef, useState } from 'react' +import React, { useRef, useState, useEffect } from 'react' import type { CSSProperties, ReactNode } from 'react' import { View, Text } from '@tarojs/components' import { Button } from '@nutui/nutui-react-taro' +import { useKeyboardHeight } from '@/store/keyboardStore' import styles from './index.module.scss' export interface CustomPopupProps { @@ -46,6 +47,24 @@ const CustomPopup: React.FC = ({ const [isDragging, setIsDragging] = useState(false) const touchStartY = useRef(0) + // 使用全局键盘状态 + const { keyboardHeight, isKeyboardVisible, addListener, initializeKeyboardListener } = useKeyboardHeight() + + // 使用全局键盘状态监听 + useEffect(() => { + // 初始化全局键盘监听器 + initializeKeyboardListener() + + // 添加本地监听器 + const removeListener = addListener((height, visible) => { + console.log('CustomPopup 收到键盘变化:', height, visible) + }) + + return () => { + removeListener() + } + }, [initializeKeyboardListener, addListener]) + if (!visible) { return null } @@ -99,6 +118,13 @@ const CustomPopup: React.FC = ({ onClose() } + // 阻止弹窗内的触摸事件冒泡 + const handleTouchMoveInPopup = (e: any) => { + if (!isKeyboardVisible) { + e.stopPropagation() + } + } + return ( = ({ style={{ zIndex: zIndex ?? undefined, alignItems: overlayAlignItems }} onClick={handleOverlayClick} > - + { e.stopPropagation() @@ -152,7 +179,7 @@ const CustomPopup: React.FC = ({ {children} - {!hideFooter && ( + {!hideFooter && !isKeyboardVisible && (