diff --git a/.DS_Store b/.DS_Store index 8457ca12..dacbfd01 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index 2fba48b9..d6efba2c 100644 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -337,8 +337,7 @@ "customSMSTemplate": "Custom SMS Template", "customMailTemplate": "Custom Mail Template", "record": "Record", - "buyRealNameTip": "When an electronic key is sent to the user, the user can be required to authenticate with his real name before unlocking to ensure that he is operating. The real-name authentication calls the interface of the national Public security system. For the payment function, please purchase the number of times before using it.", - "buyRealNameSelectYouWantBuyTip": "Please select the frequency of real name authentication you want", + "forTheFirstTime": "For the first time", "onceDay": "once a day", "weekOnce": "once a week", @@ -680,6 +679,8 @@ "型号": "Model", "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "After the password is generated, please use it once for activation before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. After the password is activated, it can be used unlimited times within the validity period.", "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "After the password is generated, please use it before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. The clear code is used to clear all the passwords generated before 0 o'clock today.", + "密码生成后,请在当日23:59前使用,否则过0点后失效。": "After the password is generated, please use it before 23:59 on the same day, otherwise it will be invalid after 0 o'clock.", + "清空密码底部提示": "The password is valid until 24 o 'clock on the day of emptying\nEmpty content 1: All passwords except custom generated before 0 o 'clock on the same day (passwords generated after 0 o 'clock on the same day are not affected by the empty password and can continue to be used) \nEmpty content 2: Clear passwords Clear all custom passwords (used and unused) immediately after use \nTo completely clear all passwords, use the Reset All Passwords feature", "相机": "camera", "相册": "photos", "读写": "storage", @@ -711,7 +712,7 @@ "请输入手机号": "Please enter mobile phone number", "家人到家": "Family gets home", "添加家人": "Add family", - "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择": "If the lock is not connected to the Internet, in addition to the electronic key, the password, card, fingerprint and other door reminders can not be sent in time, please choose according to your actual situation", + "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。": "If the lock is not connected to the Internet, in addition to the electronic key, the password, card, fingerprint and other door reminders can not be sent in time, please choose according to your actual situation", "消息提醒": "Message reminder", "开门通知": "Opening notice", "N天未开门": "N days without opening the door", @@ -839,8 +840,19 @@ "固件版本": "Firmware version", "手动升级": "Manual upgrade", "设备连接中...": "Device Connecting...", - "升级过程中无法开锁,请先开锁后再升级": "The lock cannot be unlocked during the upgrade, please unlock the lock before upgrading", + "未避免异常情况,请在门打开时升级": "Unavoidable exceptions, please upgrade when the door is open", "钥匙无效": "The key is invalid", "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。": "The operation failed. Please confirm whether the lock is nearby, or restart your phone's Bluetooth and try again.", - "如果是全自动锁,请使屏幕变亮": "If it is a fully automatic lock, please make the screen brighter" + "如果是全自动锁,请使屏幕变亮": "If it is a fully automatic lock, please make the screen brighter", + "正在尝试闭锁……": "Attempting to lock...", + "清空记录":"Clear record", + "是否要删除操作记录?":"Do you want to delete the operation record?", + "被删除的记录不能恢复":"The deleted record cannot be restored", + "全部事件":"All events", + "开锁事件":"Unlock event", + "异常事件":"Abnormal event", + "门铃事件":"Doorbell event", + "视频事件":"Video event", + "请开启蓝牙":"Please turn on Bluetooth", + "请选择有效日":"Please select the effective day" } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index e62f6b5f..52f94c2d 100644 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -707,6 +707,8 @@ "型号": "型号", "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。", "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。":"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。", + "密码生成后,请在当日23:59前使用,否则过0点后失效。": "密码生成后,请在当日23:59前使用,否则过0点后失效。", + "清空密码底部提示": "清空密码底部提示", "密码不一致哦":"密码不一致哦", "相机": "相机", @@ -739,7 +741,7 @@ "请输入手机号":"请输入手机号", "家人到家":"家人到家", "添加家人":"添加家人", - "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择":"若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择", + "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。":"若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。", "消息提醒":"消息提醒", "开门通知":"开门通知", "N天未开门":"N天未开门", @@ -867,8 +869,19 @@ "固件版本": "固件版本", "手动升级": "手动升级", "设备连接中...": "设备连接中...", - "升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级", + "未避免异常情况,请在门打开时升级": "未避免异常情况,请在门打开时升级", "钥匙无效": "钥匙无效", "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。": "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。", - "如果是全自动锁,请使屏幕变亮": "如果是全自动锁,请使屏幕变亮" + "如果是全自动锁,请使屏幕变亮": "如果是全自动锁,请使屏幕变亮", + "正在尝试闭锁……": "正在尝试闭锁……", + "清空记录":"清空记录", + "是否要删除操作记录?":"是否要删除操作记录?", + "被删除的记录不能恢复":"被删除的记录不能恢复", + "全部事件":"全部事件", + "开锁事件":"开锁事件", + "异常事件":"异常事件", + "门铃事件":"门铃事件", + "视频事件":"视频事件", + "请开启蓝牙":"请开启蓝牙", + "请选择有效日":"请选择有效日" } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index bcba9e43..51476b7a 100644 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -682,6 +682,8 @@ "型号": "型号", "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。", "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。": "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。", + "密码生成后,请在当日23:59前使用,否则过0点后失效。": "密码生成后,请在当日23:59前使用,否则过0点后失效。", + "清空密码底部提示": "清空密码当日24点前有效\n清空内容1:当日0点前生成的除自定义以外所有密码(当日0点后生成的密码,不受清空密码影响,可继续使用)\n清空内容2:清空密码使用后,立即清除所有自定义密码(含使用过和未使用过的)\n如需彻底清除所有密码,请使用重置所有密码功能", "密码不一致哦": "密码不一致哦", "相机": "相机", "相册": "相册", @@ -711,7 +713,7 @@ "请输入手机号": "请输入手机号", "家人到家": "家人到家", "添加家人": "添加家人", - "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择": "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择", + "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。": "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。", "消息提醒": "消息提醒", "开门通知": "开门通知", "N天未开门": "N天未开门", @@ -837,8 +839,19 @@ "固件版本": "固件版本", "手动升级": "手动升级", "设备连接中...": "设备连接中...", - "升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级", + "未避免异常情况,请在门打开时升级": "未避免异常情况,请在门打开时升级", "钥匙无效": "钥匙无效", "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。": "操作失败,请确认锁是否在附近,或重启手机蓝牙后再试。", - "如果是全自动锁,请使屏幕变亮": "如果是全自动锁,请使屏幕变亮" + "如果是全自动锁,请使屏幕变亮": "如果是全自动锁,请使屏幕变亮", + "正在尝试闭锁……": "正在尝试闭锁……", + "清空记录":"清空记录", + "是否要删除操作记录?":"是否要删除操作记录?", + "被删除的记录不能恢复":"被删除的记录不能恢复", + "全部事件":"全部事件", + "开锁事件":"开锁事件", + "异常事件":"异常事件", + "门铃事件":"门铃事件", + "视频事件":"视频事件", + "请开启蓝牙":"请开启蓝牙", + "请选择有效日":"请选择有效日" } diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 855cc62a..1f76cd62 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -309,7 +309,7 @@ SPEC CHECKSUMS: audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207 audioplayers_darwin: 877d9a4d06331c5c374595e46e16453ac7eafa40 auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d - camera_avfoundation: 8b8d780bcfb6a4a02b0fbe2b4bd17b5b71946e68 + camera_avfoundation: 759172d1a77ae7be0de08fc104cfb79738b8a59e connectivity_plus: bf0076dd84a130856aa636df1c71ccaff908fa1d device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed DKImagePickerController: 0a24ebfe7b48beeb74c27531540aaa2cc1dac6cf @@ -322,12 +322,12 @@ SPEC CHECKSUMS: flutter_native_contact_picker: bd430ba0fbf82768bb50c2c52a69a65759a8f907 flutter_pcm_sound: de0572ca4f99091cc2abfcc31601b8a4ddd33c0e flutter_voice_processor: 2b89b93d69b02227ae3fd58589ee0bcfa3ca2a82 - fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265 + fluttertoast: 9f2f8e81bb5ce18facb9748d7855bf5a756fe3db fluwx: daa284756ce53442b3d0417ceeda66e981906811 - google_maps_flutter_ios: d1318b4ff711612cab16862d7a87e31a7403d458 + google_maps_flutter_ios: f135b968a67c05679e0a53538e900b5c174b0d99 GoogleMaps: 20d7b12be49a14287f797e88e0e31bc4156aaeb4 image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb - image_picker_ios: 99dfe1854b4fa34d0364e74a78448a0151025425 + image_picker_ios: b545a5f16c0fa88e3ecbbce3ed4de45567a8ec18 ios-voice-processor: 8e32d7f980a06d392d128ef1cd19cf6ddcaca3c1 JCore: 05f0f3489672ea3fa55338bae4866224bc092b1f JPush: 76668b765fcfd7c15f86b05ca0e5cdc01945ce23 @@ -335,18 +335,18 @@ SPEC CHECKSUMS: just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa network_info_plus: 6d0c3eb8367b8164fa3fb0c19875e3f59d49697f package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e - path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c + path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 ReachabilitySwift: 2128f3a8c9107e1ad33574c6e58e8285d460b149 SDWebImage: 40b0b4053e36c660a764958bff99eed16610acbb - shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 + shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 system_settings: 8f5cdbfa72c677fc8d665b863bcc20d393d87e9d Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e - url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812 - video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579 - webview_flutter_wkwebview: 4f3e50f7273d31e5500066ed267e3ae4309c5ae4 + url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe + video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3 + webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36 WechatOpenSDK-XCFramework: 36fb2bea0754266c17184adf4963d7e6ff98b69f PODFILE CHECKSUM: 317f9473a5705c6fe4d79d95e81676f248048fdc diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index f628b2c8..82c40d25 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -853,6 +853,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 7D53BZAN75; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; PROVISIONING_PROFILE_SPECIFIER = ""; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -868,6 +869,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = "Runner/RunnerProfile-dev.entitlements"; DEVELOPMENT_TEAM = 7D53BZAN75; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -882,6 +884,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-dev.entitlements"; DEVELOPMENT_TEAM = 7D53BZAN75; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -896,6 +899,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = "Runner/RunnerDebug-pre.entitlements"; DEVELOPMENT_TEAM = 7D53BZAN75; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -910,6 +914,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = "Runner/RunnerProfile-pre.entitlements"; DEVELOPMENT_TEAM = 7D53BZAN75; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -924,6 +929,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-pre.entitlements"; DEVELOPMENT_TEAM = 7D53BZAN75; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -938,6 +944,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = "Runner/RunnerDebug-sky.entitlements"; DEVELOPMENT_TEAM = NAQ5PL2DYC; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -952,6 +959,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = "Runner/RunnerProfile-sky.entitlements"; DEVELOPMENT_TEAM = NAQ5PL2DYC; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -966,6 +974,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-sky.entitlements"; DEVELOPMENT_TEAM = NAQ5PL2DYC; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -980,6 +989,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; DEVELOPMENT_TEAM = P8997RW3V8; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -994,6 +1004,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; DEVELOPMENT_TEAM = P8997RW3V8; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; @@ -1008,6 +1019,7 @@ buildSettings = { CODE_SIGN_ENTITLEMENTS = "Runner/RunnerRelease-xhj.entitlements"; DEVELOPMENT_TEAM = P8997RW3V8; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; PRODUCT_NAME = Runner; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; SUPPORTS_MACCATALYST = NO; diff --git a/lib/appRouters.dart b/lib/appRouters.dart index 10428878..f415e1aa 100644 --- a/lib/appRouters.dart +++ b/lib/appRouters.dart @@ -373,7 +373,7 @@ abstract class Routers { static const getDeviceListPage = '/getDeviceListPage'; //设备列表 static const getNameListPage = '/getNameListPage'; //姓名列表 static const authorityManagementPage = '/authorityManagementPage'; //批量授权 - static const massSendLockGroupPage = '/massSendLockGroupPage'; //群发锁分组列表 + static const massSendLockGroupListPage = '/massSendLockGroupListPage'; //群发锁分组列表 static const massSendReceiverPage = '/massSendReceiverPage'; //群发接收人 static const lockUserListPage = '/lockUserListPage'; //锁用户列表 static const administratorDetailsPage = '/administratorDetailsPage'; //管理员详情 @@ -911,7 +911,7 @@ abstract class AppRouters { name: Routers.configuringWifiPage, page: () => const ConfiguringWifiPage()), GetPage( - name: Routers.massSendLockGroupPage, + name: Routers.massSendLockGroupListPage, page: () => const MassSendLockGroupListPage()), GetPage( name: Routers.massSendReceiverPage, diff --git a/lib/app_settings/app_settings.dart b/lib/app_settings/app_settings.dart index 53f711b5..7998bf68 100644 --- a/lib/app_settings/app_settings.dart +++ b/lib/app_settings/app_settings.dart @@ -14,6 +14,7 @@ class AppLog { _onlyError = onlyError ?? false; } static log(String msg,{bool? error}){ + msg = '${DateTime.now().toIso8601String()} : $msg'; DebugConsole.info(msg); if(!kDebugMode)return; error = error ?? false; diff --git a/lib/blue/blue_manage.dart b/lib/blue/blue_manage.dart index b5027d9b..223fe584 100644 --- a/lib/blue/blue_manage.dart +++ b/lib/blue/blue_manage.dart @@ -1,9 +1,13 @@ import 'dart:async'; import 'dart:io'; +import 'package:app_settings/app_settings.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/tools/showTipView.dart'; +import 'package:star_lock/widget/permission/permission_dialog.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'io_tool/io_model.dart'; import 'io_tool/io_tool.dart'; @@ -623,7 +627,7 @@ class BlueManage { } } } on Exception catch (e, s) { - AppLog.log('APP写入失败: $e'); + AppLog.log('APP写入失败: $e $s'); rethrow; } } @@ -654,6 +658,29 @@ class BlueManage { // } } + // 写入 + Future writeNull() async { + List services = + await bluetoothConnectDevice!.discoverServices(); + for (BluetoothService service in services) { + if (service.uuid == _serviceIdConnect) { + for (BluetoothCharacteristic characteristic + in service.characteristics) { + if (characteristic.characteristicUuid == _characteristicIdWrite) { + try { + List valueList = [1]; + AppLog.log('APP写入 writeNull '); + await characteristic.write(valueList); + } on Exception catch (e, s) { + AppLog.log('APP写入失败 writeNull : $e $s'); + rethrow; + } + } + } + } + } + } + // 读取 // Future> _readCharacteristic(QualifiedCharacteristic characteristic) async { // try { @@ -696,7 +723,10 @@ class BlueManage { // if(bluetoothConnectDevice != null && bluetoothConnectDevice!.connectionState == BluetoothConnectionState.connected){ connectDeviceMacAddress = ""; if (bluetoothConnectionState == BluetoothConnectionState.connected) { - await bluetoothConnectDevice!.disconnect(); + // await writeNull(); + // await Future.delayed(const Duration(milliseconds: 1000)); + //加快蓝牙断连 + await bluetoothConnectDevice!.disconnect(timeout: 2); AppLog.log("断开连接成功"); } // } @@ -712,7 +742,7 @@ class BlueManage { await FlutterBluePlus.turnOn(); } if (Platform.isIOS) { - EasyLoading.showToast("请开启蓝牙", duration: 2000.milliseconds); + EasyLoading.showToast("请开启蓝牙".tr, duration: 2000.milliseconds); } } diff --git a/lib/blue/io_protocol/io_addUser.dart b/lib/blue/io_protocol/io_addUser.dart index 890fa84c..e54463e6 100644 --- a/lib/blue/io_protocol/io_addUser.dart +++ b/lib/blue/io_protocol/io_addUser.dart @@ -66,8 +66,8 @@ class AddUserCommand extends SenderProtocol { return 'AddUserCommand{lockID: $lockID, authUserID: $authUserID,' 'keyID: $keyID, userID: $userID, openMode: $openMode, ' 'keyType: $keyType, ' - 'startDate:${DateTool().dateIntToYMDHNString(startDate)} , ' - 'expireDate: ${DateTool().dateIntToYMDHNString(expireDate)} , ' + 'startDate:$startDate startDateStr:${ DateTool().dateIntToYMDHNString(startDate)} , ' + 'expireDate:$expireDate expireDateStr: ${DateTool().dateIntToYMDHNString(expireDate)} , ' 'useCountLimit: $useCountLimit, isRound: $isRound, ' 'weekRound: $weekRound, startHour: $startHour, ' 'startMin: $startMin, endHour: $endHour, ' diff --git a/lib/blue/io_protocol/io_getStarLockStatusInfo.dart b/lib/blue/io_protocol/io_getStarLockStatusInfo.dart index 5549a8cc..1e9f064b 100644 --- a/lib/blue/io_protocol/io_getStarLockStatusInfo.dart +++ b/lib/blue/io_protocol/io_getStarLockStatusInfo.dart @@ -26,7 +26,7 @@ class GetStarLockStatuInfoCommand extends SenderProtocol { @override String toString() { return 'GetStarLockStatuInfoCommand{lockID: $lockID, ' - 'utcTimeStamp: ${DateTool().dateIntToYMDHNString(utcTimeStamp)}, unixTimeStamp: ${DateTool().dateIntToYMDHNString(unixTimeStamp)}, ' + 'utcTimeStamp:$utcTimeStamp utcTimeStamp: ${DateTool().dateIntToYMDHNString(utcTimeStamp)}, unixTimeStamp:unixTimeStamp unixTimeStamp: ${DateTool().dateIntToYMDHNString(unixTimeStamp)}, ' 'userID: $userID, privateKey: $privateKey}'; } diff --git a/lib/blue/io_protocol/io_referEventRecordTime.dart b/lib/blue/io_protocol/io_referEventRecordTime.dart index 2ffe80a5..04e38917 100644 --- a/lib/blue/io_protocol/io_referEventRecordTime.dart +++ b/lib/blue/io_protocol/io_referEventRecordTime.dart @@ -34,7 +34,7 @@ class SenderReferEventRecordTimeCommand extends SenderProtocol { @override String toString() { return 'SenderReferEventRecordTimeCommand{keyID: $keyID, ' - 'userID: $userID, logsCount: $logsCount, time: ${DateTool().dateIntToYMDHNString(time)}, ' + 'userID: $userID, logsCount: $logsCount, time:$time timeStr: ${DateTool().dateIntToYMDHNString(time)}, ' 'token: $token, needAuthor: $needAuthor, publicKey: $publicKey, ' 'privateKey: $privateKey}'; } diff --git a/lib/blue/io_protocol/io_senderCustomPasswords.dart b/lib/blue/io_protocol/io_senderCustomPasswords.dart index 1fbf7d06..9e0bb8f9 100644 --- a/lib/blue/io_protocol/io_senderCustomPasswords.dart +++ b/lib/blue/io_protocol/io_senderCustomPasswords.dart @@ -51,8 +51,8 @@ class SenderCustomPasswordsCommand extends SenderProtocol { return 'SenderCustomPasswordsCommand{keyID: $keyID, userID: $userID, ' 'pwdNo: $pwdNo, pwd: $pwd, useCountLimit: $useCountLimit, operate: $operate, isAdmin: $isAdmin,' 'token: $token, ' - 'startTime: ${DateTool().dateIntToYMDHNString(startTime)}, ' - 'endTime: ${DateTool().dateIntToYMDHNString(endTime)}, ' + 'startTime:$startTime startTimeStr: ${DateTool().dateIntToYMDHNString(startTime)}, ' + 'endTime:$endTime endTimeStr: ${DateTool().dateIntToYMDHNString(endTime)}, ' 'needAuthor: $needAuthor, signKey: $signKey, privateKey: $privateKey}'; } diff --git a/lib/blue/io_reply.dart b/lib/blue/io_reply.dart index 29265b10..56c93b70 100644 --- a/lib/blue/io_reply.dart +++ b/lib/blue/io_reply.dart @@ -16,7 +16,6 @@ abstract class Reply{ Reply.parseData(this.commandType, List dataDetail); void errorWithStstus(int status){ - switch(status){ case 0x00: // 成功 @@ -119,7 +118,7 @@ abstract class Reply{ break; case 0x16: // 正在开锁中... - AppLog.log("$logTag ${commandType!.typeName}正在开锁中..."); + AppLog.log("$logTag ${commandType!.typeName} $status 正在开锁中..."); showErrorMessage("正在开锁中..."); break; case 0xff: @@ -129,7 +128,7 @@ abstract class Reply{ break; default: //失败 - AppLog.log("$logTag ${commandType!.typeName} 蓝牙返回其他错误问题"); + AppLog.log("$logTag ${commandType!.typeName} $status 蓝牙返回其他错误问题"); break; } } diff --git a/lib/blue/io_sender.dart b/lib/blue/io_sender.dart index 3d98678d..098f50a5 100644 --- a/lib/blue/io_sender.dart +++ b/lib/blue/io_sender.dart @@ -35,7 +35,8 @@ abstract class SenderProtocol extends IOData { void printLog(List data) { AppLog.log( - "App -> 锁,指令类型:${commandType!.typeName} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); + "App -> 锁,指令类型:${commandType!.typeName} ${commandType!.typeValue == 0x3030 + ? '子命令:${data[3]}' : ''} \n参数是:\n${toString()} \n加密之前数据是:\n$data 长度是:${data.length}"); } //TODO:拼装数据Ï diff --git a/lib/blue/sender_beforeDataManage.dart b/lib/blue/sender_beforeDataManage.dart index b1ca8d5f..f751832b 100644 --- a/lib/blue/sender_beforeDataManage.dart +++ b/lib/blue/sender_beforeDataManage.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/blue/io_protocol/io_cleanUpUsers.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; @@ -156,17 +157,30 @@ class SenderBeforeDataManage { } LockListInfoItemEntity currentKeyInfo = CommonDataManage().currentKeyInfo; - DateTime startTime = DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.startDate! ~/ 1000); - DateTime endTime = DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.endDate! ~/ 1000); - bool isRound = currentKeyInfo.keyType == XSConstantMacro.keyTypeLoop; + DateTime? startTime; + DateTime? endTime; + var startDateTime = 0; + var endDateTime = 0; + bool isRound = false; + var useCountLimit = 0xffff; + if(currentKeyInfo.keyType == XSConstantMacro.keyTypeTime){ + // 限时 + startDateTime = currentKeyInfo.startDate! ~/ 1000; + endDateTime = currentKeyInfo.endDate! ~/ 1000; + }else if(currentKeyInfo.keyType == XSConstantMacro.keyTypeLoop){ + // 循环 + isRound = true; + startTime = DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.startDate!); + endTime = DateTime.fromMillisecondsSinceEpoch(currentKeyInfo.endDate!); - var startDateTime = currentKeyInfo.startDate! ~/ 1000; - var endDateTime = currentKeyInfo.endDate! ~/ 1000; - if (isRound) { - // 循环钥匙 startDateTime = DateTool().dateToTimestamp(DateTool().dateToYMDString(currentKeyInfo.startDate!.toString()), 1) ~/ 1000; endDateTime = (DateTool().dateToTimestamp(DateTool().dateToYMDString(currentKeyInfo.endDate!.toString()), 1) + CommonDataManage().dayLatestTime) ~/ 1000; - } + }else if(currentKeyInfo.keyType == XSConstantMacro.keyTypeOnce){ + // 单次 + useCountLimit = 1; + } + + // AppLog.log("startTime.hour:${startTime!.hour} startTime.minute:${startTime!.minute} endTime.hour:${endTime!.hour} endTime.minute:${endTime!.minute}}"); var addUserData = AddUserCommand( lockID: BlueManage().connectDeviceName, authUserID: currentKeyInfo.senderUserId!.toString(), @@ -176,16 +190,16 @@ class SenderBeforeDataManage { keyType: 0, startDate: startDateTime, expireDate: endDateTime, - useCountLimit: 0xFFFF, + useCountLimit: useCountLimit, isRound: isRound ? 1 : 0, weekRound: isRound ? DateTool().accordingTheCycleIntoTheCorrespondingNumber( currentKeyInfo.weekDays!) : 0, - startHour: isRound ? startTime.hour : 0, - startMin: isRound ? startTime.minute : 0, - endHour: isRound ? endTime.hour : 0, - endMin: isRound ? endTime.minute : 0, + startHour: isRound ? startTime!.hour : 0, + startMin: isRound ? startTime!.minute : 0, + endHour: isRound ? endTime!.hour : 0, + endMin: isRound ? endTime!.minute : 0, role: currentKeyInfo.keyRight == 1 ? 1 : 0, password: "123456", needAuthor: 1, diff --git a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart index 5bb5dfb1..ca2ee4e9 100644 --- a/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart +++ b/lib/main/lockDetail/authorizedAdmin/volumeAuthorizationLock/volumeAuthorizationLock_page.dart @@ -214,8 +214,9 @@ class _VolumeAuthorizationLockPageState extends State; diff --git a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart index 949a7c7b..f5676497 100644 --- a/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart +++ b/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart @@ -183,7 +183,8 @@ class _CardDetailPageState extends State with RouteAware { action: () { Get.toNamed(Routers.lockOperatingRecordPage, arguments: { 'type': 2, - 'id': state.fingerprintItemData.value.cardId.toString() + 'id': state.fingerprintItemData.value.cardId.toString(), + 'recordName': state.fingerprintItemData.value.cardName }); }), // SizedBox(height: 40.h), diff --git a/lib/main/lockDetail/card/cardList/cardList_logic.dart b/lib/main/lockDetail/card/cardList/cardList_logic.dart index c96d624a..c02dce71 100644 --- a/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -33,13 +33,13 @@ class CardListLogic extends BaseGetXController { _replyAddICCardBegin(reply); } - if(reply is SenderCheckingCardStatusReply) { - _replyReferEventRecordNumber(reply); - } - - if(reply is SenderCheckingUserInfoCountReply){ - _replyCheckingUserInfoCount(reply); - } + // if(reply is SenderCheckingCardStatusReply) { + // _replyReferEventRecordNumber(reply); + // } + // + // if(reply is SenderCheckingUserInfoCountReply){ + // _replyCheckingUserInfoCount(reply); + // } }); } @@ -94,134 +94,134 @@ class CardListLogic extends BaseGetXController { } } - // 获取卡片状态 - Future _replyReferEventRecordNumber(Reply reply) async { - int status = reply.data[2]; - switch(status){ - case 0x00: - //成功 - // _getLockStatus(); - break; - case 0x06: - //无权限 - break; - default: - //失败 - break; - } - } + // // 获取卡片状态 + // Future _replyReferEventRecordNumber(Reply reply) async { + // int status = reply.data[2]; + // switch(status){ + // case 0x00: + // //成功 + // // _getLockStatus(); + // break; + // case 0x06: + // //无权限 + // break; + // default: + // //失败 + // break; + // } + // } + // + // // 查询用户、指纹、密码、卡片数量(用于判断是否同步) + // Future _replyCheckingUserInfoCount(Reply reply) async { + // int status = reply.data[2]; + // + // // 用户数量 + // int userNum = reply.data[5]; + // + // // 指纹数量 + // int fingerNum = reply.data[6]; + // + // // 密码数量 + // 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); + // + // switch(status){ + // case 0x00: + // //成功 + // // _getLockStatus(); + // break; + // case 0x06: + // //需要鉴权 + // break; + // default: + // //失败 + // break; + // } + // } - // 查询用户、指纹、密码、卡片数量(用于判断是否同步) - Future _replyCheckingUserInfoCount(Reply reply) async { - int status = reply.data[2]; - - // 用户数量 - int userNum = reply.data[5]; - - // 指纹数量 - int fingerNum = reply.data[6]; - - // 密码数量 - 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); - - switch(status){ - case 0x00: - //成功 - // _getLockStatus(); - break; - case 0x06: - //需要鉴权 - break; - default: - //失败 - break; - } - } - - // 查询卡片状态 - Future senderCheckingCardStatus() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { - if (state == BluetoothConnectionState.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.senderCheckingCardStatusCommand( - keyID:BlueManage().connectDeviceName, - userID:await Storage.getUid(), - role:0xff, - cardCount:20, - cardNo:1, - token:getTokenList, - needAuthor:1, - publicKey:getPublicKeyList, - privateKey:getPrivateKeyList, - ); - } - }); - } - - // 查询用户、指纹、密码、卡片数量(用于判断是否同步) - Future senderCheckingUserInfoCount() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { - if (state == BluetoothConnectionState.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, - ); - } - }); - } + // // 查询卡片状态 + // Future senderCheckingCardStatus() async { + // BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { + // if (state == BluetoothConnectionState.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.senderCheckingCardStatusCommand( + // keyID:BlueManage().connectDeviceName, + // userID:await Storage.getUid(), + // role:0xff, + // cardCount:20, + // cardNo:1, + // token:getTokenList, + // needAuthor:1, + // publicKey:getPublicKeyList, + // privateKey:getPrivateKeyList, + // ); + // } + // }); + // } + // + // // 查询用户、指纹、密码、卡片数量(用于判断是否同步) + // Future senderCheckingUserInfoCount() async { + // BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState state) async { + // if (state == BluetoothConnectionState.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, + // ); + // } + // }); + // } // 删除卡片 Future senderAddICCard() async { @@ -262,19 +262,6 @@ class CardListLogic extends BaseGetXController { privateKey:getPrivateKeyList, token: getTokenList, ); - - // IoSenderManage.senderAddICCardCommand( - // keyID:state.deletKeyID, - // userID:state.deletUserID, - // cardNo:state.deletCardNo, - // useCountLimit:0, - // startTime:0x11223344, - // endTime:0x11223344, - // needAuthor:1, - // signKey:signKeyDataList, - // privateKey:getPrivateKeyList, - // token: getTokenList, - // ); } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); diff --git a/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart b/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart index b0d31bab..9c4e0414 100644 --- a/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart +++ b/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_state.dart @@ -1,5 +1,6 @@ import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import '../../../../tools/dateTool.dart'; import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart'; @@ -25,7 +26,8 @@ class OtherTypeKeyChangeDateState{ fingerprintItemData.value = map["fingerprintItemData"]; } - if(fingerprintItemData.value.startDate == 0 && fingerprintItemData.value.endDate == 0){ + AppLog.log("fingerprintItemData.value.startDate:${fingerprintItemData.value.startDate} fingerprintItemData.value.endDate:${fingerprintItemData.value.endDate}"); + if(fingerprintItemData.value.startDate == 0){ beginTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()); endTime.value = DateTool().dateToYMDHNString(DateTime.now().millisecondsSinceEpoch.toString()); beginTimeTimestamp.value = DateTime.now().millisecondsSinceEpoch; @@ -36,5 +38,7 @@ class OtherTypeKeyChangeDateState{ beginTimeTimestamp.value = fingerprintItemData.value.startDate!; endTimeTimestamp.value = fingerprintItemData.value.endDate!; } + + AppLog.log("beginTime.value:${beginTime.value} endTime.value:${endTime.value} beginTimeTimestamp.value:${beginTimeTimestamp.value} endTimeTimestamp.value:${endTimeTimestamp.value}"); } } \ No newline at end of file diff --git a/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart b/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart index 3eac5852..7fa54f98 100644 --- a/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart +++ b/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart @@ -70,7 +70,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ Storage.setStringList(saveBlueToken, saveStrList); IoSenderManage.senderAddFaceCommand( - keyID:state.fingerprintItemData.value.cardId!.toString(), + keyID:state.fingerprintItemData.value.faceId!.toString(), userID:await Storage.getUid(), faceNo:int.parse(state.fingerprintItemData.value.faceNumber!), useCountLimit:0xffff, @@ -119,7 +119,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ List signKeyDataList = changeStringListToIntList(signKey!); IoSenderManage.senderAddFaceCommand( - keyID:state.fingerprintItemData.value.cardId!.toString(), + keyID:state.fingerprintItemData.value.faceId!.toString(), userID:await Storage.getUid(), faceNo:int.parse(state.fingerprintItemData.value.faceNumber!), useCountLimit:0xffff, @@ -426,7 +426,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ endDate: state.endDateTimestamp.value, startTime: state.starTimeTimestamp.value, endTime: state.endTimeTimestamp.value, - faceType: 2, + faceType: 4, weekDay: state.weekDay.value, faceName: state.fingerprintItemData.value.faceName!, addType: "1", @@ -435,6 +435,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ ); if (entity.errorCode!.codeIsSuccessful) { showToast("修改成功", something: () { + eventBus.fire(OtherTypeRefreshListEvent()); Get.back(result: { "starDate":state.starDateTimestamp.value.toString(), "endDate":state.endDateTimestamp.value.toString(), diff --git a/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart b/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart index 13d1e249..021183c4 100644 --- a/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart +++ b/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_page.dart @@ -62,6 +62,11 @@ class _OtherTypeKeyChangeValidityDatePageState return; } + if(state.weekDay.value.isEmpty){ + logic.showToast("请选择有效日".tr); + return; + } + if (state.starTimeTimestamp.value >= state.endTimeTimestamp.value) { logic.showToast("失效时间要大于生效时间".tr); diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart index ef9613a5..ab08598e 100644 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_logic.dart @@ -1,36 +1,44 @@ import 'dart:async'; +import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../../network/api_repository.dart'; import '../../../../../tools/eventBusEventManage.dart'; import 'checkingInAddStaffSelectKey_entity.dart'; import 'checkingInAddStaff_state.dart'; -typedef KeyClickCallback = void Function(List selectKeyList); -class CheckingInAddStaffLogic extends BaseGetXController{ +typedef KeyClickCallback = void Function( + List selectKeyList); + +class CheckingInAddStaffLogic extends BaseGetXController { CheckingInAddStaffState state = CheckingInAddStaffState(); // 下级界面修改成功后传递数据 StreamSubscription? _getNumberEvent; + void _initLoadDataAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _getNumberEvent = eventBus.on().listen((event) { - state.attendanceWayNumber.value = event.number; - isCanClickAction(); - }); + _getNumberEvent = eventBus + .on() + .listen((event) { + state.attendanceWayNumber.value = event.number; + isCanClickAction(); + }); } // 添加员工 - void addStaffLoadData() async{ + void addStaffLoadData() async { var usernameType = "1"; - if(state.appUnHaveAccount.value && state.staffAccount.contains("@")){ + if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) { usernameType = "2"; } // 当是app且没有钥匙时,直接把账号赋值给attendanceWayNumber - if(state.appUnHaveAccount.value && state.selectPrintingMethodType.value == "1"){ + if (state.appUnHaveAccount.value && + state.selectPrintingMethodType.value == "1") { state.attendanceWayNumber.value = state.staffAccountController.text; } @@ -41,36 +49,38 @@ class CheckingInAddStaffLogic extends BaseGetXController{ have: state.appUnHaveAccount.value ? "2" : "1", staffName: state.staffNameController.text, countryCode: state.countryCode.value, - usernameType:usernameType, + usernameType: usernameType, ); - if(entity.errorCode!.codeIsSuccessful){ + if (entity.errorCode!.codeIsSuccessful) { eventBus.fire(RefreshCheckInSetDataEvent()); eventBus.fire(RefreshCheckInListEvent()); Get.back(result: "addScuess"); - }else if(entity.errorCode! == 425){ + } else if (entity.errorCode! == 425) { showToast(entity.errorMsg!); } } - // 考勤设置添加员工-选择钥匙 1为APP,2为密码,3为卡,4为指纹,返回数据中,attendanceWay分别为用户名、密码、卡号、指纹号 - void addStaffSelectKey(KeyClickCallback kyClickCallback) async{ + // 考勤设置添加员工-选择钥匙 1为APP,2为密码,3为卡,4为指纹,返回数据中, + // attendanceWay分别为用户名、密码、卡号、指纹号 + void addStaffSelectKey(KeyClickCallback kyClickCallback) async { var entity = await ApiRepository.to.addStaffSelectKeyData( companyId: state.companyId.value, - type:state.selectPrintingMethodType.value, + type: state.selectPrintingMethodType.value, ); - if(entity.errorCode!.codeIsSuccessful){ + if (entity.errorCode!.codeIsSuccessful) { state.keyEntity.value = entity.data!; kyClickCallback(state.keyEntity.value); } } // 编辑员工 - void editStaffLoadData() async{ + void editStaffLoadData() async { var usernameType = "1"; - if(state.appUnHaveAccount.value && state.staffAccount.contains("@")){ + if (state.appUnHaveAccount.value && state.staffAccount.contains("@")) { usernameType = "2"; } + var entity = await ApiRepository.to.editStaffData( attendanceType: state.selectPrintingMethodType.value, attendanceWay: state.attendanceWayNumber.value, @@ -126,11 +136,14 @@ class CheckingInAddStaffLogic extends BaseGetXController{ // 是否能点击 void isCanClickAction() { - if(state.selectPrintingMethodType.value == "1" && state.appUnHaveAccount.value){ + if (state.selectPrintingMethodType.value == "1" && + state.appUnHaveAccount.value) { // 没有账号的时候直接判断姓名和账号是否为空 - state.isCanClick.value = state.staffNameIsNotEmpty && state.staffAccountIsNotEmpty; - }else{ - state.isCanClick.value = state.staffNameIsNotEmpty && state.attendanceWayNumberIsNotEmpty; + state.isCanClick.value = + state.staffNameIsNotEmpty && state.staffAccountIsNotEmpty; + } else { + state.isCanClick.value = + state.staffNameIsNotEmpty && state.attendanceWayNumberIsNotEmpty; } } @@ -145,7 +158,6 @@ class CheckingInAddStaffLogic extends BaseGetXController{ @override void onInit() { - // TODO: implement onInit super.onInit(); } @@ -156,5 +168,4 @@ class CheckingInAddStaffLogic extends BaseGetXController{ _getNumberEvent!.cancel(); } - } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart index dd4b2bda..10f58706 100644 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetAddStaff/checkingInAddStaff_state.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -6,7 +5,7 @@ import '../../../../lockMian/entity/lockListInfo_entity.dart'; import '../checkingInSetStaffList/checkingInStaffList_entity.dart'; import 'checkingInAddStaffSelectKey_entity.dart'; -class CheckingInAddStaffState{ +class CheckingInAddStaffState { final getKeyInfosData = LockListInfoItemEntity().obs; final companyId = "".obs; final staffListItemData = CheckingInAddStaffListItemEntity().obs; @@ -14,36 +13,41 @@ class CheckingInAddStaffState{ final TextEditingController staffNameController = TextEditingController(); final TextEditingController staffAccountController = TextEditingController(); - final selectPrintingMethodType = "1".obs;// 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸 - final selectPrintingMethodStr = "APP".obs;// 选择打卡类型字符串 + final selectPrintingMethodType = "1".obs; // 选择打卡类型 1APP 2密码 3卡 4指纹 5人脸 + final selectPrintingMethodStr = "APP".obs; // 选择打卡类型字符串 final countryName = "中国".tr.obs; final countryCode = "86".obs; - final appUnHaveAccount = true.obs;// 默认没有账号 - final keyEntity = [].obs;// 选择钥匙数据 + final appUnHaveAccount = true.obs; // 默认没有账号 + final keyEntity = [].obs; // 选择钥匙数据 final isAdd = "1".obs; // 1添加 2编辑 final attendanceWayNumber = "".obs; final isCanClick = false.obs; var staffName = ''.obs; var staffAccount = ''.obs; + bool get staffNameIsNotEmpty => staffName.value.isNotEmpty; + bool get staffAccountIsNotEmpty => staffAccount.value.isNotEmpty; - bool get attendanceWayNumberIsNotEmpty => attendanceWayNumber.value.isNotEmpty; + + bool get attendanceWayNumberIsNotEmpty => + attendanceWayNumber.value.isNotEmpty; CheckingInAddStaffState() { Map map = Get.arguments; - getKeyInfosData.value = map["getKeyInfosData"]; - companyId.value = map["companyId"]; + getKeyInfosData.value = map["getKeyInfosData"]; + companyId.value = map["companyId"]; isAdd.value = map["isAdd"]; - if(isAdd.value == "2"){ - staffListItemData.value = map["staffListItem"]; + if (isAdd.value == "2") { + staffListItemData.value = map["staffListItem"]; staffNameController.text = staffListItemData.value.staffName!; - selectPrintingMethodType.value = staffListItemData.value.attendanceType.toString(); - switch(staffListItemData.value.attendanceType){ + selectPrintingMethodType.value = + staffListItemData.value.attendanceType.toString(); + switch (staffListItemData.value.attendanceType) { case 1: selectPrintingMethodStr.value = "APP"; break; @@ -58,17 +62,12 @@ class CheckingInAddStaffState{ break; } - if(staffListItemData.value.attendanceWay!.isNotEmpty){ - if(staffListItemData.value.cardStatus != 0){ - appUnHaveAccount.value = false; - attendanceWayNumber.value = staffListItemData.value.attendanceWay!; - }else{ - appUnHaveAccount.value = true; - } - }else{ + if (staffListItemData.value.attendanceWay!.isNotEmpty) { + appUnHaveAccount.value = false; + attendanceWayNumber.value = staffListItemData.value.attendanceWay!; + } else { appUnHaveAccount.value = true; } } } - } diff --git a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart index 46effbe5..23954119 100644 --- a/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart +++ b/lib/main/lockDetail/checkingIn/checkingInStaff/checkingInSetStaffList/checkingInStaffList_entity.dart @@ -37,7 +37,7 @@ class CheckingInAddStaffListItemEntity { int? staffId; int? attendanceType; int? countryCode; - int? cardStatus; + int? cardStatus;//0正常 1打卡失败 String? attendanceWay; String? reason; diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index d70d0b97..4852578a 100644 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -1,14 +1,14 @@ - import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart'; import 'package:star_lock/main/lockDetail/lockOperatingRecord/lockOperatingRecordGetLastRecordTime_entity.dart'; +import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; -import '../../../app_settings/app_settings.dart'; import '../../../blue/blue_manage.dart'; import '../../../blue/io_protocol/io_referEventRecordTime.dart'; import '../../../blue/io_reply.dart'; @@ -26,16 +26,17 @@ class DoorLockLogLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) { - - if (reply is SenderReferEventRecordTimeReply && state.ifCurrentScreen.value == true) { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) { + if (reply is SenderReferEventRecordTimeReply && + state.ifCurrentScreen.value == true) { _replyReferEventRecordTime(reply); } }); } // 根据时间查解析数据 - Future _replyReferEventRecordTime(Reply reply) async { + Future _replyReferEventRecordTime(Reply reply) async { cancelBlueConnetctToastTimer(); int status = reply.data[2]; switch (status) { @@ -47,7 +48,7 @@ class DoorLockLogLogic extends BaseGetXController { if (dataLength > 0) { reply.data.removeRange(0, 7); // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 - if(reply.data.length < 17){ + if (reply.data.length < 17) { return; } var getList = splitList(reply.data, 17); @@ -58,28 +59,33 @@ class DoorLockLogLogic extends BaseGetXController { // AppLog.log("indexList:$indexList"); var indexMap = {}; indexMap["type"] = indexList[0].toString(); - - if(indexList[0] == 2){ + int operateDate = 0; + if (indexList[0] == 2) { var passwordData = indexList.sublist(7, 17); var password = utf8String(passwordData); indexMap["user"] = password.toString(); - }else{ - int userNo = (indexList[1]*255) + indexList[2]; + }else { + int userNo = (indexList[1] * 256) + indexList[2]; indexMap["user"] = userNo.toString(); } indexMap["success"] = "1"; int time = ((0xff & indexList[(3)]) << 24 | - (0xff & indexList[4]) << 16 | - (0xff & indexList[5]) << 8 | - (0xFF & indexList[6])); + (0xff & indexList[4]) << 16 | + (0xff & indexList[5]) << 8 | + (0xFF & indexList[6])); indexMap["date"] = "${time * 1000}"; uploadList.add(indexMap); + + if (i == getList.length - 1) { + //设置最后的时间戳 + state.operateDate = operateDate; + } } lockRecordUploadData(uploadList); - if(dataLength == state.logCountPage){ + if (dataLength == state.logCountPage) { state.ifHaveNext = true; } } @@ -97,10 +103,11 @@ class DoorLockLogLogic extends BaseGetXController { // 查询事件记录(时间查询) Future senderReferEventRecordTime() async { showEasyLoading(); - showBlueConnetctToastTimer(action: (){ + showBlueConnetctToastTimer(action: () { dismissEasyLoading(); }); - BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionStateState) async { + BlueManage().bludSendData(BlueManage().connectDeviceName, + (BluetoothConnectionState connectionStateState) async { if (connectionStateState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -122,10 +129,11 @@ class DoorLockLogLogic extends BaseGetXController { publicKey: getPublicKeyList, privateKey: getPrivateKeyList, ); - } else if (connectionStateState == BluetoothConnectionState.disconnected) { + } else if (connectionStateState == + BluetoothConnectionState.disconnected) { dismissEasyLoading(); cancelBlueConnetctToastTimer(); - if(state.ifCurrentScreen.value == true){ + if (state.ifCurrentScreen.value == true) { showBlueConnetctToast(); } } @@ -133,17 +141,24 @@ class DoorLockLogLogic extends BaseGetXController { } //请求操作记录列表(门锁日志) - void mockNetworkDataRequest() async { + void mockNetworkDataRequest({required bool isRefresh}) async { + // 如果是下拉刷新,清空已有数据 + if (isRefresh) { + state.lockLogItemList.clear(); + pageNo = 1; + } DoorLockLogEntity entity = await ApiRepository.to.lockEventList( lockId: state.keyInfos.value.lockId!, lockEventType: state.dropdownValue.value, - pageNo: 1, + pageNo: pageNo, pageSize: int.parse(pageSize), startDate: state.startDate.value, endDate: state.endDate.value); - if (entity.errorCode!.codeIsSuccessful) { - state.lockLogItemList.value = entity.data!.itemList!; + // 更新数据列表 + state.lockLogItemList.addAll(entity.data!.itemList!); + // 更新页码 + pageNo++; } } @@ -152,20 +167,23 @@ class DoorLockLogLogic extends BaseGetXController { void _getDoorLockLogListRefreshUIAction() { _getDoorLockLogListRefreshUIEvent = eventBus.on().listen((event) { + state.currentSelectDate.value = event.getDoorLockLogTime; // 设置startDate为当天的0点 - state.startDate.value = DateTime(event.getDoorLockLogTime.year, - event.getDoorLockLogTime.month, event.getDoorLockLogTime.day) + state.startDate.value = DateTime( + state.currentSelectDate.value.year, + state.currentSelectDate.value.month, + state.currentSelectDate.value.day) .millisecondsSinceEpoch; // 设置endDate为下一天的0点,然后减去1毫秒 state.endDate.value = (DateTime( - event.getDoorLockLogTime.year, - event.getDoorLockLogTime.month, - event.getDoorLockLogTime.day + 1) + state.currentSelectDate.value.year, + state.currentSelectDate.value.month, + state.currentSelectDate.value.day + 1) .subtract(const Duration(milliseconds: 1))) .millisecondsSinceEpoch; pageNo = 1; - mockNetworkDataRequest(); + mockNetworkDataRequest(isRefresh: true); }); } @@ -186,21 +204,24 @@ class DoorLockLogLogic extends BaseGetXController { .lockRecordUploadData( lockId: state.keyInfos.value.lockId.toString(), records: list); if (entity.errorCode!.codeIsSuccessful) { - if(state.ifHaveNext == true){ + if (state.ifHaveNext == true) { getLockRecordLastUploadDataTime(); - }else{ - pageNo = 1; - mockNetworkDataRequest(); + } else { + mockNetworkDataRequest(isRefresh: true); } } } //清空操作记录 void clearOperationRecordRequest() async { - KeyOperationRecordEntity entity = - await ApiRepository.to.clearOperationRecord('28'); + KeyOperationRecordEntity entity = await ApiRepository.to + .clearOperationRecord( + CommonDataManage().currentKeyInfo.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - showToast("清除数据成功"); + showToast("清除数据成功", something: () { + pageNo = 1; + mockNetworkDataRequest(isRefresh: true); + }); } } @@ -214,7 +235,7 @@ class DoorLockLogLogic extends BaseGetXController { if (isDemoMode == false) { // _initReplySubscription(); - mockNetworkDataRequest(); + mockNetworkDataRequest(isRefresh: true); _getDoorLockLogListRefreshUIAction(); } } diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart index 37dc796e..70614ace 100644 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart @@ -5,9 +5,12 @@ import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_logic.dart'; +import 'package:star_lock/tools/EasyRefreshTool.dart'; import 'package:star_lock/tools/advancedCalendar/src/widget.dart'; +import 'package:star_lock/tools/commonDataManage.dart'; import 'package:star_lock/tools/menuItem/xsDropDownWidget.dart'; import 'package:star_lock/tools/noData.dart'; +import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:timelines/timelines.dart'; import '../../../app_settings/app_colors.dart'; @@ -26,11 +29,6 @@ class _DoorLockLogPageState extends State with RouteAware { final logic = Get.put(DoorLockLogLogic()); final state = Get.find().state; - @override - void initState() { - super.initState(); - } - @override Widget build(BuildContext context) { return Scaffold( @@ -39,6 +37,23 @@ class _DoorLockLogPageState extends State with RouteAware { barTitle: TranslationLoader.lanKeys!.operatingRecord!.tr, haveBack: true, backgroundColor: AppColors.mainColor, + actionsList: [ + Visibility( + visible: CommonDataManage().currentKeyInfo.isLockOwner == 1 + ? true + : false, + child: TextButton( + onPressed: () { + ShowCupertinoAlertView().showClearOperationRecordAlert( + clearClick: () { + logic.clearOperationRecordRequest(); + }); + }, + child: Text( + '清空记录'.tr, + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ))), + ], ), body: Column( mainAxisSize: MainAxisSize.max, @@ -52,7 +67,7 @@ class _DoorLockLogPageState extends State with RouteAware { endIndent: 30.w, ), eventDropDownWidget(), - Expanded(child: Obx(() => timeLineView(state.lockLogItemList))) + Expanded(child: timeLineView()) ], ), ); @@ -81,19 +96,34 @@ class _DoorLockLogPageState extends State with RouteAware { highlightColor: Colors.yellow, disabledColor: Colors.grey, ), - child: AdvancedCalendar( - controller: state.calendarControllerCustom, - events: state.events, - weekLineHeight: 48.0, - startWeekDay: 1, - innerDot: true, - keepLineSize: true, - calendarTextStyle: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.w400, - height: 1.3125, - letterSpacing: 0, - ), + child: Stack( + children: [ + AdvancedCalendar( + controller: state.calendarControllerCustom, + events: state.events, + weekLineHeight: 48.0, + startWeekDay: 1, + innerDot: true, + keepLineSize: true, + calendarTextStyle: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w400, + height: 1.3125, + letterSpacing: 0, + ), + ), + Positioned( + top: 8.0, + right: 8.0, + child: Obx(() => Text( + '${state.currentSelectDate.value.year}年${state.currentSelectDate.value.month}月', + style: theme.textTheme.titleMedium!.copyWith( + fontSize: 16, + color: theme.colorScheme.secondary, + ), + )), + ), + ], ), ); } @@ -110,7 +140,7 @@ class _DoorLockLogPageState extends State with RouteAware { value: state.dropdownTitle.value, valueChanged: (value) { state.dropdownValue.value = int.parse(value); - logic.mockNetworkDataRequest(); + logic.mockNetworkDataRequest(isRefresh: true); })), ], ), @@ -118,92 +148,103 @@ class _DoorLockLogPageState extends State with RouteAware { } //时间轴组件 - Widget timeLineView(List timelineDataList) { + Widget timeLineView() { return Container( margin: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 20.h, top: 20.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16.w), ), - child: timelineDataList.isNotEmpty - ? Timeline.tileBuilder( - builder: TimelineTileBuilder.fromStyle( - contentsAlign: ContentsAlign.basic, - itemCount: timelineDataList.length, - contentsBuilder: (context, index) { - DoorLockLogDataItem timelineData = timelineDataList[index]; - DateTime dateTime = DateTime.fromMillisecondsSinceEpoch( - timelineData.operateDate!); - String formattedTime = - '${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}'; - - return Padding( - padding: EdgeInsets.only(left: 20.w, top: 20.h), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - '$formattedTime ${timelineData.recordTypeName}', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 24.sp, - fontWeight: FontWeight.w600, - ), - ), - SizedBox( - height: 10.h, - ), - GestureDetector( - onTap: () { - Get.toNamed(Routers.videoLogDetailPage); - }, - child: Stack( - children: [ - timelineData.imagesUrl!.isNotEmpty - ? Image.network( - timelineData.imagesUrl!, - width: 260.w, - height: 260.h, - ) - : Container(), - Positioned( - top: 150.h, - left: 10.w, - child: Image( - image: const AssetImage( - 'images/main/icon_lockLog_play.png'), - width: 24.w, - height: 20.w, - ), - ), - ], - ), - ), - SizedBox( - height: 20.h, - ), - ], + child: Obx(() => EasyRefreshTool( + onRefresh: () async { + logic.mockNetworkDataRequest(isRefresh: true); + }, + onLoad: () async { + logic.mockNetworkDataRequest(isRefresh: false); + }, + child: state.lockLogItemList.isNotEmpty + ? Timeline.tileBuilder( + builder: _timelineBuilderWidget(), + theme: TimelineThemeData( + nodePosition: 0.04, //居左侧距离 + connectorTheme: const ConnectorThemeData( + thickness: 1.0, + color: AppColors.greyLineColor, + indent: 0.5, ), - ); + indicatorTheme: const IndicatorThemeData( + size: 8.0, + color: AppColors.greyLineColor, + position: 0.4, + ), + ), + ) + : NoData())), + ); + } + + TimelineTileBuilder _timelineBuilderWidget() { + return TimelineTileBuilder.fromStyle( + contentsAlign: ContentsAlign.basic, + itemCount: state.lockLogItemList.length, + contentsBuilder: (context, index) { + DoorLockLogDataItem timelineData = state.lockLogItemList[index]; + DateTime dateTime = + DateTime.fromMillisecondsSinceEpoch(timelineData.operateDate!); + String formattedTime = + '${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}'; + + return Padding( + padding: EdgeInsets.only(left: 20.w, top: 20.h), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '$formattedTime ${timelineData.username!.isNotEmpty ? "${timelineData.username}用" : ""}${timelineData.recordTypeName}', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 24.sp, + fontWeight: FontWeight.w600, + ), + ), + SizedBox( + height: 10.h, + ), + GestureDetector( + onTap: () { + Get.toNamed(Routers.videoLogDetailPage); }, - ), - theme: TimelineThemeData( - nodePosition: 0.04, //居左侧距离 - connectorTheme: const ConnectorThemeData( - thickness: 1.0, - color: AppColors.greyLineColor, - indent: 0.5, - ), - indicatorTheme: const IndicatorThemeData( - size: 8.0, - color: AppColors.greyLineColor, - position: 0.4, + child: Stack( + children: [ + timelineData.imagesUrl!.isNotEmpty + ? Image.network( + timelineData.imagesUrl!, + width: 260.w, + height: 260.h, + ) + : Container(), + Positioned( + top: 150.h, + left: 10.w, + child: Image( + image: const AssetImage( + 'images/main/icon_lockLog_play.png'), + width: 24.w, + height: 20.w, + ), + ), + ], ), ), - ) - : NoData(), + SizedBox( + height: 20.h, + ), + ], + ), + ); + }, ); } diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart index 5edae651..5cfeda59 100644 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart @@ -17,31 +17,38 @@ class DoorLockLogState { DateTime(2024, 10, 10), ]; - final startDate = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day).millisecondsSinceEpoch.obs; - final endDate = (DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 1).subtract(const Duration(milliseconds: 1))).millisecondsSinceEpoch.obs; + final startDate = + DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day) + .millisecondsSinceEpoch + .obs; + final endDate = (DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day + 1) + .subtract(const Duration(milliseconds: 1))) + .millisecondsSinceEpoch + .obs; - var dropdownTitle = '全部事件'.obs; + var dropdownTitle = '全部事件'.tr.obs; var dropdownValue = XSConstantMacro.lockEventTypeAll.obs; List getDropDownItemList = [ DropDownItem( - itemTitle: "全部事件", + itemTitle: "全部事件".tr, itemValue: XSConstantMacro.lockEventTypeAll.toString(), isCheked: false), DropDownItem( - itemTitle: "开锁事件", + itemTitle: "开锁事件".tr, itemValue: XSConstantMacro.lockEventTypeOpenDoor.toString(), isCheked: false), DropDownItem( - itemTitle: "异常事件", + itemTitle: "异常事件".tr, itemValue: XSConstantMacro.lockEventTypeAbnormal.toString(), isCheked: false), DropDownItem( - itemTitle: "门铃事件", + itemTitle: "门铃事件".tr, itemValue: XSConstantMacro.lockEventTypeDoorbell.toString(), isCheked: false), DropDownItem( - itemTitle: "视频事件", + itemTitle: "视频事件".tr, itemValue: XSConstantMacro.lockEventTypeVideo.toString(), isCheked: false), ]; @@ -50,6 +57,7 @@ class DoorLockLogState { var operateDate = 0; // 按日期查询消息记录的时间戳 var ifHaveNext = false; // 页码 var logCountPage = 10; // 蓝牙记录一页多少个 + var currentSelectDate = DateTime.now().obs; // 当前选择的日期 DoorLockLogState() { keyInfos.value = Get.arguments["keyInfo"]; diff --git a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart index 5a67ca86..ba70139e 100644 --- a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_logic.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:star_lock/appRouters.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import 'package:star_lock/mine/valueAddedServices/advancedFunctionRecord/advancedFunctionRecord_entity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; @@ -135,16 +137,32 @@ class ElectronicKeyDetailLogic extends BaseGetXController { Future checkRealNameStatus(int realNameAuthStatus) async { //打开实名认证 必须输入身份证号和真实姓名 if (realNameAuthStatus == 1) { - if (state.getRealName.value.isEmpty || - state.getIDCardNumber.value.isEmpty) { - ShowCupertinoAlertView() - .showOpenAuthWithIDCardInfoAlert((idCard, realName) { - state.getIDCardNumber.value = idCard ?? ''; - state.getRealName.value = realName ?? ''; + AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace( + lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, + ); + if (entity.errorCode!.codeIsSuccessful) { + if (state.getRealName.value.isEmpty || + state.getIDCardNumber.value.isEmpty) { + ShowCupertinoAlertView() + .showOpenAuthWithIDCardInfoAlert((idCard, realName) { + state.getIDCardNumber.value = idCard ?? ''; + state.getRealName.value = realName ?? ''; + updateRealNameInfoWithAuthStatus(realNameAuthStatus); + }); + } else { updateRealNameInfoWithAuthStatus(realNameAuthStatus); - }); - } else { - updateRealNameInfoWithAuthStatus(realNameAuthStatus); + } + } else if (entity.errorCode == 432) { + //432--余量不足,需购买 + ShowCupertinoAlertView().showBuyTipWithContentAlert( + titleStr: '实名认证为付费功能,请购买后再使用'.tr, + sureClick: () { + Get.toNamed(Routers.advancedFeaturesWebPage, + arguments: {'isShop': false}); + }); + } else if (entity.errorCode == 433) { + //需联系管理员购买 + ShowCupertinoAlertView().showContactAdministratorBuyAlert(); } } else { updateRealNameInfoWithAuthStatus(realNameAuthStatus); @@ -229,11 +247,14 @@ class ElectronicKeyDetailLogic extends BaseGetXController { Future openModalBottomSheet(BuildContext context) async { var textList = []; - if (CommonDataManage().currentKeyInfo.keyRight == 1) { + if (state.itemData.value.keyRight == 1) { + // 授权管理员 textList = [ - state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr + state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr, + "取消授权".tr ]; } else if (CommonDataManage().currentKeyInfo.isLockOwner == 1) { + // 锁拥有者 if (state.keyType.value == 1 || state.keyType.value == 2) { textList = [ state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr, @@ -241,9 +262,15 @@ class ElectronicKeyDetailLogic extends BaseGetXController { ]; } else if (state.keyType.value == 4) { textList = [ - state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr + state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen + ? '取消冻结'.tr + : "冻结".tr ]; } + }else{ + textList = [ + state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen ? '取消冻结'.tr : "冻结".tr, + ]; } showModalBottomSheet( context: context, @@ -336,13 +363,36 @@ class ElectronicKeyDetailLogic extends BaseGetXController { return currentController; } - noModificationAllowedDuringFreeze(){ - if(state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen){ + noModificationAllowedDuringFreeze() { + if (state.itemData.value.keyStatus == XSConstantMacro.keyStatusFrozen) { showToast("冻结状态下不允许修改钥匙权限".tr); return; } } + //检测实名认证是否支持开启 + Future keyCheckFace() async { + AdvancedFunctionRecordEntity entity = await ApiRepository.to.keyCheckFace( + lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, + ); + if (entity.errorCode!.codeIsSuccessful) { + //打开实名认证,需要弹出输入身份证信息框 + state.isRequireAuth.value = true; + state.isRealNameAuth.value = true; + } else if (entity.errorCode == 432) { + //432--余量不足,需购买 + ShowCupertinoAlertView().showBuyTipWithContentAlert( + titleStr: '实名认证为付费功能,请购买后再使用'.tr, + sureClick: () { + Get.toNamed(Routers.advancedFeaturesWebPage, + arguments: {'isShop': false}); + }); + } else if (entity.errorCode == 433) { + //需联系管理员购买 + ShowCupertinoAlertView().showContactAdministratorBuyAlert(); + } + } + @override void onReady() { // TODO: implement onReady diff --git a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart index 742d1857..0df58a34 100644 --- a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart @@ -1,3 +1,4 @@ + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -227,13 +228,16 @@ class _ElectronicKeyDetailPageState extends State { Obx( () => Visibility( // (state.keyInfo.value.lockSetting!.remoteUnlock == 1 ? true : false - visible: CommonDataManage() - .currentKeyInfo - .lockSetting! - .remoteUnlock == - 1 - ? true - : false, + // visible: CommonDataManage() + // .currentKeyInfo + // .lockSetting! + // .remoteUnlock == + // 1 + // ? true + // : false, + visible: (CommonDataManage().currentKeyInfo.lockSetting!.remoteUnlock == 1 && state.itemData.value.keyRight != 1) + ? true + : false, child: CommonItem( leftTitel: "远程开锁".tr, rightTitle: "", @@ -256,7 +260,8 @@ class _ElectronicKeyDetailPageState extends State { action: () { Get.toNamed(Routers.lockOperatingRecordPage, arguments: { 'type': 5, - 'id': state.itemData.value.keyId.toString() + 'id': state.itemData.value.keyId.toString(), + 'recordName': state.itemData.value.keyName }); }), Container(height: 40.h), diff --git a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart index 9337f8bd..63ae8a72 100644 --- a/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart +++ b/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_state.dart @@ -24,6 +24,7 @@ class ElectronicKeyDetailState { var isRealNameAuth = false.obs; //是否实名认证 0:不需要 1:需要 var getRealName = ''.obs; //真实姓名 var getIDCardNumber = ''.obs; //身份证号 + var isRequireAuth = false.obs; //是否必须输入身份信息 ElectronicKeyDetailState() { Map map = Get.arguments; diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart index 128557d8..c91a7c72 100644 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_page.dart @@ -201,8 +201,9 @@ class _MassSendElectronicKeyPageState extends State { : state.lockIdList.length.toString(), isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.massSendLockGroupPage) - .then((value) { + Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments:{ + "keyLimits":"2", + }).then((value) { //得到选中的锁ID列表 if (value != null) { value as Map; diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_state.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_state.dart index ab972b16..d513def2 100644 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_state.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendElectronicKey/massSendElectronicKey_state.dart @@ -1,5 +1,4 @@ - import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; import 'package:get/get.dart'; @@ -25,5 +24,4 @@ class MassSendElectronicKeyState{ var isDemoMode = false; final sendSucceedType = 0.obs; - } \ No newline at end of file diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart index 238bfa6d..1f916225 100644 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_logic.dart @@ -10,7 +10,7 @@ class MassSendLockGroupListLogic extends BaseGetXController { //分组列表请求 Future mockNetworkDataRequest() async { MassSendLockGroupListEntity entity = - await ApiRepository.to.lockGroupList('2'); + await ApiRepository.to.lockGroupList(state.keyLimits); if (entity.errorCode!.codeIsSuccessful) { if (entity.data != null) { state.lockGroupList.value = entity.data!.groupList!; diff --git a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_state.dart b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_state.dart index e344db01..94c259a3 100644 --- a/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_state.dart +++ b/lib/main/lockDetail/electronicKey/massSendElectronicKey/massSendLockGroupList/massSendLockGroupList_state.dart @@ -4,4 +4,12 @@ class MassSendLockGroupListState { var lockGroupList = [].obs; var selectLockIdList = [].obs; var isVip = false.obs; + + var keyLimits = '';// 1管理员(包括超级管理员跟管理员) 2普通用户 + MassSendLockGroupListState(){ + Map map = Get.arguments; + if(map["keyLimits"] != null){ + keyLimits = map['keyLimits']; + } + } } diff --git a/lib/main/lockDetail/face/addFace/addFace_logic.dart b/lib/main/lockDetail/face/addFace/addFace_logic.dart index 263d1407..b620dcce 100644 --- a/lib/main/lockDetail/face/addFace/addFace_logic.dart +++ b/lib/main/lockDetail/face/addFace/addFace_logic.dart @@ -1,9 +1,9 @@ + import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/blue/io_protocol/io_addFace.dart'; -import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/main/lockDetail/face/addFace/addFace_state.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; @@ -23,8 +23,7 @@ class AddFaceLogic extends BaseGetXController { // 监听设备返回的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = - EventBusManager().eventBus!.on().listen((reply) async { + _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { // 添加人脸开始 if (reply is SenderAddFaceReply && state.ifCurrentScreen.value == true) { _replyAddFaceBegin(reply); diff --git a/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart b/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart index bf69e34d..55f62580 100644 --- a/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart +++ b/lib/main/lockDetail/face/faceDetail/faceDetail_logic.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/blue/io_protocol/io_addFace.dart'; import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/main/lockDetail/face/faceDetail/faceDetail_state.dart'; @@ -45,7 +46,6 @@ class FaceDetailLogic extends BaseGetXController { }else{ editFaceData(); } - deletFaceData(); break; case 0x06: //无权限 diff --git a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart index fdf2389b..577361ba 100644 --- a/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart +++ b/lib/main/lockDetail/face/faceDetail/faceDetail_page.dart @@ -105,7 +105,7 @@ class _FaceDetailPageState extends State with RouteAware { state.endDate.value = data["endDate"]; state.startTime.value = data["starTime"]; state.endTime.value = data["endTime"]; - state.weekDay.value = data["weekDay"]; + state.weekDay.value = data["validityValue"]; }); } } @@ -121,7 +121,7 @@ class _FaceDetailPageState extends State with RouteAware { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, arguments: { - "pushType": 0, + "pushType": 3, "fingerprintItemData": state.faceItemData.value, }); if (data != null) { @@ -130,7 +130,7 @@ class _FaceDetailPageState extends State with RouteAware { state.endDate.value = data["endDate"]; state.startTime.value = data["starTime"]; state.endTime.value = data["endTime"]; - state.weekDay.value = data["weekDay"]; + state.weekDay.value = data["validityValue"]; }); } })))), @@ -139,13 +139,13 @@ class _FaceDetailPageState extends State with RouteAware { child: Obx(() => CommonItem( leftTitel: "有效时间", rightTitle: - "${DateTool().dateToHNString(state.startDate.value)}-${DateTool().dateToHNString(state.endDate.value)}", + "${DateTool().dateToHNString(state.startTime.value)}-${DateTool().dateToHNString(state.endTime.value)}", isHaveDirection: true, action: () async { var data = await Get.toNamed( Routers.otherTypeKeyChangeValidityDatePage, arguments: { - "pushType": 0, + "pushType": 3, "fingerprintItemData": state.faceItemData.value, }); if (data != null) { @@ -191,7 +191,8 @@ class _FaceDetailPageState extends State with RouteAware { action: () { Get.toNamed(Routers.lockOperatingRecordPage, arguments: { 'type': 4, - 'id': state.faceItemData.value.faceId.toString() + 'id': state.faceItemData.value.faceId.toString(), + 'recordName': state.faceItemData.value.faceName }); }), // SizedBox(height: 40.h), diff --git a/lib/main/lockDetail/face/faceList/faceList_logic.dart b/lib/main/lockDetail/face/faceList/faceList_logic.dart index 64a555e3..2f2e6708 100644 --- a/lib/main/lockDetail/face/faceList/faceList_logic.dart +++ b/lib/main/lockDetail/face/faceList/faceList_logic.dart @@ -7,6 +7,7 @@ import 'package:star_lock/blue/io_protocol/io_addFace.dart'; import 'package:star_lock/blue/io_protocol/io_queryingFaceStatus.dart'; import 'package:star_lock/main/lockDetail/face/faceList/faceList_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../app_settings/app_settings.dart'; import '../../../../blue/blue_manage.dart'; import '../../../../blue/io_protocol/io_checkingUserInfoCount.dart'; import '../../../../blue/io_reply.dart'; @@ -28,18 +29,18 @@ class FaceListLogic extends BaseGetXController { _replySubscription = EventBusManager().eventBus!.on().listen((reply) { // 添加人脸开始(此处用作删除人脸) - if ((reply is SenderAddFaceReply) && (state.ifCurrentScreen == true)) { + if ((reply is SenderAddFaceReply) && (state.ifCurrentScreen.value == true)) { _replyAddFaceBegin(reply); } - if (reply is SenderQueryingFaceStatusReply) { - // 获取人脸状态 - _replyQueryingFaceStatus(reply); - } - - if (reply is SenderCheckingUserInfoCountReply) { - _replyCheckingUserInfoCount(reply); - } + // if (reply is SenderQueryingFaceStatusReply) { + // // 获取人脸状态 + // _replyQueryingFaceStatus(reply); + // } + // + // if (reply is SenderCheckingUserInfoCountReply) { + // _replyCheckingUserInfoCount(reply); + // } }); } @@ -89,19 +90,6 @@ class FaceListLogic extends BaseGetXController { privateKey:getPrivateKeyList, token: token, ); - - // IoSenderManage.senderAddFaceCommand( - // keyID: state.deletKeyID, - // userID: state.deletUserID, - // faceNo: state.deletFaceNo, - // useCountLimit: 0, - // startTime: 0x11223344, - // endTime: 0x11223344, - // needAuthor: 1, - // publicKey: publicKeyDataList, - // privateKey: getPrivateKeyList, - // token: getTokenList, - // ); break; default: //失败 @@ -109,158 +97,158 @@ class FaceListLogic extends BaseGetXController { } } - // 获取人脸状态 - Future _replyQueryingFaceStatus(Reply reply) async { - int status = reply.data[2]; + // // 获取人脸状态 + // Future _replyQueryingFaceStatus(Reply reply) async { + // int status = reply.data[2]; + // + // switch (status) { + // case 0x00: + // //成功 + // // _getLockStatus(); + // break; + // case 0x06: + // //无权限 + // + // break; + // default: + // //失败 + // break; + // } + // } - switch (status) { - case 0x00: - //成功 - // _getLockStatus(); - break; - case 0x06: - //无权限 + // // 获取卡片状态 + // Future _replyReferEventRecordNumber(Reply reply) async { + // int status = reply.data[2]; + // switch (status) { + // case 0x00: + // //成功 + // + // // _getLockStatus(); + // break; + // case 0x06: + // //无权限 需要鉴权 + // + // break; + // default: + // //失败 + // break; + // } + // } - break; - default: - //失败 - break; - } - } + // // 查询用户、指纹、密码、卡片数量(用于判断是否同步) + // Future _replyCheckingUserInfoCount(Reply reply) async { + // int status = reply.data[2]; + // + // // 用户数量 + // int userNum = reply.data[5]; + // + // // 指纹数量 + // int fingerNum = reply.data[6]; + // + // // 密码数量 + // 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); + // + // switch (status) { + // case 0x00: + // //成功 + // // _getLockStatus(); + // break; + // case 0x06: + // //无权限 + // + // break; + // default: + // //失败 + // break; + // } + // } - // 获取卡片状态 - Future _replyReferEventRecordNumber(Reply reply) async { - int status = reply.data[2]; - switch (status) { - case 0x00: - //成功 + // // 获取人脸状态 + // Future senderQueryingFaceStatus() async { + // BlueManage().bludSendData(BlueManage().connectDeviceName, + // (BluetoothConnectionState state) async { + // if (state == BluetoothConnectionState.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.senderQueryingFaceStatusCommand( + // keyID: BlueManage().connectDeviceName, + // userID: await Storage.getUid(), + // role: 0xff, + // faceCount: 20, + // faceNo: 1, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList, + // ); + // } + // }); + // } - // _getLockStatus(); - break; - case 0x06: - //无权限 需要鉴权 - - break; - default: - //失败 - break; - } - } - - // 查询用户、指纹、密码、卡片数量(用于判断是否同步) - Future _replyCheckingUserInfoCount(Reply reply) async { - int status = reply.data[2]; - - // 用户数量 - int userNum = reply.data[5]; - - // 指纹数量 - int fingerNum = reply.data[6]; - - // 密码数量 - 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); - - switch (status) { - case 0x00: - //成功 - // _getLockStatus(); - break; - case 0x06: - //无权限 - - break; - default: - //失败 - break; - } - } - - // 获取人脸状态 - Future senderQueryingFaceStatus() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState state) async { - if (state == BluetoothConnectionState.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.senderQueryingFaceStatusCommand( - keyID: BlueManage().connectDeviceName, - userID: await Storage.getUid(), - role: 0xff, - faceCount: 20, - faceNo: 1, - token: getTokenList, - needAuthor: 1, - publicKey: getPublicKeyList, - privateKey: getPrivateKeyList, - ); - } - }); - } - - // 查询用户、指纹、密码、卡片数量(用于判断是否同步) - Future senderCheckingUserInfoCount() async { - BlueManage().bludSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState state) async { - if (state == BluetoothConnectionState.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, - ); - } - }); - } + // // 查询用户、指纹、密码、卡片数量(用于判断是否同步) + // Future senderCheckingUserInfoCount() async { + // BlueManage().bludSendData(BlueManage().connectDeviceName, + // (BluetoothConnectionState state) async { + // if (state == BluetoothConnectionState.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, + // ); + // } + // }); + // } // 删除人脸 Future senderAddFace() async { @@ -311,33 +299,43 @@ class FaceListLogic extends BaseGetXController { } // 获取人脸列表 - void getFaceListData() async { + Future getFaceListData() async { var entity = await ApiRepository.to.getFaceListData( lockId: state.lockId.value.toString(), - pageNo: '1', - pageSize: '20', + pageNo: pageNo.toString(), + pageSize: pageSize.toString(), searchStr: state.searchController.text, ); if (entity.errorCode!.codeIsSuccessful) { - state.faceItemListData.value = entity.data!.list!; + // state.faceItemListData.value = entity.data!.list!; + if (pageNo == 1) { + state.faceItemListData.value = entity.data!.list!; + pageNo++; + } else { + if (entity.data!.list!.isNotEmpty) { + state.faceItemListData.value.addAll(entity.data!.list!); + pageNo++; + } + } } + return entity; } // 删除的人脸 void deletFacesData() async { var faceId = ""; - var type = "1"; if (state.isDeletAll == false) { faceId = state.deletKeyID; - type = "0"; } var entity = await ApiRepository.to.deleteFaceData( faceId: int.parse(faceId), lockId: state.lockId.value, ); if (entity.errorCode!.codeIsSuccessful) { - showToast("删除成功"); - getFaceListData(); + showToast("删除成功", something: (){ + pageNo = 1; + getFaceListData(); + }); } } @@ -353,8 +351,10 @@ class FaceListLogic extends BaseGetXController { lockId: state.lockId.value, ); if (entity.errorCode!.codeIsSuccessful) { - showToast("重置成功"); - getFaceListData(); + showToast("重置成功", something: (){ + pageNo = 1; + getFaceListData(); + }); } } @@ -388,6 +388,7 @@ class FaceListLogic extends BaseGetXController { late StreamSubscription _teamEvent; void _initRefreshAction() { _teamEvent = eventBus.on().listen((event) { + pageNo = 1; getFaceListData(); }); } @@ -403,8 +404,6 @@ class FaceListLogic extends BaseGetXController { _initReplySubscription(); _initRefreshAction(); - - getFaceListData(); } } diff --git a/lib/main/lockDetail/face/faceList/faceList_page.dart b/lib/main/lockDetail/face/faceList/faceList_page.dart index 0f6d9352..28b9a109 100644 --- a/lib/main/lockDetail/face/faceList/faceList_page.dart +++ b/lib/main/lockDetail/face/faceList/faceList_page.dart @@ -10,6 +10,7 @@ import 'package:star_lock/tools/showTipView.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; +import '../../../../tools/EasyRefreshTool.dart'; import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/noData.dart'; import '../../../../tools/storage.dart'; @@ -29,6 +30,23 @@ class _FaceListPageState extends State with RouteAware { final logic = Get.put(FaceListLogic()); final state = Get.find().state; + Future getHttpData() async { + var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + if (isDemoMode == false) { + logic.getFaceListData().then((FingerprintListDataEntity value){ + if(mounted) setState(() {}); + }); + } + } + + @override + void initState() { + super.initState(); + + getHttpData(); + } + + @override Widget build(BuildContext context) { return Scaffold( @@ -62,34 +80,45 @@ class _FaceListPageState extends State with RouteAware { ), ], ), - body: Column( - children: [ - KeySearchWidget( - editingController: state.searchController, - onSubmittedAction: () { - logic.getFaceListData(); - }, - ), - SizedBox( - height: 20.h, - ), - Expanded(child: _buildMainUI()), - AddBottomWhiteBtn( - btnName: - '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}', - onClick: () async { - var data = - await Get.toNamed(Routers.addFaceTypePage, arguments: { - "lockId": state.lockId.value, - "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 - }); - if (data != null) { - logic.getFaceListData(); - } - }, - ), - SizedBox(height: 64.h) - ], + body: EasyRefreshTool( + onRefresh: (){ + logic.pageNo = 1; + getHttpData(); + }, + onLoad: (){ + getHttpData(); + }, + child: Column( + children: [ + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.pageNo = 1; + getHttpData(); + }, + ), + SizedBox( + height: 20.h, + ), + Expanded(child: _buildMainUI()), + AddBottomWhiteBtn( + btnName: + '${TranslationLoader.lanKeys!.add!.tr}${TranslationLoader.lanKeys!.face!.tr}', + onClick: () async { + var data = + await Get.toNamed(Routers.addFaceTypePage, arguments: { + "lockId": state.lockId.value, + "fromType": 1 // 1从添加钥匙列表进入 2从考勤添加员工入口进入 + }); + if (data != null) { + logic.pageNo = 1; + getHttpData(); + } + }, + ), + SizedBox(height: 64.h) + ], + ), ), ); } @@ -122,7 +151,8 @@ class _FaceListPageState extends State with RouteAware { "faceItemData": getFaceItemData, }); if (data != null) { - logic.getFaceListData(); + logic.pageNo = 1; + getHttpData(); } }), ); diff --git a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart index 23e9397e..f07976e5 100644 --- a/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart +++ b/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_page.dart @@ -6,12 +6,9 @@ import 'package:get/get.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; -import '../../../../blue/blue_manage.dart'; import '../../../../tools/appRouteObserver.dart'; import '../../../../tools/commonItem.dart'; import '../../../../tools/dateTool.dart'; -import '../../../../tools/showIosTipView.dart'; -import '../../../../tools/showTFView.dart'; import '../../../../tools/showTipView.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; @@ -201,7 +198,8 @@ class _FingerprintDetailPageState extends State // 指纹 Get.toNamed(Routers.lockOperatingRecordPage, arguments: { 'type': 3, - 'id': state.fingerprintItemData.value.fingerprintId.toString() + 'id': state.fingerprintItemData.value.fingerprintId.toString(), + 'recordName': state.fingerprintItemData.value.fingerprintName }); }), // SizedBox(height: 40.h), diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index cff7ebb3..0ecca01f 100644 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -1,3 +1,4 @@ + import 'dart:async'; import 'package:flutter/scheduler.dart'; @@ -40,26 +41,11 @@ class LockDetailLogic extends BaseGetXController { _replyOpenLock(reply); } - // 编辑锁用户 - // if(reply is EditUserReply){ - // _replyEditUserKey(reply); - // } - - // 获取星锁状态信息 - // if (reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value == true) { - // _replyGetStarLockStatusInfo(reply); - // } - // 开完锁之后上传记录 if (reply is SenderReferEventRecordTimeReply && state.ifCurrentScreen.value == true) { _replyReferEventRecordTime(reply); } - - // 添加用户 - // if ((reply is AddUserReply) && (state.ifCurrentScreen.value == true)) { - // _replyAddUserKey(reply); - // } }); } @@ -74,10 +60,7 @@ class LockDetailLogic extends BaseGetXController { cancelBlueConnetctToastTimer(); state.iSClosedUnlockSuccessfulPopup.value = true; - if (state.closedUnlockSuccessfulTimer != null) { - state.closedUnlockSuccessfulTimer!.cancel(); - state.closedUnlockSuccessfulTimer = null; - } + state.closedUnlockSuccessfulTimer?.cancel(); // 如果没有点击关闭弹窗,3秒后自动关闭 state.closedUnlockSuccessfulTimer = Timer.periodic(3.seconds, (timer) { state.iSClosedUnlockSuccessfulPopup.value = false; @@ -98,9 +81,7 @@ class LockDetailLogic extends BaseGetXController { uploadElectricQuantityRequest(); getLockRecordLastUploadDataTime(); - state.openLockBtnState.value = 0; - - eventBus.fire(RefreshLockDetailInfoDataEvent()); + resetOpenDoorState(); break; case 0x06: //无权限 @@ -128,49 +109,77 @@ class LockDetailLogic extends BaseGetXController { break; case 0x16: // 正在开锁中... - state.openLockBtnState.value = 0; - eventBus.fire(RefreshLockDetailInfoDataEvent()); + resetOpenDoorState(); showToast("正在开锁中...".tr, something: () { cancelBlueConnetctToastTimer(); }); break; case 0x0d: - // 正在开锁中... + // 钥匙无效 showToast('钥匙无效'.tr); - state.openLockBtnState.value = 0; - state.openDoorBtnisUneable.value = false; - state.animationController!.stop(); + // state.animationController!.stop(); + resetOpenDoorState(); cancelBlueConnetctToastTimer(); + BlueManage().disconnect(); + break; + case 0x0b: + // 钥匙无效 + showToast('钥匙过期'.tr); + resetOpenDoorState(); + + cancelBlueConnetctToastTimer(); + BlueManage().disconnect(); + break; + case 0x0a: + // 钥匙不存在 + showToast("钥匙不存在"); + resetOpenDoorState(); + + cancelBlueConnetctToastTimer(); + BlueManage().disconnect(); + break; + case 0x0c: + // 钥匙数量已到上限 + showToast("钥匙数量已到上限"); + resetOpenDoorState(); + + cancelBlueConnetctToastTimer(); + BlueManage().disconnect(); + break; + case 0x0e: + // 钥匙已存在 + showToast("钥匙已存在"); + resetOpenDoorState(); + + cancelBlueConnetctToastTimer(); + BlueManage().disconnect(); + break; + case 0x0f: + // 用户已存在 + showToast("用户已存在"); + resetOpenDoorState(); + + cancelBlueConnetctToastTimer(); + BlueManage().disconnect(); break; default: //失败 - state.openLockBtnState.value = 0; - state.openDoorBtnisUneable.value = false; - state.animationController!.stop(); + AppLog.log("开锁失败"); + // state.animationController!.stop(); + resetOpenDoorState(); cancelBlueConnetctToastTimer(); + BlueManage().disconnect(); break; } } - // 获取锁状态数据解析 - // Future _replyGetStarLockStatusInfo(Reply reply) async { - // int status = reply.data[2]; - // switch (status) { - // case 0x00: - // //成功 - // dismissEasyLoading(); - // cancelBlueConnetctToastTimer(); - // - // break; - // case 0x06: - // //无权限 - // - // break; - // default: - // //失败 - // break; - // } - // } + //清除开锁动画以及状态 + void closeLuckStatus() { + state.openLockBtnState.value = 0; + state.openDoorBtnisUneable.value = false; + state.animationController!.stop(canceled: true); + cancelBlueConnetctToastTimer(); + } // 根据时间查解析数据 Future _replyReferEventRecordTime(Reply reply) async { @@ -179,10 +188,10 @@ class LockDetailLogic extends BaseGetXController { case 0x00: //成功 int dataLength = (reply.data[5] << 8) + reply.data[6]; - AppLog.log("dataLength:$dataLength"); + // AppLog.log("dataLength:$dataLength"); if (dataLength > 0) { reply.data.removeRange(0, 7); - // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 + // 把得到的数据按17个字节分割成数组 然后塞进一个新的数组里面 if (reply.data.length < 17) { return; } @@ -194,13 +203,13 @@ class LockDetailLogic extends BaseGetXController { // AppLog.log("indexList:$indexList"); var indexMap = {}; indexMap["type"] = indexList[0].toString(); - + int operateDate = 0; if (indexList[0] == 2) { var passwordData = reply.data.sublist(7, 17); var password = utf8String(passwordData); indexMap["user"] = password.toString(); } else { - int userNo = (indexList[1] * 255) + indexList[2]; + int userNo = (indexList[1] * 256) + indexList[2]; indexMap["user"] = userNo.toString(); } @@ -210,8 +219,14 @@ class LockDetailLogic extends BaseGetXController { (0xff & indexList[4]) << 16 | (0xff & indexList[5]) << 8 | (0xFF & indexList[6])); - indexMap["date"] = "${time * 1000}"; + operateDate = time * 1000; + indexMap["date"] = "$operateDate"; uploadList.add(indexMap); + + if (i == getList.length - 1) { + //设置最后的时间戳 + state.operateDate = operateDate; + } } lockRecordUploadData(uploadList); @@ -234,123 +249,12 @@ class LockDetailLogic extends BaseGetXController { } } - // // 添加用户 - // Future _replyAddUserKey(Reply reply) async { - // var lockId = reply.data.sublist(2, 42); - // - // var token = reply.data.sublist(42, 46); - // List strTokenList = changeIntListToStringList(token); - // Storage.setStringList(saveBlueToken, strTokenList); - // - // int status = reply.data[46]; - // - // switch (status) { - // case 0x00: - // //成功 - // cancelBlueConnetctToastTimer(); - // state.lockUserNo = reply.data[47]; - // _updateLockUserNo(); - // - // break; - // case 0x06: - // //无权限 - // var privateKey = await Storage.getStringList(saveBluePrivateKey); - // List getPrivateKeyList = changeStringListToIntList(privateKey!); - // - // var publicKey = await Storage.getStringList(saveBluePublicKey); - // List publicKeyDataList = changeStringListToIntList(publicKey!); - // - // IoSenderManage.senderAddUser( - // lockID: BlueManage().connectDeviceName, - // authUserID: state.senderUserId.toString(), - // keyID: state.keyInfos.value.keyId.toString(), - // userID: await Storage.getUid(), - // openMode: 1, - // keyType: 0, - // startDate: state.keyInfos.value.startDate!~/10000, - // expireDate: state.keyInfos.value.endDate!~/10000, - // role: state.keyInfos.value.keyRight == 1 ? 1 : 0, - // password: "0", - // needAuthor: 1, - // publicKey: publicKeyDataList, - // privateKey: getPrivateKeyList, - // token: token); - // break; - // default: - // break; - // } - // } - - // 添加用户(普通用户接收电子钥匙) - // Future addUserConnectBlue() async { - // showBlueConnetctToastTimer(action: () { - // state.openLockBtnState.value = 0; - // eventBus.fire(RefreshLockDetailInfoDataEvent()); - // }); - // - // // var listData = AddUserCommand( - // // lockID: BlueManage().connectDeviceName, - // // authUserID: state.senderUserId.toString(), - // // keyID: state.keyInfos.value.keyId.toString(), - // // userID: await Storage.getUid(), - // // openMode: 1, - // // keyType: 0, - // // startDate: state.keyInfos.value.startDate!~/10000, - // // expireDate: state.keyInfos.value.endDate!~/10000, - // // role: state.keyInfos.value.keyRight == 1 ? 1 : 0, - // // password: "123456", - // // needAuthor: 1, - // // publicKey: publicKeyDataList, - // // privateKey: getPrivateKeyList, - // // token: getTokenList).packageData(); - // BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { - // if (deviceConnectionState == BluetoothConnectionState.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 = [0, 0, 0, 0]; - // if (token != null) { - // getTokenList = changeStringListToIntList(token); - // } - // - // IoSenderManage.senderAddUser( - // lockID: BlueManage().connectDeviceName, - // authUserID: state.senderUserId.toString(), - // keyID: state.keyInfos.value.keyId.toString(), - // userID: await Storage.getUid(), - // openMode: 1, - // keyType: 0, - // startDate: state.keyInfos.value.startDate!~/10000, - // expireDate: state.keyInfos.value.endDate!~/10000, - // role: state.keyInfos.value.keyRight == 1 ? 1 : 0, - // password: "0", - // needAuthor: 1, - // publicKey: publicKeyDataList, - // privateKey: getPrivateKeyList, - // token: getTokenList); - // } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { - // cancelBlueConnetctToastTimer(); - // if (state.ifCurrentScreen.value == true) { - // showBlueConnetctToast(); - // } - // - // state.openLockBtnState.value = 0; - // eventBus.fire(RefreshLockDetailInfoDataEvent()); - // } - // }); - // } - // 点击开门事件 Future openDoorAction() async { showBlueConnetctToastTimer(action: () { - state.openLockBtnState.value = 0; + resetOpenDoorState(); // BlueManage().stopScan(); - eventBus.fire(RefreshLockDetailInfoDataEvent()); + BlueManage().disconnect(); }); var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -383,8 +287,7 @@ class LockDetailLogic extends BaseGetXController { showBlueConnetctToast(); } - state.openLockBtnState.value = 0; - eventBus.fire(RefreshLockDetailInfoDataEvent()); + resetOpenDoorState(); } }); } @@ -393,6 +296,7 @@ class LockDetailLogic extends BaseGetXController { Future senderReferEventRecordTime() async { showBlueConnetctToastTimer( isShowBlueConnetctToast: false, + outTimer: 10, action: () { BlueManage().disconnect(); }); @@ -448,8 +352,7 @@ class LockDetailLogic extends BaseGetXController { openDoorAction(); } else { showToast("网络访问失败,请检查网络是否正常".tr, something: () { - state.openLockBtnState.value = 0; - state.animationController!.forward(); + resetOpenDoorState(); cancelBlueConnetctToastTimer(); state.lockNetToken = "0"; openDoorAction(); @@ -473,25 +376,6 @@ class LockDetailLogic extends BaseGetXController { } } - // 普通用户接收电子钥匙之后 更新锁用户NO - // void _updateLockUserNo() async { - // LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo( - // keyId: state.keyInfos.value.keyId.toString(), - // lockUserNo: state.lockUserNo.toString() - // ); - // if (entity.errorCode!.codeIsSuccessful) { - // eventBus.fire(RefreshLockDetailInfoDataEvent()); - // SchedulerBinding.instance.addPostFrameCallback((_) { - // eventBus.fire(RefreshLockListInfoDataEvent()); - // }); - // if (state.isOpenLockNeedOnline.value == 0) { - // openDoorAction(); - // } else { - // getLockNetToken(); - // } - // } - // } - // 查询锁记录最后时间 void getLockRecordLastUploadDataTime() async { LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to @@ -599,6 +483,14 @@ class LockDetailLogic extends BaseGetXController { return formattedTime; } + void resetOpenDoorState() { + state.openLockBtnState.value = 0; + state.openDoorBtnisUneable.value = false; + state.animationController!.reset(); + state.animationController!.forward(); + eventBus.fire(RefreshLockDetailInfoDataEvent()); + } + @override Future onReady() async { super.onReady(); diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 8e6cde2a..451f629f 100644 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:intl/intl.dart'; @@ -94,8 +95,10 @@ class _LockDetailPageState extends State state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) { state.openDoorBtnisUneable.value = false; + state.bottomBtnisEable.value = false; } else { state.openDoorBtnisUneable.value = true; + state.bottomBtnisEable.value = true; } state.isOnlyOneData = widget.isOnlyOneData; @@ -875,7 +878,7 @@ class _LockDetailPageState extends State // 新增配件 showWidgetArr.add(bottomItem('images/main/icon_main_addLock.png', '新增配件'.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { + state.bottomBtnisEable.value, () { Navigator.pushNamed(context, Routers.accessoriesListPage); })); @@ -914,7 +917,6 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_clockingIn.png', TranslationLoader.lanKeys!.checkingIn!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.checkingInListPage, arguments: state.keyInfos.value); @@ -924,15 +926,14 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { - Get.toNamed(Routers.lockOperatingRecordPage, + Get.toNamed(Routers.doorLockLogPage, arguments: {"keyInfo": state.keyInfos.value}); })); // 设置 showWidgetArr.add(bottomItem('images/main/icon_main_set.png', - TranslationLoader.lanKeys!.set!.tr, true, true, () { + TranslationLoader.lanKeys!.set!.tr, true, () { Get.toNamed(Routers.lockSetPage, arguments: { "lockId": state.keyInfos.value.lockId, "isOnlyOneData": state.isOnlyOneData @@ -950,7 +951,6 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_clockingIn.png', TranslationLoader.lanKeys!.checkingIn!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.checkingInListPage, arguments: state.keyInfos.value); @@ -961,7 +961,6 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_electronicKey.png', TranslationLoader.lanKeys!.electronicKey!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.electronicKeyListPage); })); @@ -970,7 +969,6 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_password.png', TranslationLoader.lanKeys!.password!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.passwordKeyListPage, arguments: {"keyInfo": state.keyInfos.value}); @@ -981,7 +979,6 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_icCard.png', TranslationLoader.lanKeys!.card!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.cardListPage, arguments: { "lockId": state.keyInfos.value.lockId, @@ -994,7 +991,6 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_fingerprint.png', TranslationLoader.lanKeys!.fingerprint!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.fingerprintListPage, arguments: { "lockId": state.keyInfos.value.lockId, @@ -1007,7 +1003,6 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_remoteControl.png', TranslationLoader.lanKeys!.remoteControl!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.remoteControlListPage); })); @@ -1019,7 +1014,6 @@ class _LockDetailPageState extends State bottomItem( 'images/main/icon_face.png', TranslationLoader.lanKeys!.humanFace!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.faceListPage, arguments: { "lockId": state.keyInfos.value.lockId, @@ -1030,8 +1024,9 @@ class _LockDetailPageState extends State if (state.keyInfos.value.lockFeature!.isSupportIris == 1) { showWidgetArr.add( - bottomItem('images/main/icon_iris.png', '虹膜'.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { + bottomItem( + 'images/main/icon_iris.png', '虹膜'.tr, state.bottomBtnisEable.value, + () { Get.toNamed(Routers.irisListPage, arguments: { "lockId": state.keyInfos.value.lockId, }); @@ -1041,8 +1036,9 @@ class _LockDetailPageState extends State if (state.keyInfos.value.lockFeature!.palmVein == 1) { showWidgetArr.add( - bottomItem('images/main/icon_palm.png', '手掌'.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { + bottomItem( + 'images/main/icon_palm.png', '手掌'.tr, state.bottomBtnisEable.value, + () { Get.toNamed(Routers.palmListPage, arguments: { "lockId": state.keyInfos.value.lockId, }); @@ -1056,7 +1052,6 @@ class _LockDetailPageState extends State bottomItem( 'images/main/icon_catEyes.png', TranslationLoader.lanKeys!.monitoring!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.realTimePicturePage, arguments: { "lockName": state.keyInfos.value.lockName, @@ -1071,7 +1066,6 @@ class _LockDetailPageState extends State showWidgetArr.add(bottomItem( 'images/main/icon_main_authorizedAdmin.png', TranslationLoader.lanKeys!.authorizedAdmin!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.authorizedAdminListPage, arguments: {"keyInfo": state.keyInfos.value}); @@ -1084,7 +1078,6 @@ class _LockDetailPageState extends State bottomItem( 'images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { // Get.toNamed(Routers.lockOperatingRecordPage, // arguments: {"keyInfo": state.keyInfos.value}); @@ -1098,7 +1091,6 @@ class _LockDetailPageState extends State endWiddget.add(bottomItem( 'images/main/icon_lockDetail_videoLog.png', TranslationLoader.lanKeys!.videoLog!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.videoLogPage, arguments: { "lockId": state.keyInfos.value.lockId, @@ -1110,7 +1102,6 @@ class _LockDetailPageState extends State bottomItem( 'images/main/icon_lockDetail_messageReminding.png', TranslationLoader.lanKeys!.messageReminding!.tr, - state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.msgNotificationPage, arguments: { "lockId": state.keyInfos.value.lockId, @@ -1121,7 +1112,7 @@ class _LockDetailPageState extends State endWiddget.add( // 设置 bottomItem('images/main/icon_main_set.png', - TranslationLoader.lanKeys!.set!.tr, true, true, () { + TranslationLoader.lanKeys!.set!.tr, true, () { // logic.clickItemBtnAction(10); Get.toNamed(Routers.lockSetPage, arguments: { "lockId": state.keyInfos.value.lockId, @@ -1133,8 +1124,8 @@ class _LockDetailPageState extends State return showWidgetArr; } - Widget bottomItem(String iconUrl, String name, bool openDoorBtnisUneable, - bool bottomBtnisEable, Function() onClick) { + Widget bottomItem( + String iconUrl, String name, bool bottomBtnisEable, Function() onClick) { Widget child = F.sw( defaultCall: () => Container( color: Colors.white, @@ -1149,10 +1140,8 @@ class _LockDetailPageState extends State child: Image.asset(iconUrl, width: 42.w, height: 42.w, - color: openDoorBtnisUneable - ? (bottomBtnisEable - ? AppColors.mainColor - : AppColors.lockDetailBottomBtnUneable) + color: bottomBtnisEable + ? AppColors.mainColor : AppColors.lockDetailBottomBtnUneable, fit: BoxFit.fitWidth), ), @@ -1162,10 +1151,8 @@ class _LockDetailPageState extends State child: Text(name, style: TextStyle( fontSize: 20.sp, - color: openDoorBtnisUneable - ? (bottomBtnisEable - ? AppColors.blackColor - : AppColors.lockDetailBottomBtnUneable) + color: bottomBtnisEable + ? AppColors.blackColor : AppColors.lockDetailBottomBtnUneable), textAlign: TextAlign.center)) ], @@ -1186,10 +1173,8 @@ class _LockDetailPageState extends State child: Image.asset(iconUrl, width: 42.w, height: 42.w, - color: openDoorBtnisUneable - ? (bottomBtnisEable - ? AppColors.mainColor - : AppColors.lockDetailBottomBtnUneable) + color: bottomBtnisEable + ? AppColors.mainColor : AppColors.lockDetailBottomBtnUneable, fit: BoxFit.fitWidth), ), @@ -1199,23 +1184,19 @@ class _LockDetailPageState extends State name, style: TextStyle( fontSize: 20.sp, - color: openDoorBtnisUneable - ? (bottomBtnisEable - ? AppColors.blackColor - : AppColors.lockDetailBottomBtnUneable) + color: bottomBtnisEable + ? AppColors.blackColor : AppColors.lockDetailBottomBtnUneable), ), ], ), )); return GestureDetector( - onTap: openDoorBtnisUneable - ? (bottomBtnisEable - ? onClick - : () { - logic.showToast("请在锁旁边完成第一次开锁".tr); - }) - : null, + onTap: bottomBtnisEable + ? onClick + : () { + logic.showToast("请在锁旁边完成第一次开锁".tr); + }, child: child, ); } @@ -1290,6 +1271,7 @@ class _LockDetailPageState extends State left: 155.w, child: GestureDetector( onTap: () { + state.closedUnlockSuccessfulTimer?.cancel(); setState(() { state.iSClosedUnlockSuccessfulPopup.value = false; }); @@ -1345,7 +1327,7 @@ class _LockDetailPageState extends State state.iSOpenLock.value = true; state.iSClosedUnlockSuccessfulPopup.value = false; state.openLockBtnState.value = 1; - // state.animationController!.forward(); + state.animationController!.forward(); AppLog.log("点击开锁"); if (state.isOpenLockNeedOnline.value == 0) { @@ -1370,6 +1352,7 @@ class _LockDetailPageState extends State state.openLockBtnState.value = 1; state.animationController!.forward(); + EasyLoading.showToast("正在尝试闭锁……".tr, duration: 2000.milliseconds); AppLog.log("长按闭锁"); if (state.isOpenLockNeedOnline.value == 0) { // 不需要联网 @@ -1429,7 +1412,7 @@ class _LockDetailPageState extends State void didPushNext() { super.didPushNext(); state.ifCurrentScreen.value = false; - logic.cancelBlueConnetctToastTimer(); - state.openLockBtnState.value = 0; + logic.closeLuckStatus(); + BlueManage().disconnect(); } } diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart index ffe61bb0..ebb452f9 100644 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_logic.dart @@ -38,7 +38,7 @@ class LockOperatingRecordLogic extends BaseGetXController { case 0x00: //成功 int dataLength = (reply.data[5] << 8) + reply.data[6]; - // AppLog.log("dataLength:$dataLength"); + AppLog.log("dataLength:$dataLength"); // var dataLength = reply.data[5]; if (dataLength > 0) { reply.data.removeRange(0, 7); @@ -61,7 +61,7 @@ class LockOperatingRecordLogic extends BaseGetXController { AppLog.log("password:$password passwordData:$passwordData"); indexMap["user"] = password; }else{ - int userNo = (indexList[1]*255) + indexList[2]; + int userNo = (indexList[1]*256) + indexList[2]; indexMap["user"] = userNo.toString(); } @@ -186,10 +186,12 @@ class LockOperatingRecordLogic extends BaseGetXController { //清空操作记录 void clearOperationRecordRequest() async { - KeyOperationRecordEntity entity = - await ApiRepository.to.clearOperationRecord('28'); + KeyOperationRecordEntity entity = await ApiRepository.to.clearOperationRecord(CommonDataManage().currentKeyInfo.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - showToast("清除数据成功"); + showToast("清除数据成功", something: (){ + pageNo = 1; + mockNetworkDataRequest(); + }); } } diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart index 15095b70..27177cf5 100644 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_page.dart @@ -51,30 +51,30 @@ class _LockOperatingRecordPageState extends State with return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.operatingRecord!.tr, + barTitle: state.recordName.value.isNotEmpty? state.recordName.value : TranslationLoader.lanKeys!.operatingRecord!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ - (CommonDataManage().currentKeyInfo.isLockOwner == 1 || - CommonDataManage().currentKeyInfo.keyRight == 1) - ? IconButton( - icon: Image.asset( - 'images/icon_bar_more.png', - height: 30.h, - width: 10.w, - ), - onPressed: () async { - var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); - if (isDemoMode == false) { - _openModalBottomSheet(); - } else { - // Get.toNamed(Routers.selectLockTypePage); - logic.showToast("演示模式"); - } - }, - ) - : Container(), - ], + // actionsList: [ + // (CommonDataManage().currentKeyInfo.isLockOwner == 1 || + // CommonDataManage().currentKeyInfo.keyRight == 1) + // ? IconButton( + // icon: Image.asset( + // 'images/icon_bar_more.png', + // height: 30.h, + // width: 10.w, + // ), + // onPressed: () async { + // var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); + // if (isDemoMode == false) { + // _openModalBottomSheet(); + // } else { + // // Get.toNamed(Routers.selectLockTypePage); + // logic.showToast("演示模式"); + // } + // }, + // ) + // : Container(), + // ], ), body: EasyRefreshTool( onRefresh: (){ @@ -86,29 +86,29 @@ class _LockOperatingRecordPageState extends State with }, child: Column( children: [ - (CommonDataManage().currentKeyInfo.isLockOwner == 1 || - CommonDataManage().currentKeyInfo.keyRight == 1) - ? Column( - children: [ - Container( - padding: EdgeInsets.only(left:20.h, right: 20.h, top: 20.h), - child: Text( - TranslationLoader.lanKeys!.lockOperatingRecordTip!.tr, - textAlign: TextAlign.start, - style: TextStyle(fontSize: 20.sp), - ), - ), - KeySearchWidget( - editingController: state.searchController, - onSubmittedAction: () { - logic.pageNo = 1; - getHttpData(); - }, - ), - ], - ) - : Container(), - SizedBox(height: 10.h), + // (CommonDataManage().currentKeyInfo.isLockOwner == 1 || + // CommonDataManage().currentKeyInfo.keyRight == 1) + // ? Column( + // children: [ + // Container( + // padding: EdgeInsets.only(left:20.h, right: 20.h, top: 20.h), + // child: Text( + // TranslationLoader.lanKeys!.lockOperatingRecordTip!.tr, + // textAlign: TextAlign.start, + // style: TextStyle(fontSize: 20.sp), + // ), + // ), + // KeySearchWidget( + // editingController: state.searchController, + // onSubmittedAction: () { + // logic.pageNo = 1; + // getHttpData(); + // }, + // ), + // ], + // ) + // : Container(), + // SizedBox(height: 10.h), Expanded(child: _buildMainUI()), ], ), @@ -128,7 +128,9 @@ class _LockOperatingRecordPageState extends State with DateTime.fromMillisecondsSinceEpoch(operateDate!); String operateDateStr = '${dateStr.toLocal().toString().substring(0, 16)} '; - return _operatingRecordItem(getTypeIcon(dataItem.recordType!), + // return _operatingRecordItem(getTypeIcon(dataItem.recordType!), + // dataItem.recordTypeName!, operateDateStr, () {}); + return _operatingOneRecordItem(getTypeIcon(dataItem.recordType!), dataItem.recordTypeName!, operateDateStr, () {}); }, separatorBuilder: (BuildContext context, int index) { @@ -166,63 +168,111 @@ class _LockOperatingRecordPageState extends State with return title; } - Widget _operatingRecordItem(String userAvatarStr, String userNameStr, - String unlockDescStr, Function() action) { + Widget _operatingOneRecordItem(String userAvatarStr, String userNameStr, String unlockDescStr, Function() action) { return GestureDetector( onTap: action, child: Container( - height: 90.h, + height: 80.h, + width: 1.sw - 10.w - 34.w - 60.w, padding: EdgeInsets.only(left: 20.w, right: 20.w), - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.circular(10.w), + // borderRadius: BorderRadius.circular(10.w), ), child: Row( + mainAxisAlignment: MainAxisAlignment.start, children: [ - Image.asset( - userAvatarStr, - width: 50.w, - height: 50.w, - ), - SizedBox( - width: 20.w, + Icon(Icons.access_time, size: 35.w), + SizedBox(width: 10.w,), + Text( + unlockDescStr, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 24.sp, + color: AppColors.darkGrayTextColor), ), + SizedBox(width: 10.h), Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - children: [ - Text( + child:Container( + margin: EdgeInsets.only(bottom: 3.w), + child: Row( + children: [ + Flexible( + child: Text( userNameStr, - style: TextStyle( - fontSize: 24.sp, color: AppColors.blackColor), - ), - ], - ), - SizedBox(height: 10.h), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - unlockDescStr, - style: TextStyle( - fontSize: 20.sp, - color: AppColors.darkGrayTextColor), - ), - ], - ), - SizedBox(width: 20.h), - ], + // "发的发生大发手动阀手动阀三大发啥打法是打发三大发啥打法是打发", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 24.sp, color: AppColors.blackColor)), + ), + ], + ), ), ), - SizedBox(width: 20.h), ], ), ), ); } + // Widget _operatingRecordItem(String userAvatarStr, String userNameStr, + // String unlockDescStr, Function() action) { + // return GestureDetector( + // onTap: action, + // child: Container( + // height: 90.h, + // padding: EdgeInsets.only(left: 20.w, right: 20.w), + // decoration: BoxDecoration( + // color: Colors.white, + // borderRadius: BorderRadius.circular(10.w), + // ), + // child: Row( + // children: [ + // Image.asset( + // userAvatarStr, + // width: 50.w, + // height: 50.w, + // ), + // SizedBox( + // width: 20.w, + // ), + // Expanded( + // child: Column( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // Row( + // children: [ + // Text( + // userNameStr, + // style: TextStyle( + // fontSize: 24.sp, color: AppColors.blackColor), + // ), + // ], + // ), + // SizedBox(height: 10.h), + // Row( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // Text( + // unlockDescStr, + // style: TextStyle( + // fontSize: 20.sp, + // color: AppColors.darkGrayTextColor), + // ), + // ], + // ), + // SizedBox(width: 20.h), + // ], + // ), + // ), + // SizedBox(width: 20.h), + // ], + // ), + // ), + // ); + // } + Future _openModalBottomSheet() async { showModalBottomSheet( context: context, diff --git a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart index 86851a31..4574189a 100644 --- a/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart +++ b/lib/main/lockDetail/lockOperatingRecord/lockOperatingRecord_state.dart @@ -14,6 +14,7 @@ class LockOperatingRecordState { var logCountPage = 10; // 蓝牙记录一页多少个 var idStr = ""; // var type = 0; // 1:密码 2:卡 3:指纹 4:人脸 5:钥匙 + var recordName = "".obs; // 记录名称 LockOperatingRecordState() { Map map = Get.arguments; @@ -26,5 +27,8 @@ class LockOperatingRecordState { if(map["type"] != null){ type = Get.arguments["type"]; } + if(map["recordName"] != null){ + recordName.value = Get.arguments["recordName"]; + } } } diff --git a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart index 09766bcd..62f4c274 100644 --- a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart @@ -48,8 +48,7 @@ class LockEscalationLogic extends BaseGetXController { //手动升级 Future otaUpdate() async { - var status = await PermissionDialog.request( - Permission.storage, '需要访问读写权限才能使用手动升级固件'.tr); + var status = await PermissionDialog.requestStorage(); if (status != true) { return; } @@ -69,8 +68,7 @@ class LockEscalationLogic extends BaseGetXController { } String md5Str = md5.convert(otaBin!).toString(); headJson!['fwMd5'] = md5Str; - ShowTipView().showIosTipWithContentDialog("升级过程中无法开锁,请先开锁后再升级".tr, - () async { + ShowTipView().showIosTipWithContentDialog("未避免异常情况,请在门打开时升级".tr, () async { blueOTAUpgrade(headJson!, [0, 0, 0, 0]); EasyLoading.show( status: '设备连接中...'.tr, maskType: EasyLoadingMaskType.black); diff --git a/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart b/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart index a05f19b8..009619ad 100644 --- a/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart +++ b/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart @@ -72,7 +72,7 @@ class _OpenDoorNotifyPageState extends State { alignment: Alignment.centerLeft, margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), child: Text( - '若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择'.tr, + '若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择。'.tr, style: TextStyle(color: AppColors.darkGrayTextColor, fontSize: 20.sp), )); } diff --git a/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index eea0b79f..b18f41ed 100644 --- a/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -5,7 +5,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; -import 'package:star_lock/tools/dateTool.dart'; import 'package:star_lock/tools/showTFView.dart'; import 'package:star_lock/tools/showTipView.dart'; @@ -104,22 +103,21 @@ class _PasswordKeyDetailPageState extends State }); if (backData != null) { state.itemData.value.startDate = - int.parse(backData["beginTimeTimestamp"]) * 1000; + int.parse(backData["beginTimeTimestamp"]); state.itemData.value.endDate = - int.parse(backData["endTimeTimestamp"]) * 1000; + int.parse(backData["endTimeTimestamp"]); // 改了日期之后,永久只能改限时的 state.itemData.value.keyboardPwdType = 3; setState(() {}); } })), - Obx(() => Visibility( - visible: state.isCirculation.value, - child: CommonItem( - leftTitel: "结束时间", - rightTitle: DateTool().dateToYMDHNString( - state.itemData.value.endDate.toString()), - isHaveLine: true), - )), + // Obx(() => Visibility( + // visible: (state.isCirculation.value == false) && (state.itemData.value.isCustom! != 1), + // child: CommonItem( + // leftTitel: "结束时间", + // rightTitle: DateTool().dateToYMDHNString(state.itemData.value.endDate.toString()), + // isHaveLine: true), + // )), Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.sender!.tr, @@ -151,12 +149,16 @@ class _PasswordKeyDetailPageState extends State rightTitle: "", isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.lockOperatingRecordPage, - arguments: { + Get.toNamed(Routers.lockOperatingRecordPage, arguments: { 'type': 1, - 'id': state.itemData.value.keyboardPwdId.toString() + 'id': state.itemData.value.keyboardPwdId.toString(), + 'recordName': state.itemData.value.keyboardPwdName }); }), + Visibility( + visible: state.itemData.value.isCustom == 0 && state.itemData.value.keyboardPwdType != 1 && state.itemData.value.keyboardPwdType != 4, + child:bottomTip() + ), Container(height: 40.h), SizedBox( width: ScreenUtil().screenWidth - 40.w, @@ -243,6 +245,27 @@ class _PasswordKeyDetailPageState extends State )); } + Widget bottomTip(){ + return Column( + children: [ + Container( + padding: EdgeInsets.all(20.w), + child: Row( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。".tr, + textAlign: TextAlign.start, + style: TextStyle(fontSize: 20.sp), + )), + ], + ), + ), + ], + ); + } + // 是否为管理员 CupertinoSwitch _isAdmin() { return CupertinoSwitch( diff --git a/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart b/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart index 1fb34418..963515a1 100644 --- a/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_state.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/network/api_repository.dart'; @@ -13,6 +14,7 @@ import '../../../../blue/io_reply.dart'; import '../../../../blue/io_tool/io_tool.dart'; import '../../../../blue/io_tool/manager_event_bus.dart'; import '../../../../blue/sender_manage.dart'; +import '../../../../tools/dateTool.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; @@ -52,10 +54,10 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController { pwdNo: state.itemData.value.pwdUserNo!, pwd: state.itemData.value.keyboardPwd!.toString(), operate: 1, - isAdmin: 0, + isAdmin: state.itemData.value.pwdUserNo!, useCountLimit: 0xffff, - startTime:state.itemData.value.startDate! ~/ 1000, - endTime:state.itemData.value.endDate! ~/ 1000, + startTime:DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1) ~/ 1000, + endTime:DateTool().dateToTimestamp(state.selectFailureDate.value, 1) ~/ 1000, needAuthor: 1, isBeforeAddUser: false, signKey: signKeyDataList, @@ -73,15 +75,15 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController { //更新密码请求 Future updatePwdRequest() async { - var beginTimeTimestamp = state.itemData.value.startDate! ~/ 1000; - var endTimeTimestamp = state.itemData.value.endDate! ~/ 1000; + var beginTimeTimestamp = DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1); + var endTimeTimestamp = DateTool().dateToTimestamp(state.selectFailureDate.value, 1); if (beginTimeTimestamp > endTimeTimestamp || beginTimeTimestamp == endTimeTimestamp) { showToast("失效时间需大于生效时间"); return; } - if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch ~/ 1000) { + if (endTimeTimestamp < DateTime.now().millisecondsSinceEpoch) { showToast("生效时间需大于当前时间"); return; } @@ -91,8 +93,8 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController { keyboardPwdId: state.itemData.value.keyboardPwdId.toString(), keyboardPwdName: state.itemData.value.keyboardPwdName!, newKeyboardPwd: state.itemData.value.keyboardPwd!, - startDate: state.itemData.value.startDate!, - endDate: state.itemData.value.endDate!, + startDate: beginTimeTimestamp, + endDate: endTimeTimestamp, changeType: '1', hoursStart: state.itemData.value.hoursStart!, hoursEnd: state.itemData.value.hoursEnd!, @@ -102,6 +104,7 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController { if (entity.errorCode!.codeIsSuccessful) { showToast("修改成功", something: (){ eventBus.fire(GetPasswordListRefreshUI()); + AppLog.log("beginTimeTimestamp:$beginTimeTimestamp endTimeTimestamp:$endTimeTimestamp"); Get.back(result: { "beginTimeTimestamp": beginTimeTimestamp.toString(), "endTimeTimestamp": endTimeTimestamp.toString(), @@ -137,8 +140,8 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController { operate: 1, isAdmin: state.itemData.value.pwdUserNo!, useCountLimit: 0xffff, - startTime:state.itemData.value.startDate! ~/ 1000, - endTime:state.itemData.value.endDate! ~/ 1000, + startTime:DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1) ~/ 1000, + endTime:DateTool().dateToTimestamp(state.selectFailureDate.value, 1) ~/ 1000, needAuthor: 1, isBeforeAddUser: false, signKey: signKeyDataList, diff --git a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index 326a0b63..71a95cbe 100644 --- a/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -272,7 +272,7 @@ class PasswordKeyListLogic extends BaseGetXController { switch (getPwdType) { case 1: //单次 1 只能在开始时间后6小时内使用一次 - useDateStr = '${sendDateStr.toLocal().toString().substring(0, 16)} ${"单次".tr}'; + useDateStr = '${startDateStr.toLocal().toString().substring(0, 16)} ${"单次".tr}'; break; case 2: //永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效 @@ -285,57 +285,57 @@ class PasswordKeyListLogic extends BaseGetXController { break; case 4: //删除 4 在锁上使用后会删除之前在锁上使用过的密码 - useDateStr = '${endDateStr.toLocal().toString().substring(0, 16)} ${"清空码".tr}'; + useDateStr = '${startDateStr.toLocal().toString().substring(0, 16)} ${"清空码".tr}'; break; case 5: //周未循环 5 在周未开始和结束时间指定时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"周末".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + '${"周末".tr}$starHour:00-$endHour:00 ${"循环".tr}'; break; case 6: //每日循环 6 每天开始和结束时间指定时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"每日".tr}$starHour:00-$endHour:00 ${"循环"}'; + '${"每日".tr}$starHour:00-$endHour:00 ${"循环"}'; break; case 7: //工作日循环 7 工作日开始和结束时间指定的时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"工作日".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + '${"工作日".tr}$starHour:00-$endHour:00 ${"循环".tr}'; break; case 8: //周一循环 8 每周一开始和结束时间指定时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"周一".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + '${"周一".tr}$starHour:00-$endHour:00 ${"循环".tr}'; break; case 9: //周二循环 9 每周二开始和结束时间指定时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"周二".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + '${"周二".tr}$starHour:00-$endHour:00 ${"循环".tr}'; break; case 10: //周三循环 10 每周三开始和结束时间指定时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"周三".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + '${"周三".tr}$starHour:00-$endHour:00 ${"循环".tr}'; break; case 11: //周四循环 11 每周四开始和结束时间指定时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"周四".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + '${"周四".tr}$starHour:00-$endHour:00 ${"循环".tr}'; break; case 12: //周五循环 12 每周五开始和结束时间指定时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"周五".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + '${"周五".tr}$starHour:00-$endHour:00 ${"循环".tr}'; break; case 13: //周六循环 13 每周六开始和结束时间指定时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"周六".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + '${"周六".tr}$starHour:00-$endHour:00 ${"循环".tr}'; break; case 14: //周天循环 14 每周日开始和结束时间指定时间段内有效 useDateStr = - '${endDateStr.toLocal().toString().substring(0, 16)} ${"周日".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + '${"周日".tr}$starHour:00-$endHour:00 ${"循环".tr}'; break; default: diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index 649cf795..48a5c689 100644 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -228,22 +228,18 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { case 0xff: // 注册人脸失败 showToast("退出添加".tr); - Get.close(1); break; case 0xFE: // 管理员已满 showToast("管理员已满".tr); - Get.close(1); break; case 0xFD: // 用户已满 showToast("用户已满".tr); - Get.close(1); break; case 0xFC: // 指纹已满 showToast("锁上面添加密码已满".tr); - Get.close(1); break; case 0xFB: // 指纹已存在 diff --git a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index af7888ab..95835bbe 100644 --- a/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -193,7 +193,7 @@ class _PasswordKeyPerpetualPageState extends State TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), keyBottomWidget( - "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。".tr) + "清空密码底部提示".tr) ], ), ); diff --git a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index abdc428b..2f5533fa 100644 --- a/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -78,7 +78,7 @@ class NearbyLockLogic extends BaseGetXController { } // 获取锁状态信息 - if (reply is GetStarLockStatuInfoReply) { + if (reply is GetStarLockStatuInfoReply && state.ifCurrentScreen.value) { _replyGetStarLockStatusInfo(reply); } @@ -431,8 +431,7 @@ class NearbyLockLogic extends BaseGetXController { //手动升级 Future otaUpdate() async { - var status = await PermissionDialog.request( - Permission.storage, '需要访问读写权限才能使用手动升级固件'.tr); + var status = await PermissionDialog.requestStorage(); if (status != true) { return; } diff --git a/lib/mine/addLock/saveLock/saveLock_logic.dart b/lib/mine/addLock/saveLock/saveLock_logic.dart index e25a940f..c7d5269a 100644 --- a/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -59,6 +59,7 @@ class SaveLockLogic extends BaseGetXController { case 0x00: //成功 如果成功保存用户编号 state.lockUserNo = listChangInt(reply.data.sublist(47, 49)); + AppLog.log("state.lockUserNo:${state.lockUserNo}"); // 关闭超时 cancelBlueConnetctToastTimer(); @@ -233,7 +234,7 @@ class SaveLockLogic extends BaseGetXController { userID: await Storage.getUid(), openMode: 1, keyType: 1, - startDate: DateTime.now().millisecondsSinceEpoch, + startDate: DateTime.now().millisecondsSinceEpoch ~/ 1000, expireDate: 0x11223344, useCountLimit: 0xFFFF, isRound: 0, diff --git a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart index bf4240ee..dc737ec3 100644 --- a/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart +++ b/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_page.dart @@ -67,8 +67,9 @@ class _AddAuthorizedAdministratorPageState : state.lockIdList.value.length.toString(), isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.massSendLockGroupPage) - .then((value) { + Navigator.pushNamed(context, Routers.massSendLockGroupListPage, arguments: { + "keyLimits":"1" + }).then((value) { //得到选中的锁ID列表 if (value != null) { value as Map; @@ -109,8 +110,9 @@ class _AddAuthorizedAdministratorPageState : state.lockIdList.value.length.toString(), isHaveDirection: true, action: () { - Navigator.pushNamed(context, Routers.massSendLockGroupPage) - .then((value) { + Navigator.pushNamed(context, Routers.massSendLockGroupListPage,arguments:{ + "keyLimits":"1", + }).then((value) { //得到选中的锁ID列表 if (value != null) { value as Map; diff --git a/lib/network/api_provider_base.dart b/lib/network/api_provider_base.dart index de87b124..aebb0e7a 100644 --- a/lib/network/api_provider_base.dart +++ b/lib/network/api_provider_base.dart @@ -35,9 +35,9 @@ class BaseProvider extends GetConnect with Api { bool? isUnShowLoading = false, // 是否显示loading bool? isUserBaseUrl = true, // 文件上传不使用baseUrl }) async { - AppLog.log("post: url:$url body:$body contentType:$contentType"); + AppLog.log("post: url:$url body:$body"); if (isUnShowLoading == false){ - AppLog.log("post: url:$url show loading"); + // AppLog.log("post: url:$url show loading"); EasyLoading.show(); } if (isUserBaseUrl == false) { diff --git a/lib/tools/advancedCalendar/src/header.dart b/lib/tools/advancedCalendar/src/header.dart index 1a09140e..026da55b 100644 --- a/lib/tools/advancedCalendar/src/header.dart +++ b/lib/tools/advancedCalendar/src/header.dart @@ -15,8 +15,7 @@ class Header extends StatelessWidget { this.todayStyle, }) : super(key: key); - static final _dateFormatter = DateFormat().add_yMMMM(); - // static final _dateFormatter = DateFormat('MM月dd日', 'zh_CN'); + static final _dateFormatter = DateFormat.yM('zh_CN'); final DateTime monthDate; final EdgeInsetsGeometry margin; final VoidCallback? onPressed; diff --git a/lib/tools/advancedCalendar/src/widget.dart b/lib/tools/advancedCalendar/src/widget.dart index 001840af..468f8fe8 100644 --- a/lib/tools/advancedCalendar/src/widget.dart +++ b/lib/tools/advancedCalendar/src/widget.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:intl/date_symbol_data_local.dart'; import 'package:intl/intl.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; @@ -24,7 +23,7 @@ class AdvancedCalendar extends StatefulWidget { this.startWeekDay, this.events, this.weekLineHeight = 32.0, - this.preloadMonthViewAmount = 13, + this.preloadMonthViewAmount = 24, //预加载的月视图 this.preloadWeekViewAmount = 21, this.weeksInMonthViewAmount = 6, this.todayStyle, diff --git a/lib/tools/baseGetXController.dart b/lib/tools/baseGetXController.dart index af626b74..4c04428c 100644 --- a/lib/tools/baseGetXController.dart +++ b/lib/tools/baseGetXController.dart @@ -66,12 +66,14 @@ class BaseGetXController extends GetxController { // CancelableOperation? _operation; void showBlueConnetctToastTimer( - {bool isShowBlueConnetctToast = true, Function? action}) { + {bool isShowBlueConnetctToast = true, + int outTimer = 15, + Function? action}) { if (_timer != null && _timer!.isActive) { _timer!.cancel(); _timer = null; } - _timer = Timer.periodic(15.seconds, (timer) { + _timer = Timer.periodic(outTimer.seconds, (timer) { if (action != null) { action(); } diff --git a/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart b/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart index ed86b3b7..0600fc56 100644 --- a/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart +++ b/lib/tools/seletKeyCyclicDate/seletKeyCyclicDate_page.dart @@ -51,9 +51,14 @@ class _SeletKeyCyclicDatePageState extends State { state.starTime.value.isNotEmpty && state.endTime.value.isNotEmpty && state.weekDay.value.isNotEmpty), - onClick: () { + onClick: (state.starDate.value.isNotEmpty && + state.endDate.value.isNotEmpty && + state.starTime.value.isNotEmpty && + state.endTime.value.isNotEmpty && + state.weekDay.value.isNotEmpty) + ? () { logic.subBtnAction(); - }), + } : null), )), ], )); diff --git a/lib/tools/showCupertinoAlertView.dart b/lib/tools/showCupertinoAlertView.dart index dd9f7336..09ee39a7 100644 --- a/lib/tools/showCupertinoAlertView.dart +++ b/lib/tools/showCupertinoAlertView.dart @@ -364,4 +364,36 @@ class ShowCupertinoAlertView { }, ); } + + //清空操作记录弹窗 + void showClearOperationRecordAlert({required Function clearClick}) { + showCupertinoDialog( + context: Get.context!, + builder: (context) { + return CupertinoAlertDialog( + title: Text('是否要删除操作记录?'.tr), + content: Text('被删除的记录不能恢复'.tr), + actions: [ + CupertinoDialogAction( + child: Text( + '取消'.tr, + style: TextStyle(color: AppColors.mainColor), + ), + onPressed: () { + Get.back(); + }, + ), + CupertinoDialogAction( + child: + Text('删除'.tr, style: TextStyle(color: AppColors.mainColor)), + onPressed: () { + Get.back(); + clearClick(); + }, + ), + ], + ); + }, + ); + } } diff --git a/lib/widget/permission/permission_dialog.dart b/lib/widget/permission/permission_dialog.dart index dabaa3df..b2f413c0 100644 --- a/lib/widget/permission/permission_dialog.dart +++ b/lib/widget/permission/permission_dialog.dart @@ -32,14 +32,30 @@ class PermissionDialog { return false; } bool application = true; - Map statuses = await [ + List permissions = [ + Permission.bluetooth, Permission.bluetoothScan, Permission.bluetoothConnect, - ].request(); + ]; + Future getPermissionStatus(List permissions) async { + bool isGranted = true; + List permissionStatus = []; + for (Permission per in permissions) { + permissionStatus.add(await per.status); + } + for (PermissionStatus per in permissionStatus) { + isGranted = isGranted && per.isGranted; + } + if (GetPlatform.isIOS) { + isGranted = permissionStatus[0].isGranted; + } + return isGranted; + } + Permission permission = Permission.bluetoothScan; dynamic cache = await Storage.getString(titles[permission]); - bool isGranted = statuses.values.every((element) => element.isGranted); - if (AppPlatform.isAndroid && !isGranted && cache is! String) { + bool isGranted = await getPermissionStatus(permissions); + if (GetPlatform.isAndroid && !isGranted && cache is! String) { application = await showCupertinoDialog( context: Get.context!, builder: (context) { @@ -69,16 +85,19 @@ class PermissionDialog { if (application) { await Storage.setString(titles[permission], titles[permission]); } - } else if (cache is String) { - bool isDenied = statuses.values.every((element) => element.isDenied); - if (isDenied) { + } else if (cache is! String) { + await Storage.setString(titles[permission], titles[permission]); + } else { + bool isGranted = await getPermissionStatus(permissions); + if (!isGranted) { showSet(permission); return false; } } if (application) { - PermissionStatus status = await permission.request(); - return status.isGranted; + await permissions.request(); + bool isGranted = await getPermissionStatus(permissions); + return isGranted; } return false; } @@ -171,6 +190,98 @@ class PermissionDialog { return false; } + //读写 + static Future requestStorage() async { + if (Get.context == null) { + return false; + } + bool isAndroid33 = + AppPlatform.isAndroid && AppPlatform.getSdkIntValue() >= 33; + + //通用的局部函数 + List requestPermission() { + List permissions; + if (isAndroid33) { + permissions = [ + Permission.mediaLibrary, + Permission.photos, + // Permission.audio, + Permission.videos, + Permission.manageExternalStorage, + ]; + } else { + permissions = [ + Permission.storage, + ]; + } + return permissions; + } + + Future permissionStatus(List permissions) async { + bool isGranted = true; + for (Permission permission in permissions) { + isGranted = + isGranted && (await permission.status) == PermissionStatus.granted; + } + if (isAndroid33) { + // android 33以上需要申请媒体库权限 + isGranted = (await Permission.mediaLibrary.status) == + PermissionStatus.granted || + (await Permission.manageExternalStorage.status) == + PermissionStatus.granted; + } + return isGranted; + } + + bool application = true; + Permission permission = Permission.photos; + List permissions = requestPermission(); + dynamic cache = await Storage.getString(titles[permission]); + bool isGranted = await permissionStatus(permissions); + if (AppPlatform.isAndroid && !isGranted && cache is! String) { + application = await showCupertinoDialog( + context: Get.context!, + builder: (context) { + return PopScope( + canPop: false, + child: CupertinoAlertDialog( + title: Text('${'申请'.tr}${titles[permission] ?? ''}${'权限'.tr}'), + content: Text('需要访问读写权限才能使用手动升级固件'.tr), + actions: [ + CupertinoDialogAction( + child: Text('不允许'.tr), + onPressed: () { + Get.back(result: false); + }, + ), + CupertinoDialogAction( + child: Text('允许'.tr), + onPressed: () { + Get.back(result: true); + }, + ), + ], + )); + }, + ); + if (application) { + await Storage.setString(titles[permission], titles[permission]); + } + } else if (cache is String) { + bool isDenied = !(await permissionStatus(permissions)); + if (isDenied) { + showSet(permission); + return false; + } + } + if (application) { + Map statuses = await permissions.request(); + bool isGranted = await permissionStatus(statuses.keys.toList()); + return isGranted; + } + return false; + } + //显示权限判断申请框 static Future request(Permission permission, [String? content]) async { if (Get.context == null) { diff --git a/pubspec.yaml b/pubspec.yaml index 9c25ad60..f5c1f26a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,8 +42,15 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # 1.0.32+2024051001:打包给欧阳回归测试 # 1.0.33+2024051401:打包给欧阳回归测试 # 1.0.34+2024051402:打包给欧阳回归测试 +# 1.0.35+2024051501:打包给欧阳回归测试 +# 1.0.36+2024051601:打包给欧阳回归测试 +# 1.0.37+2024051701:打包给欧阳回归测试 +# 1.0.38+2024051702:打包给欧阳回归测试 +# 1.0.39+2024051703:打包给欧阳回归测试 +# 1.0.40+2024051704:打包给欧阳回归测试 +# 1.0.41+2024051705:打包给公司测试 -version: 1.0.34+2024051402 +version: 1.0.41+2024051705 environment: sdk: '>=2.12.0 <3.0.0' @@ -178,6 +185,10 @@ dependencies: file_picker: ^5.3.1 +dependency_overrides: + #强制设置google_maps_flutter_ios 为 2.5.2 + google_maps_flutter_ios: 2.5.2 + dev_dependencies: flutter_test: sdk: flutter