Merge branch 'master' of gitee.com:starlock-cn/app-starlock
This commit is contained in:
commit
8d34a727f8
@ -41,7 +41,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
||||
}
|
||||
|
||||
GetMaterialApp _initMaterialApp() => GetMaterialApp(
|
||||
enableLog: false,
|
||||
// enableLog: false,
|
||||
title: F.navTitle,
|
||||
navigatorObservers: [AppRouteObserver().routeObserver],
|
||||
translations: TranslationMessage(),
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:star_lock/debug/debug_console.dart';
|
||||
@ -20,7 +21,7 @@ class AppLog {
|
||||
msg = '----->>> $msg';
|
||||
}
|
||||
DebugConsole.info(msg);
|
||||
print(msg);
|
||||
Get.log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,6 +69,7 @@ class LockDetailLogic extends BaseGetXController {
|
||||
case 0x00:
|
||||
//成功
|
||||
// _showFullScreenOverlay(Get.context!);
|
||||
cancelBlueConnetctToastTimer();
|
||||
|
||||
state.iSClosedUnlockSuccessfulPopup.value = true;
|
||||
if (state.closedUnlockSuccessfulTimer != null) {
|
||||
@ -86,7 +87,14 @@ class LockDetailLogic extends BaseGetXController {
|
||||
int power = reply.data[7];
|
||||
state.electricQuantity.value = power;
|
||||
|
||||
cancelBlueConnetctToastTimer();
|
||||
// 备用电量
|
||||
if(state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1){
|
||||
int powerStandby = reply.data[9];
|
||||
state.electricQuantityStandby.value = powerStandby;
|
||||
}
|
||||
// 更新电量
|
||||
uploadElectricQuantityRequest();
|
||||
|
||||
getLockRecordLastUploadDataTime();
|
||||
state.openLockBtnState.value = 0;
|
||||
|
||||
@ -431,6 +439,20 @@ class LockDetailLogic extends BaseGetXController {
|
||||
}
|
||||
}
|
||||
|
||||
//电量更新请求
|
||||
Future<void> uploadElectricQuantityRequest() async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(
|
||||
electricQuantity:state.electricQuantity.value.toString(),
|
||||
electricQuantityStandby: state.electricQuantityStandby.value.toString(),
|
||||
lockId: state.keyInfos.value.lockId.toString()
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 普通用户接收电子钥匙之后 更新锁用户NO
|
||||
// void _updateLockUserNo() async {
|
||||
// LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(
|
||||
|
||||
@ -529,30 +529,33 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
FlavorsImg(
|
||||
child: Image.asset(
|
||||
showElectricIcon(state.electricQuantity.value),
|
||||
width: 30.w,
|
||||
height: 24.w),
|
||||
),
|
||||
SizedBox(width: 2.w),
|
||||
Text("--%",
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.darkGrayTextColor)),
|
||||
SizedBox(width: 2.w),
|
||||
FlavorsImg(
|
||||
child: Icon(
|
||||
Icons.info, // 使用内置的 warning 图标,它是一个叹号
|
||||
color: AppColors.mainColor, // 设置图标颜色为红色
|
||||
size: 25.w, // 设置图标大小为 30
|
||||
Visibility(
|
||||
visible: state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
FlavorsImg(
|
||||
child: Image.asset(
|
||||
showElectricIcon(state.electricQuantityStandby.value),
|
||||
width: 30.w,
|
||||
height: 24.w),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.w),
|
||||
],
|
||||
SizedBox(width: 2.w),
|
||||
Text("${state.electricQuantityStandby.value}%",
|
||||
style: TextStyle(
|
||||
fontSize: 18.sp,
|
||||
color: AppColors.darkGrayTextColor)),
|
||||
SizedBox(width: 2.w),
|
||||
FlavorsImg(
|
||||
child: Icon(
|
||||
Icons.info, // 使用内置的 warning 图标,它是一个叹号
|
||||
color: AppColors.mainColor, // 设置图标颜色为红色
|
||||
size: 25.w, // 设置图标大小为 30
|
||||
),
|
||||
),
|
||||
SizedBox(width: 20.w),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
))
|
||||
|
||||
@ -22,6 +22,7 @@ class LockDetailState {
|
||||
var isAttendance = 0.obs; // 是否开启考勤
|
||||
var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网
|
||||
var electricQuantity = 0.obs; // 电量
|
||||
var electricQuantityStandby = 0.obs; // 备用电池电量
|
||||
var isOpenPassageMode = 0.obs; // 是否开启了常开模式
|
||||
var lockAlias = "".obs; // 锁名字
|
||||
|
||||
|
||||
@ -21,10 +21,12 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
final UploadElectricQuantityState state = UploadElectricQuantityState();
|
||||
|
||||
//电量更新请求
|
||||
Future<void> uploadElectricQuantityRequest(String electricQuantity) async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to
|
||||
.uploadElectricQuantity(
|
||||
electricQuantity, state.lockSetInfoData.value.lockId.toString());
|
||||
Future<void> uploadElectricQuantityRequest(String electricQuantity, String electricQuantityStandby) async {
|
||||
KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(
|
||||
electricQuantity:electricQuantity,
|
||||
electricQuantityStandby: electricQuantityStandby,
|
||||
lockId: state.lockSetInfoData.value.lockId.toString()
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast("锁电量更新成功".tr, something: () {
|
||||
eventBus
|
||||
@ -95,13 +97,15 @@ class UploadElectricQuantityLogic extends BaseGetXController {
|
||||
|
||||
// 电池剩余电量
|
||||
var battRemCap = reply.data[132];
|
||||
state.lockSetInfoData.value.lockBasicInfo!.electricQuantity =
|
||||
battRemCap;
|
||||
state.uploadElectricQuantityDate.value =
|
||||
DateTime.now().millisecondsSinceEpoch;
|
||||
state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate =
|
||||
DateTime.now().millisecondsSinceEpoch;
|
||||
uploadElectricQuantityRequest(battRemCap.toString());
|
||||
state.lockSetInfoData.value.lockBasicInfo!.electricQuantity = battRemCap;
|
||||
|
||||
// 备用电池剩余电量
|
||||
var battRemCapStandby = reply.data[133];
|
||||
state.lockSetInfoData.value.lockBasicInfo!.electricQuantityStandby = battRemCapStandby;
|
||||
|
||||
state.uploadElectricQuantityDate.value = DateTime.now().millisecondsSinceEpoch;
|
||||
state.lockSetInfoData.value.lockBasicInfo!.electricQuantityDate = DateTime.now().millisecondsSinceEpoch;
|
||||
uploadElectricQuantityRequest(battRemCap.toString(), battRemCapStandby.toString());
|
||||
break;
|
||||
case 0x06:
|
||||
//无权限
|
||||
|
||||
@ -55,20 +55,23 @@ class _UploadElectricQuantityPageState extends State<UploadElectricQuantityPage>
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"${"电池1".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo!.value.electricQuantity ?? ""}%",
|
||||
"${"电池1".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo.value.electricQuantity ?? ""}%",
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
)),
|
||||
],
|
||||
)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"${"电池2".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:--%",
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
)),
|
||||
],
|
||||
Visibility(
|
||||
visible: state.lockSetInfoData.value.lockFeature!.isSupportBackupBattery == 1,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"${"电池2".tr}:${TranslationLoader.lanKeys!.electricQuantity!.tr}:${state.lockBasicInfo.value.electricQuantityStandby ?? ""}%",
|
||||
style: TextStyle(fontSize: 20.sp),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10.h),
|
||||
Obx(() => Row(
|
||||
|
||||
@ -145,6 +145,7 @@ class LockFeature {
|
||||
int? motorTorsion;
|
||||
int? stayWarn;
|
||||
int? abnormalWarn;
|
||||
int? isSupportBackupBattery; //人脸开关 0:关闭 1:开启
|
||||
|
||||
LockFeature({
|
||||
this.password,
|
||||
@ -200,6 +201,7 @@ class LockFeature {
|
||||
this.motorTorsion,
|
||||
this.stayWarn,
|
||||
this.abnormalWarn,
|
||||
this.isSupportBackupBattery,
|
||||
});
|
||||
|
||||
LockFeature.fromJson(Map<String, dynamic> json) {
|
||||
@ -256,6 +258,7 @@ class LockFeature {
|
||||
motorTorsion = json['motorTorsion'];
|
||||
stayWarn = json['stayWarn'];
|
||||
abnormalWarn = json['abnormalWarn'];
|
||||
isSupportBackupBattery = json['isSupportBackupBattery'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -313,6 +316,7 @@ class LockFeature {
|
||||
data['motorTorsion'] = motorTorsion;
|
||||
data['stayWarn'] = stayWarn;
|
||||
data['abnormalWarn'] = abnormalWarn;
|
||||
data['isSupportBackupBattery'] = isSupportBackupBattery;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -323,6 +327,7 @@ class LockBasicInfo {
|
||||
int? keyId;
|
||||
String? model;
|
||||
int? electricQuantity;
|
||||
int? electricQuantityStandby;
|
||||
int? indate;
|
||||
int? isLockOwner;
|
||||
String? lockAlias;
|
||||
@ -349,6 +354,7 @@ class LockBasicInfo {
|
||||
this.keyId,
|
||||
this.model,
|
||||
this.electricQuantity,
|
||||
this.electricQuantityStandby,
|
||||
this.indate,
|
||||
this.isLockOwner,
|
||||
this.lockAlias,
|
||||
@ -375,6 +381,7 @@ class LockBasicInfo {
|
||||
keyId = json['keyId'];
|
||||
model = json['model'];
|
||||
electricQuantity = json['electricQuantity'];
|
||||
electricQuantityStandby = json['electricQuantityStandby'];
|
||||
indate = json['indate'];
|
||||
isLockOwner = json['isLockOwner'];
|
||||
lockAlias = json['lockAlias'];
|
||||
@ -408,6 +415,7 @@ class LockBasicInfo {
|
||||
data['keyId'] = keyId;
|
||||
data['model'] = model;
|
||||
data['electricQuantity'] = electricQuantity;
|
||||
data['electricQuantityStandby'] = electricQuantityStandby;
|
||||
data['indate'] = indate;
|
||||
data['isLockOwner'] = isLockOwner;
|
||||
data['lockAlias'] = lockAlias;
|
||||
|
||||
@ -290,6 +290,7 @@ class LockFeature {
|
||||
int? bluetoothRemoteControl;
|
||||
int? videoIntercom;
|
||||
int? isSupportCatEye;
|
||||
int? isSupportBackupBattery;
|
||||
LockFeature(
|
||||
{this.password,
|
||||
this.icCard,
|
||||
@ -300,7 +301,8 @@ class LockFeature {
|
||||
this.d3Face,
|
||||
this.bluetoothRemoteControl,
|
||||
this.videoIntercom,
|
||||
this.isSupportCatEye});
|
||||
this.isSupportCatEye,
|
||||
this.isSupportBackupBattery});
|
||||
|
||||
LockFeature.fromJson(Map<String, dynamic> json) {
|
||||
password = json['password'];
|
||||
@ -313,6 +315,7 @@ class LockFeature {
|
||||
bluetoothRemoteControl = json['bluetoothRemoteControl'];
|
||||
videoIntercom = json['videoIntercom'];
|
||||
isSupportCatEye = json['isSupportCatEye'];
|
||||
isSupportBackupBattery = json['isSupportBackupBattery'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -327,6 +330,7 @@ class LockFeature {
|
||||
data['bluetoothRemoteControl'] = bluetoothRemoteControl;
|
||||
data['videoIntercom'] = videoIntercom;
|
||||
data['isSupportCatEye'] = isSupportCatEye;
|
||||
data['isSupportBackupBattery'] = isSupportBackupBattery;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,13 +190,18 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
state.lockInfo["electricQuantity"] = battRemCap;
|
||||
AppLog.log("电池剩余电量 battRemCap:$battRemCap");
|
||||
|
||||
// 备用电池剩余电量
|
||||
var battRemCapStandby = reply.data[133];
|
||||
state.lockInfo["electricQuantityStandby"] = battRemCapStandby;
|
||||
AppLog.log("电池剩余电量 battRemCap:$battRemCap");
|
||||
|
||||
// 重置次数
|
||||
var restoreCounter = reply.data.sublist(133, 135);
|
||||
var restoreCounter = reply.data.sublist(134, 136);
|
||||
state.lockInfo["restoreCount"] = restoreCounter[0] * 256 + restoreCounter[1];
|
||||
AppLog.log("重置次数 restoreCounter:${restoreCounter[0] * 256 + restoreCounter[1]}");
|
||||
|
||||
// 重置时间
|
||||
var restoreDate = reply.data.sublist(135, 139);
|
||||
var restoreDate = reply.data.sublist(136, 140);
|
||||
int restoreDateValue = ((0xff & restoreDate[(0)]) << 24 |
|
||||
(0xff & restoreDate[1]) << 16 |
|
||||
(0xff & restoreDate[2]) << 8 |
|
||||
@ -206,13 +211,13 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
AppLog.log("重置时间 restoreDateValue:$restoreDateValue");
|
||||
|
||||
// 主控芯片型号
|
||||
var icPartNo = reply.data.sublist(139, 149);
|
||||
var icPartNo = reply.data.sublist(140, 150);
|
||||
var icPartNoStr = utf8String(icPartNo);
|
||||
state.lockInfo["icPartNo"] = icPartNoStr;
|
||||
AppLog.log("主控芯片型号 icPartNoStr:$icPartNoStr");
|
||||
|
||||
// 有效时间
|
||||
var indate = reply.data.sublist(149, 153);
|
||||
var indate = reply.data.sublist(150, 154);
|
||||
int indateValue = ((0xff & indate[(0)]) << 24 |
|
||||
(0xff & indate[1]) << 16 |
|
||||
(0xff & indate[2]) << 8 |
|
||||
@ -222,14 +227,14 @@ class NearbyLockLogic extends BaseGetXController {
|
||||
AppLog.log("有效时间 indateValue:$indateValue");
|
||||
|
||||
// mac地址
|
||||
var macAddress = reply.data.sublist(153, 173);
|
||||
var macAddress = reply.data.sublist(154, 174);
|
||||
var macAddressStr = utf8String(macAddress);
|
||||
state.lockInfo["mac"] = macAddressStr;
|
||||
AppLog.log("mac地址 macAddressStr:$macAddressStr");
|
||||
|
||||
var index = 173;
|
||||
var index = 174;
|
||||
// 锁特征值字符串长度
|
||||
var featureValueLength = reply.data[173];
|
||||
var featureValueLength = reply.data[174];
|
||||
AppLog.log("锁特征值字符串长度 featureValueLength:$featureValueLength");
|
||||
|
||||
// 锁特征值说明(本机能支持的功能)
|
||||
|
||||
@ -169,12 +169,14 @@ class ApiProvider extends BaseProvider {
|
||||
|
||||
Future<Response> uploadElectricQuantity(
|
||||
String electricQuantity,
|
||||
String electricQuantityStandby,
|
||||
String lockId,
|
||||
) =>
|
||||
post(
|
||||
uploadElectricQuantityURL.toUrl,
|
||||
jsonEncode({
|
||||
'electricQuantity': electricQuantity,
|
||||
'electricQuantityStandby': electricQuantityStandby,
|
||||
'lockId': lockId,
|
||||
}));
|
||||
|
||||
|
||||
@ -317,9 +317,13 @@ class ApiRepository {
|
||||
|
||||
//锁电量更新
|
||||
Future<KeyOperationRecordEntity> uploadElectricQuantity(
|
||||
String electricQuantity, String lockId) async {
|
||||
{
|
||||
String? electricQuantity,
|
||||
String? electricQuantityStandby,
|
||||
String? lockId
|
||||
}) async {
|
||||
final res =
|
||||
await apiProvider.uploadElectricQuantity(electricQuantity, lockId);
|
||||
await apiProvider.uploadElectricQuantity(electricQuantity!, electricQuantityStandby!, lockId!);
|
||||
return KeyOperationRecordEntity.fromJson(res.body);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user