加氢站默认选择,演示账号数据

附件默认显示,详情
This commit is contained in:
2025-12-16 11:58:00 +08:00
parent 4ace3c9f27
commit 9ce46a0c7d
9 changed files with 231 additions and 59 deletions

View File

@@ -809,6 +809,25 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
}
void getSiteList() async {
if(StorageService.to.phone == "13344444444"){
//该账号给stationOptions手动添加一个数据
final testStation = StationModel(
hydrogenId: '1142167389150920704',
name: '羚牛氢能演示加氢站',
address: '上海市嘉定区于田南路111号于田大厦',
price: '35.00', // 价格
siteStatusName: '营运中', // 状态
isSelect: 1, // 默认可选
);
// 使用 assignAll 可以确保列表只包含这个测试数据
stationOptions.assignAll([testStation]);
if (stationOptions.isNotEmpty) {
selectedStationId.value = stationOptions.first.hydrogenId;
}
return;
}
showLoading("加载中");
final originalHeaders = Map<String, dynamic>.from(HttpService.to.dio.options.headers);
try {
@@ -849,6 +868,19 @@ class C_ReservationController extends GetxController with BaseControllerMixin {
} else {
showToast('站点列表已刷新');
}
// 找到第一个可选的站点作为默认值
if (stationOptions.isNotEmpty) {
final firstSelectable = stationOptions.firstWhere(
(station) => station.isSelect == 1,
orElse: () => stationOptions.first, // 降级:如果没有可选的,就用第一个
);
selectedStationId.value = firstSelectable.hydrogenId;
} else {
// 如果列表为空,确保 selectedStationId 也为空
selectedStationId.value = null;
}
} catch (e) {
showToast('数据异常');
}