diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index 54aa67f8..56c2c03f 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -1,4 +1,3 @@ -import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:star_lock/common/safetyVerification/safetyVerification_binding.dart'; import 'package:star_lock/login/register/starLock_register_binding.dart'; @@ -20,7 +19,7 @@ import 'package:star_lock/mine/minePersonInfo/minePersonInfoViewSafetyProblem/mi import 'package:star_lock/mine/mineSet/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/adminDetailChangeDate_page.dart'; import 'package:star_lock/mine/mineSet/authorizedAdministrator/administratorDetails/administratorDetails_page.dart'; -import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList_page.dart'; +import 'package:star_lock/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockChangeDate_page.dart'; import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockList_page.dart'; import 'package:star_lock/mine/mineSet/mineSet/mineSet_page.dart'; @@ -130,7 +129,8 @@ import 'mine/mineSet/authorityManagement/authorityManagement_page.dart'; import 'mine/mineSet/authorityManagement/getDeviceList_page.dart'; import 'mine/mineSet/authorityManagement/getNameList_page.dart'; import 'mine/mineSet/hideInvalidUnlockPermissions/hideInvalidUnlockPermissions_page.dart'; -import 'mine/mineSet/lockGroup/lockItemList_page.dart'; +import 'mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart'; +import 'mine/mineSet/lockGroup/lockGroupDetailList/lockItemList_page.dart'; import 'mine/mineSet/lockScreen/lockScreen_page.dart'; import 'mine/mineSet/lockUserManage/lockUserManageList/lockUserManageList_page.dart'; import 'mine/mineSet/lockUserManage/ownedKeyList/ownedKeyList_page.dart'; @@ -201,6 +201,7 @@ abstract class Routers { '/UploadElectricQuantityPage'; // 更新锁电量 static const editLockNamePage = '/EditLockNamePage'; // 修改锁名字 static const lockSeletGroupingPage = '/LockSeletGroupingPage'; // 锁选择分组 + static const groupEditLockPage = '/GroupEditLockPage'; // 编辑锁分组里面的锁 static const adminOpenLockPasswordPage = '/AdminOpenLockPasswordPage'; // 管理员开锁密码 static const wirelessKeyboardPage = '/WirelessKeyboardPage'; // 蓝牙键盘 @@ -756,6 +757,8 @@ abstract class AppRouters { page: () => const LockUserManageListPage()), GetPage( name: Routers.lockGroupListPage, page: () => const LockGroupListPage()), + GetPage( + name: Routers.groupEditLockPage, page: () => const GroupEditLockPage()), GetPage( name: Routers.lockItemListPage, page: () => const LockItemListPage()), GetPage( diff --git a/star_lock/lib/blue/blue_manage.dart b/star_lock/lib/blue/blue_manage.dart index 4c669d50..773bf791 100644 --- a/star_lock/lib/blue/blue_manage.dart +++ b/star_lock/lib/blue/blue_manage.dart @@ -1,15 +1,11 @@ import 'dart:async'; -import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:star_lock/blue/sender_manage.dart'; -import '../app_settings/app_settings.dart'; -import '../tools/storage.dart'; import '../tools/toast.dart'; -import 'io_tool/io_manager.dart'; import 'io_tool/io_model.dart'; import 'io_tool/io_tool.dart'; import 'io_tool/manager_event_bus.dart'; @@ -218,6 +214,10 @@ class BlueManage{ // 重新连接 Future judgeReconnect(String deviceMAC, String deviceName, ConnectStateCallBack? connectStateCallBack, {bool isShowLoading = true}) async { // print("11111111$deviceConnectionState"); + if(deviceMAC.isEmpty){ + Toast.show(msg: "未连接到设备,请确保在设备附近,设备未被连接,设备已打开"); + // return; + } if(deviceConnectionState == DeviceConnectionState.connected){ // print("2222222:$deviceConnectionState"); if(isShowLoading){ @@ -369,7 +369,6 @@ class BlueManage{ } } - Future writeCharacteristicWithoutResponse( QualifiedCharacteristic characteristic, List value) async { try { diff --git a/star_lock/lib/blue/io_protocol/io_readAdminPassword.dart b/star_lock/lib/blue/io_protocol/io_readAdminPassword.dart new file mode 100644 index 00000000..aa72c7d3 --- /dev/null +++ b/star_lock/lib/blue/io_protocol/io_readAdminPassword.dart @@ -0,0 +1,121 @@ + +import 'dart:convert'; + +import '../io_tool/io_tool.dart'; +import '../sm4Encipher/sm4.dart'; +import '../io_reply.dart'; +import '../io_sender.dart'; +import '../io_type.dart'; +import 'package:crypto/crypto.dart' as crypto; + +///TODO:读取管理员密码 +class SenderReadAdminPasswordCommand extends SenderProtocol { + + String? keyID; + String? userID; + int? role; + int? pwdNum; + int? pwdNo; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; + + SenderReadAdminPasswordCommand({ + this.keyID, + this.userID, + this.role, + this.pwdNum, + this.pwdNo, + this.token, + this.needAuthor, + this.publicKey, + this.privateKey, + }) : super(CommandType.generalExtendedCommond); + + @override + List messageDetail() { + List data = []; + List subData = []; + List ebcData = []; + + // 指令类型 + int type = commandType!.typeValue; + double typeDouble = type / 256; + int type1 = typeDouble.toInt(); + int type2 = type % 256; + data.add(type1); + data.add(type2); + + // 子命令类型 + data.add(74); + + // keyID 40 + int keyIDLength = utf8.encode(keyID!).length; + // print("${commandType!.typeValue}LockIDLength:$lockIDLength utf8.encode(lockID!)${utf8.encode(lockID!)}"); + subData.addAll(utf8.encode(keyID!)); + subData = getFixedLengthList(subData, 40 - keyIDLength); + + //userID 20 + int userIDLength = utf8.encode(userID!).length; + // print("${commandType!.typeValue}IDLength:$authUserIDLength utf8.encode(authUserID!)${utf8.encode(authUserID!)}"); + subData.addAll(utf8.encode(userID!)); + subData = getFixedLengthList(subData, 20 - userIDLength); + + // Role + subData.add(role!); + + // PwdNum + subData.add(pwdNum!); + + // PwdNo + subData.add(pwdNo!); + + if(needAuthor == 0){ + //AuthCodeLen 1 + subData.add(0); + } else { + List authCodeData = []; + + //authUserID + authCodeData.addAll(utf8.encode(userID!)); + + //KeyID + authCodeData.addAll(utf8.encode(keyID!)); + + //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 + authCodeData.addAll(token!); + + authCodeData.addAll(publicKey!); + + print("${commandType!.typeValue}-authCodeData:$authCodeData"); + + // 把KeyID、authUserID、时间戳、公钥通过md5加密之后就是authCode + var authCode = crypto.md5.convert(authCodeData); + + subData.add(authCode.bytes.length); + subData.addAll(authCode.bytes); + } + + data.add(subData.length); + data.addAll(subData); + + if ((data.length % 16) != 0) { + int add = (16 - data.length % 16); + for (int i = 0; i < add; i++) { + data.add(0); + } + } + print("${commandType!.typeName} SM4Data:$data"); + // 拿到数据之后通过LockId进行SM4 ECB加密 key:544d485f633335373034383064613864 + ebcData = SM4.encrypt(data, key: privateKey, mode: SM4CryptoMode.ECB); + return ebcData; + } +} + +class SenderReadAdminPasswordReply extends Reply { + SenderReadAdminPasswordReply.parseData(CommandType commandType, List dataDetail) + : super.parseData(commandType, dataDetail) { + data = dataDetail; + } +} diff --git a/star_lock/lib/blue/io_reply.dart b/star_lock/lib/blue/io_reply.dart index 62adcb7e..05e9b7c2 100644 --- a/star_lock/lib/blue/io_reply.dart +++ b/star_lock/lib/blue/io_reply.dart @@ -1,5 +1,7 @@ import 'io_type.dart'; + + abstract class Reply{ CommandType? commandType; diff --git a/star_lock/lib/blue/io_tool/io_tool.dart b/star_lock/lib/blue/io_tool/io_tool.dart index 6b7d0797..3d20b000 100644 --- a/star_lock/lib/blue/io_tool/io_tool.dart +++ b/star_lock/lib/blue/io_tool/io_tool.dart @@ -37,7 +37,7 @@ int _hexToInt(String hex) { // a..f val += (hexDigit - 87) * (1 << (4 * (len - 1 - i))); } else { - throw new FormatException("Invalid hexadecimal value"); + throw FormatException("Invalid hexadecimal value"); } } return val; diff --git a/star_lock/lib/blue/reciver_data.dart b/star_lock/lib/blue/reciver_data.dart index 647b8b00..9776e72b 100644 --- a/star_lock/lib/blue/reciver_data.dart +++ b/star_lock/lib/blue/reciver_data.dart @@ -8,6 +8,7 @@ import 'package:star_lock/blue/io_protocol/io_deletUser.dart'; import 'package:star_lock/blue/io_protocol/io_editUser.dart'; import 'package:star_lock/blue/io_protocol/io_factoryDataReset.dart'; import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart'; +import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart'; import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsNoParameters.dart'; import 'package:star_lock/blue/io_protocol/io_readSupportFunctionsWithParameters.dart'; import 'package:star_lock/blue/io_protocol/io_referEventRecordTime.dart'; @@ -299,6 +300,12 @@ class CommandReciverManager { reply = ReadSupportFunctionsWithParametersReply.parseData(commandType, data); } break; + case 74: + { + // 读取管理员密码 + reply = SenderReadAdminPasswordReply.parseData(commandType, data); + } + break; } } break; diff --git a/star_lock/lib/blue/sender_manage.dart b/star_lock/lib/blue/sender_manage.dart index c91c3380..13ea1133 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -3,6 +3,7 @@ import 'package:star_lock/blue/io_protocol/io_addICCard.dart'; import 'package:star_lock/blue/io_protocol/io_addStressICCard.dart'; import 'package:star_lock/blue/io_protocol/io_deletUser.dart'; import 'package:star_lock/blue/io_protocol/io_getLockStatu.dart'; +import 'package:star_lock/blue/io_protocol/io_readAdminPassword.dart'; import 'io_protocol/io_addFingerprint.dart'; import 'io_protocol/io_addStressFingerprint.dart'; @@ -714,4 +715,30 @@ class IoSenderManage { ), callBack:callBack); } + //todo:读取管理员密码 + static void senderReadAdminPasswordCommand({ + required String? keyID, + required String? userID, + required int? role, + required int? pwdNum, + required int? pwdNo, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { + CommandSenderManager().managerSendData( + command: SenderReadAdminPasswordCommand( + keyID: keyID, + userID: userID, + role: role, + pwdNum: pwdNum, + pwdNo: pwdNo, + token: token, + needAuthor: needAuthor, + publicKey: publicKey, + privateKey: privateKey, + ), callBack:callBack); + } + } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart index 872e1f91..f5549722 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart @@ -52,6 +52,7 @@ class GroupListData { class GroupListItem { int? lockNum; int? keyGroupId; + int? groupType; //组类型 0未分组 1非未分组 String? keyGroupName; List? lockList; bool _isChecked = false; @@ -60,11 +61,12 @@ class GroupListItem { set isChecked(bool value) => _isChecked = value; GroupListItem( - {this.lockNum, this.keyGroupId, this.keyGroupName, this.lockList}); + {this.lockNum, this.keyGroupId, this.groupType, this.keyGroupName, this.lockList}); GroupListItem.fromJson(Map json) { lockNum = json['lockNum']; keyGroupId = json['keyGroupId']; + groupType = json['groupType']; keyGroupName = json['keyGroupName']; if (json['lockList'] != null) { lockList = []; @@ -78,6 +80,7 @@ class GroupListItem { final Map data = {}; data['lockNum'] = lockNum; data['keyGroupId'] = keyGroupId; + data['groupType'] = groupType; data['keyGroupName'] = keyGroupName; if (lockList != null) { data['lockList'] = lockList!.map((v) => v.toJson()).toList(); diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart new file mode 100644 index 00000000..78edf145 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_logic.dart @@ -0,0 +1,65 @@ + +import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; + +import '../../../../../blue/blue_manage.dart'; +import '../../../../../blue/io_tool/io_tool.dart'; +import '../../../../../blue/sender_manage.dart'; +import '../../../../../tools/baseGetXController.dart'; +import '../../../../../tools/storage.dart'; +import '../basicInformation/basicInformation_state.dart'; + +class AdminOpenLockPasswordLogic extends BaseGetXController{ + final BasicInformationState state = BasicInformationState(); + + // 读取支持功能-带参数 + Future _readAdminPassword() async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + if (connectionState == DeviceConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List getPublicKeyList = changeStringListToIntList(publicKey!); + + IoSenderManage.senderReadAdminPasswordCommand( + keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + userID: await Storage.getUid(), + role:0xff, + pwdNum:5, + pwdNo: 0, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList + ); + } + }, isShowLoading: true); + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + _readAdminPassword(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + } + + @override + void onClose() { + // TODO: implement onClose + + } + +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_state.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_state.dart new file mode 100644 index 00000000..c369c1e8 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/adminOpenLockPassword/adminOpenLockPassword_state.dart @@ -0,0 +1,16 @@ + +import 'package:get/get.dart'; + +import '../../lockSet/lockSetInfo_entity.dart'; + +class BasicInformationState { + var lockSetInfoData = LockSetInfoData().obs; + var lockBasicInfo = LockBasicInfo().obs; + + + BasicInformationState() { + var map = Get.arguments; + lockSetInfoData.value = map["lockSetInfoData"]; + lockBasicInfo.value = lockSetInfoData.value.lockBasicInfo!; + } +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_logic.dart index ffb4cc5e..dc72029c 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_logic.dart @@ -5,4 +5,55 @@ import 'basicInformation_state.dart'; class BasicInformationLogic extends BaseGetXController{ final BasicInformationState state = BasicInformationState(); + // 读取支持功能-带参数 + // Future _readAdminPassword() async { + // BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + // if (connectionState == DeviceConnectionState.connected) { + // var privateKey = await Storage.getStringList(saveBluePrivateKey); + // List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // var token = await Storage.getStringList(saveBlueToken); + // List getTokenList = changeStringListToIntList(token!); + // + // var publicKey = await Storage.getStringList(saveBluePublicKey); + // List getPublicKeyList = changeStringListToIntList(publicKey!); + // + // IoSenderManage.senderReadAdminPasswordCommand( + // keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + // userID: await Storage.getUid(), + // role:0xff, + // pwdNum:5, + // pwdNo: 0, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList + // ); + // } + // }, isShowLoading: true); + // } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + // _readAdminPassword(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + } + + @override + void onClose() { + // TODO: implement onClose + + } + } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart index 4b903b59..e90c047f 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart @@ -49,7 +49,7 @@ class _BasicInformationPageState extends State { isHaveLine: true), CommonItem( leftTitel: "MAC/ID", - rightTitle: state.lockBasicInfo.value.lockAlias, + rightTitle: state.lockBasicInfo.value.mac, allHeight: 70.h, isHaveLine: false), SizedBox( diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart index ee73544e..cc2c0212 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart @@ -313,6 +313,7 @@ class LockBasicInfo { int? keyType; int? startDate; int? endDate; + String? mac; LockBasicInfo( {this.keyId, @@ -326,7 +327,8 @@ class LockBasicInfo { this.adminPwd, this.keyType, this.startDate, - this.endDate,}); + this.endDate, + this.mac}); LockBasicInfo.fromJson(Map json) { keyId = json['keyId']; @@ -346,6 +348,7 @@ class LockBasicInfo { keyType = json['keyType']; startDate = json['startDate']; endDate = json['endDate']; + mac = json['mac']; } Map toJson() { @@ -364,6 +367,7 @@ class LockBasicInfo { data['keyType'] = keyType; data['startDate'] = startDate; data['endDate'] = endDate; + data['mac'] = mac; return data; } } @@ -410,6 +414,9 @@ class LockSettingInfo { String? adminPwd; int? unlockReminderPush; String? languageSettingLangText; + int? motorTorsion; + int? stayWarn; + int? abnormalWarn; LockSettingInfo( {this.remoteUnlock, @@ -433,7 +440,10 @@ class LockSettingInfo { this.bluetoothBroadcast, this.adminPwd, this.unlockReminderPush, - this.languageSettingLangText}); + this.languageSettingLangText, + this.motorTorsion, + this.stayWarn, + this.abnormalWarn,}); LockSettingInfo.fromJson(Map json) { remoteUnlock = json['remoteUnlock']; @@ -463,6 +473,9 @@ class LockSettingInfo { adminPwd = json['adminPwd']; unlockReminderPush = json['unlockReminderPush']; languageSettingLangText = json['languageSettingLangText']; + motorTorsion = json['motorTorsion']; + stayWarn = json['stayWarn']; + abnormalWarn = json['abnormalWarn']; } Map toJson() { @@ -492,6 +505,9 @@ class LockSettingInfo { data['adminPwd'] = adminPwd; data['unlockReminderPush'] = unlockReminderPush; data['languageSettingLangText'] = languageSettingLangText; + data['motorTorsion'] = motorTorsion; + data['stayWarn'] = stayWarn; + data['abnormalWarn'] = abnormalWarn; return data; } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart index dd95e929..39a76a8a 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart @@ -8,6 +8,8 @@ import 'package:star_lock/blue/io_type.dart'; import '../../../../appRouters.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_factoryDataReset.dart'; +import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart'; +import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart'; import '../../../../blue/io_reply.dart'; import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; @@ -41,6 +43,16 @@ class LockSetLogic extends BaseGetXController { if(reply is FactoryDataResetReply){ _replyFactoryDataResetKey(reply); } + + // 设置支持功能(不带参数) + if(reply is SetSupportFunctionsNoParametersReply) { + _replySetSupportFunctionsWithParameters(reply); + } + + // 读取支持功能(不带参数) + if((reply is ReadSupportFunctionsNoParametersReply) && (state.settingUpSupportFeatures == 56)) { + _readSupportFunctionsWithParametersReply(reply); + } }); } @@ -153,6 +165,82 @@ class LockSetLogic extends BaseGetXController { } } + // 读取支持功能带参数数据解析 + Future _readSupportFunctionsWithParametersReply(Reply reply) async { + int status = reply.data[2]; + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + state.isOpenBlueBroadcast.value = reply.data[6]; + print("isOpenBlueBroadcast:${state.isOpenBlueBroadcast.value}"); + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + break; + default: + //失败 + print("${reply.commandType}失败"); + break; + } + } + + // 设置自动落锁数据解析 + Future _replySetSupportFunctionsWithParameters(Reply reply) async { + int status = reply.data[2]; + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + // Toast.show(msg: "操作成功");featureEnable = state.isOpenStayWarn.value == 1 ? 0 : 1; + if(state.settingUpSupportFeatures == 56){ + // 蓝牙广播 + state.isOpenBlueBroadcast.value = state.isOpenBlueBroadcast.value == 1 ? 0 : 1; + state.lockSetInfoData.value.lockSettingInfo!.bluetoothBroadcast = state.isOpenBlueBroadcast.value; + }else if(state.settingUpSupportFeatures == 61){ + // 逗留警告 + state.isOpenStayWarn.value = state.isOpenStayWarn.value == 1 ? 0 : 1; + state.lockSetInfoData.value.lockSettingInfo!.stayWarn = state.isOpenStayWarn.value; + }else if(state.settingUpSupportFeatures == 62){ + // 异常警告 + state.isOpenExceptionWarnings.value = state.isOpenExceptionWarnings.value == 1 ? 0 : 1; + state.lockSetInfoData.value.lockSettingInfo!.abnormalWarn = state.isOpenExceptionWarnings.value; + } + + print("isOpenBlueBroadcast111:${state.isOpenBlueBroadcast.value}"); + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType}失败"); + + break; + } + } + // 删除用户 Future deletUserAction() async { BlueManage().judgeReconnect( @@ -207,6 +295,71 @@ class LockSetLogic extends BaseGetXController { }); } + // 读取支持功能-带参数 + // Future _readSupportFunctionsNoParameters(int type) async { + // BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + // if (connectionState == DeviceConnectionState.connected) { + // var privateKey = await Storage.getStringList(saveBluePrivateKey); + // List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // var token = await Storage.getStringList(saveBlueToken); + // List getTokenList = changeStringListToIntList(token!); + // + // var publicKey = await Storage.getStringList(saveBluePublicKey); + // List getPublicKeyList = changeStringListToIntList(publicKey!); + // + // IoSenderManage.readSupportFunctionsNoParametersCommand( + // keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + // userID: await Storage.getUid(), + // featureBit: type, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList + // ); + // } + // }, isShowLoading: true); + // } + + // 设置支持功能(带参数) + Future sendBurglarAlarm(int type) async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + if (connectionState == DeviceConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List getPublicKeyList = changeStringListToIntList(publicKey!); + + state.settingUpSupportFeatures = type; + + var featureEnable = 0; + if(type == 56){ + // 蓝牙广播 + featureEnable = state.isOpenBlueBroadcast.value == 1 ? 0 : 1; + }else if(type == 61){ + // 逗留警告 + featureEnable = state.isOpenStayWarn.value == 1 ? 0 : 1; + }else if(type == 62){ + // 异常警告 + featureEnable = state.isOpenExceptionWarnings.value == 1 ? 0 : 1; + } + IoSenderManage.setSupportFunctionsNoParametersCommand( + keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + userID: await Storage.getUid(), + featureBit: type, + featureEnable: featureEnable, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList); + } + }); + } + // 获取锁设置信息 void getLockSettingInfoData() async { var entity = await ApiRepository.to.getLockSettingInfoData( @@ -218,6 +371,11 @@ class LockSetLogic extends BaseGetXController { state.lockFeature.value = state.lockSetInfoData.value.lockFeature!; state.lockStatus.value = state.lockSetInfoData.value.lockStatus!; state.isAttendance.value = state.lockSettingInfo.value.attendance!; + + state.isOpenBlueBroadcast.value = state.lockSettingInfo.value.bluetoothBroadcast!; + state.isOpenExceptionWarnings.value = state.lockSettingInfo.value.bluetoothBroadcast!; + // await _readSupportFunctionsNoParameters(56); + // _readSupportFunctionsNoParameters(62); } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index eafca6ec..e85278cb 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -336,7 +336,9 @@ class _LockSetPageState extends State with RouteAware { isHaveLine: true, action: () { // Toast.show(msg: "功能暂未开放"); - Get.toNamed(Routers.openDoorDirectionPage); + Get.toNamed(Routers.openDoorDirectionPage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); })), // ), // Obx(() => @@ -352,18 +354,19 @@ class _LockSetPageState extends State with RouteAware { Get.toNamed(Routers.motorPowerPage); })), // ), - // Obx(() => - Visibility( - visible: true, - child: CommonItem( - leftTitel: '逗留警告', - rightTitle: "", - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: _otherToDoSwitch(0), - )), - // ), - // Obx(() => + Obx(() => + Visibility( + visible: true, + child: CommonItem( + leftTitel: '逗留警告', + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: _lockStayWarnSwitch(), + )), + ), + Obx(() => + // 异常警告 Visibility( visible: true, child: CommonItem( @@ -371,8 +374,17 @@ class _LockSetPageState extends State with RouteAware { rightTitle: "", isHaveLine: true, isHaveRightWidget: true, - rightWidget: _otherToDoSwitch(1))), - // ), + rightWidget: _lockExceptionWarningsSwitch())), + ), + // 支持蓝牙广播(关闭则不能使用蓝牙主动开锁) + Obx(() => Visibility( + visible: true, + child: CommonItem( + leftTitel: '蓝牙广播', + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: _lockBlueBroadcastSwitch()))), SizedBox(height: 10.h), //-----新增至此 // 标记房态 @@ -409,23 +421,18 @@ class _LockSetPageState extends State with RouteAware { rightTitle: "", isHaveLine: true, isHaveRightWidget: true, - rightWidget: SizedBox( - width: 60.w, child: _openCheckInSwitch()))), + rightWidget: _openCheckInSwitch())), ), // 开锁提醒 Obx( () => Visibility( - visible: state.lockFeature.value.unlockReminder == 1 - ? true - : false, + visible: state.lockFeature.value.unlockReminder == 1 ? true : false, child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.unlockReminder!.tr, + leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, rightTitle: "", isHaveLine: false, isHaveRightWidget: true, - rightWidget: SizedBox( - width: 60.w, child: _lockRemindSwitch()))), + rightWidget: _lockRemindSwitch())), ), SizedBox(height: 10.h), // wifi配网 @@ -434,8 +441,7 @@ class _LockSetPageState extends State with RouteAware { visible: state.lockFeature.value.wifi == 1 ? true : false, child: CommonItem( - leftTitel: TranslationLoader - .lanKeys!.wifiDistributionNetwork!.tr, + leftTitel: TranslationLoader.lanKeys!.wifiDistributionNetwork!.tr, rightTitle: "", isHaveLine: true, isHaveDirection: true, @@ -542,7 +548,7 @@ class _LockSetPageState extends State with RouteAware { } CupertinoSwitch _openCheckInSwitch() { - print("111111state.lockSettingInfo.value.attendance:${state.lockSettingInfo.value.attendance}"); + // print("111111state.lockSettingInfo.value.attendance:${state.lockSettingInfo.value.attendance}"); return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, @@ -574,6 +580,52 @@ class _LockSetPageState extends State with RouteAware { ); } + // 异常警告 + CupertinoSwitch _lockExceptionWarningsSwitch() { + print("isOpenBlueBroadcast222:${state.isOpenExceptionWarnings.value}"); + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: (state.isOpenExceptionWarnings.value) == 1 ? true : false, + onChanged: (value) { + setState(() { + logic.sendBurglarAlarm(62); + }); + }, + ); + } + + // 逗留警告 + CupertinoSwitch _lockStayWarnSwitch() { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: (state.isOpenExceptionWarnings.value) == 1 ? true : false, + onChanged: (value) { + setState(() { + logic.sendBurglarAlarm(61); + }); + }, + ); + } + + // 支持蓝牙广播 + CupertinoSwitch _lockBlueBroadcastSwitch() { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: (state.isOpenBlueBroadcast.value) == 1 ? true : false, + onChanged: (value) { + setState(() { + logic.sendBurglarAlarm(56); + }); + }, + ); + } + CupertinoSwitch _otherUnHaveDoneSwitch() { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart index ffbcb1ec..759af3ef 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart @@ -13,9 +13,16 @@ class LockSetState { var isAttendance = 0.obs;// 是否开启考勤 var currentDeviceUUid = "".obs;// 当前设备的uuid + var isLockPickingReminder = 0.obs;// 是否开启开锁提醒 + var isOpenBlueBroadcast = 0.obs;// 是否开启蓝牙广播 + var isOpenExceptionWarnings = 0.obs;// 是否开启异常警告 + var isOpenStayWarn = 0.obs;// 是否开启逗留警告 + var passwordTF = TextEditingController(); + var settingUpSupportFeatures = 0; + LockSetState() { Map map = Get.arguments; lockId.value = map["lockId"]; diff --git a/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_logic.dart new file mode 100644 index 00000000..6b0f5c69 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_logic.dart @@ -0,0 +1,190 @@ + +import 'dart:async'; + +import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; + +import '../../../../blue/blue_manage.dart'; +import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart'; +import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart'; +import '../../../../blue/io_reply.dart'; +import '../../../../blue/io_tool/io_tool.dart'; +import '../../../../blue/io_tool/manager_event_bus.dart'; +import '../../../../blue/sender_manage.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/baseGetXController.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/storage.dart'; +import '../../../../tools/toast.dart'; +import 'motorPower_state.dart'; + +class MotorPowerLogic extends BaseGetXController { + final MotorPowerState state = MotorPowerState(); + + // 配置锁的常开模式设置 -> 防撬报警 + Future _setLockSetGeneralSetting() async{ + var entity = await ApiRepository.to.setOpenDoorDirectionData( + lockId: state.lockSetInfoData.value.lockId!, + openDirectionValue:state.motorTorsion.value, // 1-开启、2-关闭; + ); + if(entity.errorCode!.codeIsSuccessful){ + + state.lockSetInfoData.value.lockSettingInfo!.openDirectionValue = state.motorTorsion.value; + eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); + Toast.show(msg: "操作成功"); + } + } + + // 获取解析后的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + if(reply is SetSupportFunctionsNoParametersReply) { + _replySetSupportFunctionsWithParameters(reply); + } + + // 读取支持功能(带参数) + if(reply is ReadSupportFunctionsNoParametersReply) { + _readSupportFunctionsWithParametersReply(reply); + } + }); + } + + // 读取支持功能带参数数据解析 + Future _readSupportFunctionsWithParametersReply(Reply reply) async { + int status = reply.data[2]; + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + state.motorTorsion.value = reply.data[6]; + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + break; + default: + //失败 + print("${reply.commandType}失败"); + break; + } + } + + // 设置自动落锁数据解析 + Future _replySetSupportFunctionsWithParameters(Reply reply) async { + int status = reply.data[2]; + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + _setLockSetGeneralSetting(); + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType}失败"); + + break; + } + } + + // 读取支持功能-带参数 + Future _readSupportFunctionsNoParameters() async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + if (connectionState == DeviceConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List getPublicKeyList = changeStringListToIntList(publicKey!); + + IoSenderManage.readSupportFunctionsNoParametersCommand( + keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + userID: await Storage.getUid(), + featureBit: 58, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList + ); + } + }, isShowLoading: true); + } + + // 设置支持功能(带参数) + Future sendOpenDoorDirection() async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + if (connectionState == DeviceConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List getPublicKeyList = changeStringListToIntList(publicKey!); + + IoSenderManage.setSupportFunctionsWithParametersCommand( + keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + userID: await Storage.getUid(), + featureBit: 58, + featureParaLength: 1, + featureData: [state.motorTorsion.value], + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList); + } + }); + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + _initReplySubscription(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + _readSupportFunctionsNoParameters(); + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + _replySubscription.cancel(); + } + +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_state.dart b/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_state.dart new file mode 100644 index 00000000..c23e4d94 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/motorPower/motorPower_state.dart @@ -0,0 +1,19 @@ + + +import 'package:get/get.dart'; + +import '../lockSet/lockSetInfo_entity.dart'; + +class MotorPowerState { + + var lockSetInfoData = LockSetInfoData().obs; + var motorTorsion = 1.obs; + + MotorPowerState() { + var map = Get.arguments; + lockSetInfoData.value = map["lockSetInfoData"]; + + motorTorsion.value = lockSetInfoData.value.lockSettingInfo!.motorTorsion!; + } + +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_logic.dart new file mode 100644 index 00000000..0325f044 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_logic.dart @@ -0,0 +1,191 @@ + +import 'dart:async'; + +import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; + +import '../../../../blue/blue_manage.dart'; +import '../../../../blue/io_protocol/io_readSupportFunctionsNoParameters.dart'; +import '../../../../blue/io_protocol/io_setSupportFunctionsNoParameters.dart'; +import '../../../../blue/io_reply.dart'; +import '../../../../blue/io_tool/io_tool.dart'; +import '../../../../blue/io_tool/manager_event_bus.dart'; +import '../../../../blue/sender_manage.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/baseGetXController.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/storage.dart'; +import '../../../../tools/toast.dart'; +import 'openDoorDirection_state.dart'; + +class OpenDoorDirectionLogic extends BaseGetXController { + final OpenDoorDirectionState state = OpenDoorDirectionState(); + + // 配置锁的常开模式设置 -> 防撬报警 + Future _setLockSetGeneralSetting() async{ + var entity = await ApiRepository.to.setOpenDoorDirectionData( + lockId: state.lockSetInfoData.value.lockId!, + openDirectionValue:state.openDirectionValue.value, // 1-开启、2-关闭; + ); + if(entity.errorCode!.codeIsSuccessful){ + // eventBus.fire(RefreshLockListInfoDataEvent()); + + // state.openDirectionValue.value = state.openDirectionValue.value == 1 ? 0 : 1; + state.lockSetInfoData.value.lockSettingInfo!.openDirectionValue = state.openDirectionValue.value; + eventBus.fire(PassCurrentLockInformationEvent(state.lockSetInfoData.value)); + Toast.show(msg: "操作成功"); + } + } + + // 获取解析后的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = EventBusManager().eventBus!.on().listen((reply) { + if(reply is SetSupportFunctionsNoParametersReply) { + _replySetSupportFunctionsWithParameters(reply); + } + + // 读取支持功能(带参数) + if(reply is ReadSupportFunctionsNoParametersReply) { + _readSupportFunctionsWithParametersReply(reply); + } + }); + } + + // 读取支持功能带参数数据解析 + Future _readSupportFunctionsWithParametersReply(Reply reply) async { + int status = reply.data[2]; + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + state.openDirectionValue.value = reply.data[6]; + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + break; + default: + //失败 + print("${reply.commandType}失败"); + break; + } + } + + // 设置自动落锁数据解析 + Future _replySetSupportFunctionsWithParameters(Reply reply) async { + int status = reply.data[2]; + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + _setLockSetGeneralSetting(); + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}权限校验错误"); + + break; + default: + //失败 + print("${reply.commandType}失败"); + + break; + } + } + + // 读取支持功能-带参数 + Future _readSupportFunctionsNoParameters() async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + if (connectionState == DeviceConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List getPublicKeyList = changeStringListToIntList(publicKey!); + + IoSenderManage.readSupportFunctionsNoParametersCommand( + keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + userID: await Storage.getUid(), + featureBit: 41, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList + ); + } + }, isShowLoading: true); + } + + // 设置支持功能(带参数) + Future sendOpenDoorDirection() async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + if (connectionState == DeviceConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List getPublicKeyList = changeStringListToIntList(publicKey!); + + IoSenderManage.setSupportFunctionsNoParametersCommand( + keyID: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), + userID: await Storage.getUid(), + featureBit: 41, + featureEnable: state.openDirectionValue.value, + token: getTokenList, + needAuthor: 1, + publicKey: getPublicKeyList, + privateKey: getPrivateKeyList); + } + }); + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + _initReplySubscription(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + print("onInit()"); + + _readSupportFunctionsNoParameters(); + } + + @override + void onClose() { + // TODO: implement onClose + super.onClose(); + _replySubscription.cancel(); + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_page.dart b/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_page.dart index c42899c9..ee495770 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_page.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/titleAppBar.dart'; +import 'openDoorDirection_logic.dart'; class OpenDoorDirectionPage extends StatefulWidget { const OpenDoorDirectionPage({Key? key}) : super(key: key); @@ -12,9 +14,12 @@ class OpenDoorDirectionPage extends StatefulWidget { } class _OpenDoorDirectionPageState extends State { - bool isCheck = false; - int selectIndex = 0; - int _selectGroupValue = 1; //默认选中的单选框的值 + final logic = Get.put(OpenDoorDirectionLogic()); + final state = Get.find().state; + + // bool isCheck = false; + // int selectIndex = 0; + // int _selectGroupValue = 1; //默认选中的单选框的值 @override Widget build(BuildContext context) { @@ -64,7 +69,7 @@ class _OpenDoorDirectionPageState extends State { SizedBox( width: 60.w, ), - _colorfulCheckBox(1), + Obx(() => _colorfulCheckBox(1)), Text( "左开", style: TextStyle(fontSize: 24.sp), @@ -72,7 +77,7 @@ class _OpenDoorDirectionPageState extends State { SizedBox( width: 200.w, ), - _colorfulCheckBox(2), + Obx(() => _colorfulCheckBox(2)), Text( '右开', style: TextStyle(fontSize: 24.sp), @@ -85,12 +90,13 @@ class _OpenDoorDirectionPageState extends State { return Radio( value: selectIndex, onChanged: (value) { - // print(value); - _selectGroupValue = value; - - setState(() {}); + print("selectIndex:$selectIndex valuevaluevaluevalue:$value"); + // _selectGroupValue = value; + state.openDirectionValue.value = value; + print("state.openDirectionValue.value:${state.openDirectionValue.value}"); + logic.sendOpenDoorDirection(); }, - groupValue: _selectGroupValue, + groupValue: state.openDirectionValue.value, activeColor: AppColors.mainColor, ); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_state.dart b/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_state.dart new file mode 100644 index 00000000..3f15b663 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/openDoorDirection/openDoorDirection_state.dart @@ -0,0 +1,18 @@ + + +import 'package:get/get.dart'; +import '../lockSet/lockSetInfo_entity.dart'; + +class OpenDoorDirectionState { + + var lockSetInfoData = LockSetInfoData().obs; + var openDirectionValue = 1.obs; + + OpenDoorDirectionState() { + var map = Get.arguments; + lockSetInfoData.value = map["lockSetInfoData"]; + + openDirectionValue.value = lockSetInfoData.value.lockSettingInfo!.openDirectionValue!; + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index cc968526..c63695c4 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -4,6 +4,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/blue/io_protocol/io_editUser.dart'; @@ -15,6 +16,7 @@ import 'package:star_lock/tools/toast.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart'; import '../../../blue/io_protocol/io_openLock.dart'; +import '../../../blue/io_protocol/io_referEventRecordTime.dart'; import '../../../blue/io_reply.dart'; import '../../../blue/io_tool/io_manager.dart'; import '../../../blue/io_tool/io_tool.dart'; @@ -26,6 +28,8 @@ import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; +import '../electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; +import '../lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; import 'lockDetail_state.dart'; class LockDetailLogic extends BaseGetXController{ @@ -54,6 +58,11 @@ class LockDetailLogic extends BaseGetXController{ if(reply is GetStarLockStatuInfoReply){ _replyGetStarLockStatusInfo(reply); } + + // 开完锁之后上传记录 + if(reply is SenderReferEventRecordTimeReply) { + _replyReferEventRecordTime(reply); + } }); } @@ -80,6 +89,7 @@ class LockDetailLogic extends BaseGetXController{ case 0x00: //成功 print("${reply.commandType}数据解析成功"); + getLockRecordLastUploadDataTime(); state.lockState.value = 2; state.animationController.reset(); state.animationController.forward(); @@ -335,6 +345,64 @@ class LockDetailLogic extends BaseGetXController{ } } + // 根据时间查解析数据 + Future _replyReferEventRecordTime(Reply reply) async { + int status = reply.data[2]; + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + if(reply.data[5] > 0){ + reply.data.removeRange(0, 6); + // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 + var getList = splitList(reply.data, 8); + var uploadList = []; + for(int i = 0; i openDoorAction() async { // if(BlueManage().connectDeviceMacAddress.isEmpty){ @@ -431,6 +499,34 @@ class LockDetailLogic extends BaseGetXController{ }, isShowLoading: false); } + // 查询事件记录(时间查询) + Future senderReferEventRecordTime(int time) async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { + if (state == DeviceConnectionState.connected) { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List getPublicKeyList = changeStringListToIntList(publicKey!); + + IoSenderManage.senderReferEventRecordTimeCommand( + keyID:BlueManage().connectDeviceName, + userID:await Storage.getUid(), + logsCount:20, + // time:DateTime.now().millisecondsSinceEpoch~/1000, + time: time, + token:getTokenList, + needAuthor:1, + publicKey:getPublicKeyList, + privateKey:getPrivateKeyList, + ); + } + }); + } + void startScanAction(){ BlueManage().startScan(true, (v){ print("startScanAllDevice:${v}"); @@ -467,6 +563,26 @@ class LockDetailLogic extends BaseGetXController{ } + // 查询锁记录最后时间 + void getLockRecordLastUploadDataTime() async { + LockOperatingRecordGetLastRecordTimeEntity entity = + await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString()); + if (entity.errorCode!.codeIsSuccessful) { + senderReferEventRecordTime(entity.data!.operateDate!~/1000); + } + } + + // 操作记录上传 + void lockRecordUploadData(List list) async { + KeyOperationRecordEntity entity = + await ApiRepository.to.lockRecordUploadData( + lockId: state.keyInfos.value.lockId.toString(), + records: list); + if (entity.errorCode!.codeIsSuccessful) { + // mockNetworkDataRequest(); + } + } + @override void onReady() { // TODO: implement onReady diff --git a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart index 8214a645..539d2ccd 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart @@ -1,3 +1,4 @@ + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -5,6 +6,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyO import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; +import '../../../tools/custom_bottom_sheet.dart'; import '../../../tools/jh_pop_menus.dart'; import '../../../tools/noData.dart'; import '../../../tools/storage.dart'; @@ -44,19 +46,21 @@ class _LockOperatingRecordPageState extends State { onPressed: () async { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if(isDemoMode == false){ - JhPopMenus.showLinePop(context, clickCallback: (index, selText) { - print('选中index: $index'); - print('选中text: $selText'); - if (index == 0) { - logic.mockNetworkDataRequest(); - } else if (index == 1) { - logic.clearOperationRecordRequest(); - } - }, listData: [ - {'text': '读取记录'}, - {'text': '清空记录'}, - {'text': '导出记录'}, - ]); + // JhPopMenus.showLinePop(context, clickCallback: (index, selText) { + // print('选中index: $index'); + // print('选中text: $selText'); + // if (index == 0) { + // logic.mockNetworkDataRequest(); + // } else if (index == 1) { + // logic.clearOperationRecordRequest(); + // } + // }, listData: [ + // {'text': '读取记录'}, + // {'text': '清空记录'}, + // {'text': '导出记录'}, + // ]); + + _openModalBottomSheet(); }else{ // Get.toNamed(Routers.seletLockTypePage); Toast.show(msg: "演示模式"); @@ -77,7 +81,7 @@ class _LockOperatingRecordPageState extends State { ), _searchWidget(), SizedBox( - height: 10.h, + height: 10.h ), Expanded(child: _buildMainUI()), ], @@ -128,7 +132,6 @@ class _LockOperatingRecordPageState extends State { int? operateDate = dataItem.operateDate; DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(operateDate!); String operateDateStr = '${dateStr.toLocal().toString().substring(0, 16)} '; - return _operatingRecordItem(getTypeIcon(dataItem.recordType!), dataItem.recordTypeName!, operateDateStr, () { }); @@ -238,4 +241,26 @@ class _LockOperatingRecordPageState extends State { ), ); } + + Future _openModalBottomSheet() async { + showModalBottomSheet( + context: context, + shape: RoundedRectangleBorder( + borderRadius: BorderRadiusDirectional.circular(10)), + builder: (BuildContext context) { + return AlertBottomWidget( + topTitle: '', + items: const ['读取记录', '清空记录', '导出记录'], + chooseCallback: (value) { + int getSelectIndex = value; + if (getSelectIndex == 0) { + logic.mockNetworkDataRequest(); + } else if (getSelectIndex == 1) { + logic.clearOperationRecordRequest(); + } + }, + ); + }); + } + } diff --git a/star_lock/lib/main/lockMian/lockList/lockList_page.dart b/star_lock/lib/main/lockMian/lockList/lockList_page.dart index 9ca75773..89adbe12 100644 --- a/star_lock/lib/main/lockMian/lockList/lockList_page.dart +++ b/star_lock/lib/main/lockMian/lockList/lockList_page.dart @@ -29,18 +29,6 @@ class _LockListPageState extends State { } groupDataList.addAll(widget.lockListInfoGroupEntity.groupList as Iterable); - // return ListView.builder( - // itemCount: dataList.length, - // itemBuilder: (c, index) { - // GroupList keyInfo = dataList[index]; - // return lockInfoListItem('images/icon_lock.png', keyInfo.groupName, () { - // // Get.toNamed(Routers.lockDetailMainPage, arguments: { - // // "lockMainEntity": widget.lockMainEntity, - // // "keyInfo": keyInfo - // // }); - // }); - // }); - return ListView.separated( itemCount: groupDataList.length, itemBuilder: (context, index) { @@ -48,6 +36,7 @@ class _LockListPageState extends State { return _buildLockExpandedList(context, index, itemData); }, shrinkWrap: true, + physics:const AlwaysScrollableScrollPhysics(), separatorBuilder: (context, index) { return const Divider( height: 1, @@ -94,12 +83,18 @@ class _LockListPageState extends State { child: ListView.separated( itemCount: lockItemList.length, shrinkWrap: true, + physics:const NeverScrollableScrollPhysics(), separatorBuilder: (context, index) { return const Divider(height: 1, color: AppColors.greyLineColor); }, itemBuilder: (c, index) { LockListInfoItemEntity keyInfo = lockItemList[index]; - return lockInfoListItem(keyInfo, () { + bool isLast = false; + if (lockItemList.length == index+1){ + isLast = true; + } + // print("lockItemList.length:${lockItemList.length} == ${index+1} $isLast"); + return lockInfoListItem(keyInfo, isLast, () { Get.toNamed(Routers.lockDetailMainPage, arguments: { // "lockMainEntity": widget.lockMainEntity, "keyInfo": keyInfo @@ -109,12 +104,12 @@ class _LockListPageState extends State { ); } - Widget lockInfoListItem(LockListInfoItemEntity keyInfo, Function() action) { + Widget lockInfoListItem(LockListInfoItemEntity keyInfo, bool isLast, Function() action) { return GestureDetector( onTap: action, child: Container( // height: 122.h, - margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), + margin: isLast ? EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w, bottom: 20.w) : EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20.w), diff --git a/star_lock/lib/mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart b/star_lock/lib/mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart index 890e8ef0..e1ba8ab4 100644 --- a/star_lock/lib/mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart +++ b/star_lock/lib/mine/addLock/lockAddress/gaode/lockAddressGaoDe_page.dart @@ -20,7 +20,6 @@ import '../../../../translations/trans_lib.dart'; import 'lockAddressGaoDe_logic.dart'; class LockAddressGaoDePage extends StatefulWidget { - const LockAddressGaoDePage({Key? key}) : super(key: key); @override @@ -141,7 +140,7 @@ class _LockAddressGaoDePageState extends State{ height: 1.sw/5*4, width: 1.sw, child: - (addressInfo!["address"].toString().isNotEmpty) ? + (addressInfo!["address"].toString().isNotEmpty) ? AMapWidget( apiKey: amapApiKeys, // 初始化地图中心 diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 077f8717..64b1397e 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -1,7 +1,5 @@ import 'dart:async'; -import 'dart:convert'; -import 'dart:math'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:get/get.dart'; @@ -9,22 +7,18 @@ import 'package:get/get.dart'; import '../../../appRouters.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_addUser.dart'; -import '../../../blue/io_protocol/io_getLockStatu.dart'; import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart'; import '../../../blue/io_reply.dart'; -import '../../../blue/io_tool/io_manager.dart'; import '../../../blue/io_tool/io_tool.dart'; import '../../../blue/io_tool/manager_event_bus.dart'; import '../../../blue/sender_manage.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; -import '../../../tools/dateTool.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/storage.dart'; import 'saveLock_state.dart'; class SaveLockLogic extends BaseGetXController { - final SaveLockState state = SaveLockState(); // 获取解析后的数据 @@ -39,7 +33,6 @@ class SaveLockLogic extends BaseGetXController { if(reply is GetStarLockStatuInfoReply) { _replyGetStarLockStatusInfo(reply); } - }); } @@ -193,9 +186,15 @@ class SaveLockLogic extends BaseGetXController { state.lockInfo["indate"] = indateValue*1000; // print("indate:$indate indateValue:$indateValue"); - var index = 153; + // mac地址 + var macAddress = reply.data.sublist(153, 173); + var macAddressStr = utf8String(macAddress); + state.lockInfo["mac"] = macAddressStr; + print("macAddress:$macAddress macAddressStr:$macAddressStr"); + + var index = 173; // 锁特征值字符串长度 - var featureValueLength = reply.data[153]; + var featureValueLength = reply.data[173]; // 锁特征值说明(本机能支持的功能) // 获取到锁给的字符数组 var featureValue = reply.data.sublist(index+1, index + featureValueLength+1); diff --git a/star_lock/lib/mine/mine/safeVerify/safeVerify_state.dart b/star_lock/lib/mine/mine/safeVerify/safeVerify_state.dart index 05ea13a9..8f52ad20 100644 --- a/star_lock/lib/mine/mine/safeVerify/safeVerify_state.dart +++ b/star_lock/lib/mine/mine/safeVerify/safeVerify_state.dart @@ -42,7 +42,7 @@ class SafeVerifyState { ///初始化本地数据 void initLoginData() async { final data = await Storage.getString('userLoginData'); - print("getLoginData:$data"); + // print("getLoginData:$data"); if (data != null && data.isNotEmpty) { loginData.value = LoginData.fromJson(jsonDecode(data)); diff --git a/star_lock/lib/mine/mine/starLockMine_state.dart b/star_lock/lib/mine/mine/starLockMine_state.dart index 9f8f45c6..315848ec 100644 --- a/star_lock/lib/mine/mine/starLockMine_state.dart +++ b/star_lock/lib/mine/mine/starLockMine_state.dart @@ -19,7 +19,7 @@ class StarLockMineState { ///初始化本地数据 void initLoginData() async { final data = await Storage.getString('userLoginData'); - print("getLoginData:$data"); + // print("getLoginData:$data"); if (data != null && data.isNotEmpty) { loginData.value = LoginData.fromJson(jsonDecode(data)); } diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccountNext/minePersonInfoEditAccountNext_state.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccountNext/minePersonInfoEditAccountNext_state.dart index de66eb55..9da9a937 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccountNext/minePersonInfoEditAccountNext_state.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccountNext/minePersonInfoEditAccountNext_state.dart @@ -44,7 +44,7 @@ class PersonInfoEditAccountState { ///初始化本地数据 void initLoginData() async { final data = await Storage.getString('userLoginData'); - print("getLoginData:$data"); + // print("getLoginData:$data"); if (data != null && data.isNotEmpty) { loginData.value = LoginData.fromJson(jsonDecode(data)); } diff --git a/star_lock/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart b/star_lock/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart index 7b470215..f828cc48 100644 --- a/star_lock/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart +++ b/star_lock/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_page.dart @@ -37,15 +37,15 @@ class _APPUnlockNeedMobileNetworkingLockPageState extends State createState() => _GroupAddLockPageState(); -} - -class _GroupAddLockPageState extends State { - List lockList = []; - @override - Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["lockList"] != null)) { - lockList = obj["lockList"]; - } - - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.lock!.tr, - haveBack: true, - actionsList: [ - IconButton( - icon: Image.asset( - 'images/icon_bar_more.png', - height: 30.h, - width: 10.w, - ), - onPressed: () { - // 处理操作按钮的点击事件-添加锁分组 - }, - ), - ], - backgroundColor: AppColors.mainColor), - body: lockList.isNotEmpty - ? ListView.separated( - itemBuilder: (context, index) { - LockListItem itemData = lockList[index]; - return _listItemView(itemData); - }, - itemCount: lockList.length, - separatorBuilder: (BuildContext context, int index) { - return Divider( - height: 1.h, - color: AppColors.greyLineColor, - ); - }, - ) - : Stack( - alignment: Alignment.center, - children: [ - Positioned( - bottom: 350.h, - left: (ScreenUtil().screenWidth - 200.w) / 2, - width: 200.w, - child: SubmitBtn( - btnName: '添加', - onClick: () { - //选择要添加到分组的锁 - }, - )), - const NoData(), - ], - )); - } - - Widget _listItemView(LockListItem itemData) { - return GestureDetector( - child: Container( - color: Colors.white, - height: 80.h, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - width: 20.w, - ), - Image.asset( - 'images/icon_lockGroup_item.png', - width: 36, - height: 36, - fit: BoxFit.fill, - ), - SizedBox( - width: 10.w, - ), - Text( - itemData.lockAlias ?? '', - style: TextStyle(fontSize: 24.sp), - ) - ], - ), - ), - onTap: () {}, - ); - } -} diff --git a/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_logic.dart b/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_logic.dart new file mode 100644 index 00000000..3189fd40 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_logic.dart @@ -0,0 +1,37 @@ + +import 'package:get/get.dart'; + +import '../../../../network/api_repository.dart'; +import '../../../../tools/baseGetXController.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; +import 'groupEditLock_state.dart'; + +class GroupEditLockLogic extends BaseGetXController { + final GroupEditLockState state = GroupEditLockState(); + + //锁分组里面添加锁 + Future lockGroupAddLock(List lockId) async { + var entity = await ApiRepository.to.lockGroupAddLock( + lockIds: lockId, + groupId: state.seletGroupListItem.keyGroupId!); + if (entity.errorCode!.codeIsSuccessful) { + Toast.show(msg: "添加成功"); + eventBus.fire(LockGroupEditGroupLockRefreshEvent()); + eventBus.fire(RefreshLockListInfoDataEvent()); + Get.close(2); + } + } + + //锁分组里面添加锁 + Future lockGroupDeletLock(List lockId) async { + var entity = await ApiRepository.to.lockGroupDeletLock(lockIds: lockId); + if (entity.errorCode!.codeIsSuccessful) { + Toast.show(msg: "删除成功"); + eventBus.fire(LockGroupEditGroupLockRefreshEvent()); + eventBus.fire(RefreshLockListInfoDataEvent()); + Get.close(2); + } + } + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart b/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart new file mode 100644 index 00000000..3e923b6c --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockGroup/groupEditLock/groupEditLock_page.dart @@ -0,0 +1,117 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; +import 'package:star_lock/tools/noData.dart'; + +import '../../../../../../app_settings/app_colors.dart'; +import '../../../../../../tools/titleAppBar.dart'; +import '../../../../../../translations/trans_lib.dart'; +import '../../../../tools/submitBtn.dart'; +import 'groupEditLock_logic.dart'; + +class GroupEditLockPage extends StatefulWidget { + const GroupEditLockPage({Key? key}) : super(key: key); + + @override + State createState() => _GroupEditLockPageState(); +} + +class _GroupEditLockPageState extends State { + final logic = Get.put(GroupEditLockLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: state.type == 0 ? TranslationLoader.lanKeys!.add!.tr : TranslationLoader.lanKeys!.delete!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + Container( + margin: EdgeInsets.all(15.w), + child: Row( + children: [ + Text("选择要加入分组的锁", style: TextStyle(fontSize: 25.sp)), + ], + ), + ), + Expanded(child: _buildMainUI()), + SubmitBtn(btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () async { + var idList = []; + for(int i = 0; i[]; + var type = 0;// 0添加 1删除 + var seletGroupListItem = GroupListItem(); + var ungrouped = GroupListItem(); + GroupEditLockState() { + Map map = Get.arguments; + type = map["type"]; + seletGroupListItem = map["groupListItem"]; + ungrouped = map["ungrouped"]; + if(type == 0){ + lockList = ungrouped.lockList!; + }else{ + lockList = seletGroupListItem.lockList!; + } + + for(int i = 0; i { List lockList = []; + var ungrouped = GroupListItem(); + @override Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["lockList"] != null)) { - lockList = obj["lockList"]; - } + Map map = Get.arguments; + GroupListItem groupListItem = map["groupListItem"]; + lockList = groupListItem.lockList!; + ungrouped = map["ungrouped"]; return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( barTitle: TranslationLoader.lanKeys!.lock!.tr, haveBack: true, - actionsList: [ + actionsList: (lockList.isNotEmpty && groupListItem.groupType == 0) ? [ IconButton( icon: Image.asset( 'images/icon_bar_more.png', @@ -38,10 +43,26 @@ class _LockItemListPageState extends State { width: 10.w, ), onPressed: () { - // 处理操作按钮的点击事件-添加锁分组 + // 处理操作按钮的点击事件 + _openModalBottomSheet(groupListItem); + // JhPopMenus.showLinePop(context, clickCallback: (index, selText) { + // print('选中index: $index'); + // print('选中text: $selText'); + // if (index == 0) { + // Get.back(); + // // Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0}); + // Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0}); + // } else if (index == 1) { + // Get.back(); + // Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 1}); + // } + // }, listData: [ + // {'text': '添加'}, + // {'text': '删除'}, + // ]); }, ), - ], + ] :[], backgroundColor: AppColors.mainColor), body: lockList.isNotEmpty ? ListView.separated( @@ -68,6 +89,7 @@ class _LockItemListPageState extends State { btnName: '添加', onClick: () { //选择要添加到分组的锁 + Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0}); }, )), const NoData(), @@ -106,4 +128,26 @@ class _LockItemListPageState extends State { onTap: () {}, ); } + + Future _openModalBottomSheet(GroupListItem groupListItem) async { + showModalBottomSheet( + context: context, + shape: RoundedRectangleBorder( + borderRadius: BorderRadiusDirectional.circular(10)), + builder: (BuildContext context) { + return AlertBottomWidget( + topTitle: '', + items: const ['添加', '删除'], + chooseCallback: (value) { + int getSelectIndex = value; + if (getSelectIndex == 0) { + Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 0}); + } else if (getSelectIndex == 1) { + Get.toNamed(Routers.groupEditLockPage, arguments: {'groupListItem': groupListItem, 'ungrouped': ungrouped, 'type': 1}); + } + + }, + ); + }); + } } diff --git a/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_logic.dart b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_logic.dart new file mode 100644 index 00000000..28056940 --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_logic.dart @@ -0,0 +1,82 @@ + +import 'dart:async'; + +import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/baseGetXController.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; +import 'lockGroupList_state.dart'; + +class LockGroupListLogic extends BaseGetXController { + final LockGroupListState state = LockGroupListState(); + + //分组列表请求 + void mockNetworkDataRequest() async { + var entity = await ApiRepository.to.lockGroupList('1'); + if (entity.errorCode!.codeIsSuccessful) { + if (entity.data != null) { + state.lockNum = 0; + state.itemDataList.value = entity.data!.groupList!; + } + } + } + + //创建锁分组请求 + Future addLockGroupRequest() async { + MassSendLockGroupListEntity entity = + await ApiRepository.to.addLockGroup(state.changeNameController.text, '0'); + if (entity.errorCode!.codeIsSuccessful) { + Toast.show(msg: "创建成功"); + mockNetworkDataRequest(); + } + } + + //编辑锁名字 + Future editLockGroupRequest(int groupId) async { + var entity = await ApiRepository.to.editLockGroupRequest(groupId:groupId, groupName:state.changeNameController.text); + if (entity.errorCode!.codeIsSuccessful) { + Toast.show(msg: "编辑成功"); + mockNetworkDataRequest(); + } + } + + //删除组 + Future deleteLockGroupRequest(int groupId) async { + var entity = await ApiRepository.to.deleteGroup(groupId); + if (entity.errorCode!.codeIsSuccessful) { + Toast.show(msg: "删除成功"); + mockNetworkDataRequest(); + } + } + + // 监听修改完详情之后刷新列表 + late StreamSubscription _teamEvent; + void _initRefreshAction() { + _teamEvent = eventBus.on().listen((event) { + mockNetworkDataRequest(); + }); + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + _initRefreshAction(); + + mockNetworkDataRequest(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + _teamEvent.cancel(); + } + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart new file mode 100644 index 00000000..6c85b8ec --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_page.dart @@ -0,0 +1,217 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; +import 'package:star_lock/tools/showTFView.dart'; +import 'package:star_lock/tools/toast.dart'; + +import '../../../../../../appRouters.dart'; +import '../../../../../../app_settings/app_colors.dart'; +import '../../../../../../tools/commonItem.dart'; +import '../../../../../../tools/titleAppBar.dart'; +import '../../../../../../translations/trans_lib.dart'; +import '../../../../tools/left_slide_actions.dart'; +import '../../../../tools/noData.dart'; +import '../../../../tools/showIosTipView.dart'; +import 'lockGroupList_logic.dart'; + +class LockGroupListPage extends StatefulWidget { + const LockGroupListPage({Key? key}) : super(key: key); + + @override + State createState() => _LockGroupListPageState(); +} + +class _LockGroupListPageState extends State { + final logic = Get.put(LockGroupListLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.lockGroup!.tr, + haveBack: true, + actionsList: [ + IconButton( + icon: Image.asset( + 'images/icon_add_white.png', + width: 36.w, + height: 36.w, + ), + onPressed: () { + // 处理操作按钮的点击事件-添加锁分组 + showCupertinoAlertDialog(context, true, 0); + }, + ), + ], + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + Expanded(child: Obx(() => state.itemDataList.value.isEmpty ? const NoData(): _buildMainUI())), + ], + ), + ); + } + + Widget _buildMainUI() { + for (int i = 0; i < state.itemDataList.value.length; i++) { + GroupListItem itemData = state.itemDataList.value[i]; + state.lockNum += itemData.lockList!.length; + } + return ListView.separated( + itemCount: state.itemDataList.value.length + 1, + itemBuilder: (c, index) { + if (index == state.itemDataList.value.length) { + return Center( + child: Column( + children: [ + SizedBox( + height: 20.h, + ), + SizedBox( + height: 40.h, + child: Text( + '锁数量:${state.lockNum.toString()}', + style: TextStyle( + color: AppColors.darkGrayTextColor, fontSize: 20.sp), + ), + ) + ], + ), + ); + } else { + GroupListItem itemData = state.itemDataList.value[index]; + if(itemData.groupType == 0){ + state.ungrouped = itemData; + } + if (index < state.itemDataList.value.length) { + return LeftSlideActions( + key: Key(itemData.keyGroupId!.toString()), + actionsWidth: itemData.groupType != 0 ? 200.w : 0, + actions: itemData.groupType != 0 ? [ + _buildEditBtn(itemData), + _buildDeleteBtn(itemData), + ] : [], + decoration: const BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(1)), + ), + child: CommonItem( + leftTitel: + '${itemData.keyGroupName}(${itemData.lockList?.length})', + rightTitle: "", + allHeight: 70.h, + action: () { + + Get.toNamed(Routers.lockItemListPage, arguments: {'groupListItem': itemData, "ungrouped": state.ungrouped}); + }), + ); + } + return const SizedBox.shrink(); + } + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }); + } + + void showCupertinoAlertDialog(BuildContext context, bool isAdd, int groupId) { + showDialog( + context: context, + builder: (BuildContext context) { + return ShowTFView( + title: TranslationLoader.lanKeys!.createNewGroup!.tr, + tipTitle: TranslationLoader.lanKeys!.pleaseEnter!.tr, + controller: state.changeNameController, + sureClick: () { + //发送编辑钥匙名称请求 + if (state.changeNameController.text.isNotEmpty) { + if(isAdd == true){ + logic.addLockGroupRequest(); + }else{ + logic.editLockGroupRequest(groupId); + } + Navigator.pop(context); + } else { + Toast.show(msg: '请输入分组名称'); + } + }, + cancelClick: () { + Navigator.pop(context); + }, + ); + }, + ); + } + + Widget _buildDeleteBtn(GroupListItem groupListItem) { + return GestureDetector( + onTap: () { + // 省略: 弹出是否删除的确认对话框。 + showIosTipViewDialog(context, groupListItem); + }, + child: Container( + width: 100.w, + color: const Color(0xFFF20101), + alignment: Alignment.center, + child: const Text( + '删除', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.white, + height: 1, + ), + ), + ), + ); + } + + Widget _buildEditBtn(GroupListItem groupListItem) { + return GestureDetector( + onTap: () { + // 编辑 + state.changeNameController.text = groupListItem.keyGroupName!; + showCupertinoAlertDialog(context, false, groupListItem.keyGroupId!); + }, + child: Container( + width: 100.w, + color: AppColors.mainColor, + alignment: Alignment.center, + child: const Text( + '编辑', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.white, + height: 1, + ), + ), + ), + ); + } + + void showIosTipViewDialog(BuildContext context, GroupListItem groupListItem) { + showDialog( + context: context, + builder: (BuildContext context) { + return ShowIosTipView( + title: "提示", + tipTitle: "确定要删除吗?", + sureClick: () { + Get.back(); + logic.deleteLockGroupRequest(groupListItem.keyGroupId!); + }, + cancelClick: () { + Get.back(); + }, + ); + } + ); + } + +} diff --git a/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_state.dart b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_state.dart new file mode 100644 index 00000000..15d1423c --- /dev/null +++ b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList/lockGroupList_state.dart @@ -0,0 +1,13 @@ + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import '../../../../main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; + +class LockGroupListState { + + TextEditingController changeNameController = TextEditingController(); + var itemDataList = [].obs; + int lockNum = 0; + var ungrouped = GroupListItem(); + +} \ No newline at end of file diff --git a/star_lock/lib/mine/mineSet/lockGroup/lockGroupList_page.dart b/star_lock/lib/mine/mineSet/lockGroup/lockGroupList_page.dart deleted file mode 100644 index 0b74adc8..00000000 --- a/star_lock/lib/mine/mineSet/lockGroup/lockGroupList_page.dart +++ /dev/null @@ -1,158 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupListEntity.dart'; -import 'package:star_lock/network/api_repository.dart'; -import 'package:star_lock/tools/baseGetXController.dart'; -import 'package:star_lock/tools/showTFView.dart'; -import 'package:star_lock/tools/toast.dart'; - -import '../../../../../appRouters.dart'; -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/commonItem.dart'; -import '../../../../../tools/titleAppBar.dart'; -import '../../../../../translations/trans_lib.dart'; - -class LockGroupListPage extends StatefulWidget { - const LockGroupListPage({Key? key}) : super(key: key); - - @override - State createState() => _LockGroupListPageState(); -} - -class _LockGroupListPageState extends State { - TextEditingController _changeNameController = TextEditingController(); - List itemDataList = []; - int lockNum = 0; - - @override - void initState() { - super.initState(); - - mockNetworkDataRequest(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.lockGroup!.tr, - haveBack: true, - actionsList: [ - IconButton( - icon: Image.asset( - 'images/icon_add_white.png', - width: 36.w, - height: 36.w, - ), - onPressed: () { - // 处理操作按钮的点击事件-添加锁分组 - showCupertinoAlertDialog(context); - }, - ), - ], - backgroundColor: AppColors.mainColor), - body: Column( - children: [ - Expanded(child: _buildMainUI()), - ], - ), - ); - } - - Widget _buildMainUI() { - for (int i = 0; i < itemDataList.length; i++) { - GroupListItem itemData = itemDataList[i]; - lockNum += itemData.lockList!.length; - } - return ListView.builder( - itemCount: itemDataList.length + 1, - itemBuilder: (c, index) { - if (index == itemDataList.length) { - return Center( - child: Column( - children: [ - SizedBox( - height: 20.h, - ), - SizedBox( - height: 40.h, - child: Text( - '锁数量:${lockNum.toString()}', - style: TextStyle( - color: AppColors.darkGrayTextColor, fontSize: 20.sp), - ), - ) - ], - ), - ); - } else { - GroupListItem itemData = itemDataList[index]; - - return CommonItem( - leftTitel: - '${itemData.keyGroupName}(${itemData.lockList?.length})', - rightTitle: "", - allHeight: 70.h, - isHaveLine: true, - action: () { - Navigator.pushNamed(context, Routers.lockItemListPage, - arguments: {'lockList': itemData.lockList}); - }); - } - }); - } - - //分组列表请求 - Future> mockNetworkDataRequest() async { - MassSendLockGroupListEntity entity = - await ApiRepository.to.lockGroupList('1'); - List dataList = []; - if (entity.errorCode!.codeIsSuccessful) { - if (entity.data != null) { - dataList = entity.data!.groupList!; - } - } - setState(() { - itemDataList = dataList; - }); - return dataList; - } - - //创建锁分组请求 - Future addLockGroupRequest() async { - MassSendLockGroupListEntity entity = - await ApiRepository.to.addLockGroup(_changeNameController.text, '0'); - if (entity.errorCode!.codeIsSuccessful) { - Toast.show(msg: "创建成功"); - mockNetworkDataRequest(); - setState(() {}); - } - } - - void showCupertinoAlertDialog(BuildContext context) { - showDialog( - context: context, - builder: (BuildContext context) { - return ShowTFView( - title: TranslationLoader.lanKeys!.createNewGroup!.tr, - tipTitle: TranslationLoader.lanKeys!.pleaseEnter!.tr, - controller: _changeNameController, - sureClick: () { - //发送编辑钥匙名称请求 - if (_changeNameController.text.isNotEmpty) { - addLockGroupRequest(); - Navigator.pop(context); - } else { - Toast.show(msg: '请输入分组名称'); - } - }, - cancelClick: () { - Navigator.pop(context); - }, - ); - }, - ); - } -} diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 14869ab0..b474315a 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -47,12 +47,17 @@ abstract class Api { final String updatePasswordKeyURL = '/keyboardPwd/update'; //修改密码详情 final String clearOperationRecordURL = '/lockRecords/clear'; //清空操作记录 final String addlockGroupURL = '/keyGroup/add'; //创建锁分组 + final String editlockGroupURL = '/keyGroup/modifyGroupName'; //编辑锁分组 final String setlockGroupURL = '/keyGroup/setGroup'; //设置锁分组 final String lockGroupListURL = '/authorizedAdmin/listGroup'; //锁分组列表 + final String lockDeletGroupURL = '/keyGroup/delete'; //删除锁分组 + final String lockGroupAddLockURL = '/keyGroup/addLockGroup'; //锁分组里面添加锁 + final String lockGroupDeletLockURL = '/keyGroup/deleteLockGroup'; //锁分组里面删除锁 + final String listLockByGroupURL = '/authorizedAdmin/listLockByGroup'; //获取分组下的锁列表 final String setRoomStatusURL = '/lock/updateLockStatus'; //标记房态 - final String keyGroupListURL = '/keyGroup/list'; //分组列表 - final String lockListByGroupURL = '/room/listByGroup'; //分组下的锁 + // final String keyGroupListURL = '/keyGroup/list'; //分组列表 + // final String lockListByGroupURL = '/room/listByGroup'; //分组下的锁 final String getWifiServiceIpURL = '/wifiLock/getWifiServiceIp'; // 获取Wifi锁服务器 final String updateLockSettingUrl = '/lockSetting/updateLockSetting'; // 锁设置里面所有的设置 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 12f446f2..c31eeef9 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -444,6 +444,11 @@ class ApiProvider extends BaseProvider { addlockGroupURL.toUrl, jsonEncode({'groupName': groupName, 'operatorUid': operatorUid})); + // 编辑锁名字 + Future editLockGroupRequest(int groupId, String groupName) => post( + editlockGroupURL.toUrl, + jsonEncode({'groupId': groupId, 'groupName': groupName})); + Future setLockGroup(String lockId, String groupId) => post( setlockGroupURL.toUrl, jsonEncode({'lockId': lockId, 'groupId': groupId})); @@ -451,6 +456,28 @@ class ApiProvider extends BaseProvider { Future lockGroupList(String type) => post(lockGroupListURL.toUrl, jsonEncode({'type': type})); + // 删除组 + Future deleteGroup(int groupId) => post( + lockDeletGroupURL.toUrl, + jsonEncode({ + 'groupId': groupId, + })); + + // 锁分组里面添加锁 + Future lockGroupAddLock(List lockIds, int groupId) => post( + lockGroupAddLockURL.toUrl, + jsonEncode({ + 'lockId': lockIds, + 'groupId': groupId, + })); + + // 锁分组里面删除锁 + Future lockGroupDeletLock(List lockIds) => post( + lockGroupDeletLockURL.toUrl, + jsonEncode({ + 'lockId': lockIds, + })); + Future selectLockList() => post(selectLockListURL.toUrl, jsonEncode({})); @@ -501,12 +528,12 @@ class ApiProvider extends BaseProvider { // post(updateSettingURL.toUrl, // jsonEncode({'lockId': lockId, 'isOn': isOn, 'type': type})); - Future keyGroupList(String type) => - post(keyGroupListURL.toUrl, jsonEncode({'type': type})); - - Future lockListByGroup(String type, String keyGroupId) => post( - lockListByGroupURL.toUrl, - jsonEncode({'type': type, 'keyGroupId': keyGroupId})); + // Future keyGroupList(String type) => + // post(keyGroupListURL.toUrl, jsonEncode({'type': type})); + // + // Future lockListByGroup(String type, String keyGroupId) => post( + // lockListByGroupURL.toUrl, + // jsonEncode({'type': type, 'keyGroupId': keyGroupId})); /// 锁设置模块 // 自动闭锁 @@ -539,6 +566,16 @@ class ApiProvider extends BaseProvider { 'antiPrySwitch': antiPrySwitch, })); + // 开门方向 + Future setOpenDoorDirectionData( + int lockId, int openDirectionValue) => + post( + updateLockSettingUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'openDirectionValue': openDirectionValue, + })); + // 远程开锁 Future remoteUnlockingOpenOrCloseLoadData(int lockId, int remoteUnlock) => post( diff --git a/star_lock/lib/network/api_provider_base.dart b/star_lock/lib/network/api_provider_base.dart index f8ebd259..f39f9f6f 100644 --- a/star_lock/lib/network/api_provider_base.dart +++ b/star_lock/lib/network/api_provider_base.dart @@ -32,7 +32,7 @@ class BaseProvider extends GetConnect with Api { // print("post: url:${url} body:${body} contentType:${contentType} headers:${headers} query:${query}"); if (isUnShowLoading == false) EasyLoading.show(); - print('哈喽请求body体为:${body}'); + print('星锁请求body体为:${body}'); var res = await super.post(url, body, contentType: contentType, headers: headers, diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 891cf2df..8db146d8 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -440,6 +440,15 @@ class ApiRepository { return MassSendLockGroupListEntity.fromJson(res.body); } + // 编辑锁名字 + Future editLockGroupRequest({ + required int groupId, + required String groupName + }) async { + final res = await apiProvider.editLockGroupRequest(groupId, groupName); + return MassSendLockGroupListEntity.fromJson(res.body); + } + //设置锁分组 Future setLockGroup( String lockId, String groupId) async { @@ -453,6 +462,34 @@ class ApiRepository { return MassSendLockGroupListEntity.fromJson(res.body); } + //删除锁分组 + Future deleteGroup(int groupId) async { + final res = + await apiProvider.deleteGroup(groupId); + return MassSendLockGroupListEntity.fromJson(res.body); + } + + //锁分组里面添加锁 + Future lockGroupAddLock( + { + required List lockIds, + required int groupId + }) async { + final res = + await apiProvider.lockGroupAddLock(lockIds, groupId); + return MassSendLockGroupListEntity.fromJson(res.body); + } + + //锁分组里面删除锁 + Future lockGroupDeletLock( + { + required List lockIds + }) async { + final res = + await apiProvider.lockGroupDeletLock(lockIds); + return MassSendLockGroupListEntity.fromJson(res.body); + } + //选择锁列表 Future selectLockList() async { final res = await apiProvider.selectLockList(); @@ -505,18 +542,18 @@ class ApiRepository { return PasswordKeyEntity.fromJson(res.body); } - //分组列表 - Future keyGroupList(String type) async { - final res = await apiProvider.keyGroupList(type); - return PasswordKeyEntity.fromJson(res.body); - } - - //分组下的锁 - Future lockListByGroup( - String type, String keyGroupId) async { - final res = await apiProvider.lockListByGroup(type, keyGroupId); - return PasswordKeyEntity.fromJson(res.body); - } + // //分组列表 + // Future keyGroupList111(String type) async { + // final res = await apiProvider.keyGroupList(type); + // return PasswordKeyEntity.fromJson(res.body); + // } + // + // //分组下的锁 + // Future lockListByGroup111( + // String type, String keyGroupId) async { + // final res = await apiProvider.lockListByGroup(type, keyGroupId); + // return PasswordKeyEntity.fromJson(res.body); + // } // 获取Wifi锁服务器 Future getWifiLockServiceIpAndPort() async { @@ -585,6 +622,16 @@ class ApiRepository { return LoginEntity.fromJson(res.body); } + // 设置开门方向 + Future setOpenDoorDirectionData({ + required int lockId, + required int openDirectionValue, + }) async { + final res = + await apiProvider.setOpenDoorDirectionData(lockId, openDirectionValue); + return LoginEntity.fromJson(res.body); + } + // 设置房态 Future setRoomStatusData({ required int lockId, diff --git a/star_lock/lib/tools/eventBusEventManage.dart b/star_lock/lib/tools/eventBusEventManage.dart index c46d8f1e..52dc945d 100644 --- a/star_lock/lib/tools/eventBusEventManage.dart +++ b/star_lock/lib/tools/eventBusEventManage.dart @@ -42,4 +42,9 @@ class ScanAllDeviceFindCurrentDeviceConnectedEvent{ class ChangeLanguageBlockLastLanguageEvent{ String languageTitle; ChangeLanguageBlockLastLanguageEvent(this.languageTitle); +} + +/// 锁分组添加或者删除锁之后刷新首页数据 +class LockGroupEditGroupLockRefreshEvent{ + LockGroupEditGroupLockRefreshEvent(); } \ No newline at end of file diff --git a/star_lock/lib/tools/left_slide_actions.dart b/star_lock/lib/tools/left_slide_actions.dart index faa250cb..90762da5 100644 --- a/star_lock/lib/tools/left_slide_actions.dart +++ b/star_lock/lib/tools/left_slide_actions.dart @@ -88,8 +88,7 @@ class _LeftSlideActionsState extends State } void _onHorizontalDragUpdate(DragUpdateDetails details) { - _translateX = - (_translateX + details.delta.dx).clamp(-widget.actionsWidth, 0.0); + _translateX = (_translateX + details.delta.dx).clamp(-widget.actionsWidth, 0.0); setState(() {}); }