| | |
| | | const [orderData, setOrderData] = useState<any>({}); // 订单数据 |
| | | const [isLogin, setIsLogin] = useState(false); // 是否登录 |
| | | |
| | | const [boxHeight, setBoxHeight] = useState<number>(266); // 活动区域高度 |
| | | const [boxHeight, setBoxHeight] = useState<number>(320); // 活动区域高度 |
| | | const startY = useRef(0); // 拖动开始时的Y坐标 |
| | | const startHeight = useRef(0); // 拖动开始时的高度 |
| | | const fullHeight = useRef(0); // 活动区域最大高度 |
| | | const minHeight = useRef(0); // 活动区域最小高度 |
| | | const isDragging = useRef(false); // 是否正在拖动 |
| | | const dragFrame = useRef<any>(null); |
| | | const pendingHeight = useRef<number | null>(null); |
| | | const shouldIgnoreRegionChange = useRef(false); // 是否忽略地图区域变化 |
| | | const resetTimer = useRef<any>(null); // 自动归位定时器 |
| | | const isReturningToOrigin = useRef(false); // 是否正在自动归位 |
| | |
| | | setTimeout(() => { |
| | | const query = Taro.createSelectorQuery(); |
| | | // 获取内部内容容器的完整高度(不受父容器 overflow:hidden 影响) |
| | | query.select('.select-site').boundingClientRect(rect => { |
| | | query.select('.content-body').boundingClientRect(rect => { |
| | | if (rect) { |
| | | const contentHeight = rect.height; |
| | | const baseHeight = 266; |
| | | const baseHeight = 320; |
| | | fullHeight.current = Math.max(contentHeight, baseHeight); |
| | | minHeight.current = baseHeight; |
| | | setBoxHeight(baseHeight); |
| | | } else { |
| | | // 兜底逻辑 |
| | | minHeight.current = 266; |
| | | fullHeight.current = 266; |
| | | setBoxHeight(266); |
| | | minHeight.current = 320; |
| | | fullHeight.current = 320; |
| | | setBoxHeight(320); |
| | | } |
| | | }).exec(); |
| | | }, 500); |
| | |
| | | isDragging.current = true; |
| | | startY.current = e.touches[0].clientY; |
| | | startHeight.current = typeof boxHeight === 'number' ? boxHeight : fullHeight.current; |
| | | if (dragFrame.current) { |
| | | clearTimeout(dragFrame.current); |
| | | dragFrame.current = null; |
| | | } |
| | | pendingHeight.current = null; |
| | | } |
| | | |
| | | const handleTouchMove = (e: any) => { |
| | |
| | | if (newHeight < minHeight.current) newHeight = minHeight.current; |
| | | if (newHeight > fullHeight.current) newHeight = fullHeight.current; |
| | | |
| | | setBoxHeight(newHeight); |
| | | pendingHeight.current = newHeight; |
| | | if (dragFrame.current) return; |
| | | dragFrame.current = setTimeout(() => { |
| | | if (pendingHeight.current !== null) { |
| | | setBoxHeight(pendingHeight.current); |
| | | } |
| | | pendingHeight.current = null; |
| | | dragFrame.current = null; |
| | | }, 16); |
| | | } |
| | | |
| | | const handleTouchEnd = () => { |
| | | isDragging.current = false; |
| | | if (dragFrame.current) { |
| | | clearTimeout(dragFrame.current); |
| | | dragFrame.current = null; |
| | | } |
| | | if (pendingHeight.current !== null) { |
| | | setBoxHeight(pendingHeight.current); |
| | | pendingHeight.current = null; |
| | | } |
| | | const movableRange = fullHeight.current - minHeight.current; |
| | | if (typeof boxHeight === 'number' && boxHeight > minHeight.current + movableRange / 2) { |
| | | setBoxHeight(fullHeight.current); |
| | |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | |
| | | return ( |
| | | <View className="home-container"> |
| | | <Map |
| | |
| | | polygons={polygons} |
| | | showLocation={!!longitude} |
| | | onRegionChange={handleRegionChange} |
| | | style={{ width: '100%', flex: 1 }} |
| | | style={{ width: '100%', height: '80vh', flex: 'none' }} |
| | | > |
| | | {/* 选择城市 */} |
| | | <View onClick={toSeleteCityPage} className="select-city"> |
| | |
| | | <Image className={`pointer-icon ${bounce ? 'bounce' : ''}`} src={pointer} /> |
| | | </View> |
| | | } |
| | | {/* 复位按钮 */} |
| | | <View className="origin-box"> |
| | | <Image onClick={toOrigin} className="origin-icon" src={originIcon} /> |
| | | </View> |
| | | <View className="position-box"> |
| | | {/* 游客模式展示同意协议 */} |
| | | { |
| | | (Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true' && !isLogin) && <View className="visitor-stste"> |
| | | <View className="visitor-stste-tip">同意隐私协议体验更多约车体验</View> |
| | | <View onClick={() => setShowPrivacy(true)} className="visitor-stste-go">去同意</View> |
| | | </View> |
| | | } |
| | | {/* 未开启位置权限 */} |
| | | { |
| | | isLocationAuthDenied && <View className="visitor-stste"> |
| | | <View className="visitor-stste-tip">未开启位置权限,开启后即可发布行程</View> |
| | | <View onClick={handleOpenSetting} className="visitor-stste-go">去开启</View> |
| | | </View> |
| | | } |
| | | {/* 系统维护 */} |
| | | { |
| | | isMaintain && <View className="is-maintain">系统维护中,预计今日11:00恢复服务</View> |
| | | } |
| | | {/* 查看运营区域 */} |
| | | { |
| | | !isOperatingArea && <View onClick={handleViewOperatingArea} className="is-operating-area">查看运营区域</View> |
| | | } |
| | | </View> |
| | | </Map> |
| | | {/* 是否登录 */} |
| | | { |
| | | isLogin && |
| | | <View className={`login-bar ${isLogin ? '' : 'hide'}`}> |
| | | <View className='text'>立即登录,即可体验Robotaxi行程服务</View> |
| | | <View className='more' |
| | | onClick={() => { |
| | | jumpTo({ url: '/pages/user/login?hideBack=1' }); |
| | | }} |
| | | > |
| | | <Button className='more-btn'>立即登录</Button> |
| | | <Image src={`${CDN}/common/arrow-white-new.png`} className='more-icon'></Image> |
| | | </View> |
| | | </View> |
| | | } |
| | | {/* 选择站点 */} |
| | | <View |
| | | className="content-box" |
| | | style={{ height: bannerList.length > 1 ? `${boxHeight}px` : `auto`, transition: isDragging.current ? 'none' : 'height 0.3s ease-out' }} |
| | | onTouchStart={handleTouchStart} |
| | | onTouchMove={handleTouchMove} |
| | | onTouchEnd={handleTouchEnd} |
| | | catchMove |
| | | onTouchStart={(e) => { |
| | | e.stopPropagation(); |
| | | handleTouchStart(e); |
| | | }} |
| | | onTouchMove={(e) => { |
| | | e.stopPropagation(); |
| | | handleTouchMove(e); |
| | | }} |
| | | onTouchEnd={(e) => { |
| | | e.stopPropagation(); |
| | | handleTouchEnd(); |
| | | }} |
| | | > |
| | | <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"> |
| | | {/* 起点 */} |
| | | <View onClick={() => toSeleteSitePage('start', true)} className="now-site"> |
| | | <View className="now-site-dot"></View> |
| | | <View className="now-site-address"> |
| | | <View className="now-site-address-content"> |
| | | 从 |
| | | <Text className="now-site-address-text"> |
| | | {(!isOperatingArea || isAdsorbed) ? (currentSite.name || '请选择上车点') : '推荐上车点'} |
| | | </Text> |
| | | 出发 |
| | | <View className="content-body"> |
| | | <View className="content-box-top"> |
| | | <View className="position-box"> |
| | | {/* 占位 */} |
| | | { |
| | | getShowDomFlag() && |
| | | <View style={{ height: '33px' }}></View> |
| | | } |
| | | {/* 游客模式展示同意协议 */} |
| | | { |
| | | (Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true' && !isLogin) && <View className="visitor-stste"> |
| | | <View className="visitor-stste-tip">同意隐私协议体验更多约车体验</View> |
| | | <View onClick={() => setShowPrivacy(true)} className="visitor-stste-go">去同意</View> |
| | | </View> |
| | | <Image className="now-site-icon" src={rightIcon} /> |
| | | </View> |
| | | } |
| | | {/* 未开启位置权限 */} |
| | | { |
| | | isLocationAuthDenied && <View className="visitor-stste"> |
| | | <View className="visitor-stste-tip">未开启位置权限,开启后即可发布行程</View> |
| | | <View onClick={handleOpenSetting} className="visitor-stste-go">去开启</View> |
| | | </View> |
| | | } |
| | | {/* 系统维护 */} |
| | | { |
| | | isMaintain && <View className="is-maintain">系统维护中,预计今日11:00恢复服务</View> |
| | | } |
| | | {/* 查看运营区域 */} |
| | | { |
| | | !isOperatingArea && <View onClick={handleViewOperatingArea} className="is-operating-area">查看运营区域</View> |
| | | } |
| | | </View> |
| | | {/* 终点 */} |
| | | <View onClick={() => toSeleteSitePage('end')} className="to-site"> |
| | | <View className="to-site-dot"></View> |
| | | <View className="to-site-address"> |
| | | <View className="to-site-text">你想去哪?</View> |
| | | {/* <View |
| | | onClick={(e) => { |
| | | e.stopPropagation(); |
| | | toBeginRoute() |
| | | }} |
| | | className="to-site-fast" |
| | | >去:中国南方电网·3号门</View> */} |
| | | </View> |
| | | <View className="origin-box"> |
| | | <Image onClick={toOrigin} className="origin-icon" src={originIcon} /> |
| | | </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"> |
| | | {/* 起点 */} |
| | | <View onClick={() => toSeleteSitePage('start', true)} className="now-site"> |
| | | <View className="now-site-dot"></View> |
| | | <View className="now-site-address"> |
| | | <View className="now-site-address-content"> |
| | | 从 |
| | | <Text className="now-site-address-text"> |
| | | {(!isOperatingArea || isAdsorbed) ? (currentSite.name || '请选择上车点') : '推荐上车点'} |
| | | </Text> |
| | | 出发 |
| | | </View> |
| | | <Image className="now-site-icon" src={rightIcon} /> |
| | | </View> |
| | | </View> |
| | | {/* 终点 */} |
| | | <View onClick={() => toSeleteSitePage('end')} className="to-site"> |
| | | <View className="to-site-dot"></View> |
| | | <View className="to-site-address"> |
| | | <View className="to-site-text">你想去哪?</View> |
| | | {/* <View |
| | | onClick={(e) => { |
| | | e.stopPropagation(); |
| | | toBeginRoute() |
| | | }} |
| | | className="to-site-fast" |
| | | >去:中国南方电网·3号门</View> */} |
| | | </View> |
| | | </View> |
| | | </View> |
| | | {/* 订单状态卡片 */} |
| | | { |
| | | [2, 3, 4, 5, 6, 7, 8].includes(tripStatus) && |
| | | <View className="order-status"> |
| | |
| | | {/* 产品名 */} |
| | | <View className="product-name">XPENG Robotaxi</View> |
| | | </View> |
| | | </View> |
| | | </View> |
| | | {/* 是否登录 */} |
| | | { |
| | | isLogin && |
| | | <View className={`login-bar ${isLogin ? '' : 'hide'}`}> |
| | | <View className='text'>立即登录,即可体验Robotaxi行程服务</View> |
| | | <View className='more' |
| | | onClick={() => { |
| | | jumpTo({ url: '/pages/user/login?hideBack=1' }); |
| | | }} |
| | | > |
| | | <Button className='more-btn'>立即登录</Button> |
| | | <Image src={`${CDN}/common/arrow-white-new.png`} className='more-icon'></Image> |
| | | </View> |
| | | </View> |
| | | } |
| | | {/* 隐私政策弹窗 */} |
| | | <PrivacyPopup |
| | | show={showPrivacy} |