修复 点击作业参数 查看详情 有些账号 点击不了的问题

This commit is contained in:
mmc
2026-03-10 16:09:08 +08:00
parent 137c28d0f0
commit db65fbab6f
2 changed files with 12 additions and 21 deletions

View File

@@ -16,9 +16,7 @@ class DeviceHostrityWorkRepositoryImpl implements DeviceHostrityWorkRepositoryRe
DeviceHostrityWorkRepositoryImpl({required this.client, required this.userStorage});
@override
Future<Either<DeviceFailure, List<DeviceRunStatisticsEntity>>> getDeviceHRunStatistics({
required String deviceId,
}) async {
Future<Either<DeviceFailure, List<DeviceRunStatisticsEntity>>> getDeviceHRunStatistics({required String deviceId}) async {
try {
debugPrint('开始获取用户信息...');
final user = await userStorage.getUser();
@@ -31,12 +29,7 @@ class DeviceHostrityWorkRepositoryImpl implements DeviceHostrityWorkRepositoryRe
final response = await client.get(
'https://serviceri.satabot.com/iot/device/getDeviceRunStatistics?deviceId=$deviceId',
options: Options(
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer $token',
},
),
options: Options(headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer $token'}),
);
if (response.statusCode == 200) {
@@ -44,13 +37,16 @@ class DeviceHostrityWorkRepositoryImpl implements DeviceHostrityWorkRepositoryRe
if (jsonBody['code'] == 200) {
final List<dynamic> data = jsonBody['data'];
final List<DeviceRunStatisticsEntity> statistics = data
.map((item) => DeviceRunStatisticsEntity(
startTime: item['startTime'] as String, // 开始时间
endTime: item['endTime'] as String, // 结束时间
workArea: (item['workArea'] as num).toDouble(), // 工作面积
distance: item['distance'] != null ? (item['distance'] as num).toDouble() : null, // 工作距离
time: item['time'] as int, // 花费时间
)).toList();
.map(
(item) => DeviceRunStatisticsEntity(
startTime: item['startTime'] as String, // 开始时间
endTime: item['endTime'] as String, // 结束时间
workArea: (item['workArea'] as num).toDouble(), // 工作面积
distance: item['distance'] != null ? (item['distance'] as num).toDouble() : null, // 工作距离
time: (item['time'] as num?)?.toInt() ?? 0,
),
)
.toList();
return Right(statistics);
} else {
debugPrint('服务器返回错误码: ${jsonBody['code']}');
@@ -68,5 +64,4 @@ class DeviceHostrityWorkRepositoryImpl implements DeviceHostrityWorkRepositoryRe
return Left(DeviceFailure.unknownError(message: e.toString()));
}
}
}

View File

@@ -22,21 +22,17 @@ class _DjPageState extends State<DjPage> {
controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
// 监听 H5 消息
..addJavaScriptChannel(
'MapChannel',
onMessageReceived: (JavaScriptMessage message) {
_handleJsMessage(message.message);
},
)
// 加载网页
..loadRequest(Uri.parse(url));
}
/// 处理 H5 返回的数据
void _handleJsMessage(String msg) {
debugPrint("H5消息: $msg");
try {
final data = jsonDecode(msg);