| | |
| | | const [isMaintain, setIsMaintain] = useState(false); // 是否维护中 |
| | | const [maintainBounce, setMaintainBounce] = useState(false); |
| | | const [hotfixEndText, setHotfixEndText] = useState(''); |
| | | const [isOperatingArea, setIsOperatingArea] = useState(false); // 是否在运营区域内 |
| | | const [isOperatingArea, setIsOperatingArea] = useState(true); // 是否在运营区域内 |
| | | const [polygons, setPolygons] = useState<any[]>([]); // 地图围栏 |
| | | const [tripStatus, setTripStatus] = useState<number>(0); // 行程状态 |
| | | const [currentSite, setCurrentSite] = useState<any>({}); // 当前站点 |
| | |
| | | const [orderData, setOrderData] = useState<any>({}); // 订单数据 |
| | | const [isLogin, setIsLogin] = useState(false); // 是否登录 |
| | | |
| | | const [boxHeight, setBoxHeight] = useState<number>(0); // 活动区域高度 |
| | | const [boxHeight, setBoxHeight] = useState<number>(280); // 活动区域高度 |
| | | const [originOpacity, setOriginOpacity] = useState(1); |
| | | const startY = useRef(0); // 拖动开始时的Y坐标 |
| | | const startHeight = useRef(0); // 拖动开始时的高度 |
| | |
| | | // 监听展示项与 Banner 变化,重新计算高度 |
| | | useEffect(() => { |
| | | calculateBoxHeight(); |
| | | }, [bannerList, tripStatus, isLogin, isLocationAuthDenied, isMaintain, isOperatingArea]); |
| | | }, [bannerList, tripStatus]); |
| | | |
| | | // 监听城市变化,更新电子围栏 |
| | | useEffect(() => { |
| | |
| | | if (res && Array.isArray(res) && res.length > 0) { |
| | | const newPolygons = formatGeofencePolygons(res); |
| | | setPolygons(newPolygons); |
| | | // if ((orderData || orderData?.id) && JSON.stringify(orderData) != '{}') return; |
| | | // 定位到第一个运营区域的第一个点 |
| | | // const firstPolygon = res[0]; |
| | | // if (firstPolygon && firstPolygon.points && firstPolygon.points.length > 0) { |
| | | // const firstPoint = firstPolygon.points[0]; |
| | | // setLatitude(Number(firstPoint.lat)); |
| | | // setLongitude(Number(firstPoint.lng)); |
| | | // skipNextLocationCenterRef.current = true; |
| | | // shouldIgnoreRegionChange.current = true; |
| | | // const mapCtx = Taro.createMapContext('map'); |
| | | // mapCtx.moveToLocation({ |
| | | // latitude: Number(firstPoint.lat), |
| | | // longitude: Number(firstPoint.lng), |
| | | // }); |
| | | // } |
| | | if (!Taro.getStorageSync('startSite')) { |
| | | if (skipFenceIncludePointsRef.current) { |
| | | skipFenceIncludePointsRef.current = false; |
| | |
| | | // 延迟计算,确保 DOM 渲染完成 |
| | | setTimeout(() => { |
| | | const query = Taro.createSelectorQuery(); |
| | | query.select('.content-body').boundingClientRect(); |
| | | query.selectAll('.position-box .visitor-stste, .position-box .is-maintain, .position-box .is-operating-area').boundingClientRect(); |
| | | query.exec((res: any[]) => { |
| | | const bodyRect = res?.[0]; |
| | | const itemRects: Array<{ height: number }> = res?.[1] || []; |
| | | const dynamicTopHeight = itemRects.reduce((sum, r) => sum + (r?.height || 0), 0); |
| | | if (bodyRect && bodyRect.height) { |
| | | const contentHeight = bodyRect.height; |
| | | const baseHeight = 320 + dynamicTopHeight; |
| | | // 获取内部内容容器的完整高度(不受父容器 overflow:hidden 影响) |
| | | query.select('.content-body').boundingClientRect(rect => { |
| | | if (rect) { |
| | | const contentHeight = rect.height; |
| | | const baseHeight = 280; |
| | | fullHeight.current = Math.max(contentHeight, baseHeight); |
| | | minHeight.current = baseHeight; |
| | | setBoxHeight(baseHeight); |
| | | } else { |
| | | const baseHeight = 320 + dynamicTopHeight; |
| | | minHeight.current = baseHeight; |
| | | fullHeight.current = baseHeight; |
| | | setBoxHeight(baseHeight); |
| | | // 兜底逻辑 |
| | | minHeight.current = 280; |
| | | fullHeight.current = 280; |
| | | setBoxHeight(280); |
| | | } |
| | | }); |
| | | }).exec(); |
| | | }, 500); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | const getShowDomFlag = () => { |
| | | const showPrivacyBox = Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true' && !isLogin; |
| | | const showLocationBox = isLocationAuthDenied; |
| | | const showMaintainBox = isMaintain; |
| | | const showOperatingBox = !isOperatingArea; |
| | | return !(showPrivacyBox || showLocationBox || showMaintainBox || showOperatingBox); |
| | | } |
| | | |
| | | const toAgreementPage = async () => { |
| | | const ok = await ensureNetwork(); |
| | | if (!ok) return; |
| | |
| | | if (!ok) return; |
| | | jumpTo({ url: '/pages/user/login?hideBack=1' }); |
| | | } |
| | | |
| | | const topSpacerHeight = useMemo(() => { |
| | | const showPrivacyBox = Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true' && !isLogin; |
| | | const showLocationBox = isLocationAuthDenied; |
| | | const showMaintainBox = isMaintain; |
| | | const showOperatingBox = !isOperatingArea; |
| | | const anyShown = showPrivacyBox || showLocationBox || showMaintainBox || showOperatingBox; |
| | | return anyShown ? 0 : 32; |
| | | }, [isLogin, isLocationAuthDenied, isMaintain, isOperatingArea]); |
| | | |
| | | return ( |
| | | <View className="home-container"> |
| | |
| | | {/* 定位图标 */} |
| | | <View className="origin-box" style={{ opacity: originOpacity, transition: isDragging.current ? 'none' : 'opacity 0.2s ease-out' }}> |
| | | <Image onClick={toOrigin} className="origin-icon" src={originIcon} /> |
| | | </View> |
| | | {/* 地图浮层tip */} |
| | | <View className="content-box-top"> |
| | | <View className="position-box"> |
| | | {/* 游客模式展示同意协议 */} |
| | | { |
| | | (Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true' && !isLogin) && <View className="visitor-stste ml-32"> |
| | | <View className="visitor-stste-tip">同意隐私协议体验更多约车体验</View> |
| | | <View onClick={() => setShowPrivacy(true)} className="visitor-stste-go">去同意</View> |
| | | </View> |
| | | } |
| | | {/* 未开启位置权限 */} |
| | | { |
| | | isLocationAuthDenied && <View className="visitor-stste ml-32 mt-20"> |
| | | <View className="visitor-stste-tip">未开启位置权限,开启后即可发布行程</View> |
| | | <View onClick={handleOpenSetting} className="visitor-stste-go">去开启</View> |
| | | </View> |
| | | } |
| | | {/* 系统维护 */} |
| | | { |
| | | isMaintain && <View className={`is-maintain ml-32 ${maintainBounce ? 'maintain-bounce' : ''}`}>系统维护中,预计今日{hotfixEndText || '11:00'}恢复服务</View> |
| | | } |
| | | {/* 查看运营区域 */} |
| | | { |
| | | !isOperatingArea && <View onClick={handleViewOperatingArea} className="is-operating-area mt-20">查看运营区域</View> |
| | | } |
| | | </View> |
| | | </View> |
| | | {/* 地图浮层入口 */} |
| | | <View className="map-entry"> |
| | |
| | | }} |
| | | > |
| | | <View className="content-body"> |
| | | <View className="content-box-top"> |
| | | <View className="position-box"> |
| | | {/* 占位 */} |
| | | { |
| | | getShowDomFlag() && |
| | | <View style={{ height: `${topSpacerHeight}px` }}></View> |
| | | } |
| | | {/* 游客模式展示同意协议 */} |
| | | { |
| | | (Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true' && !isLogin) && <View className="visitor-stste ml-32"> |
| | | <View className="visitor-stste-tip">同意隐私协议体验更多约车体验</View> |
| | | <View onClick={() => setShowPrivacy(true)} className="visitor-stste-go">去同意</View> |
| | | </View> |
| | | } |
| | | {/* 未开启位置权限 */} |
| | | { |
| | | isLocationAuthDenied && <View className="visitor-stste ml-32 mt-20"> |
| | | <View className="visitor-stste-tip">未开启位置权限,开启后即可发布行程</View> |
| | | <View onClick={handleOpenSetting} className="visitor-stste-go">去开启</View> |
| | | </View> |
| | | } |
| | | {/* 系统维护 */} |
| | | { |
| | | isMaintain && <View className={`is-maintain ml-32 ${maintainBounce ? 'maintain-bounce' : ''}`}>系统维护中,预计今日{hotfixEndText || '11:00'}恢复服务</View> |
| | | } |
| | | {/* 查看运营区域 */} |
| | | { |
| | | !isOperatingArea && <View onClick={handleViewOperatingArea} className="is-operating-area mt-20">查看运营区域</View> |
| | | } |
| | | </View> |
| | | </View> |
| | | <View className="select-site"> |
| | | <Image className="site-top-bg" src='https://huishou-1323682843.cos.ap-nanjing.myqcloud.com/images/cab0e5b2-0da0-4d2e-80e6-0fc2da8d2532.png' /> |
| | | <View className="site-boarding-point"> |