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:
+4
-1
@@ -43,11 +43,14 @@ export function setCampusCenter(lat: any, lng: any) {
|
||||
const la = Number(lat), ln = Number(lng);
|
||||
if (Number.isFinite(la) && Number.isFinite(ln) && la !== 0 && ln !== 0) {
|
||||
campusCenter = { lat: la, lng: ln };
|
||||
// 同时镜像到全局 state:迁到 TS 后所有可变状态都该能在 S 里看到,
|
||||
// 也让"地图没加载出来时用校园中心兜底"这条链可测、可现场排查。
|
||||
(S as any).campusCenter = campusCenter;
|
||||
}
|
||||
}
|
||||
|
||||
export function getCampusCenter() {
|
||||
return campusCenter;
|
||||
return campusCenter || ((S as any).campusCenter ?? null);
|
||||
}
|
||||
|
||||
/** 拿校园中心(GCJ02);没有缓存就现取一次 /api/config。拿不到返回 null。 */
|
||||
|
||||
Reference in New Issue
Block a user