优化+摄像头+扫码绑定
This commit is contained in:
@@ -8,7 +8,7 @@ abstract class BindDeviceDatasource {
|
||||
Future<void> bindDevice({
|
||||
required List<String> deviceIds,
|
||||
required int orgId,
|
||||
required int siteId,
|
||||
required int userId,
|
||||
int? siteId,
|
||||
int? userId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -105,11 +105,13 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
}
|
||||
|
||||
DeviceDataModel _parseDeviceFromJson(Map<String, dynamic> json) {
|
||||
// 在线状态:使用 onlineStatus 字段(1=在线, 0=离线)
|
||||
final onlineStatus = json['onlineStatus'] ?? 0;
|
||||
return DeviceDataModel(
|
||||
deviceId: json['deviceId']?.toString() ?? '',
|
||||
name: json['deviceName'] ?? json['name'] ?? '',
|
||||
type: json['deviceTypeName'] ?? json['type'] ?? '未知设备',
|
||||
status: _getStatusText(json['status'] ?? 0),
|
||||
status: onlineStatus == 1 ? '在线' : '离线',
|
||||
power: (json['power'] as num?)?.toDouble() ?? 0,
|
||||
todayEnergy: (json['todayEnergy'] as num?)?.toDouble() ?? 0,
|
||||
temperature: (json['temperature'] as num?)?.toDouble(),
|
||||
|
||||
@@ -127,18 +127,17 @@ class BindDeviceDatasourceImpl implements BindDeviceDatasource {
|
||||
Future<void> bindDevice({
|
||||
required List<String> deviceIds,
|
||||
required int orgId,
|
||||
required int siteId,
|
||||
required int userId,
|
||||
int? siteId,
|
||||
int? userId,
|
||||
}) async {
|
||||
final token = await _getToken();
|
||||
final Map<String, dynamic> body = {'deviceIds': deviceIds, 'orgId': orgId};
|
||||
if (siteId != null) body['siteId'] = siteId;
|
||||
if (userId != null) body['userId'] = userId;
|
||||
|
||||
final response = await _dio.post(
|
||||
HttpApiConsts.bindDevice,
|
||||
data: {
|
||||
'deviceIds': deviceIds,
|
||||
'orgId': orgId,
|
||||
'siteId': siteId,
|
||||
'userId': userId,
|
||||
},
|
||||
data: body,
|
||||
options: Options(
|
||||
headers: {
|
||||
'Authorization': token != null ? 'Bearer $token' : '',
|
||||
|
||||
Reference in New Issue
Block a user