hejianhao
2026-02-26 0453fe6b8cd246cfa2268d8d10fcd7b9cd39a312
fix: 修复用户认证和等待界面显示问题

- 移除硬编码的测试用户ID,使用实际存储的UID进行认证
- 修复checkOtp函数逻辑,启用实际的OTP检查流程
- 调整等待界面布局和样式,修复雷达动画位置问题
- 更新配置文件中的AppID和密钥为实际值
- 修复WebSocket认证时使用正确的用户ID
8个文件已修改
80 ■■■■■ 已修改文件
config/dev.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project.config.json 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/robotaxi/home/index.tsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/index.less 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/robotaxi/pages/begin-route/index.tsx 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.ts 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/tools.ts 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/websocket.ts 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/dev.js
@@ -23,13 +23,15 @@
const ROBOTAXI_WS_HOST = '"ws://221.182.45.100:8888/websocket"';
const XP_APPID_MAP = {
  weapp: '"xxxxxxx"', // 用户中心登录appId
  weapp: '"xp_cs_wom"',
};
const XP_SECRET_MAP = {
  weapp: '"xxxxxxx"', // 用户中心登录密钥
  weapp: '"7OmygYfd8dyCigN3"',
};
const PLATFORM_APPID_MAP = {
  weapp: '"xxxxxxx"', // 微信小程序平台 appId
  weapp: '"wx57bb0455a168278b"',
};
const GIO_CONFIG = {
project.config.json
@@ -60,7 +60,7 @@
    "ignore": [],
    "include": []
  },
  "appid": "xxxxxxxxxxxxx",
  "appid": "wx57bb0455a168278b",
  "projectname": "xp-robotaxi-miniprogram",
  "libVersion": "3.13.0"
}
src/pages/robotaxi/home/index.tsx
@@ -101,7 +101,7 @@
    // 从本地存储中获取行程状态
    const tripStatus = Taro.getStorageSync('tripStatus');
    setTripStatus(Number(tripStatus) || 0);
    checkOtp(false).then(otp => {
    checkOtp(true, true).then(otp => {
      if (otp) {
        wsManager.connect(_ROBOTAXI_WS_HOST);
        getOrderActive().then(res => {
src/robotaxi/pages/begin-route/index.less
@@ -80,6 +80,14 @@
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.waiting-callout-content {
    position: absolute;
    top: 200px;
    left: 50%;
    transform: translateX(-50%);
}
.custom-callout-content {
@@ -127,24 +135,23 @@
    align-items: flex-start;
    justify-content: flex-start;
    overflow: visible; // 确保辐射动画不被裁剪
    min-width: 220px;
    height: 270px;
    min-width: 700px;
    height: 600px;
}
.waiting-radar {
    position: absolute;
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 220px;
    height: 350px;
    pointer-events: none;
}
.waiting-radar-img {
    position: relative;
    width: 220px;
    height: 220px;
    position: fixed;
    width: 700px;
    height: 350px;
    top: 48%;
    left: 50%;
    transform: translate(-50%, -48%);
@@ -158,6 +165,7 @@
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: fit-content;
}
.waiting-callout-bg-img {
src/robotaxi/pages/begin-route/index.tsx
@@ -93,6 +93,7 @@
  const shouldShowWaitingRadar = isAndroid && [2, 3].includes(tripStatus);
  useEffect(() => {
    if (![2, 3].includes(tripStatus)) return;
    if (Taro.getEnv?.() !== Taro.ENV_TYPE.WEAPP) {
      return;
    }
@@ -119,7 +120,7 @@
    return () => {
      cancelled = true;
    };
  }, []);
  }, [tripStatus]);
  const updateWaitingRadarPosition = () => {
    if (!shouldShowWaitingRadar) {
@@ -565,7 +566,7 @@
      zIndex: 2,
      name: s?.name || '上车点',
      customCallout: {
        anchorY: [2, 3].includes(tripStatus) ? 80 : 8,
        anchorY: [2, 3].includes(tripStatus) ? 150 : 8,
        anchorX: 0,
        display: 'ALWAYS'
      }
@@ -903,12 +904,14 @@
            if (isWaiting) {
              return (
                <CoverView slot="callout" marker-id={item.id} key={item.id} className="waiting-callout">
                  <CoverView className="waiting-callout-content">
                  <CoverView className="waiting-callout-bg">
                    <CoverImage className="waiting-callout-bg-img" src={waitingCalloutBgSrc} />
                    <CoverView className="waiting-callout-bg-text">{formatTime(elapsedSeconds)}</CoverView>
                  </CoverView>
                  <CoverView className="waiting-callout-txt">
                    <CoverView className="waiting-callout-txt-content">{item.name}</CoverView>
                    </CoverView>
                  </CoverView>
                  <CoverImage className="waiting-radar" src={waitingRadarSrc} />
                </CoverView>
@@ -947,7 +950,7 @@
        {shouldShowWaitingRadar && waitingRadarVisible && (
          <Image className="waiting-radar-img" src={waitingRadarSrc} webp={true} style={waitingRadarStyle} />
        )}
        {/* 选择城市 */}
        {/* 返回按钮 */}
        <View onClick={toBack} className="select-city">
          <Image className="select-city-icon" src={backIcon} />
        </View>
src/utils/request.ts
@@ -151,7 +151,7 @@
  // 获取uid
  const uid = await getStorage(_UID) || '-1';
  header['XP-Uid'] = 1 || uid.toString();
  header['XP-Uid'] = uid.toString();
  // 获取设备id
  header['XP-Deviceid'] = Taro.getStorageSync('wxOpenId') || 'default_device_id';
src/utils/tools.ts
@@ -543,22 +543,21 @@
// 查看本地是否已有otp
export function checkOtp(autoLogin?, hideBack?) {
  return new Promise((resolve) => {
    resolve(true);
    // getStorage('otp')
    //   .then(res => {
    //     resolve(res);
    //     // 无otp,发起登录请求
    //     if (!res && autoLogin) {
    //       if (hideBack) {
    //         jumpTo({ url: '/pages/user/login?hideBack=1' });
    //       } else {
    //         jumpTo({ url: '/pages/user/login' });
    //       }
    //     }
    //   })
    //   .catch(() => {
    //     resolve('');
    //   });
    getStorage('otp')
      .then(res => {
        resolve(res);
        // 无otp,发起登录请求
        if (!res && autoLogin) {
          if (hideBack) {
            jumpTo({ url: '/pages/user/login?hideBack=1' });
          } else {
            jumpTo({ url: '/pages/user/login' });
          }
        }
      })
      .catch(() => {
        resolve('');
      });
  });
}
src/utils/websocket.ts
@@ -42,7 +42,7 @@
    const uid = await getStorage(_UID) || '-1';
    const task = Taro.connectSocket({
      header: {
        'XP-Uid': 1 || uid.toString(),
        'XP-Uid': uid.toString(),
      },
      url: this.url,
      success: () => { },
@@ -88,7 +88,7 @@
        this.reconnectAttempts = 0;
        this.startHeartbeat();
        const uid = await getStorage(_UID) || '-1';
        this.send({ type: 'auth', appUserId: '12345678', timestamp: Date.now() });
        this.send({ type: 'auth', appUserId: uid, timestamp: Date.now() });
        this.notifyListeners('open', { status: 'connected' });
      });