样式调整

This commit is contained in:
2026-02-12 16:54:50 +08:00
parent 909dc95771
commit 3dfc1dfc2c
2 changed files with 62 additions and 33 deletions

View File

@@ -195,10 +195,10 @@
<div id="search-box"> <div id="search-box">
<div class="input-row"> <div class="input-row">
<input id="startInput" placeholder="起点: 请输入当前地点" /> <input id="startInput" placeholder="起点: 请输入当前地点" onfocus="this.select()" />
</div> </div>
<div class="input-row"> <div class="input-row">
<input id="endInput" placeholder="终点: 请输入目的地" /> <input id="endInput" placeholder="终点: 请输入目的地" onfocus="this.select()" />
<button onclick="startRouteSearch()">路径规划</button> <button onclick="startRouteSearch()">路径规划</button>
</div> </div>
</div> </div>
@@ -244,6 +244,11 @@
} }
}); });
// 点击地图空白处重置状态
map.on('click', function() {
resetSearchState();
});
// 添加基础控件 // 添加基础控件
map.addControl(new AMap.Scale()); map.addControl(new AMap.Scale());
map.addControl(new AMap.ToolBar({ map.addControl(new AMap.ToolBar({
@@ -285,6 +290,19 @@
}); });
} }
/**
* 重置搜索状态,隐藏面板和路线
*/
function resetSearchState() {
if (document.body.classList.contains('panel-active')) {
console.log("JS->: 重置地图状态");
document.body.classList.remove('panel-active');
var panel = document.getElementById('panel');
panel.style.display = 'none';
if (driving) driving.clear();
}
}
/** /**
* 核心功能 1: 接收 Flutter 传来的定位数据 * 核心功能 1: 接收 Flutter 传来的定位数据
* Flutter 端调用: webViewController.evaluateJavascript("updateMyLocation(...)") * Flutter 端调用: webViewController.evaluateJavascript("updateMyLocation(...)")
@@ -481,19 +499,25 @@
offset: new AMap.Pixel(-16, -32), offset: new AMap.Pixel(-16, -32),
title: station.name, title: station.name,
label: { label: {
content: '<div class="custom-bubble">' + station.name + '</div>', content: '<div class="custom-bubble">' + station.name +
'</div>',
direction: 'top' direction: 'top'
} }
}); });
// 3. 绑定点击事件:选中即为目的地,并开始规划 // 3. 绑定点击事件:选中即为目的地,并开始规划
sMarker.on('click', function () { sMarker.on('click', function () {
document.getElementById('endInput').value = station.address || station.name; var stationName = station.name || "目的地";
// 更新当前的 destMarker (如果需要) document.getElementById('endInput').value = station.address ||
if (destMarker) destMarker.setMap(null); stationName;
// 更新当前的 destMarker
if (destMarker && destMarker !== sMarker) destMarker.setMap(null);
destMarker = sMarker; destMarker = sMarker;
startRouteSearch(); // 直接传入坐标对象,避免关键字搜索失败
var loc = new AMap.LngLat(station.longitude, station.latitude);
startRouteSearch(loc);
}); });
stationMarkers.push(sMarker); stationMarkers.push(sMarker);
@@ -554,11 +578,12 @@
} }
} }
/** /**
* 路径规划 * 路径规划
* @param {AMap.LngLat} [destLoc] 可选的终点坐标
*/ */
function startRouteSearch() { function startRouteSearch(destLoc) {
// 获取输入框的文字
var startKw = document.getElementById('startInput').value; var startKw = document.getElementById('startInput').value;
var endKw = document.getElementById('endInput').value; var endKw = document.getElementById('endInput').value;
@@ -566,28 +591,21 @@
alert("请输入起点"); alert("请输入起点");
return; return;
} }
if (!endKw) { if (!endKw) {
alert("请输入终点"); alert("请输入终点");
return; return;
} }
// 清除旧路线
if (driving) driving.clear(); if (driving) driving.clear();
// 收起键盘
document.getElementById('startInput').blur(); document.getElementById('startInput').blur();
document.getElementById('endInput').blur(); document.getElementById('endInput').blur();
// --- 构造路径规划的点 ---
var points = []; var points = [];
// 1. 处理起点逻辑 // 1. 起点逻辑
if (!startKw || startKw === '我的位置' || startKw.includes('当前位置')) { if (!startKw || startKw === '我的位置' || startKw.includes('当前位置')) {
if (!currentLng || !currentLat) { if (!currentLng || !currentLat) {
if (window.flutter_inappwebview) { if (window.flutter_inappwebview) window.flutter_inappwebview.callHandler('requestLocation');
window.flutter_inappwebview.callHandler('requestLocation');
}
alert("正在获取定位,请稍后..."); alert("正在获取定位,请稍后...");
return; return;
} }
@@ -601,10 +619,17 @@
}); });
} }
// 2. 处理终点逻辑 // 2. 终点逻辑:如果有传入坐标,则直接使用坐标导航,成功率最高
if (destLoc) {
points.push({
keyword: endKw,
location: destLoc // 关键:使用精确坐标
});
} else {
points.push({ points.push({
keyword: endKw keyword: endKw
}); });
}
// 3. 发起搜索 // 3. 发起搜索
driving.search(points, function (status, result) { driving.search(points, function (status, result) {
@@ -613,10 +638,12 @@
var panel = document.getElementById('panel'); var panel = document.getElementById('panel');
panel.style.display = 'block'; panel.style.display = 'block';
document.body.classList.add('panel-active'); document.body.classList.add('panel-active');
} else {
console.log('JS: 规划失败', result);
alert("规划失败,请检查起终点名称");
} }
// else {
// console.error('JS: 规划失败', result);
// // 如果坐标规划都失败了,通常是由于起终点距离过近或政策限制(如货车禁行)
// alert("路径规划未成功,请尝试微调起终点");
// }
}); });
} }

View File

@@ -253,7 +253,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
if (_debounce?.isActive ?? false) { if (_debounce?.isActive ?? false) {
return; return;
} }
_debounce = Timer(const Duration(seconds: 1), () {}); _debounce = Timer(const Duration(milliseconds: 200), () {});
showLoading("加载中"); showLoading("加载中");
@@ -393,7 +393,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
// 创建一个每1分钟执行一次的周期性定时器 // 创建一个每1分钟执行一次的周期性定时器
_refreshTimer = Timer.periodic(const Duration(minutes: 1), (timer) { _refreshTimer = Timer.periodic(const Duration(minutes: 1), (timer) {
getSiteList(); getSiteList(showloading: false);
}); });
} }
@@ -521,7 +521,7 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
updateUi(); updateUi();
} }
void getSiteList() async { void getSiteList({showloading = true}) async {
if (StorageService.to.phone == "13888888888") { if (StorageService.to.phone == "13888888888") {
//该账号给stationOptions手动添加一个数据 //该账号给stationOptions手动添加一个数据
final testStation = StationModel( final testStation = StationModel(
@@ -546,7 +546,9 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
} }
try { try {
if(showloading){
showLoading("加氢站数据加载中"); showLoading("加氢站数据加载中");
}
var responseData = await HttpService.to.get( var responseData = await HttpService.to.get(
"appointment/station/queryHydrogenSiteInfo", "appointment/station/queryHydrogenSiteInfo",