feat(还车): 拿不到定位时静默兜底,不再弹「三选一」问用户

用户口径:还车/锁车这块不要打断人去选,按地图中心或找个停车点直接还就行。

改法
- getOrderOperationLocation() 改为自动兜底链,全程不问用户:
  navigator.geolocation(WGS84,直接用)
  → 页面上的「我」标记(BD09 → GCJ02 → WGS84,位置最贴近用户)
  → 地图中心(BD09 → WGS84)
  → 校园中心(/api/config 的 center_lat/lng,GCJ02 → WGS84)
  → 都没有才返回 null 并中止(仍不伪造 36.67/116.98 这类魔数)
- 走兜底时只给一条 toast:「定位不可用,已用地图中心上报位置」,不阻塞操作
- 删除弹窗相关代码:askOperationLocation / settleOperationLocation /
  chooseGeoRetry / chooseGeoMapCenter / cancelGeoChoice 及其状态与超时常量;
  templates/map.html 的 #geo-choice-modal 整块、compat/globals.ts 的 3 个 window 挂载
- map/core.ts:校园中心同时镜像到 S.campusCenter(getCampusCenter 会回读 S),
  让「地图没加载出来」这条兜底链可测、现场可在控制台看到

测试
- test_ux_p0_rental_return.cjs 的 UX-04 三条改写为新口径:
  · 无定位 → 静默用地图中心(校验 BD09→WGS84 数值、source=map-center、toast 有提示)
  · 地图没就绪 → 退校园中心(source=campus-center)
  · 都没有 → 返回 null 且不发还车请求
- 全量 238 pytest + 43 node 全绿
- 浏览器实测(390px,禁用 geolocation):DOM 里没有 #geo-choice-modal,
  window.chooseGeo* 已不存在;取坐标返回 {lat 36.53198, lng 116.77749, source map-center},
  toast「定位不可用,已用地图中心上报位置」,JS 异常 0
