hejianhao
2026-03-04 38b2103cd4ba9c38eab0e68c5a3f7731314fbcaa
feat(robotaxi): 重构首页布局并优化拖拽交互

- 将地图容器高度设为固定值,避免内容区域挤压
- 重构底部内容区域结构,将登录条移至地图外独立定位
- 优化拖拽逻辑,使用防抖减少渲染次数
- 调整复位按钮和位置提示框的定位层级
- 为骨架屏添加无障碍属性
3个文件已修改
389 ■■■■■ 已修改文件
src/pages/robotaxi/home/index.less 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/robotaxi/home/index.tsx 215 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/select-city/index.tsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/robotaxi/home/index.less
@@ -137,87 +137,6 @@
  overflow: hidden;
  position: relative;
  .origin-box {
    position: absolute;
    bottom: 72px;
    right: 32px;
    z-index: 102;
    .origin-icon {
      width: 88px;
      height: 88px;
    }
  }
  .position-box {
    position: absolute;
    bottom: 68px;
    left: 32px;
    z-index: 101;
    width: calc(100% - 64px);
    .is-operating-area {
      margin: 0 auto;
      margin-top: 20px;
      width: fit-content;
      line-height: 64px;
      font-size: 24px;
      font-weight: normal;
      letter-spacing: normal;
      color: #FFFFFF;
      border-radius: 200px;
      background: rgba(0, 0, 0, 0.4);
      backdrop-filter: blur(40px);
      padding: 0 44px;
    }
    .is-maintain {
      margin-top: 20px;
      border-radius: 16px;
      background: rgba(255, 249, 226, 0.9);
      box-sizing: border-box;
      border: 1px solid #FFFFFF;
      backdrop-filter: blur(40px);
      box-shadow: 0px 4px 16px 0px rgba(84, 92, 143, 0.1);
      font-size: 24px;
      font-weight: normal;
      line-height: 64px;
      text-align: center;
      letter-spacing: normal;
      color: #F58900;
      padding: 0 24px;
      width: fit-content;
    }
    .visitor-stste {
      width: fit-content;
      margin-top: 20px;
      display: flex;
      align-items: center;
      border-radius: 16px;
      background: rgba(0, 0, 0, 0.4);
      backdrop-filter: blur(40px);
      padding: 9px 24px;
      .visitor-stste-tip {
        font-size: 24px;
        font-weight: normal;
        line-height: 46px;
        letter-spacing: normal;
        color: #FFFFFF;
      }
      .visitor-stste-go {
        margin-left: 24px;
        font-size: 24px;
        font-weight: normal;
        line-height: 46px;
        letter-spacing: normal;
        color: #AFEA60;
      }
    }
  }
  .login-bar {
    position: fixed;
    left: 0;
@@ -284,13 +203,98 @@
.content-box {
  width: 100%;
  // z-index: 100;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background-color: transparent;
  overflow: hidden;
  margin-top: -52px;
  margin-top: 0;
  border-radius: 38px 38px 0 0;
  .content-box-top {
    padding-bottom: 24px;
  }
  .origin-box {
    position: absolute;
    top: -24px;
    right: 32px;
    z-index: 1;
    .origin-icon {
      width: 88px;
      height: 88px;
    }
  }
  .position-box {
    width: 100%;
    .is-operating-area {
      margin: 0 auto;
      // margin-top: 20px;
      width: fit-content;
      line-height: 64px;
      font-size: 24px;
      font-weight: normal;
      letter-spacing: normal;
      color: #FFFFFF;
      border-radius: 200px;
      background: rgba(0, 0, 0, 0.4);
      backdrop-filter: blur(40px);
      padding: 0 44px;
    }
    .is-maintain {
      margin-top: 20px;
      border-radius: 16px;
      background: rgba(255, 249, 226, 0.9);
      box-sizing: border-box;
      border: 1px solid #FFFFFF;
      backdrop-filter: blur(40px);
      box-shadow: 0px 4px 16px 0px rgba(84, 92, 143, 0.1);
      font-size: 24px;
      font-weight: normal;
      line-height: 64px;
      text-align: center;
      letter-spacing: normal;
      color: #F58900;
      padding: 0 24px;
      width: fit-content;
    }
    .visitor-stste {
      width: fit-content;
      // margin-top: 20px;
      display: flex;
      align-items: center;
      border-radius: 16px;
      background: rgba(0, 0, 0, 0.4);
      backdrop-filter: blur(40px);
      padding: 9px 24px;
      .visitor-stste-tip {
        font-size: 24px;
        font-weight: normal;
        line-height: 46px;
        letter-spacing: normal;
        color: #FFFFFF;
      }
      .visitor-stste-go {
        margin-left: 24px;
        font-size: 24px;
        font-weight: normal;
        line-height: 46px;
        letter-spacing: normal;
        color: #AFEA60;
      }
    }
  }
  .select-site {
    overflow: hidden;
    position: relative;
    padding: 32px;
    padding-top: 40px;
src/pages/robotaxi/home/index.tsx
@@ -55,12 +55,14 @@
  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); // 是否正在自动归位
@@ -415,18 +417,18 @@
    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);
@@ -714,6 +716,11 @@
    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) => {
@@ -724,11 +731,27 @@
    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);
@@ -888,6 +911,14 @@
    }
  }
  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
@@ -899,7 +930,7 @@
        polygons={polygons}
        showLocation={!!longitude}
        onRegionChange={handleRegionChange}
        style={{ width: '100%', flex: 1 }}
        style={{ width: '100%', height: '80vh', flex: 'none' }}
      >
        {/* 选择城市 */}
        <View onClick={toSeleteCityPage} className="select-city">
@@ -938,91 +969,93 @@
            <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">
@@ -1067,7 +1100,23 @@
          {/* 产品名 */}
          <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}
src/robotaxi/pages/select-city/index.tsx
@@ -120,7 +120,7 @@
      </View>
      {
        isLoading &&
        <View className='city-content skeleton'>
        <View className='city-content skeleton' aria-hidden='true'>
          <View className='skeleton-service'>
            <View className='skeleton-title'></View>
            <View className='skeleton-chip-list'>