diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index 4fc21bb8..472d1f5f 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -122,6 +122,8 @@ "remoteUnlocking":"Remote Unlocking", "automaticBlocking":"Automatic Blocking", "normallyOpenMode":"Normally Open Mode", + "automaticUnLock":"Automatic UnLock", + "automaticUnLockTip":"After opening, the lock will open automatically at the beginning of the normally open mode", "lockSound":"Lock Sound", "burglarAlarm":"Burglar Alarm", "resetButton":"Reset Button", @@ -226,6 +228,8 @@ "lockScreen":"Lock Screen", "closed":"Closed", "opened":"Opened", + "close":"Close", + "open":"Open", "hideInvalidUnlockPermissions":"Hide Invalid Unlock Permissions", "appUnlockRequiresMobilePhoneAccessToTheLock":"APP Unlock Requires Mobile Phone Access To The Lock", "valueAddedServices":"Value Added Services", @@ -390,5 +394,11 @@ "lockScreenTip":"After the function is enabled, you need to use your fingerprint, face or account password to open the APP. There is no need to verify again for 3 minutes", "hideInvalidUnlockPermissionsTip":"After the function is enabled, the password, electronic key, card, fingerprint and other unlocking permissions that have been invalid for a long time will be hidden and not displayed in the list.", "appUnlockRequiresMobilePhoneAccessToTheLockTip":"For the selected locks, when the user uses the APP to unlock the lock, his phone needs to be connected to the Internet, otherwise the lock cannot be unlocked", - "checkAll":"Check All" + "checkAll":"Check All", + + "wifiDistributionNetwork":"WiFi Distribution Network", + "configuringWiFi":"Configuring WiFi", + "pleaseEnterWifiName":"Please Enter Wifi Name", + "wifiPwd":"WiFi password", + "pleaseEnterWifiPwd":"Please Enter WiFi Password" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index de90f57e..9bc856b7 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -122,6 +122,8 @@ "remoteUnlocking":"remoteUnlocking", "automaticBlocking":"automaticBlocking", "normallyOpenMode":"normallyOpenMode", + "automaticUnLock":"automaticUnLock", + "automaticUnLockTip":"automaticUnLockTip", "lockSound":"lockSound", "burglarAlarm":"burglarAlarm", "resetButton":"resetButton", @@ -223,6 +225,8 @@ "lockScreen":"lockScreen", "closed":"closed", "opened":"opened", + "close":"close", + "open":"open", "hideInvalidUnlockPermissions":"hideInvalidUnlockPermissions", "appUnlockRequiresMobilePhoneAccessToTheLock":"appUnlockRequiresMobilePhoneAccessToTheLock", "valueAddedServices":"valueAddedServices", @@ -390,5 +394,11 @@ "lockScreenTip":"lockScreenTip", "hideInvalidUnlockPermissionsTip":"hideInvalidUnlockPermissionsTip", "appUnlockRequiresMobilePhoneAccessToTheLockTip":"appUnlockRequiresMobilePhoneAccessToTheLockTip", - "checkAll":"checkAll" + "checkAll":"checkAll", + + "wifiDistributionNetwork":"wifiDistributionNetwork", + "configuringWiFi":"configuringWiFi", + "pleaseEnterWifiName":"pleaseEnterWifiName", + "wifiPwd":"wifiPwd", + "pleaseEnterWifiPwd":"pleaseEnterWifiPwd" } \ No newline at end of file diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index 110d48d8..3be9ca46 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -122,6 +122,8 @@ "remoteUnlocking":"远程开锁", "automaticBlocking":"自动闭锁", "normallyOpenMode":"常开模式", + "automaticUnLock":"自动开锁", + "automaticUnLockTip":"开启后锁将在常开模式开始时自动打开", "lockSound":"锁声音", "burglarAlarm":"防撬报警", "resetButton":"重置键", @@ -223,6 +225,8 @@ "lockScreen":"锁屏", "closed":"已关闭", "opened":"已开启", + "close":"关闭", + "open":"开启", "hideInvalidUnlockPermissions":"隐藏无效开锁权限", "appUnlockRequiresMobilePhoneAccessToTheLock":"APP开锁时需手机连网的锁", "valueAddedServices":"增值服务", @@ -393,5 +397,11 @@ "lockScreenTip":"功能开启后,需使用指纹、人脸或账号密码来打开 APP。3分钟内不需要再次验证", "hideInvalidUnlockPermissionsTip":"功能开启后,已失效较长时间的密码、电子钥匙、卡、指纹等开锁权限将被隐藏,不在列表里显示。", "appUnlockRequiresMobilePhoneAccessToTheLockTip":"对于选中的这些锁,当用户用APP开锁时,他的手机需要是连网的,否则无法开锁", - "checkAll":"全选" + "checkAll":"全选", + + "wifiDistributionNetwork":"WiFi配网", + "configuringWiFi":"配置WiFi", + "pleaseEnterWifiName":"请输入WiFi名字", + "wifiPwd":"WiFi名字", + "pleaseEnterWifiPwd":"请输入WiFi密码" } \ No newline at end of file diff --git a/star_lock/ios/Podfile.lock b/star_lock/ios/Podfile.lock index 379be2ea..bed9bd9a 100644 --- a/star_lock/ios/Podfile.lock +++ b/star_lock/ios/Podfile.lock @@ -32,6 +32,8 @@ PODS: - GoogleMaps/Base - image_picker_ios (0.0.1): - Flutter + - network_info_plus (0.0.1): + - Flutter - package_info_plus (0.4.5): - Flutter - path_provider_foundation (0.0.1): @@ -63,6 +65,7 @@ DEPENDENCIES: - geocoding_ios (from `.symlinks/plugins/geocoding_ios/ios`) - google_maps_flutter_ios (from `.symlinks/plugins/google_maps_flutter_ios/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) + - network_info_plus (from `.symlinks/plugins/network_info_plus/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) @@ -101,6 +104,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/google_maps_flutter_ios/ios" image_picker_ios: :path: ".symlinks/plugins/image_picker_ios/ios" + network_info_plus: + :path: ".symlinks/plugins/network_info_plus/ios" package_info_plus: :path: ".symlinks/plugins/package_info_plus/ios" path_provider_foundation: @@ -129,6 +134,7 @@ SPEC CHECKSUMS: google_maps_flutter_ios: abdac20d6ce8931f6ebc5f46616df241bfaa2cfd GoogleMaps: 025272d5876d3b32604e5c080dc25eaf68764693 image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5 + network_info_plus: 122280582fe2fa2bbb8681a4269745cd5c3a9b32 package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6 diff --git a/star_lock/ios/Runner.xcodeproj/project.pbxproj b/star_lock/ios/Runner.xcodeproj/project.pbxproj index 004b97ec..9f133cf6 100644 --- a/star_lock/ios/Runner.xcodeproj/project.pbxproj +++ b/star_lock/ios/Runner.xcodeproj/project.pbxproj @@ -372,6 +372,8 @@ ALWAYS_SEARCH_USER_PATHS = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = ZJ29NYHTV5; ENABLE_BITCODE = NO; @@ -382,6 +384,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; }; name = Profile; @@ -500,6 +503,8 @@ ALWAYS_SEARCH_USER_PATHS = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = ZJ29NYHTV5; ENABLE_BITCODE = NO; @@ -510,6 +515,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -521,6 +527,8 @@ ALWAYS_SEARCH_USER_PATHS = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = ZJ29NYHTV5; ENABLE_BITCODE = NO; @@ -531,6 +539,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "cn.star-lock.lock"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; diff --git a/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index f3d88ace..c87d15a3 100644 --- a/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/star_lock/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -40,7 +40,7 @@ - + + com.apple.external-accessory.wireless-configuration + + diff --git a/star_lock/lib/appRouters.dart b/star_lock/lib/appRouters.dart index 4edb0965..abe82a75 100644 --- a/star_lock/lib/appRouters.dart +++ b/star_lock/lib/appRouters.dart @@ -36,6 +36,7 @@ import 'main/lockDetail/lcokSet/basicInformation/editLockName/editLockName_page. import 'main/lockDetail/lcokSet/basicInformation/lockSeletGrouping/lockSeletGrouping_page.dart'; import 'main/lockDetail/lcokSet/basicInformation/uploadElectricQuantity/uploadElectricQuantity_page.dart'; import 'main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_page.dart'; +import 'main/lockDetail/lcokSet/configuringWifi/configuringWifi_page.dart'; import 'main/lockDetail/lcokSet/diagnose/diagnose_page.dart'; import 'main/lockDetail/lcokSet/doorMagnetic/addDoorMagnetic/addDoorMagnetic_page.dart'; import 'main/lockDetail/lcokSet/doorMagnetic/doorMagneticList/doorMagnetic_page.dart'; @@ -189,6 +190,7 @@ abstract class Routers { static const burglarAlarmPage = '/BurglarAlarmPage'; // 防撬警报 static const resetButtonPage = '/ResetButtonPage'; // 锁重置键 static const unlockQRCodePage = '/UnlockQRCodePage'; // 开锁二维码 + static const configuringWifiPage = '/ConfiguringWifiPage'; // 配置WiFi static const lockTimePage = '/LockTimePage'; // 锁时间 static const diagnosePage = '/DiagnosePage'; // 诊断 static const uploadDataPage = '/UploadDataPage'; // 上传数据 @@ -734,5 +736,8 @@ abstract class AppRouters { GetPage( name: Routers.addFingerprintPage, page: () => const AddFingerprintPage()), + GetPage( + name: Routers.configuringWifiPage, + page: () => const ConfiguringWifiPage()), ]; } diff --git a/star_lock/lib/blue/io_protocol/io_checkingUserInfoCount.dart b/star_lock/lib/blue/io_protocol/io_checkingUserInfoCount.dart new file mode 100644 index 00000000..e95bf38e --- /dev/null +++ b/star_lock/lib/blue/io_protocol/io_checkingUserInfoCount.dart @@ -0,0 +1,120 @@ + +//TODO:查询用户、指纹、密码、卡片数量(用于判断是否同步) +import 'dart:convert'; + +import '../io_reply.dart'; +import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; +import '../io_type.dart'; +import '../sm4Encipher/sm4.dart'; +import 'package:crypto/crypto.dart' as crypto; + +class SenderCheckingUserInfoCountCommand extends SenderProtocol { + + String? keyID; + String? userID; + int? role; + int? nowTime; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; + + SenderCheckingUserInfoCountCommand({ + this.keyID, + this.userID, + this.role, + this.nowTime, + 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(15); + + // keyID 40 + int keyIDLength = utf8.encode(keyID!).length; + subData.addAll(utf8.encode(keyID!)); + subData = getFixedLengthList(subData, 40 - keyIDLength); + + //userID 20 + int userIDLength = utf8.encode(userID!).length; + subData.addAll(utf8.encode(userID!)); + subData = getFixedLengthList(subData, 20 - userIDLength); + + // Role + subData.add(role!); + + // time + subData.add((nowTime! & 0xff000000) >> 24); + subData.add((nowTime! & 0xff0000) >> 16); + subData.add((nowTime! & 0xff00) >> 8); + subData.add((nowTime! & 0xff)); + + // token + // subData.addAll(token!); + + 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 SenderCheckingUserInfoCountReply extends Reply { + SenderCheckingUserInfoCountReply.parseData(CommandType commandType, List dataDetail) + : super.parseData(commandType, dataDetail) { + data = dataDetail; + } +} \ No newline at end of file diff --git a/star_lock/lib/blue/io_protocol/io_configuringWifi.dart b/star_lock/lib/blue/io_protocol/io_configuringWifi.dart new file mode 100644 index 00000000..00575c68 --- /dev/null +++ b/star_lock/lib/blue/io_protocol/io_configuringWifi.dart @@ -0,0 +1,131 @@ + +//TODO:WIFI配网 +import 'dart:convert'; + +import '../io_reply.dart'; +import '../io_sender.dart'; +import '../io_tool/io_tool.dart'; +import '../io_type.dart'; +import '../sm4Encipher/sm4.dart'; +import 'package:crypto/crypto.dart' as crypto; + +class SenderConfiguringWifiCommand extends SenderProtocol { + + String? keyID; + String? userID; + String? ssid; + String? password; + int? numberOfServers; + int? listOfServers; + List? token; + int? needAuthor; + List? publicKey; + List? privateKey; + + SenderConfiguringWifiCommand({ + this.keyID, + this.userID, + this.ssid, + this.password, + this.numberOfServers, + this.listOfServers, + 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(50); + + // keyID 40 + int keyIDLength = utf8.encode(keyID!).length; + subData.addAll(utf8.encode(keyID!)); + subData = getFixedLengthList(subData, 40 - keyIDLength); + + //userID 20 + int userIDLength = utf8.encode(userID!).length; + subData.addAll(utf8.encode(userID!)); + subData = getFixedLengthList(subData, 20 - userIDLength); + + //SSID 30 + int ssidLength = utf8.encode(ssid!).length; + subData.addAll(utf8.encode(ssid!)); + subData = getFixedLengthList(subData, 30 - ssidLength); + + //Password 20 + int passwordLength = utf8.encode(password!).length; + subData.addAll(utf8.encode(password!)); + subData = getFixedLengthList(subData, 20 - passwordLength); + + // NumberOfServers + subData.add(numberOfServers!); + + // listOfServers + subData.add(listOfServers!); + + // token + // subData.addAll(token!); + + if(needAuthor == 0){ + //AuthCodeLen 1 + subData.add(0); + } else { + List authCodeData = []; + + //userID + 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 SenderConfiguringWifiReply extends Reply { + SenderConfiguringWifiReply.parseData(CommandType commandType, List dataDetail) + : super.parseData(commandType, dataDetail) { + data = dataDetail; + } +} \ No newline at end of file diff --git a/star_lock/lib/blue/io_tool/manager_event_bus.dart b/star_lock/lib/blue/io_tool/manager_event_bus.dart index e202f64d..d094cff5 100644 --- a/star_lock/lib/blue/io_tool/manager_event_bus.dart +++ b/star_lock/lib/blue/io_tool/manager_event_bus.dart @@ -22,9 +22,3 @@ class EventBusManager { eventBus?.fire(event); } } - - -///刷新锁列表数据 -class RefreshLockListInfoDataEvent{ - RefreshLockListInfoDataEvent(); -} \ No newline at end of file diff --git a/star_lock/lib/blue/reciver_data.dart b/star_lock/lib/blue/reciver_data.dart index 928117b7..8c623bdb 100644 --- a/star_lock/lib/blue/reciver_data.dart +++ b/star_lock/lib/blue/reciver_data.dart @@ -16,6 +16,8 @@ import 'io_protocol/io_addFingerprint.dart'; import 'io_protocol/io_addUser.dart'; import 'io_protocol/io_automaticPadlock.dart'; import 'io_protocol/io_checkingCardStatus.dart'; +import 'io_protocol/io_checkingUserInfoCount.dart'; +import 'io_protocol/io_configuringWifi.dart'; import 'io_protocol/io_getPrivateKey.dart'; import 'io_protocol/io_getPublicKey.dart'; import 'io_protocol/io_openLock.dart'; @@ -174,6 +176,12 @@ class CommandReciverManager { reply = AutomaticPadlockReply.parseData(commandType, data); } break; + case 15: + { + // 查询用户、指纹、密码、卡片数量(用于判断是否同步) + reply = SenderCheckingUserInfoCountReply.parseData(commandType, data); + } + break; case 20: { // 查询卡片状态 @@ -210,6 +218,12 @@ class CommandReciverManager { reply = SenderReferEventRecordNumberReply.parseData(commandType, data); } break; + case 51: + { + // wifi配网结果 + reply = SenderConfiguringWifiReply.parseData(commandType, data); + } + break; } } break; diff --git a/star_lock/lib/blue/sender_manage.dart b/star_lock/lib/blue/sender_manage.dart index 1bd9a94e..a00b4756 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -6,6 +6,8 @@ import 'io_protocol/io_addFingerprint.dart'; import 'io_protocol/io_addUser.dart'; import 'io_protocol/io_automaticPadlock.dart'; import 'io_protocol/io_checkingCardStatus.dart'; +import 'io_protocol/io_checkingUserInfoCount.dart'; +import 'io_protocol/io_configuringWifi.dart'; import 'io_protocol/io_editUser.dart'; import 'io_protocol/io_factoryDataReset.dart'; import 'io_protocol/io_getPrivateKey.dart'; @@ -430,4 +432,56 @@ class IoSenderManage { privateKey: privateKey, ), callBack:callBack); } + + //todo:查询用户、指纹、密码、卡片数量(用于判断是否同步) + static void senderCheckingUserInfoCountCommand({ + required String? keyID, + required String? userID, + required int? role, + required int? nowTime, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { + CommandSenderManager().managerSendData( + command: SenderCheckingUserInfoCountCommand( + keyID: keyID, + userID: userID, + role: role, + nowTime: nowTime, + token: token, + needAuthor: needAuthor, + publicKey: publicKey, + privateKey: privateKey, + ), callBack:callBack); + } + + //todo:配置wifi + static void senderConfiguringWifiCommand({ + required String? keyID, + required String? userID, + required String? ssid, + required String? password, + required int? numberOfServers, + required int? listOfServers, + required List? token, + required int? needAuthor, + required List? publicKey, + required List? privateKey, + CommandSendCallBack? callBack}) { + CommandSenderManager().managerSendData( + command: SenderConfiguringWifiCommand( + keyID: keyID, + userID: userID, + ssid: ssid, + password: password, + numberOfServers: numberOfServers, + listOfServers: listOfServers, + token: token, + needAuthor: needAuthor, + publicKey: publicKey, + privateKey: privateKey, + ), callBack:callBack); + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart index bebc7caf..76918278 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_logic.dart @@ -11,11 +11,35 @@ 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/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; +import '../../../../tools/toast.dart'; import 'automaticBlocking_state.dart'; class AutomaticBlockingLogic extends BaseGetXController{ - final AutomaticBlockingState automaticBlockingState = AutomaticBlockingState(); + final AutomaticBlockingState state = AutomaticBlockingState(); + + void setAutoUnLock() async{ + String autoTime; + if(state.isOpen.value == false){ + autoTime = "-1"; + }else{ + autoTime = state.autoLockTime.value; + } + + var entity = await ApiRepository.to.setAutoUnlock( + lockId: state.getKeyInfosData.value.lockId.toString(), + autoLockTime:autoTime, + type: "1", + ); + if(entity.errorCode!.codeIsSuccessful){ + state.getKeyInfosData.value.autoLockTime = int.parse(autoTime); + eventBus.fire(RefreshLockListInfoDataEvent()); + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Toast.show(msg: "操作成功"); + } + } // 获取解析后的数据 late StreamSubscription _replySubscription; @@ -40,8 +64,6 @@ class AutomaticBlockingLogic extends BaseGetXController{ //成功 print("${reply.commandType}数据解析成功"); - // 锁当前时间 - break; case 0x06: //无权限 @@ -66,7 +88,7 @@ class AutomaticBlockingLogic extends BaseGetXController{ } } - // 校时数据解析 + // 设置自动落锁数据解析 Future _replyAutomaticPadlock(Reply reply) async { int status = reply.data[2]; switch(status){ @@ -101,8 +123,8 @@ class AutomaticBlockingLogic extends BaseGetXController{ // 获取锁状态 Future _getLockStatus() async { // 进来之后首先连接 - BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { - if (state == DeviceConnectionState.connected) { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); IoSenderManage.senderGetLockStatu( @@ -114,10 +136,10 @@ class AutomaticBlockingLogic extends BaseGetXController{ }); } - // 校验时间 - Future sendTiming() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { - if (state == DeviceConnectionState.connected) { + // 自动落锁 + Future sendAutoLock() async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { + if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -127,11 +149,11 @@ class AutomaticBlockingLogic extends BaseGetXController{ var signKey = await Storage.getStringList(saveBlueSignKey); List getSignKeyList = changeStringListToIntList(signKey!); - print("automaticBlockingState.isOpen.value:${automaticBlockingState.isOpen.value}"); + print("automaticBlockingState.isOpen.value:${state.isOpen.value}"); IoSenderManage.senderAutomaticPadlockCommand( lockID:BlueManage().connectDeviceName, userID:await Storage.getUid(), - autoLockFlag:automaticBlockingState.isOpen.value ? 1 : 0, + autoLockFlag:state.isOpen.value ? 1 : 0, token:getTokenList, needAuthor:1, signKey:getSignKeyList, diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart index debf7e8b..2545f7a9 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart @@ -22,7 +22,7 @@ class AutomaticBlockingPage extends StatefulWidget { class _AutomaticBlockingPageState extends State { final TextEditingController _timeController = TextEditingController(); final logic = Get.put(AutomaticBlockingLogic()); - final state = Get.find().automaticBlockingState; + final state = Get.find().state; @override Widget build(BuildContext context) { @@ -38,8 +38,9 @@ class _AutomaticBlockingPageState extends State { style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () { - logic.sendTiming(); - }, + // logic.sendAutoLock(); + logic.setAutoUnLock(); + }, ), ], backgroundColor: AppColors.mainColor), @@ -47,7 +48,7 @@ class _AutomaticBlockingPageState extends State { children: [ Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.automaticBlocking!.tr, - rightTitle: "${state.automaticBlockingTime}s", + rightTitle: "${state.autoLockTime}s", isHaveLine: false, isHaveRightWidget: true, rightWidget: @@ -56,9 +57,9 @@ class _AutomaticBlockingPageState extends State { height: 10.h, ), Builder(builder: (context) { - return CommonItem( + return Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.delayTime!.tr, - rightTitle: "5s", + rightTitle: "${state.autoLockTime.value}s", isHaveLine: false, isHaveDirection: true, action: () { @@ -71,10 +72,10 @@ class _AutomaticBlockingPageState extends State { TranslationLoader.lanKeys!.custom!.tr ]; ShowBottomSheetTool().showSingleRowPicker( - //上下文 + //上下文 context, //默认的索引 - normalIndex: 2, + normalIndex: 0, title: TranslationLoader.lanKeys!.time!.tr, cancelTitle: TranslationLoader.lanKeys!.cancel!.tr, sureTitle: TranslationLoader.lanKeys!.sure!.tr, @@ -85,12 +86,12 @@ class _AutomaticBlockingPageState extends State { //选择事件的回调 clickCallBack: (int index, var str) { if(index != 5){ - state.automaticBlockingTime.value = str.toString(); + state.autoLockTime.value = str.toString(); }else{ state.isCustomLockTime.value = true; } }); - }); + })); }), Container( height: 10.h, diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart index 303074f2..eca4579e 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart @@ -1,8 +1,26 @@ import 'package:get/get.dart'; +import '../../../lockMian/entity/lockInfoEntity.dart'; + class AutomaticBlockingState { - var isOpen = false.obs; - var automaticBlockingTime = "5".obs; - var isCustomLockTime = false.obs; + var getKeyInfosData = KeyInfos().obs; + + var isOpen = false.obs;// 是否开启自动落锁 + var autoLockTime = "5".obs; + var isCustomLockTime = false.obs;// 自定义 + + AutomaticBlockingState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + isOpen.value = getKeyInfosData.value.autoLockTime! > -1 ? true : false; + autoLockTime.value = getKeyInfosData.value.autoLockTime!.toString(); + if((getKeyInfosData.value.autoLockTime! > 0) + && (getKeyInfosData.value.autoLockTime! != 5) + && (getKeyInfosData.value.autoLockTime! != 10) + && (getKeyInfosData.value.autoLockTime! != 15) + && (getKeyInfosData.value.autoLockTime! != 30) + && (getKeyInfosData.value.autoLockTime! != 60)){ + isCustomLockTime.value = true; + } + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart new file mode 100644 index 00000000..e7fedce9 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_logic.dart @@ -0,0 +1,29 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; +import 'burglarAlarm_state.dart'; + +class BurglarAlarmLogic extends BaseGetXController{ + BurglarAlarmState state = BurglarAlarmState(); + + // 配置锁的常开模式设置 -> 防撬报警 + Future setLockSetGeneralSetting() async{ + var entity = await ApiRepository.to.setLockSetGeneralSettingData( + lockId: state.getKeyInfosData.value.lockId.toString(), + changeType:"1", + isOn:state.burglarAlarmEnable.value == 1 ? "2" : "1", // 1-开启、2-关闭; + type:"3", // 3 防撬报警 + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshLockListInfoDataEvent()); + + state.burglarAlarmEnable.value = state.burglarAlarmEnable.value == 1 ? 2 : 1; + state.getKeyInfosData.value.tamperAlert = state.burglarAlarmEnable.value; + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Toast.show(msg: "操作成功"); + } + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_page.dart b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_page.dart index 8b1eee67..5d4458ec 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_page.dart @@ -6,6 +6,7 @@ import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'burglarAlarm_logic.dart'; class BurglarAlarmPage extends StatefulWidget { const BurglarAlarmPage({Key? key}) : super(key: key); @@ -15,6 +16,9 @@ class BurglarAlarmPage extends StatefulWidget { } class _BurglarAlarmPageState extends State { + final logic = Get.put(BurglarAlarmLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -40,27 +44,29 @@ class _BurglarAlarmPageState extends State { SizedBox( height: 20.h, ), - Row( + Obx(() => Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Text( - "${TranslationLoader.lanKeys!.currentMode!.tr} : ${TranslationLoader.lanKeys!.opened!.tr}", - style: + "${TranslationLoader.lanKeys!.currentMode!.tr} : ${state.burglarAlarmEnable.value == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr}", + style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w600), - )), + )), ], - ), + )), SizedBox( height: 40.h, ), - SubmitBtn( - btnName: TranslationLoader.lanKeys!.closed!.tr, + Obx(() => SubmitBtn( + btnName: state.burglarAlarmEnable.value == 1 ? TranslationLoader.lanKeys!.close!.tr : TranslationLoader.lanKeys!.open!.tr, borderRadius: 20.w, fontSize: 32.sp, // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), - onClick: () {}), + onClick: () { + logic.setLockSetGeneralSetting(); + })), ], ), )); diff --git a/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_state.dart b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_state.dart new file mode 100644 index 00000000..cfa688a7 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/burglarAlarm/burglarAlarm_state.dart @@ -0,0 +1,16 @@ + +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class BurglarAlarmState{ + var getKeyInfosData = KeyInfos().obs; + + var burglarAlarmEnable = 1.obs; + + BurglarAlarmState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + burglarAlarmEnable.value = getKeyInfosData.value.tamperAlert!; + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifiEntity.dart b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifiEntity.dart new file mode 100644 index 00000000..dbed5c9c --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifiEntity.dart @@ -0,0 +1,72 @@ +class ConfiguringWifiEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + ConfiguringWifiEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + ConfiguringWifiEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + int? serviceNum; + List? serviceList; + + Data({this.serviceNum, this.serviceList}); + + Data.fromJson(Map json) { + serviceNum = json['serviceNum']; + if (json['serviceList'] != null) { + serviceList = []; + json['serviceList'].forEach((v) { + serviceList!.add(ServiceList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['serviceNum'] = serviceNum; + if (serviceList != null) { + data['serviceList'] = serviceList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ServiceList { + String? serviceIp; + String? port; + + ServiceList({this.serviceIp, this.port}); + + ServiceList.fromJson(Map json) { + serviceIp = json['serviceIp']; + port = json['port']; + } + + Map toJson() { + final Map data = {}; + data['serviceIp'] = serviceIp; + data['port'] = port; + return data; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart new file mode 100644 index 00000000..dc7e7f8f --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_logic.dart @@ -0,0 +1,175 @@ + +import 'dart:async'; + +import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; +import 'package:network_info_plus/network_info_plus.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../blue/blue_manage.dart'; +import '../../../../blue/io_protocol/io_configuringWifi.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/storage.dart'; +import 'configuringWifi_state.dart'; + +class ConfiguringWifiLogic extends BaseGetXController{ + final ConfiguringWifiState state = ConfiguringWifiState(); + + Future getWifiLockServiceIpAndPort() async { + var entity = await ApiRepository.to.getWifiLockServiceIpAndPort(); + if(entity.errorCode! == 0){ + state.configuringWifiEntity.value = entity; + } + } + + // 监听设备返回的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { + // 配置wifi + if(reply is SenderConfiguringWifiReply) { + _replySenderConfiguringWifi(reply); + } + }); + } + + // 开门数据解析 + Future _replySenderConfiguringWifi(Reply reply) async { + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); + + var tokenData = reply.data.sublist(2, 6); + var saveStrList = changeIntListToStringList(tokenData); + print("openDoorToken:$tokenData"); + Storage.setStringList(saveBlueToken, saveStrList); + + int status = reply.data[6]; + print("status:$status"); + + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + + break; + case 0x06: + //无权限 + print("${reply.commandType}需要鉴权"); + + IoSenderManage.senderOpenLock( + keyID: "1", + userID: await Storage.getUid(), + openMode: 1, + openTime: DateTime.now().millisecondsSinceEpoch, + token: tokenData, + needAuthor: 1, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + ); + + break; + case 0x07: + //无权限 + print("${reply.commandType}用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("${reply.commandType}校验错误"); + + break; + default: + //失败 + print("${reply.commandType}失败"); + + break; + } + } + + // 点击配置wifi + Future senderConfiguringWifiAction() 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 publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + print("openDoorTokenPubToken:$getTokenList"); + + print("millisecondsSinceEpoch/1000:${DateTime.now().millisecondsSinceEpoch~/1000}"); + IoSenderManage.senderConfiguringWifiCommand( + keyID: "1", + userID: await Storage.getUid(), + ssid: state.wifiNameController.text, + password: state.wifiPWDController.text, + numberOfServers: state.configuringWifiEntity.value.data!.serviceNum, + listOfServers: 0, + token: getTokenList, + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + ); + } + }); + } + + final _networkInfo = NetworkInfo(); + Future getWifiName() async { + // if(!(await checkLocationPermission())) { + // print("未获取定位权限"); + // return ''; + // } + var ssid = ''; + ssid = (await _networkInfo.getWifiName())!; + ssid = ssid ?? ''; + ssid = ssid.replaceAll(r'"', ''); + print("ssid:$ssid"); + return ssid ?? ''; + } + + ///定位权限 + Future checkLocationPermission() async { + PermissionStatus value = await locationPermission(); + bool allow = value != PermissionStatus.permanentlyDenied && value != PermissionStatus.denied; + return allow; + } + + Future locationPermission() async => Permission.location.request(); + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + + getWifiName().then((value) { + print("wifiName:$value"); + state.wifiNameController.text = value; + }); + + getWifiLockServiceIpAndPort(); + _initReplySubscription(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_page.dart b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_page.dart new file mode 100644 index 00000000..2d29585f --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_page.dart @@ -0,0 +1,92 @@ + +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/commonItem.dart'; +import '../../../../tools/submitBtn.dart'; +import '../../../../tools/titleAppBar.dart'; +import '../../../../translations/trans_lib.dart'; +import 'configuringWifi_logic.dart'; + +class ConfiguringWifiPage extends StatefulWidget { + const ConfiguringWifiPage({Key? key}) : super(key: key); + + @override + State createState() => _ConfiguringWifiPageState(); +} + +class _ConfiguringWifiPageState extends State { + final logic = Get.put(ConfiguringWifiLogic()); + final state = Get.find().state; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.configuringWiFi!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + children: [ + configuringWifiTFWidget(TranslationLoader.lanKeys!.wifiName!.tr, TranslationLoader.lanKeys!.pleaseEnterWifiName!.tr, state.wifiNameController), + Container(width: 1.sw, height: 1.h,color: AppColors.mainBackgroundColor), + configuringWifiTFWidget(TranslationLoader.lanKeys!.wifiPassward!.tr, TranslationLoader.lanKeys!.pleaseEnterWifiPwd!.tr, state.wifiPWDController), + SizedBox(height: 50.h,), + SubmitBtn(btnName: TranslationLoader.lanKeys!.sure!.tr, onClick: () { + + }), + ], + )); + } + + Widget configuringWifiTFWidget( + String titleStr, String rightTitle,TextEditingController controller) { + return Column( + children: [ + Container(height: 10.h), + CommonItem( + leftTitel: titleStr, + rightTitle: "", + isHaveRightWidget: true, + rightWidget: getTFWidget(rightTitle)), + Container(height: 10.h), + ], + ); + } + + // 接受者信息输入框 + Widget getTFWidget(String tfStr) { + return Container( + height: 50.h, + width: 300.w, + child: Row( + children: [ + Expanded( + child: TextField( + //输入框一行 + maxLines: 1, + // controller: _controller, + autofocus: false, + textAlign: TextAlign.end, + decoration: InputDecoration( + //输入里面输入文字内边距设置 + contentPadding: const EdgeInsets.only(top: 12.0, bottom: 8.0), + hintText: tfStr, + hintStyle: TextStyle(fontSize: 24.sp), + //不需要输入框下划线 + border: InputBorder.none, + ), + ), + ), + SizedBox( + width: 10.w, + ), + ], + ), + ); + } + +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_state.dart b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_state.dart new file mode 100644 index 00000000..a7b72204 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/configuringWifi/configuringWifi_state.dart @@ -0,0 +1,17 @@ + + +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import 'configuringWifiEntity.dart'; + +class ConfiguringWifiState{ + var configuringWifiEntity = ConfiguringWifiEntity().obs; + + TextEditingController wifiNameController = TextEditingController(); + TextEditingController wifiPWDController = TextEditingController(); + ConfiguringWifiState() { + // wifiNameController.text = emailOrPhone.value; + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_logic.dart new file mode 100644 index 00000000..2dacce4a --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_logic.dart @@ -0,0 +1,9 @@ + +import 'package:star_lock/tools/baseGetXController.dart'; + +import 'diagnose_state.dart'; + +class DiagnoseLogic extends BaseGetXController{ + DiagnoseState state = DiagnoseState(); + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_page.dart b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_page.dart index d8f102ce..993484b1 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_page.dart @@ -34,7 +34,7 @@ class _DiagnosePageState extends State { child: Text( TranslationLoader.lanKeys!.diagnoseTip!.tr, style: TextStyle( - fontSize: 20.sp, color: AppColors.darkGrayTextColor), + fontSize: 22.sp, color: AppColors.darkGrayTextColor), )), ], ), diff --git a/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_state.dart b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_state.dart new file mode 100644 index 00000000..442da472 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/diagnose/diagnose_state.dart @@ -0,0 +1,4 @@ + +class DiagnoseState{ + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockEscalation/lockEscalation_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockEscalation/lockEscalation_logic.dart new file mode 100644 index 00000000..3f87d923 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/lockEscalation/lockEscalation_logic.dart @@ -0,0 +1,41 @@ + + +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../network/api_repository.dart'; +import 'lockEscalation_state.dart'; + +class LockEscalationLogic extends BaseGetXController{ + LockEscalationState state = LockEscalationState(); + + // 配置锁的常开模式设置 + Future setLockSetGeneralSetting() async{ + var entity = await ApiRepository.to.getLockVersionInfoData( + lockId: state.getKeyInfosData.value.lockId.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + setLockSetGeneralSetting(); + } + + @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/lockEscalation/lockEscalation_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockEscalation/lockEscalation_page.dart index 6a777fb7..6413bc3b 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockEscalation/lockEscalation_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockEscalation/lockEscalation_page.dart @@ -6,6 +6,7 @@ import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'lockEscalation_logic.dart'; class LockEscalationPage extends StatefulWidget { const LockEscalationPage({Key? key}) : super(key: key); @@ -15,6 +16,9 @@ class LockEscalationPage extends StatefulWidget { } class _LockEscalationPageState extends State { + final logic = Get.put(LockEscalationLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockEscalation/lockEscalation_state.dart b/star_lock/lib/main/lockDetail/lcokSet/lockEscalation/lockEscalation_state.dart new file mode 100644 index 00000000..4ce32511 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/lockEscalation/lockEscalation_state.dart @@ -0,0 +1,8 @@ + +import 'package:get/get.dart'; +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class LockEscalationState{ + var getKeyInfosData = KeyInfos().obs; + +} \ No newline at end of file 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 2e69907d..63b8bd81 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart @@ -14,12 +14,15 @@ 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 'lockSet_state.dart'; +typedef BlockSetStateCallback = void Function(); class LockSetLogic extends BaseGetXController{ final LockSetState state = LockSetState(); + // 删除锁调用后台接口 void deletLockInfoData() async{ var entity = await ApiRepository.to.deletLockData( lockId:state.getKeyInfosData.value.lockId.toString(), @@ -29,6 +32,17 @@ class LockSetLogic extends BaseGetXController{ } } + // 下级界面修改成功后传递数据 + StreamSubscription? _passCurrentLockInformationEvent; + void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) { + // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus + _passCurrentLockInformationEvent = eventBus.on().listen((event) { + state.getKeyInfosData.value = event.keyInfo; + blockSetStateCallback(); + }); + } + + // 监听蓝牙协议返回结果 late StreamSubscription _replySubscription; void _initReplySubscription() { _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { @@ -87,6 +101,7 @@ class LockSetLogic extends BaseGetXController{ }); } + // 删除用户蓝牙协议 Future deletUserAction() async { BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected){ @@ -119,6 +134,7 @@ class LockSetLogic extends BaseGetXController{ // TODO: implement onReady super.onReady(); print("onReady()"); + _initReplySubscription(); } @@ -135,6 +151,7 @@ class LockSetLogic extends BaseGetXController{ void onClose() { // TODO: implement onClose _replySubscription.cancel(); + _passCurrentLockInformationEvent!.cancel(); } } \ No newline at end of file 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 ad898cbf..7ce6659e 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -6,8 +8,10 @@ import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/commonItem.dart'; +import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; +import '../../../../tools/toast.dart'; import '../../../../translations/trans_lib.dart'; import 'lockSet_logic.dart'; @@ -21,6 +25,17 @@ class LockSetPage extends StatefulWidget { class _LockSetPageState extends State { final logic = Get.put(LockSetLogic()); final state = Get.find().state; + StreamSubscription? _passCurrentLockInformationEvent; + + @override + void initState() { + // TODO: implement initState + super.initState(); + + logic.initLoadDataAction(() { + setState(() {}); + }); + } @override Widget build(BuildContext context) { @@ -42,8 +57,7 @@ class _LockSetPageState extends State { isHaveLine: false, isHaveDirection: true, action: () { - Navigator.pushNamed( - context, Routers.basicInformationPage); + Get.toNamed(Routers.basicInformationPage); }), SizedBox( height: 10.h, @@ -55,8 +69,8 @@ class _LockSetPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed( - context, Routers.wirelessKeyboardPage); + // Get.toNamed(Routers.wirelessKeyboardPage); + Toast.show(msg: "功能暂未开放"); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.doorMagnetic!.tr, @@ -64,78 +78,102 @@ class _LockSetPageState extends State { isHaveLine: false, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.doorMagneticPage); + // Get.toNamed(Routers.doorMagneticPage); + Toast.show(msg: "功能暂未开放"); }), SizedBox( height: 10.h, ), - CommonItem( + Obx(()=> CommonItem( leftTitel: TranslationLoader.lanKeys!.remoteUnlocking!.tr, - rightTitle: TranslationLoader.lanKeys!.closed!.tr, + rightTitle: state.getKeyInfosData.value.remoteEnable == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, - action: () { - Navigator.pushNamed( - context, Routers.remoteUnlockingPage); - }), - CommonItem( + action: () { + Get.toNamed(Routers.remoteUnlockingPage, arguments: state.getKeyInfosData.value); + })), + Obx(() => CommonItem( leftTitel: - TranslationLoader.lanKeys!.automaticBlocking!.tr, - rightTitle: "5s", + TranslationLoader.lanKeys!.automaticBlocking!.tr, + rightTitle: state.getKeyInfosData.value.autoLockTime! > -1 ? "${state.getKeyInfosData.value.autoLockTime!.toString()}s" : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed( - context, Routers.automaticBlockingPage); - }), - CommonItem( + Get.toNamed(Routers.automaticBlockingPage, arguments: state.getKeyInfosData.value); + })), + Obx(() => CommonItem( leftTitel: - TranslationLoader.lanKeys!.normallyOpenMode!.tr, - rightTitle: TranslationLoader.lanKeys!.closed!.tr, + TranslationLoader.lanKeys!.normallyOpenMode!.tr, + rightTitle: state.getKeyInfosData.value.passageMode == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed( - context, Routers.normallyOpenModePage); - }), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.lockSound!.tr, - rightTitle: "高", - isHaveLine: true, - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.lockSoundSetPage); - }), - CommonItem( + Get.toNamed(Routers.normallyOpenModePage, arguments: state.getKeyInfosData.value); + }),), + Obx(() { + var titleStr = ""; + if(state.getKeyInfosData.value.lockSound == 1){ + switch(state.getKeyInfosData.value.volume){ + case 1: + titleStr = TranslationLoader.lanKeys!.low!.tr; + break; + case 2: + titleStr = TranslationLoader.lanKeys!.lower!.tr; + break; + case 3: + titleStr = TranslationLoader.lanKeys!.medium!.tr; + break; + case 4: + titleStr = TranslationLoader.lanKeys!.high!.tr; + break; + case 5: + titleStr = TranslationLoader.lanKeys!.higher!.tr; + break; + } + }else{ + titleStr = TranslationLoader.lanKeys!.closed!.tr; + } + return CommonItem( + leftTitel: TranslationLoader.lanKeys!.lockSound!.tr, + rightTitle: titleStr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.lockSoundSetPage, arguments: state.getKeyInfosData.value); + }); + }), + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.burglarAlarm!.tr, - rightTitle: TranslationLoader.lanKeys!.opened!.tr, + rightTitle: state.getKeyInfosData.value.tamperAlert == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.burglarAlarmPage); - }), - CommonItem( + Get.toNamed(Routers.burglarAlarmPage, arguments: state.getKeyInfosData.value); + })), + Obx(() => CommonItem( leftTitel: TranslationLoader.lanKeys!.resetButton!.tr, - rightTitle: TranslationLoader.lanKeys!.opened!.tr, + rightTitle: state.getKeyInfosData.value.resetButton == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr, isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.resetButtonPage); - }), + Get.toNamed(Routers.resetButtonPage, arguments: state.getKeyInfosData.value); + })), CommonItem( leftTitel: TranslationLoader.lanKeys!.unlockQRCode!.tr, rightTitle: "", isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.unlockQRCodePage); + Get.toNamed(Routers.unlockQRCodePage); }), CommonItem( - leftTitel: 'WiFi配网', + leftTitel: TranslationLoader.lanKeys!.wifiDistributionNetwork!.tr, rightTitle: "", isHaveLine: false, isHaveDirection: true, - action: () {}), + action: () { + Get.toNamed(Routers.configuringWifiPage); + }), SizedBox( height: 10.h, ), @@ -145,7 +183,7 @@ class _LockSetPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.lockTimePage); + Get.toNamed(Routers.lockTimePage, arguments: state.getKeyInfosData.value); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.diagnose!.tr, @@ -153,7 +191,7 @@ class _LockSetPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.diagnosePage); + Get.toNamed(Routers.diagnosePage); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.uploadData!.tr, @@ -161,7 +199,7 @@ class _LockSetPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.uploadDataPage); + Get.toNamed(Routers.uploadDataPage); }), CommonItem( leftTitel: @@ -170,8 +208,7 @@ class _LockSetPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Navigator.pushNamed( - context, Routers.importOtherLockDataPage); + Get.toNamed(Routers.importOtherLockDataPage); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.lockEscalation!.tr, @@ -179,8 +216,7 @@ class _LockSetPageState extends State { isHaveLine: false, isHaveDirection: true, action: () { - Navigator.pushNamed( - context, Routers.lockEscalationPage); + Get.toNamed(Routers.lockEscalationPage); }), SizedBox( height: 10.h, @@ -200,16 +236,23 @@ class _LockSetPageState extends State { SizedBox( height: 10.h, ), - CommonItem( - leftTitel: - TranslationLoader.lanKeys!.markedHouseState!.tr, - rightTitle: "空闲", - isHaveLine: true, - isHaveDirection: true, - action: () { - Navigator.pushNamed( - context, Routers.markedHouseStatePage); - }), + Obx((){ + var title = ""; + if(state.getKeyInfosData.value.roomStatus == 1){ + title = TranslationLoader.lanKeys!.checkedIn!.tr; + }else if(state.getKeyInfosData.value.roomStatus == 2){ + title = TranslationLoader.lanKeys!.leisure!.tr; + } + return CommonItem( + leftTitel: + TranslationLoader.lanKeys!.markedHouseState!.tr, + rightTitle: title, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.markedHouseStatePage, arguments: state.getKeyInfosData.value); + }); + }), CommonItem( leftTitel: TranslationLoader.lanKeys!.checkingIn!.tr, rightTitle: "", @@ -232,6 +275,7 @@ class _LockSetPageState extends State { isDelete: true, onClick: () { logic.deletUserAction(); + // logic.deletLockInfoData(); }), ), ], 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 6e22dd2b..e57c619c 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart @@ -4,7 +4,7 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; class LockSetState { - var getKeyInfosData = KeyInfos().obs; + final getKeyInfosData = KeyInfos().obs; LockSetState() { getKeyInfosData.value = Get.arguments as KeyInfos; diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart new file mode 100644 index 00000000..bcb66a11 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_logic.dart @@ -0,0 +1,37 @@ +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; +import 'lockSoundSet_state.dart'; + +class LockSoundSetLogic extends BaseGetXController { + LockSoundSetState state = LockSoundSetState(); + + // 配置锁的常开模式设置 -> 锁声音设置 + void setLockSetGeneralSetting() async{ + int isOn; + int type; + if(state.isOpenLockSound.value == false){ + // 音量关了的时候 + isOn = 2; type = 6; + }else{ + // 音量开了的时候 + isOn = state.lockSoundLevel.value; type = 8; + } + var entity = await ApiRepository.to.setLockSetGeneralSettingData( + lockId: state.getKeyInfosData.value.lockId.toString(), + changeType:"1", + isOn:isOn.toString(), // 1-开启、2-关闭; 设置音量:1到5; + type:type.toString(), // 6-锁声音开关 8-音量、 + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshLockListInfoDataEvent()); + // + state.getKeyInfosData.value.lockSound = state.isOpenLockSound.value == true ? 1 :2; + state.getKeyInfosData.value.volume = state.lockSoundLevel.value; + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Toast.show(msg: "操作成功"); + } + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_page.dart index 391a7342..922d2e73 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_page.dart @@ -8,6 +8,7 @@ import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'lockSoundSet_logic.dart'; class LockSoundSetPage extends StatefulWidget { const LockSoundSetPage({Key? key}) : super(key: key); @@ -17,6 +18,9 @@ class LockSoundSetPage extends StatefulWidget { } class _LockSoundSetPageState extends State { + final logic = Get.put(LockSoundSetLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -25,7 +29,7 @@ class _LockSoundSetPageState extends State { barTitle: TranslationLoader.lanKeys!.lockSound!.tr, haveBack: true, backgroundColor: AppColors.mainColor), - body: ListView( + body: Obx(() => ListView( children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.lockSound!.tr, @@ -33,7 +37,7 @@ class _LockSoundSetPageState extends State { isHaveLine: false, isHaveRightWidget: true, rightWidget: - SizedBox(width: 60.w, height: 50.h, child: _switch())), + SizedBox(width: 60.w, height: 50.h, child: _switch())), Container( height: 10.h, ), @@ -46,9 +50,9 @@ class _LockSoundSetPageState extends State { children: [ Expanded( child: Text( - TranslationLoader.lanKeys!.lockSoundTip!.tr, - style: TextStyle(fontSize: 20.sp), - )), + TranslationLoader.lanKeys!.lockSoundTip!.tr, + style: TextStyle(fontSize: 20.sp), + )), ], ), ), @@ -56,7 +60,7 @@ class _LockSoundSetPageState extends State { height: 10.h, ), Visibility( - visible: true, + visible: state.isOpenLockSound.value, child: Container( color: Colors.white, child: Column( @@ -72,11 +76,15 @@ class _LockSoundSetPageState extends State { isHaveLine: true, isHaveRightWidget: true, rightWidget: GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + state.lockSoundLevel.value = 1; + }); + }, child: Row( children: [ Image.asset( - 'images/icon_round_unSelet.png', + state.lockSoundLevel.value == 1 ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w, ), @@ -89,11 +97,15 @@ class _LockSoundSetPageState extends State { isHaveLine: true, isHaveRightWidget: true, rightWidget: GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + state.lockSoundLevel.value = 2; + }); + }, child: Row( children: [ Image.asset( - 'images/icon_round_unSelet.png', + state.lockSoundLevel.value == 2 ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w, ), @@ -106,11 +118,15 @@ class _LockSoundSetPageState extends State { isHaveLine: true, isHaveRightWidget: true, rightWidget: GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + state.lockSoundLevel.value = 3; + }); + }, child: Row( children: [ Image.asset( - 'images/icon_round_unSelet.png', + state.lockSoundLevel.value == 3 ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w, ), @@ -123,11 +139,15 @@ class _LockSoundSetPageState extends State { isHaveLine: true, isHaveRightWidget: true, rightWidget: GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + state.lockSoundLevel.value = 4; + }); + }, child: Row( children: [ Image.asset( - 'images/icon_round_unSelet.png', + state.lockSoundLevel.value == 4 ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w, ), @@ -140,11 +160,15 @@ class _LockSoundSetPageState extends State { isHaveLine: true, isHaveRightWidget: true, rightWidget: GestureDetector( - onTap: () {}, + onTap: () { + setState(() { + state.lockSoundLevel.value = 5; + }); + }, child: Row( children: [ Image.asset( - 'images/icon_round_unSelet.png', + state.lockSoundLevel.value == 5 ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', width: 30.w, height: 30.w, ), @@ -159,23 +183,22 @@ class _LockSoundSetPageState extends State { child: SubmitBtn( btnName: TranslationLoader.lanKeys!.save!.tr, onClick: () { - // Navigator.pushNamed(context, Routers.nearbyLockPage); + logic.setLockSetGeneralSetting(); }), ), ], - )); + ))); } CupertinoSwitch _switch() { - bool _isOn = false; return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: _isOn, + value: state.isOpenLockSound.value, onChanged: (value) { setState(() { - _isOn = value; + state.isOpenLockSound.value = value; }); }, ); diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_state.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_state.dart new file mode 100644 index 00000000..c3867c83 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSoundSet/lockSoundSet_state.dart @@ -0,0 +1,16 @@ + +import 'package:get/get.dart'; +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class LockSoundSetState { + var getKeyInfosData = KeyInfos().obs; + + var isOpenLockSound = false.obs;// 是否开启声音 + var lockSoundLevel = 0.obs;// 音量等级 + + LockSoundSetState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + isOpenLockSound.value = getKeyInfosData.value.lockSound == 1 ? true : false; + lockSoundLevel.value = getKeyInfosData.value.volume!; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/GetServerDatetimeEntity.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/GetServerDatetimeEntity.dart new file mode 100644 index 00000000..6bc69cbb --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/GetServerDatetimeEntity.dart @@ -0,0 +1,45 @@ + +class GetServerDatetimeEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + GetServerDatetimeEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + GetServerDatetimeEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + String? date; + + Data( + {this.date}); + + Data.fromJson(Map json) { + date = json['date']; + } + + Map toJson() { + final Map data = {}; + data['date'] = date; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart index d3ed27b3..19462cc6 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_logic.dart @@ -13,6 +13,7 @@ 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/storage.dart'; @@ -54,7 +55,7 @@ class LockTimeLogic extends BaseGetXController{ (0xff & lockTime[2]) << 8 | (0xFF & lockTime[3])); - String dataEime = DateTool().dateToString("${value}000"); + String dataEime = DateTool().dateToString("${value}"); state.dateTime.value = dataEime; print("lockTime:$lockTime value:$value dataEime:$dataEime"); break; @@ -156,6 +157,28 @@ class LockTimeLogic extends BaseGetXController{ }); } + // 获取锁的常开模式设置 + void getLockTimeFromGateway() async{ + var entity = await ApiRepository.to.getLockTimeFromGateway( + lockId: state.getKeyInfosData.value.lockId.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + + } + } + + // 获取锁的常开模式设置 + void getServerDatetime() async{ + var entity = await ApiRepository.to.getServerDatetimeData( + lockId: state.getKeyInfosData.value.lockId.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + String dataEime = DateTool().dateToString("${int.parse(entity.data!.date.toString())~/1000}"); + state.dateTime.value = dataEime; + sendTiming(); + } + } + @override void onReady() { // TODO: implement onReady @@ -163,6 +186,7 @@ class LockTimeLogic extends BaseGetXController{ print("onReady()"); _initReplySubscription(); + getLockTimeFromGateway(); } @override diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_page.dart index 66783689..f8178765 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_page.dart @@ -52,8 +52,9 @@ class _LockTimePageState extends State { // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { - print("1111111"); - logic.sendTiming(); + // print("1111111"); + // logic.sendTiming(); + logic.getServerDatetime(); }), SizedBox( height: 40.h, diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_state.dart b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_state.dart index 1e8da8f4..7a5eebd4 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockTime/lockTime_state.dart @@ -2,6 +2,14 @@ import 'package:get/get.dart'; +import '../../../lockMian/entity/lockInfoEntity.dart'; + class LockTimeState{ var dateTime = "".obs; + + var getKeyInfosData = KeyInfos().obs; + + LockTimeState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_logic.dart new file mode 100644 index 00000000..510c1fc6 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_logic.dart @@ -0,0 +1,35 @@ + + +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; +import 'markedHouseState_state.dart'; + +class MarkedHouseStateLogic extends BaseGetXController{ + MarkedHouseStateState state = MarkedHouseStateState(); + + // 配置锁的常开模式设置 + Future setLockSetGeneralSetting() async{ + var entity = await ApiRepository.to.setLockSetGeneralSettingData( + lockId: state.getKeyInfosData.value.lockId.toString(), + changeType:"1", + isOn:state.roomStatus.value.toString(), // 已入住: 1 空闲:2 + type:"13", // 标记房态 + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshLockListInfoDataEvent()); + + state.roomStatus.value = state.roomStatus.value; + state.getKeyInfosData.value.roomStatus = state.roomStatus.value; + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Toast.show(msg: "操作成功"); + }else if(entity.errorCode! == 1){ + // 跳转到高级功能界面 需要开通高级功能 + + } + } + + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_page.dart b/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_page.dart index 96e8fdd9..099897e3 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_page.dart @@ -7,6 +7,7 @@ import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'markedHouseState_logic.dart'; class MarkedHouseStatePage extends StatefulWidget { const MarkedHouseStatePage({Key? key}) : super(key: key); @@ -16,6 +17,9 @@ class MarkedHouseStatePage extends StatefulWidget { } class _MarkedHouseStatePageState extends State { + final logic = Get.put(MarkedHouseStateLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -24,55 +28,63 @@ class _MarkedHouseStatePageState extends State { barTitle: TranslationLoader.lanKeys!.markedHouseState!.tr, haveBack: true, backgroundColor: AppColors.mainColor), - body: Container( - child: Column( - children: [ - CommonItem( - leftTitel: TranslationLoader.lanKeys!.leisure!.tr, - rightTitle: "", - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.checkedIn!.tr, - rightTitle: "", - isHaveLine: false, - isHaveRightWidget: true, - rightWidget: GestureDetector( - onTap: () {}, - child: Row( - children: [ - Image.asset( - 'images/icon_round_unSelet.png', - width: 30.w, - height: 30.w, - ), - ], - ), - )), - SizedBox( - height: 60.h, - ), - SubmitBtn( - btnName: TranslationLoader.lanKeys!.sure!.tr, - borderRadius: 20.w, - fontSize: 32.sp, - // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), - padding: EdgeInsets.only(top: 20.w, bottom: 20.w), - onClick: () {}), - ], - ), + body: Column( + children: [ + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.leisure!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: GestureDetector( + onTap: () { + setState(() { + state.roomStatus.value = 2; + }); + }, + child: Row( + children: [ + Image.asset( + state.roomStatus.value == 2 ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', + width: 30.w, + height: 30.w, + ), + ], + ), + ))), + Obx(() => CommonItem( + leftTitel: TranslationLoader.lanKeys!.checkedIn!.tr, + rightTitle: "", + isHaveLine: false, + isHaveRightWidget: true, + rightWidget: GestureDetector( + onTap: () { + setState(() { + state.roomStatus.value = 1; + }); + }, + child: Row( + children: [ + Image.asset( + state.roomStatus.value == 1 ? 'images/icon_round_selet.png' : 'images/icon_round_unSelet.png', + width: 30.w, + height: 30.w, + ), + ], + ), + ))), + SizedBox( + height: 60.h, + ), + SubmitBtn( + btnName: TranslationLoader.lanKeys!.sure!.tr, + borderRadius: 20.w, + fontSize: 32.sp, + // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), + padding: EdgeInsets.only(top: 20.w, bottom: 20.w), + onClick: () { + logic.setLockSetGeneralSetting(); + }), + ], )); } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_state.dart b/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_state.dart new file mode 100644 index 00000000..8731eb4b --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/markedHouseState/markedHouseState_state.dart @@ -0,0 +1,16 @@ + + +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class MarkedHouseStateState{ + var getKeyInfosData = KeyInfos().obs; + + var roomStatus = 0.obs; + + MarkedHouseStateState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + roomStatus.value = getKeyInfosData.value.roomStatus!; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/GetPassageModeConfigEntity.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/GetPassageModeConfigEntity.dart new file mode 100644 index 00000000..c4790e53 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/GetPassageModeConfigEntity.dart @@ -0,0 +1,65 @@ + +class GetPassageModeConfigEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + GetPassageModeConfigEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + GetPassageModeConfigEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + int? passageMode; + int? startDate; + int? endDate; + int? isAllDay; + List? weekDays; + int? autoUnlock; + + Data( + {this.passageMode, + this.startDate, + this.endDate, + this.isAllDay, + this.weekDays, + this.autoUnlock}); + + Data.fromJson(Map json) { + passageMode = json['passageMode']; + startDate = json['startDate']; + endDate = json['endDate']; + isAllDay = json['isAllDay']; + weekDays = json['weekDays']; + autoUnlock = json['autoUnlock']; + } + + Map toJson() { + final Map data = {}; + data['passageMode'] = passageMode; + data['startDate'] = startDate; + data['endDate'] = endDate; + data['isAllDay'] = isAllDay; + data['weekDays'] = weekDays; + data['autoUnlock'] = autoUnlock; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart new file mode 100644 index 00000000..4f93e298 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_logic.dart @@ -0,0 +1,82 @@ + + +import 'package:date_format/date_format.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; +import 'normallyOpenMode_state.dart'; + +class NormallyOpenModeLogic extends BaseGetXController{ + NormallyOpenModeState state = NormallyOpenModeState(); + + // 获取锁的常开模式设置 + void getNormallyOpenModeConfig() async{ + var entity = await ApiRepository.to.getPassageModeConfig( + lockId: state.getKeyInfosData.value.lockId.toString(), + ); + if(entity.errorCode!.codeIsSuccessful){ + state.getPassageModeConfigData.value = entity; + state.isOpenNormallyOpenMode.value = state.getPassageModeConfigData.value.data!.passageMode == 1 ? true : false; + state.isOpenAutomaticUnLock.value = state.getPassageModeConfigData.value.data!.autoUnlock == 1 ? true : false; + state.isAllDay.value = state.getPassageModeConfigData.value.data!.isAllDay == 1 ? 1 : 2; + state.weekDays.value = state.getPassageModeConfigData.value.data!.weekDays!; + + state.beginTimeMinute.value = state.getPassageModeConfigData.value.data!.startDate!; + state.beginTime.value = "${state.getPassageModeConfigData.value.data!.startDate!~/60}:${state.getPassageModeConfigData.value.data!.startDate! % 60}"; + state.endTimeMinute.value = state.getPassageModeConfigData.value.data!.endDate!; + state.endTime.value = "${state.getPassageModeConfigData.value.data!.endDate!~/60}:${state.getPassageModeConfigData.value.data!.endDate! % 60}"; + } + } + + // 配置锁的常开模式设置 + void configPassageMode() async{ + if(state.endTimeMinute.value < state.beginTimeMinute.value){ + Toast.show(msg:"结束时间不能小于开始时间哦"); + return; + } + + print("state.isOpenNormallyOpenMode.value:${state.isOpenNormallyOpenMode.value}"); + var entity = await ApiRepository.to.configPassageModeLoadData( + lockId: state.getKeyInfosData.value.lockId.toString(), + passageMode:state.isOpenNormallyOpenMode.value == true ? "1":"2", + autoUnlock:state.isOpenAutomaticUnLock.value == true ? "1":"2", + type: "1", + startDate: state.beginTimeMinute.toString(), + endDate: state.endTimeMinute.toString(), + isAllDay: state.isAllDay.value == 1 ? "1":"2", + weekDays: state.weekDays, + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshLockListInfoDataEvent()); + + state.getKeyInfosData.value.passageMode = state.isOpenNormallyOpenMode.value == true ? 1:2; + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Toast.show(msg: "操作成功"); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + + if(state.getKeyInfosData.value.passageMode == 1){ + getNormallyOpenModeConfig(); + } + } + + @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/normallyOpenMode/normallyOpenMode_page.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart index 9d70a881..2fbaf95e 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart @@ -1,5 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_pickers/pickers.dart'; +import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -8,6 +10,7 @@ import '../../../../tools/commonItem.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'normallyOpenMode_logic.dart'; class NormallyOpenModePage extends StatefulWidget { const NormallyOpenModePage({Key? key}) : super(key: key); @@ -17,6 +20,9 @@ class NormallyOpenModePage extends StatefulWidget { } class _NormallyOpenModePageState extends State { + final logic = Get.put(NormallyOpenModeLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -25,7 +31,7 @@ class _NormallyOpenModePageState extends State { barTitle: TranslationLoader.lanKeys!.normallyOpenMode!.tr, haveBack: true, backgroundColor: AppColors.mainColor), - body: ListView( + body: Obx(() => ListView( children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.normallyOpenMode!.tr, @@ -33,9 +39,9 @@ class _NormallyOpenModePageState extends State { isHaveLine: false, isHaveRightWidget: true, rightWidget: - SizedBox(width: 60.w, height: 50.h, child: _switch())), - Container( - height: 10.h, + SizedBox(width: 60.w, height: 50.h, child: _normallyOpenModeSwitch())), + SizedBox( + height: 1.h, ), Container( padding: EdgeInsets.only( @@ -46,9 +52,9 @@ class _NormallyOpenModePageState extends State { children: [ Expanded( child: Text( - TranslationLoader.lanKeys!.normallyOpenModeTip!.tr, - style: TextStyle(fontSize: 20.sp), - )), + TranslationLoader.lanKeys!.normallyOpenModeTip!.tr, + style: TextStyle(fontSize: 20.sp), + )), ], ), ), @@ -56,11 +62,41 @@ class _NormallyOpenModePageState extends State { height: 10.h, ), Visibility( - visible: true, + visible: state.isOpenNormallyOpenMode.value, child: Container( color: Colors.white, child: Column( children: [ + CommonItem( + leftTitel: TranslationLoader.lanKeys!.automaticUnLock!.tr, + rightTitle: "", + isHaveLine: false, + isHaveRightWidget: true, + rightWidget: + SizedBox(width: 60.w, height: 50.h, child: _autoUnlockSwitch())), + Container( + height: 1.h, + color: AppColors.mainBackgroundColor, + ), + Container( + padding: EdgeInsets.only( + left: 30.w, right: 30.w, top: 20.w, bottom: 20.w), + color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: Text( + TranslationLoader.lanKeys!.automaticUnLockTip!.tr, + style: TextStyle(fontSize: 20.sp), + )), + ], + ), + ), + Container( + height: 10.h, + color: AppColors.mainBackgroundColor, + ), topWidget(), SizedBox( height: 10.h, @@ -74,11 +110,11 @@ class _NormallyOpenModePageState extends State { child: SubmitBtn( btnName: TranslationLoader.lanKeys!.save!.tr, onClick: () { - // Navigator.pushNamed(context, Routers.nearbyLockPage); + logic.configPassageMode(); }), ), ], - )); + ))); } Widget topWidget() { @@ -106,6 +142,7 @@ class _NormallyOpenModePageState extends State { itemCount: 7, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { + index += 1; return btnItem(index); })), ], @@ -116,9 +153,6 @@ class _NormallyOpenModePageState extends State { Widget btnItem(int index) { String dateStr; switch (index) { - case 0: - dateStr = TranslationLoader.lanKeys!.sundayShort!.tr; - break; case 1: dateStr = TranslationLoader.lanKeys!.mondayShort!.tr; break; @@ -137,27 +171,39 @@ class _NormallyOpenModePageState extends State { case 6: dateStr = TranslationLoader.lanKeys!.saturdayShort!.tr; break; + case 7: + dateStr = TranslationLoader.lanKeys!.sundayShort!.tr; + break; default: dateStr = ""; break; } return GestureDetector( - onTap: () {}, - child: Container( + onTap: () { + if(state.weekDays.value.contains(index)){ + state.weekDays.value.remove(index); + }else{ + state.weekDays.value.add(index); + } + state.weekDays.value.sort(); + setState(() {}); + // print("index:$index data:${state.normallyOpenPeriod.value}"); + }, + child: Obx(() => Container( width: 40.w, height: 40.w, margin: EdgeInsets.all(10.w), decoration: BoxDecoration( - // color: Colors.blue, + color: state.weekDays.value.contains(index) ? AppColors.mainColor :Colors.white, border: Border.all(width: 1, color: AppColors.btnDisableColor), borderRadius: BorderRadius.circular(30.w), ), child: Center( child: Text( - dateStr, - style: TextStyle(fontSize: 20.sp, color: AppColors.darkGrayTextColor), - )), - ), + dateStr, + style: TextStyle(fontSize: 20.sp, color: state.weekDays.value.contains(index) ? Colors.white : AppColors.darkGrayTextColor), + )), + )), ); } @@ -168,14 +214,22 @@ class _NormallyOpenModePageState extends State { color: AppColors.mainBackgroundColor, height: 10.h, ), - CommonItem( + Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.normallyOpen!.tr}${TranslationLoader.lanKeys!.time!.tr}", + "${TranslationLoader.lanKeys!.normallyOpen!.tr}${TranslationLoader.lanKeys!.time!.tr}", rightTitle: "", isHaveLine: true, isHaveRightWidget: true, rightWidget: GestureDetector( - onTap: () {}, + onTap: () { + // 选择全天模式 + if(state.isAllDay.value == 1){ + state.isAllDay.value = 2; + }else{ + state.isAllDay.value = 1; + } + setState(() {}); + }, child: Row( children: [ Text( @@ -186,32 +240,46 @@ class _NormallyOpenModePageState extends State { width: 5.w, ), Image.asset( - 'images/icon_round_unSelet.png', + state.isAllDay.value == 1 ? 'images/icon_round_selet.png': 'images/icon_round_unSelet.png', width: 30.w, height: 30.w, ), ], ), - )), + ))), Visibility( visible: true, child: Container( color: Colors.white, child: Column( children: [ - CommonItem( + Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}", - rightTitle: "", + "${TranslationLoader.lanKeys!.begin!.tr}${TranslationLoader.lanKeys!.time!.tr}", + rightTitle: state.beginTime.value, isHaveDirection: true, isHaveLine: true, - action: () {}), - CommonItem( + action: () { + Pickers.showDatePicker(context, mode: DateMode.HM, + onConfirm: (p) { + state.beginTimeMinute.value = p.hour!*60 + p.minute!; + state.beginTime.value = "${p.hour}:${p.minute!}"; + setState(() {}); + }); + })), + Obx(() => CommonItem( leftTitel: - "${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}", - rightTitle: "", + "${TranslationLoader.lanKeys!.end!.tr}${TranslationLoader.lanKeys!.time!.tr}", + rightTitle: state.endTime.value, isHaveDirection: true, - action: () {}), + action: () { + Pickers.showDatePicker(context, mode: DateMode.HM, + onConfirm: (p) { + state.endTimeMinute.value = p.hour!*60 + p.minute!; + state.endTime.value = "${p.hour}:${p.minute!}"; + setState(() {}); + }); + })), Container(height: 10.h), ], ), @@ -220,16 +288,29 @@ class _NormallyOpenModePageState extends State { ); } - CupertinoSwitch _switch() { - bool _isOn = false; + CupertinoSwitch _normallyOpenModeSwitch() { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: _isOn, + value: state.isOpenNormallyOpenMode.value, onChanged: (value) { setState(() { - _isOn = value; + state.isOpenNormallyOpenMode.value = value; + }); + }, + ); + } + + CupertinoSwitch _autoUnlockSwitch() { + return CupertinoSwitch( + activeColor: CupertinoColors.activeBlue, + trackColor: CupertinoColors.systemGrey5, + thumbColor: CupertinoColors.white, + value: state.isOpenAutomaticUnLock.value, + onChanged: (value) { + setState(() { + state.isOpenAutomaticUnLock.value = value; }); }, ); diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart new file mode 100644 index 00000000..95675e05 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart @@ -0,0 +1,24 @@ + + +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lcokSet/normallyOpenMode/GetPassageModeConfigEntity.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class NormallyOpenModeState{ + var getKeyInfosData = KeyInfos().obs; + + var getPassageModeConfigData = GetPassageModeConfigEntity().obs; + var isOpenNormallyOpenMode = false.obs;// 是否开启常开模式 常开模式:1-开启、2-关闭 + var isOpenAutomaticUnLock = false.obs;// 是否开启自动开锁模式 自动开锁:1-开启、2-关闭,开启后锁将在常开模式开始时自动打开 + var isAllDay = 0.obs;// 是否开启全天模式 是否全天常开:1-是、2-否, 如果全天常开,startDate和endDate参数将被忽略. + var weekDays = [].obs;// 常开时期 + var beginTime = "".obs;// 开始时间 + var endTime = "".obs;// 结束时间 + var beginTimeMinute = 0.obs;// 开始时间分钟 + var endTimeMinute = 0.obs;// 结束时间分钟 + + NormallyOpenModeState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart new file mode 100644 index 00000000..e6ec5935 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart @@ -0,0 +1,51 @@ +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; + +import '../../../../blue/io_tool/manager_event_bus.dart'; +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import 'remoteUnlocking_state.dart'; + +class RemoteUnlockingLogic extends BaseGetXController{ + RemoteUnlockingState state = RemoteUnlockingState(); + + void remoteUnlockingOpenOrClose() async{ + var entity = await ApiRepository.to.remoteUnlockingOpenOrClose( + lockId: state.getKeyInfosData.value.lockId.toString(), + // featureValue:state.getKeyInfosData.value.featureValue.toString() + featureValue:"1234" + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshLockListInfoDataEvent()); + if(state.remoteEnable.value == 1){ + state.remoteEnable.value = 2; + }else if(state.remoteEnable.value == 2){ + state.remoteEnable.value = 1; + } + state.getKeyInfosData.value.remoteEnable = state.remoteEnable.value; + print("state.remoteEnable.value:${state.remoteEnable.value} state.getKeyInfosData.value.remoteEnable:${state.getKeyInfosData.value.remoteEnable}"); + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Toast.show(msg: "操作成功"); + } + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + print("onReady()"); + } + + @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/remoteUnlocking/remoteUnlocking_page.dart b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_page.dart index e06741c6..275bbaa5 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_logic.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; @@ -15,6 +16,9 @@ class RemoteUnlockingPage extends StatefulWidget { } class _RemoteUnlockingPageState extends State { + final logic = Get.put(RemoteUnlockingLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -41,23 +45,28 @@ class _RemoteUnlockingPageState extends State { SizedBox( height: 20.h, ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: Text( - "${TranslationLoader.lanKeys!.currentMode!.tr} : ${TranslationLoader.lanKeys!.opened!.tr}", - style: - TextStyle(fontWeight: FontWeight.w600, fontSize: 22.sp), - )), - ], - ), + Obx((){ + // print("state.remoteEnable:${state.remoteEnable}"); + return Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: Text( + "${TranslationLoader.lanKeys!.currentMode!.tr} : ${state.remoteEnable.value == 1 ?TranslationLoader.lanKeys!.opened!.tr: TranslationLoader.lanKeys!.closed!.tr}", + style: + TextStyle(fontWeight: FontWeight.w600, fontSize: 22.sp), + )), + ], + ); + }), SizedBox( height: 40.h, ), - SubmitBtn( - btnName: TranslationLoader.lanKeys!.closed!.tr, - onClick: () {}), + Obx(() => SubmitBtn( + btnName: state.remoteEnable.value == 1 ?TranslationLoader.lanKeys!.close!.tr: TranslationLoader.lanKeys!.open!.tr, + onClick: () { + logic.remoteUnlockingOpenOrClose(); + })), ], ), )); diff --git a/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_state.dart b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_state.dart new file mode 100644 index 00000000..146b6ac6 --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/remoteUnlocking/remoteUnlocking_state.dart @@ -0,0 +1,13 @@ + +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class RemoteUnlockingState{ + var getKeyInfosData = KeyInfos().obs; + var remoteEnable = 1.obs; + RemoteUnlockingState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + remoteEnable.value = getKeyInfosData.value.remoteEnable!; + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart new file mode 100644 index 00000000..8a76fbce --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_logic.dart @@ -0,0 +1,30 @@ + +import 'package:star_lock/main/lockDetail/lcokSet/resetButton/resetButton_state.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +import '../../../../network/api_repository.dart'; +import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/toast.dart'; + +class ResetButtonLogic extends BaseGetXController{ + ResetButtonState state = ResetButtonState(); + + + // 配置锁的常开模式设置 -> 重置开关 + Future setLockSetGeneralSetting() async{ + var entity = await ApiRepository.to.setLockSetGeneralSettingData( + lockId: state.getKeyInfosData.value.lockId.toString(), + changeType:"1", + isOn:state.resetButtonEnable.value == 1 ? "2" : "1", // 1-开启、2-关闭; + type:"4", // 4 重置键开关 + ); + if(entity.errorCode!.codeIsSuccessful){ + eventBus.fire(RefreshLockListInfoDataEvent()); + + state.resetButtonEnable.value = state.resetButtonEnable.value == 1 ? 2 : 1; + state.getKeyInfosData.value.resetButton = state.resetButtonEnable.value; + eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value)); + Toast.show(msg: "操作成功"); + } + } +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_page.dart b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_page.dart index 15658545..e430307c 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_page.dart @@ -6,6 +6,7 @@ import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; import '../../../../translations/trans_lib.dart'; +import 'resetButton_logic.dart'; class ResetButtonPage extends StatefulWidget { const ResetButtonPage({Key? key}) : super(key: key); @@ -15,6 +16,9 @@ class ResetButtonPage extends StatefulWidget { } class _ResetButtonPageState extends State { + final logic = Get.put(ResetButtonLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( @@ -53,27 +57,29 @@ class _ResetButtonPageState extends State { SizedBox( height: 30.h, ), - Row( + Obx(() => Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: Text( - "${TranslationLoader.lanKeys!.currentMode!.tr} : ${TranslationLoader.lanKeys!.opened!.tr}", - style: + "${TranslationLoader.lanKeys!.currentMode!.tr} : ${state.resetButtonEnable.value == 1 ? TranslationLoader.lanKeys!.opened!.tr : TranslationLoader.lanKeys!.closed!.tr}", + style: TextStyle(fontWeight: FontWeight.w600, fontSize: 20.sp), - )), + )), ], - ), + )), SizedBox( height: 30.h, ), - SubmitBtn( - btnName: TranslationLoader.lanKeys!.closed!.tr, + Obx(() => SubmitBtn( + btnName: state.resetButtonEnable.value == 1 ? TranslationLoader.lanKeys!.close!.tr : TranslationLoader.lanKeys!.open!.tr, borderRadius: 20.w, fontSize: 32.sp, // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), - onClick: () {}), + onClick: () { + logic.setLockSetGeneralSetting(); + })), ], ), )); diff --git a/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_state.dart b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_state.dart new file mode 100644 index 00000000..7fed643a --- /dev/null +++ b/star_lock/lib/main/lockDetail/lcokSet/resetButton/resetButton_state.dart @@ -0,0 +1,16 @@ + +import 'package:get/get.dart'; + +import '../../../lockMian/entity/lockInfoEntity.dart'; + +class ResetButtonState{ + + var getKeyInfosData = KeyInfos().obs; + var resetButtonEnable = 1.obs; + + ResetButtonState() { + getKeyInfosData.value = Get.arguments as KeyInfos; + resetButtonEnable.value = getKeyInfosData.value.tamperAlert!; + } + +} \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/lcokSet/uploadData/uploadData_page.dart b/star_lock/lib/main/lockDetail/lcokSet/uploadData/uploadData_page.dart index 9a2ca115..457775c7 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/uploadData/uploadData_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/uploadData/uploadData_page.dart @@ -27,13 +27,13 @@ class _UploadDataPageState extends State { Row( mainAxisAlignment: MainAxisAlignment.start, children: [ - Expanded(child: Text(TranslationLoader.lanKeys!.uploadDataTip!.tr)), + Expanded(child: Text(TranslationLoader.lanKeys!.uploadDataTip!.tr, style: TextStyle(fontSize: 24.sp,),)), ], ), SizedBox(height: 30.h,), SubmitBtn(btnName: TranslationLoader.lanKeys!.begin!.tr, borderRadius: 20.w, - fontSize: 32.sp, + fontSize: 24.sp, // margin: EdgeInsets.only(left: 03.w, right: 30.w, top: 20.w), padding: EdgeInsets.only(top: 20.w, bottom: 20.w), onClick: () { diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 24f0272d..b5b69cdc 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:get/get.dart'; import '../../../appRouters.dart'; import '../../../app_settings/app_colors.dart'; @@ -127,13 +128,15 @@ class _LockDetailPageState extends State { child: Image.asset('images/main/icon_main_openLockBtn.png', width: 268.w, height: 268.w), )), - Align( - alignment: const Alignment(0.6, 1), - child: Image.asset( - 'images/main/icon_main_remoteUnlocking.png', - width: 50.w, - height: 52.w, - )), + Visibility( + visible: state.keyInfos.value.remoteEnable == 1 ? true: false, + child: Align( + alignment: const Alignment(0.6, 1), + child: Image.asset( + 'images/main/icon_main_remoteUnlocking.png', + width: 50.w, + height: 52.w, + ))), ], ), ), @@ -176,78 +179,92 @@ class _LockDetailPageState extends State { crossAxisSpacing: 20.w, mainAxisSpacing: 0.h, physics: const NeverScrollableScrollPhysics(), - children: [ - bottomItem('images/main/icon_main_clockingIn.png', - TranslationLoader.lanKeys!.checkingIn!.tr, () { - Navigator.pushNamed(context, Routers.checkingInListPage); - }), - bottomItem('images/main/icon_main_electronicKey.png', - TranslationLoader.lanKeys!.electronicKey!.tr, () { - Navigator.pushNamed(context, Routers.electronicKeyListPage, - arguments: { - "lockMainEntity": widget.lockMainEntity, - "keyInfo": widget.keyInfo - }); - }), - bottomItem('images/main/icon_main_password.png', - TranslationLoader.lanKeys!.password!.tr, () { - Navigator.pushNamed(context, Routers.passwordKeyListPage, - arguments: { - "lockMainEntity": widget.lockMainEntity, - "keyInfo": widget.keyInfo - }); - }), - bottomItem('images/main/icon_main_icCard.png', - TranslationLoader.lanKeys!.card!.tr, () { - Navigator.pushNamed(context, Routers.otherTypeKeyListPage, - arguments: 0); - }), - bottomItem('images/main/icon_main_fingerprint.png', - TranslationLoader.lanKeys!.fingerprint!.tr, () { - Navigator.pushNamed(context, Routers.otherTypeKeyListPage, - arguments: 1); - }), - bottomItem('images/main/icon_main_remoteControl.png', - TranslationLoader.lanKeys!.remoteControl!.tr, () { - Navigator.pushNamed(context, Routers.otherTypeKeyListPage, - arguments: 2); - }), - //可视对讲门锁新增->人脸、监控 - bottomItem('images/main/icon_main_fingerprint.png', '人脸', () { - // Navigator.pushNamed(context, Routers.otherTypeKeyListPage, - // arguments: 1); - }), - bottomItem('images/main/icon_main_fingerprint.png', '监控', () { - // Navigator.pushNamed(context, Routers.otherTypeKeyListPage, - // arguments: 1); - }), - bottomItem('images/main/icon_main_authorizedAdmin.png', - TranslationLoader.lanKeys!.authorizedAdmin!.tr, () { - Navigator.pushNamed(context, Routers.authorizedAdminListPage, - arguments: { - "lockMainEntity": widget.lockMainEntity, - "keyInfo": widget.keyInfo - }); - }), - bottomItem('images/main/icon_main_operatingRecord.png', - TranslationLoader.lanKeys!.operatingRecord!.tr, () { - Navigator.pushNamed(context, Routers.lockOperatingRecordPage, - arguments: { - "lockMainEntity": widget.lockMainEntity, - "keyInfo": widget.keyInfo - }); - }), - bottomItem('images/main/icon_main_set.png', - TranslationLoader.lanKeys!.set!.tr, () { - Navigator.pushNamed(context, Routers.lockSetPage, - arguments: widget.keyInfo); - }), - ], + children: getShowWidget() ), ), ); } + List getShowWidget(){ + var showWidgetArr = []; + + // 考勤 + showWidgetArr.add(bottomItem('images/main/icon_main_clockingIn.png', + TranslationLoader.lanKeys!.checkingIn!.tr, () { + Get.toNamed( Routers.checkingInListPage); + })); + + var defaultWidgetArr = [ + // 电子钥匙 + bottomItem('images/main/icon_main_electronicKey.png', TranslationLoader.lanKeys!.electronicKey!.tr, () { + Get.toNamed(Routers.electronicKeyListPage, arguments: { + "lockMainEntity": widget.lockMainEntity, + "keyInfo": widget.keyInfo + }); + }), + // 密码 + bottomItem('images/main/icon_main_password.png', TranslationLoader.lanKeys!.password!.tr, () { + Get.toNamed(Routers.passwordKeyListPage, + arguments: { + "lockMainEntity": widget.lockMainEntity, + "keyInfo": widget.keyInfo + }); + }), + // ic卡 + bottomItem('images/main/icon_main_icCard.png', TranslationLoader.lanKeys!.card!.tr, () { + Get.toNamed(Routers.otherTypeKeyListPage, + arguments: 0); + }), + // 指纹 + bottomItem('images/main/icon_main_fingerprint.png', TranslationLoader.lanKeys!.fingerprint!.tr, () { + Get.toNamed(Routers.otherTypeKeyListPage, + arguments: 1); + }), + // 遥控 + bottomItem('images/main/icon_main_remoteControl.png', TranslationLoader.lanKeys!.remoteControl!.tr, () { + Get.toNamed(Routers.otherTypeKeyListPage, + arguments: 2); + }), + ]; + showWidgetArr.addAll(defaultWidgetArr); + + //可视对讲门锁新增->人脸 + showWidgetArr.add(bottomItem('images/main/icon_main_fingerprint.png', '人脸', () { + // Navigator.pushNamed(context, Routers.otherTypeKeyListPage, + // arguments: 1); + }),); + + //可视对讲门锁新增->监控 + showWidgetArr.add(bottomItem('images/main/icon_main_fingerprint.png', '监控', () { + // Navigator.pushNamed(context, Routers.otherTypeKeyListPage, + // arguments: 1); + }),); + + var endWiddget = [ + // 授权管理员 + bottomItem('images/main/icon_main_authorizedAdmin.png', TranslationLoader.lanKeys!.authorizedAdmin!.tr, () { + Get.toNamed(Routers.authorizedAdminListPage, arguments: { + "lockMainEntity": widget.lockMainEntity, + "keyInfo": widget.keyInfo + }); + }), + // 操作记录 + bottomItem('images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, () { + Get.toNamed(Routers.lockOperatingRecordPage, + arguments: { + "lockMainEntity": widget.lockMainEntity, + "keyInfo": widget.keyInfo + }); + }), + // 设置 + bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () { + Get.toNamed(Routers.lockSetPage, arguments: widget.keyInfo); + }), + ]; + showWidgetArr.addAll(endWiddget); + return showWidgetArr; + } + Widget bottomItem(String iconUrl, String name, Function() onClick) { var width = 42.w; var height = 42.h; diff --git a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index b52cf826..58c8bb7f 100644 --- a/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/star_lock/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -128,7 +128,8 @@ class LockOperatingRecordLogic extends BaseGetXController{ super.onInit(); print("onInit()"); - senderReferEventRecordNumberTime(); + // senderReferEventRecordNumberTime(); + senderReferEventRecordNumber(); } @override diff --git a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart index a83f716e..6bbab42b 100644 --- a/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/otherTypeKey/otherTypeKeyList/otherTypeKeyList_logic.dart @@ -5,6 +5,7 @@ import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_checkingCardStatus.dart'; +import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart'; import '../../../../blue/io_protocol/io_queryingFingerprintStatus.dart'; import '../../../../blue/io_reply.dart'; import '../../../../blue/io_tool/io_manager.dart'; @@ -30,12 +31,17 @@ class OtherTypeKeyListLogic extends BaseGetXController{ if(reply is SenderCheckingCardStatusReply) { _replyReferEventRecordNumber(reply); } + + if(reply is SenderCheckingUserInfoCountReply){ + _replyCheckingUserInfoCount(reply); + } }); } // 获取指纹状态 Future _replyQueryingFingerprintStatus(Reply reply) async { int status = reply.data[2]; + switch(status){ case 0x00: //成功 @@ -97,6 +103,80 @@ class OtherTypeKeyListLogic extends BaseGetXController{ } } + // 查询用户、指纹、密码、卡片数量(用于判断是否同步) + Future _replyCheckingUserInfoCount(Reply reply) async { + int status = reply.data[2]; + + // 用户数量 + int userNum = reply.data[5]; + // print("userNum:$userNum"); + + // 指纹数量 + int fingerNum = reply.data[6]; + // print("fingerNum:$fingerNum"); + + // 密码数量 + int pwdNum = reply.data[7]; + + // 卡片数量 + int cardNum = reply.data[8]; + + // 记录数量 + int logsNum = reply.data[9]; + + // 版本 + int verNo = reply.data[10]; + + // 最大管理员指纹数量 + int maxAdminFingerNum = reply.data[11]; + + // 最大用户指纹数量 + int maxUserFingerNum = reply.data[12]; + + // 最大管理员密码数量 + int maxAdminPassNum = reply.data[13]; + + // 最大用户密码数量 + int maxUserPassNum = reply.data[14]; + + // 最大管理员卡片数量 + int maxAdminCardNum = reply.data[15]; + + // 最大用户卡片数量 + int maxUserCardNum = reply.data[16]; + + // 序列号 + var serialNo = reply.data.sublist(17, 21); + print("serialNo:$serialNo"); + + switch(status){ + case 0x00: + //成功 + print("${reply.commandType}数据解析成功"); + // _getLockStatus(); + 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 senderQueryingFingerprintStatus() async { BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { @@ -153,6 +233,33 @@ class OtherTypeKeyListLogic extends BaseGetXController{ }); } + // 查询用户、指纹、密码、卡片数量(用于判断是否同步) + Future senderCheckingUserInfoCount() 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.senderCheckingUserInfoCountCommand( + keyID:BlueManage().connectDeviceName, + userID:await Storage.getUid(), + role:0xff, + nowTime:DateTime.now().millisecondsSinceEpoch~/1000, + token:getTokenList, + needAuthor:1, + publicKey:getPublicKeyList, + privateKey:getPrivateKeyList, + ); + } + }); + } + @override void onReady() { // TODO: implement onReady @@ -169,7 +276,8 @@ class OtherTypeKeyListLogic extends BaseGetXController{ print("onInit()"); // senderQueryingFingerprintStatus(); - senderCheckingCardStatus(); + // senderCheckingCardStatus(); + senderCheckingUserInfoCount(); } @override diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index 5d57a1fc..7910426e 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -22,12 +22,12 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { EventBusManager().eventBus!.on().listen((reply) async { // 设置自定义密码 if (reply is SenderCustomPasswordsReply) { - var token = reply.data.sublist(2, 6); + var token = reply.data.sublist(5, 9); var saveStrList = changeIntListToStringList(token); print("_replyFactoryDataResetKeyToken:$token"); Storage.setStringList(saveBlueToken, saveStrList); - int status = reply.data[6]; + int status = reply.data[2]; print("status:$status"); switch (status) { diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index cb51559b..51a59dc1 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -352,6 +352,7 @@ class _PasswordKeyPerpetualPageState extends State { SubmitBtn( btnName: TranslationLoader.lanKeys!.getPassword!.tr, onClick: () { + // logic.senderCustomPasswords(); logic.getStartDate(_effectiveDateTime); getKeyboardPwdRequest(); }), diff --git a/star_lock/lib/main/lockMian/entity/lockInfoEntity.dart b/star_lock/lib/main/lockMian/entity/lockInfoEntity.dart index d705bd0d..8e406175 100644 --- a/star_lock/lib/main/lockMian/entity/lockInfoEntity.dart +++ b/star_lock/lib/main/lockMian/entity/lockInfoEntity.dart @@ -226,6 +226,7 @@ class KeyInfos { int? keyRight; int? electricQuantity; int? lockSound; + int? volume; int? specialValue; int? displayPasscode; int? lockId; @@ -235,13 +236,12 @@ class KeyInfos { Bluetooth? bluetooth; String? lockName; int? monitorFlag; - Null? bondPassword; - int? soundVolume; + String? bondPassword; String? lockAlias; int? isFrozen; - int? isRemoteUnlock; + int? remoteEnable; int? lockFlagPos; - int? autoUnlockRssi; + int? autoLockTime; int? unlockDirection; int? isCameraEnable; int? startDate; @@ -260,9 +260,8 @@ class KeyInfos { int? adminUid; String? lockMac; String? wirelessKeypadFeatureValue; - int? autoLockTime; int? tamperAlert; - + int? roomStatus; KeyInfos( {this.lightingTime, this.privacyLock, @@ -282,6 +281,7 @@ class KeyInfos { this.keyRight, this.electricQuantity, this.lockSound, + this.volume, this.specialValue, this.displayPasscode, this.lockId, @@ -291,12 +291,11 @@ class KeyInfos { this.lockName, this.monitorFlag, this.bondPassword, - this.soundVolume, this.lockAlias, this.isFrozen, - this.isRemoteUnlock, + this.remoteEnable, this.lockFlagPos, - this.autoUnlockRssi, + this.autoLockTime, this.unlockDirection, this.isCameraEnable, this.startDate, @@ -315,8 +314,8 @@ class KeyInfos { this.adminUid, this.lockMac, this.wirelessKeypadFeatureValue, - this.autoLockTime, this.tamperAlert, + this.roomStatus, this.bluetooth}); KeyInfos.fromJson(Map json) { @@ -338,6 +337,7 @@ class KeyInfos { keyRight = json['keyRight']; electricQuantity = json['electricQuantity']; lockSound = json['lockSound']; + volume = json['volume']; specialValue = json['specialValue']; displayPasscode = json['displayPasscode']; lockId = json['lockId']; @@ -349,12 +349,11 @@ class KeyInfos { lockName = json['lockName']; monitorFlag = json['monitorFlag']; bondPassword = json['bondPassword']; - soundVolume = json['soundVolume']; lockAlias = json['lockAlias']; isFrozen = json['isFrozen']; - isRemoteUnlock = json['isRemoteUnlock']; + remoteEnable = json['remoteEnable']; lockFlagPos = json['lockFlagPos']; - autoUnlockRssi = json['autoUnlockRssi']; + autoLockTime = json['autoLockTime']; unlockDirection = json['unlockDirection']; isCameraEnable = json['isCameraEnable']; startDate = json['startDate']; @@ -373,8 +372,8 @@ class KeyInfos { adminUid = json['adminUid']; lockMac = json['lockMac']; wirelessKeypadFeatureValue = json['wirelessKeypadFeatureValue']; - autoLockTime = json['autoLockTime']; tamperAlert = json['tamperAlert']; + roomStatus = json['roomStatus']; bluetooth = json['bluetooth'] != null ? Bluetooth.fromJson(json['bluetooth']) : null; @@ -400,6 +399,7 @@ class KeyInfos { data['keyRight'] = keyRight; data['electricQuantity'] = electricQuantity; data['lockSound'] = lockSound; + data['volume'] = volume; data['specialValue'] = specialValue; data['displayPasscode'] = displayPasscode; data['lockId'] = lockId; @@ -411,12 +411,10 @@ class KeyInfos { data['lockName'] = lockName; data['monitorFlag'] = monitorFlag; data['bondPassword'] = bondPassword; - data['soundVolume'] = soundVolume; data['lockAlias'] = lockAlias; data['isFrozen'] = isFrozen; - data['isRemoteUnlock'] = isRemoteUnlock; + data['remoteEnable'] = remoteEnable; data['lockFlagPos'] = lockFlagPos; - data['autoUnlockRssi'] = autoUnlockRssi; data['unlockDirection'] = unlockDirection; data['isCameraEnable'] = isCameraEnable; data['startDate'] = startDate; @@ -437,6 +435,7 @@ class KeyInfos { data['wirelessKeypadFeatureValue'] = wirelessKeypadFeatureValue; data['autoLockTime'] = autoLockTime; data['tamperAlert'] = tamperAlert; + data['roomStatus'] = roomStatus; if (bluetooth != null) { data['bluetooth'] = bluetooth!.toJson(); } diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart index 6209cc7f..e033008c 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -6,6 +6,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import '../../../blue/io_tool/manager_event_bus.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; +import '../../../tools/eventBusEventManage.dart'; import 'lockMain_state.dart'; class LockMainLogic extends BaseGetXController { @@ -57,21 +58,22 @@ class LockMainLogic extends BaseGetXController { // refreshController.refreshCompleted(); } - // 监听设备返回的数据 - late StreamSubscription _addLockSubscription; - void _initAddLockSubscription() { - _addLockSubscription = EventBusManager().eventBus!.on().listen((event) async { + late StreamSubscription _teamEvent; + void _initLoadDataAction() { + _teamEvent = eventBus.on().listen((event) { getLockInfo(); + print("收到消息"); }); } + @override void onReady() { // TODO: implement onReady super.onReady(); print("onReady()"); - _initAddLockSubscription(); + _initLoadDataAction(); } @override @@ -89,7 +91,7 @@ class LockMainLogic extends BaseGetXController { super.onClose(); // refreshController.dispose(); - _addLockSubscription.cancel(); + _teamEvent.cancel(); } } \ No newline at end of file diff --git a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart index 68a75265..7e7e2cc1 100644 --- a/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/lockMain_page.dart @@ -1,4 +1,6 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 079de566..43bf6048 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -17,6 +17,7 @@ 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 'saveLock_state.dart'; @@ -52,7 +53,7 @@ class SaveLockLogic extends BaseGetXController { int status = reply.data[46]; print("status:$status"); - userNo = reply.data[47]; + userNo = reply.data[46]; print("status:$status"); switch(status){ case 0x00: @@ -262,10 +263,12 @@ class SaveLockLogic extends BaseGetXController { position:positionMap, bluetooth:bluetooth, deviceNo:"123456", - lockUserNo:userNo.toString() + // lockUserNo:userNo.toString(), + lockUserNo:"1234", + pwdTimestamp:"11223344" ); if(entity.errorCode!.codeIsSuccessful){ - EventBusManager().eventBusFir(RefreshLockListInfoDataEvent); + eventBus.fire(RefreshLockListInfoDataEvent()); Get.offAllNamed(Routers.starLockMain); } } diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 450deeec..74a6d0c3 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -38,4 +38,14 @@ abstract class Api { final String updateSettingURL = '/room/updateSetting'; //标记房态 final String keyGroupListURL = '/keyGroup/list'; //分组列表 final String lockListByGroupURL = '/room/listByGroup'; //分组下的锁 + + final String getWifiServiceIpURL = '/wifiLock/getWifiServiceIp'; // 获取Wifi锁服务器 + final String updateSpecialValueUrl = '/room/updateSpecialValue'; // 开启/关闭 远程开锁 + final String setAutoLockTimeUrl = '/room/setAutoLockTime'; // 自动闭锁 + final String getPassageModeConfigUrl = '/room/getPassageModeConfig'; // 获取锁的常开模式设置 + final String configPassageModeUrl = '/room/configPassageMode'; // 配置锁的常开模式 + final String updateSettingUrl = '/room/updateSetting'; // 锁声音/防撬报警/重置键/考勤 + final String roomQueryDateUrl = '/room/queryDate'; // 获取网关时间 + final String getServerDatetimeUrl = '/check/getServerDatetime'; // 获取服务器当前时间 + final String getLockVersionInfoUrl = '/room/update'; // 获取锁当前版本信息 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 4af64b07..b72c6b74 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -264,7 +264,8 @@ class ApiProvider extends BaseProvider { Map position, Map bluetooth, String deviceNo, - String lockUserNo) => + String lockUserNo, + String pwdTimestamp) => post( bindingBlueAdminURL.toUrl, jsonEncode({ @@ -277,6 +278,7 @@ class ApiProvider extends BaseProvider { 'bluetooth': bluetooth, 'deviceNo': deviceNo, 'lockUserNo': lockUserNo, + 'pwdTimestamp': pwdTimestamp, })); // 获取锁信息 @@ -294,6 +296,12 @@ class ApiProvider extends BaseProvider { 'lockId': lockId, })); + // 获取Wifi锁服务器 + Future getWifiLockServiceIpAndPort() => post( + getWifiServiceIpURL.toUrl, + jsonEncode({ + })); + Future passwordKeyList( String keyStatus, String lockId, @@ -373,6 +381,84 @@ class ApiProvider extends BaseProvider { Future lockListByGroup(String type, String keyGroupId) => post( lockListByGroupURL.toUrl, jsonEncode({'type': type, 'keyGroupId': keyGroupId})); + +/// 锁设置模块 + // 远程开锁 + Future remoteUnlockingOpenOrCloseLoadData(String lockId, String featureValue) => + post( + updateSpecialValueUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'featureValue': featureValue, + })); + + // 自动闭锁 + Future setAutoUnlockLoadData(String lockId, String autoLockTime, String type) => + post( + setAutoLockTimeUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'autoLockTime': autoLockTime, + 'type': type, + })); + + // 获取锁的常开模式设置 + Future getPassageModeConfigLoadData(String lockId) => + post( + getPassageModeConfigUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + })); + + // 获取锁的常开模式设置 + Future configPassageMode(String lockId, String passageMode, String autoUnlock, String type, String startDate, String endDate, String isAllDay, List weekDays) => + post( + configPassageModeUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'passageMode': passageMode, + 'autoUnlock': autoUnlock, + 'type': type, + 'startDate': startDate, + 'endDate': endDate, + 'isAllDay': isAllDay, + 'weekDays': weekDays, + })); + + // 获取锁的常开模式设置 + Future setLockSetGeneralSetting(String lockId, String changeType, String isOn, String type) => + post( + updateSettingUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + 'changeType': changeType, + 'isOn': isOn, + 'type': type, + })); + + // 通过网关获取锁的时间 + Future getLockTimeFromGatewayLoadData(String lockId) => + post( + roomQueryDateUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + })); + + // 获取服务器当前时间 + Future getServerDatetimeLoadData(String lockId) => + post( + getServerDatetimeUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + })); + + // 获取锁版本信息 + Future getLockVersionInfoLoadData(String lockId) => + post( + getLockVersionInfoUrl.toUrl, + jsonEncode({ + 'lockId': lockId, + })); } extension ExtensionString on String { diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index b90d03c7..09478d6b 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -9,6 +9,9 @@ import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart'; import '../common/safetyVerification/entity/SafetyVerificationEntity.dart'; import '../login/login/entity/LoginEntity.dart'; import '../login/register/entity/SendValidationCodeEntity.dart'; +import '../main/lockDetail/lcokSet/configuringWifi/configuringWifiEntity.dart'; +import '../main/lockDetail/lcokSet/lockTime/GetServerDatetimeEntity.dart'; +import '../main/lockDetail/lcokSet/normallyOpenMode/GetPassageModeConfigEntity.dart'; import '../main/lockMian/entity/lockInfoEntity.dart'; import '../mine/addLock/saveLock/entity/SaveLockEntity.dart'; import 'api_provider.dart'; @@ -192,7 +195,8 @@ class ApiRepository { required Map position, required Map bluetooth, required String deviceNo, - required String lockUserNo}) async { + required String lockUserNo, + required String pwdTimestamp}) async { final res = await apiProvider.bindingBlueAdmin( bindingDate, hotelMode, @@ -202,7 +206,8 @@ class ApiRepository { position, bluetooth, deviceNo, - lockUserNo); + lockUserNo, + pwdTimestamp); return SaveLockEntity.fromJson(res.body); } @@ -362,4 +367,104 @@ class ApiRepository { final res = await apiProvider.lockListByGroup(type, keyGroupId); return PasswordKeyEntity.fromJson(res.body); } + + // 获取Wifi锁服务器 + Future getWifiLockServiceIpAndPort() async { + final res = await apiProvider.getWifiLockServiceIpAndPort(); + return ConfiguringWifiEntity.fromJson(res.body); + } + +/// 锁设置模块 + // 远程开锁开/关 + Future remoteUnlockingOpenOrClose( + { + required String lockId, + required String featureValue, + }) async { + final res = + await apiProvider.remoteUnlockingOpenOrCloseLoadData(lockId, featureValue); + return LoginEntity.fromJson(res.body); + } + + // 自动闭锁 + Future setAutoUnlock( + { + required String lockId, + required String autoLockTime, + required String type, + }) async { + final res = + await apiProvider.setAutoUnlockLoadData(lockId, autoLockTime, type); + return LoginEntity.fromJson(res.body); + } + + // 获取锁的常开模式设置 configPassageMode + Future getPassageModeConfig( + { + required String lockId, + }) async { + final res = + await apiProvider.getPassageModeConfigLoadData(lockId); + return GetPassageModeConfigEntity.fromJson(res.body); + } + + // 配置锁的常开模式 + Future configPassageModeLoadData( + { + required String lockId, + required String passageMode, + required String autoUnlock, + required String type, + required String startDate, + required String endDate, + required String isAllDay, + required List weekDays, + }) async { + final res = + await apiProvider.configPassageMode(lockId, passageMode, autoUnlock, type, startDate, endDate, isAllDay, weekDays); + return GetPassageModeConfigEntity.fromJson(res.body); + } + + // 配置锁的常规设置 + Future setLockSetGeneralSettingData( + { + required String lockId, + required String changeType, + required String isOn, + required String type, + }) async { + final res = + await apiProvider.setLockSetGeneralSetting(lockId, changeType, isOn, type); + return LoginEntity.fromJson(res.body); + } + + // 获取锁时间 通过网关 + Future getLockTimeFromGateway( + { + required String lockId, + }) async { + final res = + await apiProvider.getLockTimeFromGatewayLoadData(lockId); + return GetPassageModeConfigEntity.fromJson(res.body); + } + + // 获取服务器当前时间 + Future getServerDatetimeData( + { + required String lockId, + }) async { + final res = + await apiProvider.getServerDatetimeLoadData(lockId); + return GetServerDatetimeEntity.fromJson(res.body); + } + + // 获取锁版本信息 + Future getLockVersionInfoData( + { + required String lockId, + }) async { + final res = + await apiProvider.getLockVersionInfoLoadData(lockId); + return GetServerDatetimeEntity.fromJson(res.body); + } } diff --git a/star_lock/lib/tools/dateTool.dart b/star_lock/lib/tools/dateTool.dart index 82733dc3..ae6dd6cb 100644 --- a/star_lock/lib/tools/dateTool.dart +++ b/star_lock/lib/tools/dateTool.dart @@ -28,7 +28,7 @@ class DateTool { int time = int.parse(timeDate); DateTime nowDate = DateTime.fromMillisecondsSinceEpoch(time); - String appointmentDate = formatDate(nowDate, [yyyy,'.',mm,'.',dd,' ',HH,':',nn]); + String appointmentDate = formatDate(nowDate, [yyyy,'.',mm,'.',dd,' ',HH,':',nn ,':',ss]); return appointmentDate; } diff --git a/star_lock/lib/tools/eventBusEventManage.dart b/star_lock/lib/tools/eventBusEventManage.dart new file mode 100644 index 00000000..b3981bfa --- /dev/null +++ b/star_lock/lib/tools/eventBusEventManage.dart @@ -0,0 +1,16 @@ +import 'package:event_bus/event_bus.dart'; +import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; + +/// 创建EventBus +EventBus eventBus = EventBus(); + +/// 刷新锁列表数据 +class RefreshLockListInfoDataEvent{ + RefreshLockListInfoDataEvent(); +} + +/// 传递当前锁信息 +class PassCurrentLockInformationEvent{ + KeyInfos keyInfo; + PassCurrentLockInformationEvent(this.keyInfo); +} diff --git a/star_lock/lib/tools/titleAppBar.dart b/star_lock/lib/tools/titleAppBar.dart index 479c5929..71c3615c 100644 --- a/star_lock/lib/tools/titleAppBar.dart +++ b/star_lock/lib/tools/titleAppBar.dart @@ -10,6 +10,7 @@ class TitleAppBar extends AppBar { final bool? haveTitleWidget; final Widget? titleWidget; final bool? haveBack; + final Function? backAction; final bool? haveOtherLeftWidget; final Widget? leftWidget; List? actionsList; @@ -24,6 +25,7 @@ class TitleAppBar extends AppBar { this.backgroundColor, this.actionsList, this.haveBack, + this.backAction, this.haveOtherLeftWidget = false, this.leftWidget}) : super(key: key); @@ -43,7 +45,7 @@ class _TitleAppBarState extends State { ? IconButton( icon: Icon(Icons.arrow_back_ios, color: widget.iconColor ?? Colors.white), - onPressed: () => Navigator.of(context).pop(), + onPressed: () => widget.backAction ?? Navigator.of(context).pop(), ) : Container()), backgroundColor: widget.backgroundColor ?? Colors.white, diff --git a/star_lock/lib/translations/lanKeyEntity.dart b/star_lock/lib/translations/lanKeyEntity.dart index 2234b02f..b8bcbaf7 100644 --- a/star_lock/lib/translations/lanKeyEntity.dart +++ b/star_lock/lib/translations/lanKeyEntity.dart @@ -89,6 +89,8 @@ class LanKeyEntity { this.remoteUnlocking, this.automaticBlocking, this.normallyOpenMode, + this.automaticUnLock, + this.automaticUnLockTip, this.lockSound, this.burglarAlarm, this.resetButton, @@ -219,6 +221,8 @@ class LanKeyEntity { this.lockScreen, this.closed, this.opened, + this.close, + this.open, this.hideInvalidUnlockPermissions, this.appUnlockRequiresMobilePhoneAccessToTheLock, this.valueAddedServices, @@ -377,7 +381,13 @@ class LanKeyEntity { this.hideInvalidUnlockPermissionsTip, this.appUnlockRequiresMobilePhoneAccessToTheLockTip, this.checkAll, - this.getVerificationCode}); + this.getVerificationCode, + this.configuringWiFi, + this.pleaseEnterWifiName, + this.wifiPwd, + this.pleaseEnterWifiPwd, + this.wifiDistributionNetwork, +}); LanKeyEntity.fromJson(dynamic json) { starLock = json['starLock']; @@ -502,6 +512,8 @@ class LanKeyEntity { remoteUnlocking = json['remoteUnlocking']; automaticBlocking = json['automaticBlocking']; normallyOpenMode = json['normallyOpenMode']; + automaticUnLock = json['automaticUnLock']; + automaticUnLockTip = json['automaticUnLockTip']; lockSound = json['lockSound']; burglarAlarm = json['burglarAlarm']; resetButton = json['resetButton']; @@ -608,6 +620,8 @@ class LanKeyEntity { lockScreen = json['lockScreen']; closed = json['closed']; opened = json['opened']; + close = json['close']; + open = json['open']; hideInvalidUnlockPermissions = json['hideInvalidUnlockPermissions']; appUnlockRequiresMobilePhoneAccessToTheLock = json['appUnlockRequiresMobilePhoneAccessToTheLock']; @@ -786,6 +800,12 @@ class LanKeyEntity { json['appUnlockRequiresMobilePhoneAccessToTheLockTip']; checkAll = json['checkAll']; getVerificationCode = json['getVerificationCode']; + + configuringWiFi = json['configuringWiFi']; + pleaseEnterWifiName = json['pleaseEnterWifiName']; + wifiPwd = json['wifiPwd']; + pleaseEnterWifiPwd = json['pleaseEnterWifiPwd']; + wifiDistributionNetwork = json['wifiDistributionNetwork']; } String? starLock; String? clickUnlockAndHoldDownClose; @@ -944,6 +964,8 @@ class LanKeyEntity { String? remoteUnlocking; String? automaticBlocking; String? normallyOpenMode; + String? automaticUnLock; + String? automaticUnLockTip; String? lockSound; String? burglarAlarm; String? resetButton; @@ -1012,6 +1034,8 @@ class LanKeyEntity { String? lockScreen; String? closed; String? opened; + String? close; + String? open; String? hideInvalidUnlockPermissions; String? appUnlockRequiresMobilePhoneAccessToTheLock; String? valueAddedServices; @@ -1182,6 +1206,12 @@ class LanKeyEntity { String? checkAll; String? getVerificationCode; + String? configuringWiFi; + String? pleaseEnterWifiName; + String? wifiPwd; + String? pleaseEnterWifiPwd; + String? wifiDistributionNetwork; + Map toJson() { final map = {}; map['starLock'] = starLock; @@ -1311,6 +1341,8 @@ class LanKeyEntity { map['remoteUnlocking'] = remoteUnlocking; map['automaticBlocking'] = automaticBlocking; map['normallyOpenMode'] = normallyOpenMode; + map['automaticUnLock'] = automaticUnLock; + map['automaticUnLockTip'] = automaticUnLockTip; map['lockSound'] = lockSound; map['burglarAlarm'] = burglarAlarm; map['resetButton'] = resetButton; @@ -1410,6 +1442,8 @@ class LanKeyEntity { map['lockScreen'] = lockScreen; map['closed'] = closed; map['opened'] = opened; + map['close'] = close; + map['open'] = open; map['hideInvalidUnlockPermissions'] = hideInvalidUnlockPermissions; map['appUnlockRequiresMobilePhoneAccessToTheLock'] = appUnlockRequiresMobilePhoneAccessToTheLock; @@ -1587,6 +1621,12 @@ class LanKeyEntity { appUnlockRequiresMobilePhoneAccessToTheLockTip; map['checkAll'] = checkAll; map['getVerificationCode'] = getVerificationCode; + + map['configuringWiFi'] = configuringWiFi; + map['pleaseEnterWifiName'] = pleaseEnterWifiName; + map['wifiPwd'] = wifiPwd; + map['pleaseEnterWifiPwd'] = pleaseEnterWifiPwd; + map['wifiDistributionNetwork'] = wifiDistributionNetwork; return map; } } diff --git a/star_lock/macos/Flutter/GeneratedPluginRegistrant.swift b/star_lock/macos/Flutter/GeneratedPluginRegistrant.swift index 8a945aa6..f3092101 100644 --- a/star_lock/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/star_lock/macos/Flutter/GeneratedPluginRegistrant.swift @@ -8,6 +8,7 @@ import Foundation import aj_captcha_flutter import device_info_plus import file_selector_macos +import network_info_plus import package_info_plus import path_provider_foundation import shared_preferences_foundation @@ -17,6 +18,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AjCaptchaFlutterPlugin.register(with: registry.registrar(forPlugin: "AjCaptchaFlutterPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) + NetworkInfoPlusPlugin.register(with: registry.registrar(forPlugin: "NetworkInfoPlusPlugin")) FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 153ce01b..467485ca 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -102,6 +102,8 @@ dependencies: google_maps_flutter: ^2.2.5 geocoding: ^2.1.0 + # 允许App发现网络的相关信息并且进行相应的配置 + network_info_plus: ^4.0.2 dev_dependencies: flutter_test: sdk: flutter