fix: 修复用户认证和等待界面显示问题
- 移除硬编码的测试用户ID,使用实际存储的UID进行认证
- 修复checkOtp函数逻辑,启用实际的OTP检查流程
- 调整等待界面布局和样式,修复雷达动画位置问题
- 更新配置文件中的AppID和密钥为实际值
- 修复WebSocket认证时使用正确的用户ID
| | |
| | | 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 = { |
| | |
| | | "ignore": [], |
| | | "include": [] |
| | | }, |
| | | "appid": "xxxxxxxxxxxxx", |
| | | "appid": "wx57bb0455a168278b", |
| | | "projectname": "xp-robotaxi-miniprogram", |
| | | "libVersion": "3.13.0" |
| | | } |
| | |
| | | // 从本地存储中获取行程状态 |
| | | 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 => { |
| | |
| | | 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 { |
| | |
| | | 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%); |
| | |
| | | display: flex; |
| | | align-items: flex-start; |
| | | justify-content: center; |
| | | width: fit-content; |
| | | } |
| | | |
| | | .waiting-callout-bg-img { |
| | |
| | | const shouldShowWaitingRadar = isAndroid && [2, 3].includes(tripStatus); |
| | | |
| | | useEffect(() => { |
| | | if (![2, 3].includes(tripStatus)) return; |
| | | if (Taro.getEnv?.() !== Taro.ENV_TYPE.WEAPP) { |
| | | return; |
| | | } |
| | |
| | | return () => { |
| | | cancelled = true; |
| | | }; |
| | | }, []); |
| | | }, [tripStatus]); |
| | | |
| | | const updateWaitingRadarPosition = () => { |
| | | if (!shouldShowWaitingRadar) { |
| | |
| | | zIndex: 2, |
| | | name: s?.name || '上车点', |
| | | customCallout: { |
| | | anchorY: [2, 3].includes(tripStatus) ? 80 : 8, |
| | | anchorY: [2, 3].includes(tripStatus) ? 150 : 8, |
| | | anchorX: 0, |
| | | display: 'ALWAYS' |
| | | } |
| | |
| | | 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> |
| | |
| | | {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> |
| | |
| | | |
| | | // 获取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'; |
| | |
| | | // 查看本地是否已有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(''); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | |
| | | const uid = await getStorage(_UID) || '-1'; |
| | | const task = Taro.connectSocket({ |
| | | header: { |
| | | 'XP-Uid': 1 || uid.toString(), |
| | | 'XP-Uid': uid.toString(), |
| | | }, |
| | | url: this.url, |
| | | success: () => { }, |
| | |
| | | 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' }); |
| | | }); |
| | | |