fix(robotaxi): 人在广州市,切到成都市,点选择上车,到搜索页会出现必须要传经纬度的提示
Co-Authored-By: '廖芳' <liaof@xiaopeng.com>
| | |
| | | isLocationAuthDenied: boolean; |
| | | /** 当前电子围栏 ID */ |
| | | electronicAreaId: string; |
| | | /** 当前地图中心纬度 */ |
| | | latitude: number | null; |
| | | /** 当前地图中心经度 */ |
| | | longitude: number | null; |
| | | /** 当前选中站点 */ |
| | | currentSite: any; |
| | | /** 首页确认上车点。 */ |
| | |
| | | return; |
| | | } |
| | | reportEditStationEvent(type); |
| | | // 切换城市后 currentSite 会被清空(无经纬度),此时回退到当前地图中心坐标, |
| | | // 避免传入 longitude=undefined/latitude=undefined 导致搜索页接口报“必须要传经纬度”。 |
| | | const siteLongitude = Number(deps.currentSite?.longitude); |
| | | const siteLatitude = Number(deps.currentSite?.latitude); |
| | | const hasValidSiteCoord = Number.isFinite(siteLongitude) && Number.isFinite(siteLatitude); |
| | | const mapLongitude = Number(deps.longitude); |
| | | const mapLatitude = Number(deps.latitude); |
| | | const hasValidMapCoord = Number.isFinite(mapLongitude) && Number.isFinite(mapLatitude); |
| | | const startLongitude = hasValidSiteCoord ? siteLongitude : (hasValidMapCoord ? mapLongitude : null); |
| | | const startLatitude = hasValidSiteCoord ? siteLatitude : (hasValidMapCoord ? mapLatitude : null); |
| | | if (startLongitude === null || startLatitude === null) { |
| | | Taro.showToast({ title: '请先移动到运营区内', icon: 'none' }); |
| | | return; |
| | | } |
| | | Taro.navigateTo({ |
| | | url: `/robotaxi/pages/site-search/index?pageType=${type}&electronicAreaId=${deps.electronicAreaId}&longitude=${deps.currentSite.longitude}&latitude=${deps.currentSite.latitude}`, |
| | | url: `/robotaxi/pages/site-search/index?pageType=${type}&electronicAreaId=${deps.electronicAreaId}&longitude=${startLongitude}&latitude=${startLatitude}`, |
| | | success: () => { |
| | | reportEvent(SEARCH_CLICK_EVENT_ID, { element_type: type == 'start' ? 'start' : 'dest' }); |
| | | } |
| | |
| | | setShowPrivacy, |
| | | isLocationAuthDenied, |
| | | electronicAreaId, |
| | | latitude, |
| | | longitude, |
| | | currentSite, |
| | | preferredStartSite, |
| | | userCurrentLocation, |
| | |
| | | // 重新拉取初始化数据(历史记录和附近站点) |
| | | const refreshData = async () => { |
| | | const { pageType: type, latitude: lat, longitude: lon, electronicAreaId } = deps.router.params; |
| | | if (lat && lon) { |
| | | const hasValidCoord = Number.isFinite(Number(lat)) && Number.isFinite(Number(lon)); |
| | | if (hasValidCoord) { |
| | | fetchNearbySites(Number(lat), Number(lon), electronicAreaId); |
| | | } |
| | | const otp = await checkOtp(false); |
| | | if (otp && lat && lon) { |
| | | if (otp && hasValidCoord) { |
| | | const payload = { lat: Number(lat), lon: Number(lon), electronicAreaId }; |
| | | const handleSuccess = (res: any) => { |
| | | if (Array.isArray(res)) { |
| | |
| | | let isUnmounted = false; |
| | | const initPageData = async () => { |
| | | const { pageType: type, latitude: lat, longitude: lon, electronicAreaId } = deps.router.params; |
| | | const hasValidCoord = Number.isFinite(Number(lat)) && Number.isFinite(Number(lon)); |
| | | const initTasks: Promise<unknown>[] = []; |
| | | if (lat && lon) { |
| | | if (hasValidCoord) { |
| | | initTasks.push( |
| | | fetchNearbySites( |
| | | Number(lat), |
| | |
| | | initTasks.push((async () => { |
| | | try { |
| | | const otp = await checkOtp(false); |
| | | if (!otp || !lat || !lon) { |
| | | if (!otp || !hasValidCoord) { |
| | | return; |
| | | } |
| | | const payload = { lat: Number(lat), lon: Number(lon), electronicAreaId }; |