hejianhao
2026-03-04 5ecea8989912189e8d3c4eeb16e03a6d44fd47cd
fix(robotaxi): 修复未登录时隐私弹窗逻辑及登录提示条样式

- 移除调试用的 console.log 语句
- 调整隐私协议检查逻辑,避免未登录时重复弹窗
- 添加底部登录提示条组件及样式
- 优化地理位置授权状态判断逻辑
3个文件已修改
135 ■■■■■ 已修改文件
src/pages/robotaxi/home/index.less 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/robotaxi/home/index.tsx 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/Robotaxi-public-method.ts 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/robotaxi/home/index.less
@@ -217,11 +217,74 @@
      }
    }
  }
  .login-bar {
    position: fixed;
    left: 0;
    bottom: -1px;
    z-index: 98;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 88px;
    padding: 0 48px;
    background: rgba(0, 0, 0, 0.8);
    background-size: cover;
    opacity: 1;
    transform: translateY(0);
    transition: transform 0.4s, opacity 0.4s;
    .hide {
      opacity: 0;
      transform: translateY(90px);
    }
    .text {
      font-size: 24px;
      color: #FFFFFF;
      width: 460px;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      word-break: break-all;
    }
    .more {
      display: flex;
      flex-direction: row;
      align-items: center;
      .more-btn {
        flex-shrink: 0;
        height: 64px;
        margin: 0;
        color: #fff;
        font-size: 24px;
        font-weight: 600;
        line-height: 64px;
        background: transparent;
        max-width: 130px;
        text-align: center;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        word-break: break-all;
        padding: 0;
      }
      .more-icon {
        margin-left: 8px;
        width: 32px;
        height: 32px;
      }
    }
  }
}
.content-box {
  width: 100%;
  z-index: 100;
  // z-index: 100;
  background-color: transparent;
  overflow: hidden;
  margin-top: -52px;
src/pages/robotaxi/home/index.tsx
@@ -1,6 +1,6 @@
import Taro, { useDidShow } from "@tarojs/taro"
import { useEffect, useState, useRef } from 'react';
import { View, Map, Text, Image } from '@tarojs/components';
import { View, Map, Text, Image, Button } from '@tarojs/components';
import './index.less';
import PrivacyPopup from './components/privacy-popup';
import CustomerServicePopup from '../../../robotaxi/components/customer-service';
@@ -24,7 +24,8 @@
  getCityInfoWithId,
  getLocationByIP
} from '../../../utils/Robotaxi-public-method';
import { _ROBOTAXI_WS_HOST } from '../../../constants/api';
import { jumpTo } from '../../../utils/jump';
import { _ROBOTAXI_WS_HOST, CDN } from '../../../constants/api';
import { getGeofence, getBannerList, getAgreement, getOrderActive } from '../../../robotaxi/api/home';
import { getServicePhone } from '../../../robotaxi/api/customer-service';
import { getOrderDistance } from '../../../robotaxi/api/select-map-site';
@@ -52,6 +53,7 @@
  const [electronicAreaId, setElectronicAreaId] = useState(''); // 大头针所在电子围栏ID
  const [adsorptionDistance, setAdsorptionDistance] = useState(null); // 吸附距离
  const [orderData, setOrderData] = useState<any>({}); // 订单数据
  const [isLogin, setIsLogin] = useState(false); // 是否登录
  const [boxHeight, setBoxHeight] = useState<number>(266); // 活动区域高度
  const startY = useRef(0); // 拖动开始时的Y坐标
@@ -121,9 +123,20 @@
    // 从本地存储中获取行程状态
    const tripStatus = Taro.getStorageSync('tripStatus');
    setTripStatus(Number(tripStatus) || 0);
    checkOtp(true, true).then(otp => {
    checkOtp(false).then(otp => {
      setIsLogin(!otp);
      if (otp) {
        wsManager.connect(_ROBOTAXI_WS_HOST);
        getAgreement().then((res: any) => {
          // 如果接口返回未同意,则显示弹窗
          if (res === false) {
            setShowPrivacy(true);
            Taro.setStorageSync('has_show_privicy_Robotaxi', 'false');
          } else {
            setShowPrivacy(false);
            Taro.setStorageSync('has_show_privicy_Robotaxi', 'true');
          }
        })
        getOrderActive().then(res => {
          if (!res) {
            Taro.removeStorageSync('orderRouteDuration');
@@ -171,6 +184,11 @@
    Taro.getSetting({
      success: (res) => {
        const auth = res.authSetting['scope.userLocation'];
        console.log('getSetting获取scope.userLocation授权状态', auth);
        if (auth == undefined) {
          getLocationInfo();
          return;
        }
        if (auth === false) {
          setIsLocationAuthDenied(true);
          // 检查是否有选中的城市缓存
@@ -262,29 +280,6 @@
  // 监听隐私政策显示状态
  useEffect(() => {
    checkOtp(false).then(otp => {
      if (otp) {
        getAgreement().then((res: any) => {
          console.log('获取协议状态:', res);
          // 如果接口返回未同意,则显示弹窗
          if (res === false) {
            setShowPrivacy(true);
            Taro.setStorageSync('has_show_privicy_Robotaxi', 'false');
          } else {
            setShowPrivacy(false);
            Taro.setStorageSync('has_show_privicy_Robotaxi', 'true');
          }
        }).catch(err => {
          console.error('获取协议状态失败', err);
          // 兜底逻辑:如果接口报错,根据本地缓存判断
          setShowPrivacy(Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true');
        });
      } else {
        // 未登录时,根据本地缓存判断
        setShowPrivacy(Taro.getStorageSync('has_show_privicy_Robotaxi') != 'true');
      }
    });
    getBannerList().then((res: any) => {
      if (res && Array.isArray(res)) {
        setBannerList(res);
@@ -450,6 +445,7 @@
  // 获取用户位置信息
  const getLocationInfo = (updateCenter = true) => {
    console.log('getLocation获取用户位置信息');
    Taro.getLocation({ type: 'gcj02' })
      .then(async res => {
        setIsLocationAuthDenied(false);
@@ -507,7 +503,8 @@
            setCurrentSite({ name: '未知位置' });
          });
      })
      .catch(() => {
      .catch((err) => {
        console.log('getLocation获取用户位置失败', err);
        Taro.getSetting({
          success: (res) => {
            const auth = res.authSetting['scope.userLocation'];
@@ -941,6 +938,21 @@
          }
        </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"
@@ -1006,7 +1018,7 @@
                  </View>
                </View>
              }
              <View onClick={toOrderDetail} className="order-status-btn">查看</View>
              <Image className="order-status-bg" src={require('../../../robotaxi/assets/order-card-bg.png')} />
            </View>
src/utils/Robotaxi-public-method.ts
@@ -291,8 +291,6 @@
export const getCityInfoWithId = async (cityCode: string, cityName: string) => {
  try {
    const res: any = await getOpenCity();
    console.log(res);
    console.log(cityCode);
    
    let cityId = 0;
    if (Array.isArray(res.cities)) {