| | |
| | | const [bannerList, setBannerList] = useState<any[]>([]); // 轮播图列表 |
| | | const [orderData, setOrderData] = useState<any>({}); // 订单数据 |
| | | const [isLogin, setIsLogin] = useState(false); // 是否登录 |
| | | const [overlayAnchorBottom, setOverlayAnchorBottom] = useState<number | null>(null); // 浮层初始化锚点(距底部) |
| | | const overlayAnchorInitedRef = useRef(false); // 浮层锚点是否已初始化 |
| | | const { |
| | | boxHeight, |
| | | originOpacity, |
| | |
| | | |
| | | useDidShow(() => { |
| | | bootstrap.onDidShow(); |
| | | setTimeout(() => { |
| | | initOverlayAnchor(); |
| | | }, 80); |
| | | }); |
| | | |
| | | const { handleRegionChange, queryPointerByCenter } = useRegionChange({ |
| | |
| | | const handleCloseCustomerService = () => { |
| | | setShowCustomerService(false); |
| | | }; |
| | | |
| | | // 初始化浮层锚点:固定在 content-box 顶部上方 32px |
| | | const initOverlayAnchor = () => { |
| | | if (overlayAnchorInitedRef.current) return; |
| | | // content-box 高度受 banner 数量影响:多 banner 复用 boxHeight,单 banner 走渲染后实测高度 |
| | | if (bannerList.length > 1) { |
| | | const bottom = Math.max(0, Number(boxHeight) + 115); |
| | | if (bottom <= 0) return; |
| | | setOverlayAnchorBottom(bottom); |
| | | overlayAnchorInitedRef.current = true; |
| | | return; |
| | | } |
| | | const query = Taro.createSelectorQuery(); |
| | | query.select('.content-box').boundingClientRect(); |
| | | query.exec((res) => { |
| | | if (overlayAnchorInitedRef.current) return; |
| | | const rect = res?.[0]; |
| | | const height = Number(rect?.height); |
| | | if (!Number.isFinite(height) || height <= 0) return; |
| | | const bottom = Math.max(0, height + 115); |
| | | setOverlayAnchorBottom(bottom); |
| | | overlayAnchorInitedRef.current = true; |
| | | }); |
| | | }; |
| | | |
| | | useEffect(() => { |
| | | const timer = setTimeout(() => { |
| | | Taro.nextTick(() => { |
| | | initOverlayAnchor(); |
| | | }); |
| | | }, 80); |
| | | return () => clearTimeout(timer); |
| | | }, [bannerList.length, tripStatus, boxHeight]); |
| | | |
| | | // 处理点击地图 marker |
| | | const handleMarkerTap = (e: any) => { |
| | |
| | | <Image className="select-city-icon" src={selectCityIcon} /> |
| | | </View> |
| | | {/* 定位图标 */} |
| | | <View className="origin-box" style={{ opacity: originOpacity, transition: isDragging.current ? 'none' : 'opacity 0.2s ease-out' }}> |
| | | <View |
| | | className="origin-box" |
| | | style={{ |
| | | opacity: originOpacity, |
| | | transition: isDragging.current ? 'none' : 'opacity 0.2s ease-out', |
| | | top: typeof overlayAnchorBottom === 'number' ? 'auto' : undefined, |
| | | bottom: typeof overlayAnchorBottom === 'number' ? `${overlayAnchorBottom}px` : undefined, |
| | | }} |
| | | > |
| | | <Image onClick={toOrigin} className="origin-icon" src={originIcon} /> |
| | | </View> |
| | | <MapOverlayTips |
| | |
| | | isMaintain={isMaintain} |
| | | maintainBounce={maintainBounce} |
| | | hotfixEndText={hotfixEndText} |
| | | anchorBottom={overlayAnchorBottom ?? undefined} |
| | | onShowPrivacy={() => setShowPrivacy(true)} |
| | | onOpenSetting={handleOpenSetting} |
| | | onViewOperatingArea={handleViewOperatingArea} |