This commit is contained in:
zzy
2026-11-17 14:38:41 +08:00
parent 2f3d4a724d
commit 5342554b5f
6 changed files with 114 additions and 192 deletions
+1 -4
View File
@@ -14,7 +14,7 @@ import { createFullIcon, getBikeIcon, getBikeKind, getBikeState, makeIconDataURI
import { bindMarkerDomTouch, bindMarkerTap, bringMarkerToTop, clearHighlight, findMarkerById, rebuildMarkersForZoom, renderMap, setHighlight, setupClusterListener } from "../map/markers";
import { _applyHeading, _applyRoute, _bearing, _bindCompass, _centerOnUser, _clearNavArrow, _clearNavLayers, _destIcon, _ensureCompassPermission, _gpsToGcj, _haversineM, _markProgrammaticMove, _navArrowIcon, _navBanner, _navBtnText, _navGuidance, _navPill, _navTick, _onMapDragEnd, _onMapDragStart, _onMapDragging, _placeNavArrow, _projectOnRoute, _recomputeRoute, _redrawRoute, _requestNavRoute, _rotateByAnimation, _rotateNavArrow, _scheduleResume, _setTurnIcon, _turnKind, _turnSvg, bindNavMapEvents, resumeNavigation, startNavigation, stopNavigation, toggleNavigation } from "../nav/navigation";
import { parseWalkDistance, parseWalkDuration, refineWalkRoute } from "../nav/walk-route";
import { _doFindBikeRequest, _onPageUnload, _onVisibilityChange, addRoundForCurrent, addRoundFromBanner, cancelGeoChoice, checkRentalStatus, chooseGeoMapCenter, chooseGeoRetry, chooseUnlockSrc, clearRentalState, closeAddRoundModal, closeBellModal, closeLostModal, closeOrderTrajModal, closeOrdersModal, closeRentalSettingsModal, closeReturnConfirm, closeReturnModal, closeUnlockConfirm, closeUnlockSrc, confirmAddRound, confirmReturn, disableLostMode, doReturnBike, doUnlockBike, enableLostMode, findBike, getFilteredBikes, getOrderOperationLocation, handleQuickUnlock, isNativeShell, loadUnlockPreview, loadUnlockSrcShowAll, nativeUnlockBike, openOrderTrajectory, openOrdersModal, openRentalSettingsModal, openUnlockAccountChooser, proceedToUnlockConfirm, quickUnlock, rentalIsRealOrder, renderOrderTrajectory, renderUnlockPreview, renderUnlockSrcList, saveRentalSettings, scanCode, selectRadius, showAddRoundConfirm, showBellPasswordModal, showLostModal, showRentalBar, showRentalReturn, showReturnConfirm, showReturnModal, startRental, startRentalFromServer, submitBellPassword, switchBellTab, syncWechatOrder, tempLockCurrentOrder, tempUnlockCurrentOrder, toggleStatusFilter, tryCardPayOrRedirect, unlockBike, updateFilterInfo, updateRangeCircle, updateRentalCountdown, updateRentalFinalTime, updateStatusCounts, useCenterLocation, useCurrentLocation } from "../order/actions";
import { _doFindBikeRequest, _onPageUnload, _onVisibilityChange, addRoundForCurrent, addRoundFromBanner, checkRentalStatus, chooseUnlockSrc, clearRentalState, closeAddRoundModal, closeBellModal, closeLostModal, closeOrderTrajModal, closeOrdersModal, closeRentalSettingsModal, closeReturnConfirm, closeReturnModal, closeUnlockConfirm, closeUnlockSrc, confirmAddRound, confirmReturn, disableLostMode, doReturnBike, doUnlockBike, enableLostMode, findBike, getFilteredBikes, getOrderOperationLocation, handleQuickUnlock, isNativeShell, loadUnlockPreview, loadUnlockSrcShowAll, nativeUnlockBike, openOrderTrajectory, openOrdersModal, openRentalSettingsModal, openUnlockAccountChooser, proceedToUnlockConfirm, quickUnlock, rentalIsRealOrder, renderOrderTrajectory, renderUnlockPreview, renderUnlockSrcList, saveRentalSettings, scanCode, selectRadius, showAddRoundConfirm, showBellPasswordModal, showLostModal, showRentalBar, showRentalReturn, showReturnConfirm, showReturnModal, startRental, startRentalFromServer, submitBellPassword, switchBellTab, syncWechatOrder, tempLockCurrentOrder, tempUnlockCurrentOrder, toggleStatusFilter, tryCardPayOrRedirect, unlockBike, updateFilterInfo, updateRangeCircle, updateRentalCountdown, updateRentalFinalTime, updateStatusCounts, useCenterLocation, useCurrentLocation } from "../order/actions";
import { _alertOrderExpiring, checkOrderStatus, closeOrderActionsModal, fetchOrderCountdown, findCurrentOrderBike, handleOrderBannerClick, handleOrderBannerSurfaceClick, hideOrderBanner, hideOrderCountdown, isOrderActionEligible, orderCardHtml, payCurrentOrderFromModal, returnCurrentOrderFromModal, showOrderActionsModal, showOrderBanner, showOrderCountdown, startOrderCountdown, updateOrderCountdownText } from "../order/status";
import { acceptCurrentShareAsk, acceptShareRequest, checkPendingShareRequests, closeShareConfig, closeShareModal, closeShareRemark, closeShareReturnModal, confirmShareReturn, loadShareData, nextShareAskIfQueue, openShareConfig, openShareModal, openShareRemark, openShareReturnByIdx, partnerLabel, refreshShareBanners, rejectCurrentShareAsk, rejectShareRequest, saveShareConfig, saveShareRemark, sendShareRequest, sharePendingHtml, switchShareTab, unbindShare, updateShareCountdowns } from "../share/share";
import { addSubscribeRule, closeSubscribeModal, deleteSubscribeRule, loadSubscribeLocations, loadSubscribeRules, openSubscribeModal, subRuleRowHtml, toggleSubAdvanced, toggleSubscribeRule } from "../subscribe/subscribe";
@@ -79,10 +79,7 @@ window.checkOrderStatus = checkOrderStatus;
window.checkPendingShareRequests = checkPendingShareRequests;
window.checkRentalStatus = checkRentalStatus;
window.checkStrictGuide = checkStrictGuide;
window.chooseGeoMapCenter = chooseGeoMapCenter;
window.chooseGeoRetry = chooseGeoRetry;
window.chooseUnlockSrc = chooseUnlockSrc;
window.cancelGeoChoice = cancelGeoChoice;
window.clearHighlight = clearHighlight;
window.clearRentalState = clearRentalState;
window.closeAddRoundModal = closeAddRoundModal;