| | |
| | | success: (res) => { |
| | | const auth = res.authSetting['scope.userLocation']; |
| | | if (auth === false) { |
| | | setIsLocationAuthDenied(true); |
| | | // setIsLocationAuthDenied(true); |
| | | // 检查是否有选中的城市缓存 |
| | | const selectedCity = Taro.getStorageSync('selectedCity'); |
| | | if (!selectedCity || !selectedCity.code) { |
| | |
| | | const cityName = (city && typeof city === 'string' && city.length > 0) ? city : province; |
| | | const cityCode = convertAdcodeToCityCode(adcode, cityName, province); |
| | | getCityInfoWithId(cityCode, cityName).then(cityInfo => { |
| | | skipCityChangeEffectRef.current = true; |
| | | // skipCityChangeEffectRef.current = true; |
| | | setSelectedCity(cityInfo); |
| | | Taro.setStorageSync('selectedCity', cityInfo); |
| | | }); |
| | |
| | | if (res && Array.isArray(res) && res.length > 0) { |
| | | const newPolygons = formatGeofencePolygons(res); |
| | | setPolygons(newPolygons); |
| | | if ((orderData || orderData?.id) && JSON.stringify(orderData) != '{}') return; |
| | | // if ((orderData || orderData?.id) && JSON.stringify(orderData) != '{}') return; |
| | | // 定位到第一个运营区域的第一个点 |
| | | const firstPolygon = res[0]; |
| | | if (firstPolygon && firstPolygon.points && firstPolygon.points.length > 0) { |
| | |
| | | } |
| | | } |
| | | |
| | | const queryPointerByCenter = async (lat: number, lng: number) => { |
| | | setBounce(true); |
| | | setShowToolTip(false); |
| | | try { |
| | | const { isInside, newMarkers, sites } = await updateMapData(lat, lng); |
| | | if (!isInside) { |
| | | setBounce(false); |
| | | return; |
| | | } |
| | | |
| | | const nearestCandidates = sites.length > 0 ? sites : newMarkers; |
| | | const { targetMarker, minDistance } = findNearestMarker(lat, lng, nearestCandidates); |
| | | |
| | | setTimeout(() => { |
| | | setBounce(false); |
| | | if (minDistance < adsorptionDistance) { |
| | | setIsAdsorbed(true); |
| | | if (targetMarker) { |
| | | setCurrentSite(targetMarker); |
| | | } |
| | | setShowToolTip(true); |
| | | } else { |
| | | setIsAdsorbed(false); |
| | | setCurrentSite({ name: '正在获取位置...' }); |
| | | getAddressByLocation(lng, lat) |
| | | .then((data) => { |
| | | const address = data.name || data.desc; |
| | | setCurrentAddress(address); |
| | | setCurrentSite({ name: address, latitude: lat, longitude: lng }); |
| | | }) |
| | | .catch(() => { |
| | | setCurrentAddress('未知位置'); |
| | | setCurrentSite({ name: '未知位置' }); |
| | | }); |
| | | setShowToolTip(true); |
| | | } |
| | | }, 600); |
| | | } catch (error) { |
| | | setBounce(false); |
| | | } |
| | | } |
| | | |
| | | const handleTouchStart = (e: any) => { |
| | | isDragging.current = true; |
| | | startY.current = e.touches[0].clientY; |
| | |
| | | }) |
| | | } |
| | | |
| | | const toSeleteSitePage = (type: string) => { |
| | | const toSeleteSitePage = (type: string, isToMapStart: boolean) => { |
| | | if (isLocationAuthDenied) { |
| | | Taro.showToast({ |
| | | title: '请先开启定位权限', |
| | |
| | | icon: 'none' |
| | | }); |
| | | return; |
| | | } |
| | | if (isToMapStart) { |
| | | Taro.navigateTo({ |
| | | url: '/robotaxi/pages/select-map-site/index?pageType=' + type, |
| | | }) |
| | | } |
| | | if (type == 'end') { |
| | | Taro.setStorageSync('startSite', currentSite); |
| | |
| | | points: points, |
| | | padding: [100, 100, 100, 100] |
| | | }); |
| | | setTimeout(() => { |
| | | mapCtx.getCenterLocation({ |
| | | success: (res) => { |
| | | queryPointerByCenter(res.latitude, res.longitude); |
| | | } |
| | | }); |
| | | }, 600); |
| | | } else { |
| | | Taro.showToast({ |
| | | title: '此城市暂未开通运营区域', |
| | |
| | | {/* 选择站点 */} |
| | | <View |
| | | className="content-box" |
| | | style={{ height: bannerList.length > 0 ? `${boxHeight}px` : `auto`, transition: isDragging.current ? 'none' : 'height 0.3s ease-out' }} |
| | | style={{ height: bannerList.length > 1 ? `${boxHeight}px` : `auto`, transition: isDragging.current ? 'none' : 'height 0.3s ease-out' }} |
| | | onTouchStart={handleTouchStart} |
| | | onTouchMove={handleTouchMove} |
| | | onTouchEnd={handleTouchEnd} |
| | |
| | | <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')} className="now-site"> |
| | | <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"> |