修复 点击作业参数 查看详情 有些账号 点击不了的问题
This commit is contained in:
@@ -16,9 +16,7 @@ class DeviceHostrityWorkRepositoryImpl implements DeviceHostrityWorkRepositoryRe
|
|||||||
DeviceHostrityWorkRepositoryImpl({required this.client, required this.userStorage});
|
DeviceHostrityWorkRepositoryImpl({required this.client, required this.userStorage});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Either<DeviceFailure, List<DeviceRunStatisticsEntity>>> getDeviceHRunStatistics({
|
Future<Either<DeviceFailure, List<DeviceRunStatisticsEntity>>> getDeviceHRunStatistics({required String deviceId}) async {
|
||||||
required String deviceId,
|
|
||||||
}) async {
|
|
||||||
try {
|
try {
|
||||||
debugPrint('开始获取用户信息...');
|
debugPrint('开始获取用户信息...');
|
||||||
final user = await userStorage.getUser();
|
final user = await userStorage.getUser();
|
||||||
@@ -31,12 +29,7 @@ class DeviceHostrityWorkRepositoryImpl implements DeviceHostrityWorkRepositoryRe
|
|||||||
|
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
'https://serviceri.satabot.com/iot/device/getDeviceRunStatistics?deviceId=$deviceId',
|
'https://serviceri.satabot.com/iot/device/getDeviceRunStatistics?deviceId=$deviceId',
|
||||||
options: Options(
|
options: Options(headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer $token'}),
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Authorization': 'Bearer $token',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
@@ -44,13 +37,16 @@ class DeviceHostrityWorkRepositoryImpl implements DeviceHostrityWorkRepositoryRe
|
|||||||
if (jsonBody['code'] == 200) {
|
if (jsonBody['code'] == 200) {
|
||||||
final List<dynamic> data = jsonBody['data'];
|
final List<dynamic> data = jsonBody['data'];
|
||||||
final List<DeviceRunStatisticsEntity> statistics = data
|
final List<DeviceRunStatisticsEntity> statistics = data
|
||||||
.map((item) => DeviceRunStatisticsEntity(
|
.map(
|
||||||
startTime: item['startTime'] as String, // 开始时间
|
(item) => DeviceRunStatisticsEntity(
|
||||||
endTime: item['endTime'] as String, // 结束时间
|
startTime: item['startTime'] as String, // 开始时间
|
||||||
workArea: (item['workArea'] as num).toDouble(), // 工作面积
|
endTime: item['endTime'] as String, // 结束时间
|
||||||
distance: item['distance'] != null ? (item['distance'] as num).toDouble() : null, // 工作距离
|
workArea: (item['workArea'] as num).toDouble(), // 工作面积
|
||||||
time: item['time'] as int, // 花费时间
|
distance: item['distance'] != null ? (item['distance'] as num).toDouble() : null, // 工作距离
|
||||||
)).toList();
|
time: (item['time'] as num?)?.toInt() ?? 0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
return Right(statistics);
|
return Right(statistics);
|
||||||
} else {
|
} else {
|
||||||
debugPrint('服务器返回错误码: ${jsonBody['code']}');
|
debugPrint('服务器返回错误码: ${jsonBody['code']}');
|
||||||
@@ -68,5 +64,4 @@ class DeviceHostrityWorkRepositoryImpl implements DeviceHostrityWorkRepositoryRe
|
|||||||
return Left(DeviceFailure.unknownError(message: e.toString()));
|
return Left(DeviceFailure.unknownError(message: e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,21 +22,17 @@ class _DjPageState extends State<DjPage> {
|
|||||||
|
|
||||||
controller = WebViewController()
|
controller = WebViewController()
|
||||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
// 监听 H5 消息
|
|
||||||
..addJavaScriptChannel(
|
..addJavaScriptChannel(
|
||||||
'MapChannel',
|
'MapChannel',
|
||||||
onMessageReceived: (JavaScriptMessage message) {
|
onMessageReceived: (JavaScriptMessage message) {
|
||||||
_handleJsMessage(message.message);
|
_handleJsMessage(message.message);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
// 加载网页
|
|
||||||
..loadRequest(Uri.parse(url));
|
..loadRequest(Uri.parse(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 处理 H5 返回的数据
|
/// 处理 H5 返回的数据
|
||||||
void _handleJsMessage(String msg) {
|
void _handleJsMessage(String msg) {
|
||||||
debugPrint("H5消息: $msg");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final data = jsonDecode(msg);
|
final data = jsonDecode(msg);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user