From 0c85af9d0fa6c23661d55e4230a4c65a1bf688a7 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 15 Jun 2024 13:35:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=E6=8E=A5=E5=85=A5=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=B6=88=E6=81=AF=EF=BC=8C=E5=AE=8C=E6=88=90=E9=94=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=8A=B6=E6=80=81=E6=94=B9=E5=8F=98=E5=92=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=92=8C=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- images/lan/lan_en.json | 3 +- images/lan/lan_keys.json | 3 +- images/lan/lan_zh.json | 3 +- lib/login/login/starLock_login_logic.dart | 18 +-- .../register/starLock_register_logic.dart | 2 +- lib/main.dart | 2 +- .../lockDetail/lockDetail_logic.dart | 65 +++++++- .../lockDetail/lockDetail_page.dart | 149 ++++++++++-------- .../lockMian/entity/lockListInfo_entity.dart | 4 + .../lockMian/lockList/lockList_xhj_page.dart | 2 +- .../lockMian/lockMain/lockMain_logic.dart | 125 ++++++++++++++- lib/main/lockMian/lockMain/lockMain_page.dart | 112 +++++++------ lib/mine/mineSet/mineSet/mineSet_logic.dart | 2 +- lib/nav/navBinding.dart | 11 -- lib/nav/navLogic.dart | 6 - lib/nav/navPages.dart | 82 ---------- lib/network/api_provider.dart | 5 +- lib/network/api_repository.dart | 7 + lib/tools/appFirstEnterHandle.dart | 2 +- lib/tools/commonDataManage.dart | 14 +- lib/tools/eventBusEventManage.dart | 74 ++++++--- lib/tools/push/message_constant.dart | 10 ++ lib/tools/push/message_management.dart | 67 ++++++++ lib/tools/{ => push}/xs_jPhush.dart | 4 +- 24 files changed, 493 insertions(+), 279 deletions(-) delete mode 100755 lib/nav/navBinding.dart delete mode 100755 lib/nav/navLogic.dart delete mode 100755 lib/nav/navPages.dart create mode 100644 lib/tools/push/message_constant.dart create mode 100644 lib/tools/push/message_management.dart rename lib/tools/{ => push}/xs_jPhush.dart (96%) diff --git a/images/lan/lan_en.json b/images/lan/lan_en.json index f902422b..49195924 100755 --- a/images/lan/lan_en.json +++ b/images/lan/lan_en.json @@ -885,5 +885,6 @@ "请输入时间(秒)": "Please enter the time (seconds)", "加载数据失败": "Failed to load data", "重试": "Retry", - "升级中,是否退出": "During the upgrade, whether to exit" + "升级中,是否退出": "During the upgrade, whether to exit", + "该已锁被删除": "The locked is deleted" } diff --git a/images/lan/lan_keys.json b/images/lan/lan_keys.json index 8f5845a0..47e06154 100755 --- a/images/lan/lan_keys.json +++ b/images/lan/lan_keys.json @@ -917,5 +917,6 @@ "请输入时间(秒)": "请输入时间(秒)", "加载数据失败": "加载数据失败", "重试": "重试", - "升级中,是否退出": "升级中,是否退出" + "升级中,是否退出": "升级中,是否退出", + "该已锁被删除": "该已锁被删除" } diff --git a/images/lan/lan_zh.json b/images/lan/lan_zh.json index 12c79ae2..8d414f53 100755 --- a/images/lan/lan_zh.json +++ b/images/lan/lan_zh.json @@ -883,5 +883,6 @@ "请输入时间(秒)": "请输入时间(秒)", "加载数据失败": "加载数据失败", "重试": "重试", - "升级中,是否退出": "升级中,是否退出" + "升级中,是否退出": "升级中,是否退出", + "该已锁被删除": "该已锁被删除" } diff --git a/lib/login/login/starLock_login_logic.dart b/lib/login/login/starLock_login_logic.dart index f91a8646..6a82a6c9 100755 --- a/lib/login/login/starLock_login_logic.dart +++ b/lib/login/login/starLock_login_logic.dart @@ -9,7 +9,7 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/mine/mine/starLockMine_state.dart'; import 'package:star_lock/tools/baseGetXController.dart'; -import 'package:star_lock/tools/xs_jPhush.dart'; +import 'package:star_lock/tools/push/xs_jPhush.dart'; import '../../mine/mine/starLockMine_logic.dart'; import '../../network/api_repository.dart'; @@ -48,7 +48,7 @@ class StarLockLoginLogic extends BaseGetXController { password: state.pwd.value, countryCode: state.countryCode.value, username: state.emailOrPhone.value, - deviceInfo: state.deviceInfoMap.value); + deviceInfo: state.deviceInfoMap); if (entity.errorCode!.codeIsSuccessful) { Storage.saveLoginData(entity.data); Storage.setBool(saveIsVip, entity.data!.isVip == 1); @@ -61,12 +61,13 @@ class StarLockLoginLogic extends BaseGetXController { } Future checkIpAction() async { - final CheckIPEntity entity = await ApiRepository.to.checkIpAction( - ip: '' - ); + final CheckIPEntity entity = await ApiRepository.to.checkIpAction(ip: ''); if (entity.errorCode!.codeIsSuccessful) { - if(state.countryName.value == entity.data!.name){ - ShowTipView().showSureAlertDialog('国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续'.tr, tipTitle: '确认国家或地区'.tr, sureStr: '我知道了'.tr); + if (state.countryName.value == entity.data!.name) { + ShowTipView().showSureAlertDialog( + '国家地区的选择将影响数据安全,你当前选择的是阿尔巴尼亚,请确认后再继续'.tr, + tipTitle: '确认国家或地区'.tr, + sureStr: '我知道了'.tr); } } } @@ -103,7 +104,7 @@ class StarLockLoginLogic extends BaseGetXController { } //刷新设备信息 - void flushedDeviceInfo(){ + void flushedDeviceInfo() { XSConstantMacro().getDeviceInfoData().then((Map data) { state.deviceInfoMap.value = data; }).catchError((dynamic error) { @@ -111,5 +112,4 @@ class StarLockLoginLogic extends BaseGetXController { AppLog.log('获取设备信息时出错: $error'); }); } - } diff --git a/lib/login/register/starLock_register_logic.dart b/lib/login/register/starLock_register_logic.dart index e19b5be7..4ecce101 100755 --- a/lib/login/register/starLock_register_logic.dart +++ b/lib/login/register/starLock_register_logic.dart @@ -11,7 +11,7 @@ import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/login/register/entity/SendValidationCodeEntity.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; import 'package:star_lock/tools/storage.dart'; -import 'package:star_lock/tools/xs_jPhush.dart'; +import 'package:star_lock/tools/push/xs_jPhush.dart'; import '../../network/api_repository.dart'; import '../../tools/baseGetXController.dart'; diff --git a/lib/main.dart b/lib/main.dart index 612b0694..d68c857f 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,7 +14,7 @@ import 'package:star_lock/tools/device_info_service.dart'; import 'package:star_lock/tools/pay/wx_pay_tool.dart'; import 'package:star_lock/tools/platform_info_services.dart'; import 'package:star_lock/tools/storage.dart'; -import 'package:star_lock/tools/xs_jPhush.dart'; +import 'package:star_lock/tools/push/xs_jPhush.dart'; import 'package:star_lock/translations/trans_lib.dart'; import 'app.dart'; diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 1f324ede..4081e77a 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -9,6 +9,7 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; +import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import 'package:star_lock/tools/throttler.dart'; import 'package:star_lock/widget/permission/permission_dialog.dart'; @@ -174,6 +175,66 @@ class LockDetailLogic extends BaseGetXController { } } + + Future loadData({ required LockListInfoItemEntity lockListInfoItemEntity,required bool isOnlyOneData}) async { + state.keyInfos.value = lockListInfoItemEntity; + CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!; + CommonDataManage().currentKeyInfo = state.keyInfos.value; + + state.lockUserNo = state.keyInfos.value.lockUserNo!; + + if (state.keyInfos.value.keyStatus == + XSConstantMacro.keyStatusWaitIneffective || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen || + state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || + 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 = isOnlyOneData; + state.senderUserId = state.keyInfos.value.senderUserId!; + state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!; + state.isOpenLockNeedOnline.value = + state.keyInfos.value.lockSetting!.appUnlockOnline!; + state.electricQuantity.value = state.keyInfos.value.electricQuantity!; + state.isOpenPassageMode.value = state.keyInfos.value.passageMode!; + state.lockAlias.value = state.keyInfos.value.lockAlias!; + Storage.setString(saveLockAlias, state.lockAlias.value); + + BlueManage().connectDeviceName = + state.keyInfos.value.bluetooth!.bluetoothDeviceName!; + + final List publicKeyData = + state.keyInfos.value.bluetooth!.publicKey!.cast(); + final List saveStrList = changeIntListToStringList(publicKeyData); + Storage.setStringList(saveBluePublicKey, saveStrList); + + // 私钥 + final List privateKeyData = + state.keyInfos.value.bluetooth!.privateKey!.cast(); + final List savePrivateKeyList = + changeIntListToStringList(privateKeyData); + Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); + + // signKey + final List signKeyData = + state.keyInfos.value.bluetooth!.signKey!.cast(); + final List saveSignKeyList = changeIntListToStringList(signKeyData); + Storage.setStringList(saveBlueSignKey, saveSignKeyList); + + final bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken); + if (!ifHaveKey) { + final List saveTokenList = + changeIntListToStringList([0, 0, 0, 0]); + Storage.setStringList(saveBlueToken, saveTokenList); + } + } + //开门指令失败 void openDoorError() { resetOpenDoorState(); @@ -184,7 +245,7 @@ class LockDetailLogic extends BaseGetXController { //清除开锁动画以及状态 void closeLuckStatus() { state.openLockBtnState.value = 0; - state.openDoorBtnisUneable.value = true; + // state.openDoorBtnisUneable.value = true; state.animationController!.stop(canceled: true); cancelBlueConnetctToastTimer(); } @@ -516,7 +577,7 @@ class LockDetailLogic extends BaseGetXController { void resetOpenDoorState() { state.openLockBtnState.value = 0; - state.openDoorBtnisUneable.value = false; + // state.openDoorBtnisUneable.value = false; state.animationController?.reset(); state.animationController?.forward(); eventBus.fire(RefreshLockDetailInfoDataEvent()); diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 196d7ba6..08e6a153 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -46,6 +46,7 @@ class _LockDetailPageState extends State // with RouteAware final LockDetailLogic logic = Get.put(LockDetailLogic()); final LockDetailState state = Get.find().state; + StreamSubscription? _lockRefreshLockDetailInfoDataEvent; @override void initState() { @@ -60,6 +61,16 @@ class _LockDetailPageState extends State _initRefreshLockDetailInfoDataEventAction(); logic.initReplySubscription(); logic.initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction(); + + logic.loadData( + lockListInfoItemEntity: widget.lockListInfoItemEntity, + isOnlyOneData: widget.isOnlyOneData); + } + + @override + void deactivate() { + Get.delete(); + super.deactivate(); } @override @@ -70,8 +81,6 @@ class _LockDetailPageState extends State AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); } - StreamSubscription? _lockRefreshLockDetailInfoDataEvent; - void _initRefreshLockDetailInfoDataEventAction() { // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus _lockRefreshLockDetailInfoDataEvent = eventBus @@ -81,68 +90,8 @@ class _LockDetailPageState extends State }); } - Future loadData() async { - state.keyInfos.value = widget.lockListInfoItemEntity; - CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!; - CommonDataManage().currentKeyInfo = state.keyInfos.value; - - state.lockUserNo = state.keyInfos.value.lockUserNo!; - - if (state.keyInfos.value.keyStatus == - XSConstantMacro.keyStatusWaitIneffective || - state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusFrozen || - state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || - 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; - state.senderUserId = state.keyInfos.value.senderUserId!; - state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!; - state.isOpenLockNeedOnline.value = - state.keyInfos.value.lockSetting!.appUnlockOnline!; - state.electricQuantity.value = state.keyInfos.value.electricQuantity!; - state.isOpenPassageMode.value = state.keyInfos.value.passageMode!; - state.lockAlias.value = state.keyInfos.value.lockAlias!; - Storage.setString(saveLockAlias, state.lockAlias.value); - - BlueManage().connectDeviceName = - state.keyInfos.value.bluetooth!.bluetoothDeviceName!; - - final List publicKeyData = - state.keyInfos.value.bluetooth!.publicKey!.cast(); - final List saveStrList = changeIntListToStringList(publicKeyData); - Storage.setStringList(saveBluePublicKey, saveStrList); - - // 私钥 - final List privateKeyData = - state.keyInfos.value.bluetooth!.privateKey!.cast(); - final List savePrivateKeyList = - changeIntListToStringList(privateKeyData); - Storage.setStringList(saveBluePrivateKey, savePrivateKeyList); - - // signKey - final List signKeyData = - state.keyInfos.value.bluetooth!.signKey!.cast(); - final List saveSignKeyList = changeIntListToStringList(signKeyData); - Storage.setStringList(saveBlueSignKey, saveSignKeyList); - - final bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken); - if (!ifHaveKey) { - final List saveTokenList = - changeIntListToStringList([0, 0, 0, 0]); - Storage.setStringList(saveBlueToken, saveTokenList); - } - } - @override Widget build(BuildContext context) { - loadData(); return F.sw(skyCall: skWidget, xhjCall: xhjWidget); } @@ -175,10 +124,16 @@ class _LockDetailPageState extends State height: 35.h, ), labelText('images/icon_slider_horizontal.png', '功能'.tr, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.to(LockDetailListPage( title: '功能'.tr, items: getBottomWidget())); }), labelText('images/icon_puzzlepiece_extension.png', '配件'.tr, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.to(LockDetailListPage( title: '配件'.tr, items: getAttachmentWidget())); }), @@ -365,7 +320,7 @@ class _LockDetailPageState extends State Icon( Icons.bluetooth_searching, size: 78.r, - color: AppColors.mainColor.withOpacity(0.6), + color: AppColors.wifiDisableColor.withOpacity(0.7), ) else Image.asset( @@ -388,7 +343,7 @@ class _LockDetailPageState extends State width: 168.r, height: 168.r, color: state.openDoorBtnisUneable.value == false - ? AppColors.mainColor.withOpacity(0.6) + ? AppColors.wifiDisableColor.withOpacity(0.7) : state.isOpenPassageMode.value == 1 ? Colors.red : AppColors.mainColor, @@ -407,8 +362,7 @@ class _LockDetailPageState extends State crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - TranslationLoader - .lanKeys!.clickUnlockAndHoldDownClose!.tr, + logic.getKeyStatusTextAndShow(), style: TextStyle( color: AppColors.darkGrayTextColor, fontSize: 20.sp, @@ -677,6 +631,9 @@ class _LockDetailPageState extends State state.keyInfos.value.lockSetting!.remoteUnlock == 1, child: GestureDetector( onTap: () { + if (state.openDoorBtnisUneable.value == false) { + return; + } ShowCupertinoAlertView().isToRemoteUnLockAlert( remoteUnlockAction: () { if (state.keyInfos.value.hasGateway != 1) { @@ -793,6 +750,9 @@ class _LockDetailPageState extends State const Spacer(), GestureDetector( onTap: () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.selectLockTypePage); }, child: Padding( @@ -926,6 +886,9 @@ class _LockDetailPageState extends State // 新增配件 showWidgetArr.add(bottomItem('images/main/icon_main_addLock.png', '新增配件'.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Navigator.pushNamed(context, Routers.accessoriesListPage); })); @@ -965,6 +928,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_clockingIn.png', TranslationLoader.lanKeys!.checkingIn!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.checkingInListPage, arguments: state.keyInfos.value); })); @@ -974,6 +940,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.doorLockLogPage, arguments: { 'keyInfo': state.keyInfos.value @@ -983,6 +952,9 @@ class _LockDetailPageState extends State // 设置 showWidgetArr.add(bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, true, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.lockSetPage, arguments: { 'lockId': state.keyInfos.value.lockId, 'isOnlyOneData': state.isOnlyOneData @@ -1001,6 +973,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_clockingIn.png', TranslationLoader.lanKeys!.checkingIn!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.checkingInListPage, arguments: state.keyInfos.value); })); @@ -1011,6 +986,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_electronicKey.png', TranslationLoader.lanKeys!.electronicKey!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.electronicKeyListPage); })); @@ -1019,6 +997,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_password.png', TranslationLoader.lanKeys!.password!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.passwordKeyListPage, arguments: { 'keyInfo': state.keyInfos.value @@ -1031,6 +1012,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_icCard.png', TranslationLoader.lanKeys!.card!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.cardListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1043,6 +1027,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_fingerprint.png', TranslationLoader.lanKeys!.fingerprint!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.fingerprintListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1055,6 +1042,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_remoteControl.png', TranslationLoader.lanKeys!.remoteControl!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.remoteControlListPage); })); } @@ -1066,6 +1056,9 @@ class _LockDetailPageState extends State 'images/main/icon_face.png', TranslationLoader.lanKeys!.humanFace!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.faceListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1078,6 +1071,9 @@ class _LockDetailPageState extends State bottomItem( 'images/main/icon_iris.png', '虹膜'.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.irisListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1090,6 +1086,9 @@ class _LockDetailPageState extends State bottomItem( 'images/main/icon_palm.png', '手掌'.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.palmListPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1104,6 +1103,9 @@ class _LockDetailPageState extends State 'images/main/icon_catEyes.png', TranslationLoader.lanKeys!.monitoring!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.realTimePicturePage, arguments: { 'lockName': state.keyInfos.value.lockName, 'isMonitoring': true @@ -1118,6 +1120,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_authorizedAdmin.png', TranslationLoader.lanKeys!.authorizedAdmin!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.authorizedAdminListPage, arguments: { 'keyInfo': state.keyInfos.value @@ -1132,6 +1137,9 @@ class _LockDetailPageState extends State 'images/main/icon_main_operatingRecord.png', TranslationLoader.lanKeys!.operatingRecord!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } // Get.toNamed(Routers.lockOperatingRecordPage, // arguments: {"keyInfo": state.keyInfos.value}); Get.toNamed(Routers.doorLockLogPage, @@ -1147,6 +1155,9 @@ class _LockDetailPageState extends State 'images/main/icon_lockDetail_videoLog.png', TranslationLoader.lanKeys!.videoLog!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.videoLogPage, arguments: { 'lockId': state.keyInfos.value.lockId, }); @@ -1158,6 +1169,9 @@ class _LockDetailPageState extends State 'images/main/icon_lockDetail_messageReminding.png', TranslationLoader.lanKeys!.messageReminding!.tr, state.bottomBtnisEable.value, () { + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.msgNotificationPage, arguments: { 'lockId': state.keyInfos.value.lockId, 'isSupportCatEye': state.keyInfos.value.lockFeature!.isSupportCatEye, @@ -1170,6 +1184,9 @@ class _LockDetailPageState extends State bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, true, () { // logic.clickItemBtnAction(10); + if (state.openDoorBtnisUneable.value == false) { + return; + } Get.toNamed(Routers.lockSetPage, arguments: { 'lockId': state.keyInfos.value.lockId, 'isOnlyOneData': state.isOnlyOneData, diff --git a/lib/main/lockMian/entity/lockListInfo_entity.dart b/lib/main/lockMian/entity/lockListInfo_entity.dart index ecb49bbd..7e1cae0d 100755 --- a/lib/main/lockMian/entity/lockListInfo_entity.dart +++ b/lib/main/lockMian/entity/lockListInfo_entity.dart @@ -143,6 +143,7 @@ class LockListInfoItemEntity { int? hasGateway; int? appUnlockOnline; String? mac; + int? updateDate; LockListInfoItemEntity({ this.keyId, @@ -180,6 +181,7 @@ class LockListInfoItemEntity { this.hasGateway, this.appUnlockOnline, this.mac, + this.updateDate, }); LockListInfoItemEntity.fromJson(Map json) { @@ -224,6 +226,7 @@ class LockListInfoItemEntity { hasGateway = json['hasGateway']; appUnlockOnline = json['appUnlockOnline']; mac = json['mac']; + updateDate = json['updateDate']; } Map toJson() { @@ -269,6 +272,7 @@ class LockListInfoItemEntity { data['hasGateway'] = hasGateway; data['appUnlockOnline'] = appUnlockOnline; data['mac'] = mac; + data['updateDate'] = updateDate; return data; } diff --git a/lib/main/lockMian/lockList/lockList_xhj_page.dart b/lib/main/lockMian/lockList/lockList_xhj_page.dart index 3ffd4e5c..c86fdaaa 100755 --- a/lib/main/lockMian/lockList/lockList_xhj_page.dart +++ b/lib/main/lockMian/lockList/lockList_xhj_page.dart @@ -182,7 +182,7 @@ class _LockListXHJPageState extends State with RouteAware { isLast = true; } list.add(Slidable( - key: ValueKey(keyInfo.keyId), + key: ValueKey('${keyInfo.keyId}_${keyInfo.updateDate}'), endActionPane: ActionPane( extentRatio: 0.5, motion: const ScrollMotion(), diff --git a/lib/main/lockMian/lockMain/lockMain_logic.dart b/lib/main/lockMian/lockMain/lockMain_logic.dart index 94459e55..94838b61 100755 --- a/lib/main/lockMian/lockMain/lockMain_logic.dart +++ b/lib/main/lockMian/lockMain/lockMain_logic.dart @@ -1,10 +1,16 @@ import 'dart:async'; import 'dart:io'; import 'package:connectivity_plus/connectivity_plus.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/flavors.dart'; +import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart'; import 'package:star_lock/main/lockMian/lockList/lockList_logic.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; import 'package:star_lock/tools/showTipView.dart'; import '../../../app_settings/app_settings.dart'; @@ -18,6 +24,8 @@ import 'lockMain_state.dart'; class LockMainLogic extends BaseGetXController { final LockMainState state = LockMainState(); + final List> _subscriptions = + >[]; Future getStarLockInfo( {bool isUnShowLoading = false}) async { @@ -29,13 +37,14 @@ class LockMainLogic extends BaseGetXController { ); if (entity.errorCode!.codeIsSuccessful) { loadMainDataLogic(entity.data!); - Storage.saveMainListData(entity.data!); } return entity; } void loadMainDataLogic(LockListInfoGroupEntity entity) { - if (entity.groupList!.isEmpty) { + final bool every = entity.groupList!.every((GroupList list) => + (list.lockList ?? []).isEmpty); + if (entity.groupList!.isEmpty || every) { state.dataLength.value = 0; } else if (entity.groupList!.length == 1) { final GroupList groupList = entity.groupList![0]; @@ -61,12 +70,13 @@ class LockMainLogic extends BaseGetXController { } }); } + Storage.saveMainListData(entity); } /// 获取联网类型 - void getConnectType() async { + Future getConnectType() async { final ConnectivityResult connectResult = - await (Connectivity().checkConnectivity()); + await Connectivity().checkConnectivity(); if (connectResult == ConnectivityResult.mobile) { // _netType = "4G"; state.networkConnectionStatus.value = 1; @@ -133,6 +143,109 @@ class LockMainLogic extends BaseGetXController { } } + //刷新锁设备 + Future flushedStarLockInfo(int keyId, int lockId) async { + final LockListInfoEntity entity = await ApiRepository.to.getStarLockInfo( + keyId: keyId, + ); + if (entity.errorCode!.codeIsSuccessful) { + state.lockListInfoGroupEntity.value.groupList ??= []; + final GroupList list = entity.data!.groupList!.first; + final LockListInfoItemEntity listItem = + entity.data!.groupList!.first.lockList!.first; + final int groupIndex = state.lockListInfoGroupEntity.value.groupList + ?.indexWhere( + (GroupList group) => group.groupId == list.groupId) ?? + -1; + if (groupIndex != -1) { + //已存在 + state.lockListInfoGroupEntity.value.groupList![groupIndex].lockList ??= + []; + final List lockList = state + .lockListInfoGroupEntity.value.groupList![groupIndex].lockList!; + + list.lockList ??= []; + final int keyIndex = lockList.indexWhere( + (LockListInfoItemEntity lock) => lock.keyId == keyId) ?? + -1; + if (keyIndex != -1) { + //已存在 + + lockList.removeAt(keyIndex); + lockList.insert(keyIndex, listItem); + if (Get.isRegistered()) { + final bool isOnlyOneData = + F.sw(xhjCall: () => false, skyCall: () => lockList.length > 1); + Get.find().loadData( + lockListInfoItemEntity: listItem, isOnlyOneData: isOnlyOneData); + } + } else { + //新增 + lockList.insert(0, listItem); + } + } else { + //新增 + state.lockListInfoGroupEntity.value.groupList!.insert(0, list); + } + state.lockListInfoGroupEntity.refresh(); + loadMainDataLogic(state.lockListInfoGroupEntity.value); + } + update(); + } + + //删除锁设备 + Future deleteStarLockInfo(int keyId, int lockId) async { + state.lockListInfoGroupEntity.value.groupList + ?.forEach((GroupList groupList) { + groupList.lockList + ?.removeWhere((LockListInfoItemEntity lock) => lock.keyId == keyId); + }); + state.lockListInfoGroupEntity.refresh(); + loadMainDataLogic(state.lockListInfoGroupEntity.value); + if (Get.isRegistered()) { + final bool isKey = + Get.find().state.keyInfos.value.keyId == keyId; + if (isKey) { + //判断当前是否为当前锁 + EasyLoading.showToast('该已锁被删除'.tr, duration: 3.seconds); + Get.until((Route route) => + route.settings.name == Routers.starLockMain); + } + } + update(); + } + + //初始化订阅 + void _initSubscription() { + _subscriptions.add(eventBus + .on() + .listen((RefreshLockInfoDataEvent event) { + //锁设备刷新 + flushedStarLockInfo( + event.keyId, + event.lockId, + ); + })); + _subscriptions.add(eventBus + .on() + .listen((DeleteLockInfoDataEvent event) { + //锁设备删除 + deleteStarLockInfo( + event.keyId, + event.lockId, + ); + })); + _subscriptions.add(eventBus + .on() + .listen((RogerThatLockInfoDataEvent event) { + //锁设备新增 + flushedStarLockInfo( + event.keyId, + event.lockId, + ); + })); + } + @override void onReady() { super.onReady(); @@ -145,10 +258,14 @@ class LockMainLogic extends BaseGetXController { void onInit() { super.onInit(); checkWhetherPushIsEnabled(); + _initSubscription(); } @override void onClose() { + _subscriptions.forEach((StreamSubscription subscription) { + subscription.cancel(); + }); super.onClose(); } } diff --git a/lib/main/lockMian/lockMain/lockMain_page.dart b/lib/main/lockMian/lockMain/lockMain_page.dart index 22aa7e6e..b5532c6a 100755 --- a/lib/main/lockMian/lockMain/lockMain_page.dart +++ b/lib/main/lockMian/lockMain/lockMain_page.dart @@ -75,60 +75,62 @@ class _StarLockMainPageState extends State @override Widget build(BuildContext context) { - Widget child = EasyRefreshTool( - onRefresh: () { - SchedulerBinding.instance.addPostFrameCallback((_) { - // 更新状态的代码 - logic.pageNo = 1; - getHttpData(); - }); - }, - // child: getDataReturnUI(state.dataLength.value)); - child: getDataReturnUI(state.dataLength.value)); - if (widget.showAppBar || widget.showDrawer) { - child = Scaffold( - backgroundColor: const Color(0xFFF5F5F5), - appBar: widget.showAppBar - ? TitleAppBar( - barTitle: F.navTitle, - haveBack: false, - haveOtherLeftWidget: true, - leftWidget: Builder( - builder: (BuildContext context) => IconButton( - icon: Image.asset( - 'images/main/mainLeft_menu_icon.png', - color: Colors.white, - width: 44.w, - height: 44.w, - ), - onPressed: () { - Scaffold.of(context).openDrawer(); - }, - )), - backgroundColor: AppColors.mainColor, - ) - : null, - drawer: widget.showDrawer - ? Drawer( - width: 1.sw / 3 * 2, - child: const StarLockMinePage(), - ) - : null, - body: child, - ); - } - child = F.sw( - skyCall: () => child, - xhjCall: () => Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage('images/xhj_main_bg.jpg'), - fit: BoxFit.cover, + return GetBuilder(builder: (LockMainLogic logic) { + Widget child = EasyRefreshTool( + onRefresh: () { + SchedulerBinding.instance.addPostFrameCallback((_) { + // 更新状态的代码 + logic.pageNo = 1; + getHttpData(); + }); + }, + // child: getDataReturnUI(state.dataLength.value)); + child: getDataReturnUI(state.dataLength.value)); + if (widget.showAppBar || widget.showDrawer) { + child = Scaffold( + backgroundColor: const Color(0xFFF5F5F5), + appBar: widget.showAppBar + ? TitleAppBar( + barTitle: F.navTitle, + haveBack: false, + haveOtherLeftWidget: true, + leftWidget: Builder( + builder: (BuildContext context) => IconButton( + icon: Image.asset( + 'images/main/mainLeft_menu_icon.png', + color: Colors.white, + width: 44.w, + height: 44.w, + ), + onPressed: () { + Scaffold.of(context).openDrawer(); + }, + )), + backgroundColor: AppColors.mainColor, + ) + : null, + drawer: widget.showDrawer + ? Drawer( + width: 1.sw / 3 * 2, + child: const StarLockMinePage(), + ) + : null, + body: child, + ); + } + child = F.sw( + skyCall: () => child, + xhjCall: () => Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage('images/xhj_main_bg.jpg'), + fit: BoxFit.cover, + ), ), - ), - child: child, - )); - return child; + child: child, + )); + return child; + }); } Widget getDataReturnUI(int type) { @@ -232,10 +234,6 @@ class _StarLockMainPageState extends State ); } - void onShow() {} - - void onHide() {} - late StreamSubscription _teamEvent; void _initLoadDataAction() { diff --git a/lib/mine/mineSet/mineSet/mineSet_logic.dart b/lib/mine/mineSet/mineSet/mineSet_logic.dart index 18bb111b..ba045239 100755 --- a/lib/mine/mineSet/mineSet/mineSet_logic.dart +++ b/lib/mine/mineSet/mineSet/mineSet_logic.dart @@ -8,7 +8,7 @@ import 'package:star_lock/mine/mineSet/mineSet/mineSet_state.dart'; import 'package:star_lock/mine/mineSet/mineSet/weChatQRCodeEntity.dart'; import 'package:star_lock/tools/showCupertinoAlertView.dart'; import 'package:star_lock/tools/storage.dart'; -import 'package:star_lock/tools/xs_jPhush.dart'; +import 'package:star_lock/tools/push/xs_jPhush.dart'; import 'package:star_lock/versionUndate/versionUndate_entity.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; diff --git a/lib/nav/navBinding.dart b/lib/nav/navBinding.dart deleted file mode 100755 index 49ec13ab..00000000 --- a/lib/nav/navBinding.dart +++ /dev/null @@ -1,11 +0,0 @@ - -import 'package:get/get.dart'; - -import 'navLogic.dart'; - -class NavBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut(() => NavLogic()); - } -} \ No newline at end of file diff --git a/lib/nav/navLogic.dart b/lib/nav/navLogic.dart deleted file mode 100755 index ed2bd480..00000000 --- a/lib/nav/navLogic.dart +++ /dev/null @@ -1,6 +0,0 @@ - -import '../tools/baseGetXController.dart'; - -class NavLogic extends BaseGetXController { - -} \ No newline at end of file diff --git a/lib/nav/navPages.dart b/lib/nav/navPages.dart deleted file mode 100755 index b4f1ddbd..00000000 --- a/lib/nav/navPages.dart +++ /dev/null @@ -1,82 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:star_lock/mine/mine/starLockMine_page.dart'; - -import '../app_settings/app_colors.dart'; -import '../main/lockMian/lockMain/lockMain_page.dart'; - -class NavPages extends StatefulWidget { - const NavPages({Key? key}) : super(key: key); - - @override - State createState() => _NavPagesState(); -} - -class _NavPagesState extends State { - int _currentIndex = 0; - final List _listPage = [ - StarLockMainPage(), - // StarLockMinePage(key: starLockMineKey), - ]; - - @override - Widget build(BuildContext context) { - var sp; - return Scaffold( - body: IndexedStack( - /// 在这里修改 - // index: _currentIndex, - children: _listPage, - ), - // bottomNavigationBar: BottomNavigationBar( - // elevation: 0.0, - // selectedFontSize: 24.sp, - // unselectedFontSize: 24.sp, - // type: BottomNavigationBarType.fixed, - // selectedItemColor: AppColors.mainColor, - // backgroundColor: Colors.white, - // currentIndex: _currentIndex, //对应点击/显示哪个底部导航栏按钮 - // onTap: (index) { - // //bottomNavigationBar的点击事件 - // if (_currentIndex == index) { - // return; - // } - // setState(() { - // _currentIndex = index; //将选中的下标进行替换 - // }); - // if (_currentIndex == 0) { - // starLockMainKey.currentState?.onShow(); - // starLockMineKey.currentState?.onHide(); - // } else if (_currentIndex == 1) { - // starLockMainKey.currentState?.onHide(); - // starLockMineKey.currentState?.onShow(); - // } - // }, - // items: [ - // BottomNavigationBarItem( - // icon: SizedBox( - // width: 56.w, - // height: 56.w, - // child: Image.asset( - // _currentIndex == 0 - // ? 'images/tabbar/icon_tab_main_select.png' - // : 'images/tabbar/icon_tab_main_unselect.png', - // fit: BoxFit.cover), - // ), - // label: '首页'), - // BottomNavigationBarItem( - // icon: SizedBox( - // width: 56.w, - // height: 56.w, - // child: Image.asset( - // _currentIndex == 1 - // ? 'images/tabbar/icon_tab_my_select.png' - // : 'images/tabbar/icon_tab_my_unselect.png', - // fit: BoxFit.cover), - // ), - // label: '我的'), - // ], - // ), - ); - } -} diff --git a/lib/network/api_provider.dart b/lib/network/api_provider.dart index 6bf76bb6..6ac915cc 100755 --- a/lib/network/api_provider.dart +++ b/lib/network/api_provider.dart @@ -389,12 +389,13 @@ class ApiProvider extends BaseProvider { // 获取锁信息列表 Future getStarLockListInfo(int pageNo, int pageSize, - {bool isUnShowLoading = true}) => + {bool isUnShowLoading = true, int? keyId,}) => post( getStarLockInfoURL.toUrl, - jsonEncode({ + jsonEncode({ 'pageNo': pageNo, 'pageSize': pageSize, + 'keyId': keyId, }), isUnShowLoading: isUnShowLoading); diff --git a/lib/network/api_repository.dart b/lib/network/api_repository.dart index b7a46ad1..c55e6fd8 100755 --- a/lib/network/api_repository.dart +++ b/lib/network/api_repository.dart @@ -457,6 +457,13 @@ class ApiRepository { return LockListInfoEntity.fromJson(res.body); } + // 获取锁信息列表 + Future getStarLockInfo({required int keyId}) async { + final res = await apiProvider.getStarLockListInfo(1, 20, + isUnShowLoading: true, keyId: keyId); + return LockListInfoEntity.fromJson(res.body); + } + // 获取所有锁设置信息 Future getLockSettingInfoData( {required String lockId}) async { diff --git a/lib/tools/appFirstEnterHandle.dart b/lib/tools/appFirstEnterHandle.dart index bdc10af1..8699f57a 100755 --- a/lib/tools/appFirstEnterHandle.dart +++ b/lib/tools/appFirstEnterHandle.dart @@ -19,7 +19,7 @@ import 'package:star_lock/tools/storage.dart'; import '../versionUndate/versionUndateTool.dart'; import 'bugly/bugly_tool.dart'; -import 'xs_jPhush.dart'; +import 'push/xs_jPhush.dart'; class AppFirstEnterHandle { Future getAppFirstEnter(String flagStr) async { diff --git a/lib/tools/commonDataManage.dart b/lib/tools/commonDataManage.dart index 4703000b..5a06c176 100755 --- a/lib/tools/commonDataManage.dart +++ b/lib/tools/commonDataManage.dart @@ -1,4 +1,3 @@ - // 实现一个CommonDataManage的单例,用来管理项目中使用的一些公共数据 import 'package:get/get.dart'; @@ -6,9 +5,10 @@ import '../main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import '../main/lockMian/entity/lockListInfo_entity.dart'; class CommonDataManage { - factory CommonDataManage() => shareManager()!; + CommonDataManage._init(); + static CommonDataManage? _manager; static CommonDataManage? shareManager() { @@ -16,27 +16,29 @@ class CommonDataManage { // _manager!._initBlue(); return _manager; } + CommonDataManage? get manager => shareManager(); // 首页列表锁长度 final RxInt _mainLockCount = 0.obs; + set setMainLockCount(int v) => _mainLockCount.value = v; - get getMainLockCount => _mainLockCount; + + RxInt get getMainLockCount => _mainLockCount; // 锁信息 LockListInfoItemEntity currentKeyInfo = LockListInfoItemEntity(); // 当前锁的用户编号 int currentLockUserNo = 0; + // set setCurrentLockUserNo(int v) => _currentLockUserNo = v; // get getCurrentLockUserNo => _currentLockUserNo; LockSetInfoData currentLockSetInfoData = LockSetInfoData(); - int dayLatestTime = (86400-1)*1000; + int dayLatestTime = (86400 - 1) * 1000; // 选择的锁类型 0-所有锁;1-门锁;2-NFC无源锁;3-挂锁;4-保险箱锁;5-车位锁;6-智能门禁;7-网关 8-智能门锁 int seletLockType = 0; } - - diff --git a/lib/tools/eventBusEventManage.dart b/lib/tools/eventBusEventManage.dart index c72c44ae..3dfe48fe 100755 --- a/lib/tools/eventBusEventManage.dart +++ b/lib/tools/eventBusEventManage.dart @@ -7,20 +7,20 @@ EventBus eventBus = EventBus(); /// 刷新锁列表数据 class RefreshLockListInfoDataEvent { + RefreshLockListInfoDataEvent( + {this.clearScanDevices = false, this.isUnShowLoading = false}); + //是否清除蓝牙设备列表缓存 bool clearScanDevices; bool isUnShowLoading; - - RefreshLockListInfoDataEvent( - {this.clearScanDevices = false, this.isUnShowLoading = false}); } /// 蓝牙添加用户成功 class LockAddUserSucceedEvent { + LockAddUserSucceedEvent(this.dataList, this.type); + int type; // 0用户号更新成功 1token失效 List dataList; - - LockAddUserSucceedEvent(this.dataList, this.type); } /// 刷新锁详情数据 @@ -45,9 +45,9 @@ class RefreshCheckInListEvent { /// 传递当前锁信息 class PassCurrentLockInformationEvent { - LockSetInfoData lockSetInfoData; - PassCurrentLockInformationEvent(this.lockSetInfoData); + + LockSetInfoData lockSetInfoData; } /// 卡、密码、指纹修改之后刷新列表 @@ -57,16 +57,16 @@ class OtherTypeRefreshListEvent { /// 考情添加员工卡、指纹之后回调卡、指纹number class ChickInAddStaffCardAndFingerprintBlockNumberEvent { - String number; - ChickInAddStaffCardAndFingerprintBlockNumberEvent(this.number); + + String number; } /// 多语言 切换之后传值到上一级界面 class ChangeLanguageBlockLastLanguageEvent { - String languageTitle; - ChangeLanguageBlockLastLanguageEvent(this.languageTitle); + + String languageTitle; } /// 锁分组添加或者删除锁之后刷新首页数据 @@ -76,45 +76,45 @@ class LockGroupEditGroupLockRefreshEvent { /// 锁设置里面开启关闭刷新锁详情 class LockSetChangeSetRefreshLockDetailWithType { + LockSetChangeSetRefreshLockDetailWithType(this.type, this.setResult); + int type; // 0 考勤 1开锁时是否需联网 2常开模式 3修改了锁名字 4修改了电量 5远程开锁 dynamic setResult; - - LockSetChangeSetRefreshLockDetailWithType(this.type, this.setResult); } /// 获取到视频流数据然后刷新界面 class GetTVDataRefreshUI { - List tvList; - GetTVDataRefreshUI(this.tvList); + + List tvList; } /// 获取到UDP接收状态然后刷新界面 class GetUDPStatusRefreshUI { - int udpStatus; - GetUDPStatusRefreshUI(this.udpStatus); + + int udpStatus; } /// 获取到UDP接收状态然后刷新监控界面 class GetUDPStatusMonitorUI { - int udpStatus; - GetUDPStatusMonitorUI(this.udpStatus); + + int udpStatus; } /// 获取到第一帧图片数据后跳转 class GetFirstFrameGoPush { - bool isFirstFrame; - GetFirstFrameGoPush(this.isFirstFrame); + + bool isFirstFrame; } /// 获取到实时点击的密码类型更新typeIndex class GetPasswordTypeUpdateIndex { - int passwordType; - GetPasswordTypeUpdateIndex(this.passwordType); + + int passwordType; } /// 刷新密码列表 @@ -144,9 +144,9 @@ class MineAuthorizedAdminPageRefreshUI { /// 刷新门锁日志列表 class DoorLockLogListRefreshUI { - DateTime getDoorLockLogTime; - DoorLockLogListRefreshUI(this.getDoorLockLogTime); + + DateTime getDoorLockLogTime; } /// 刷新更多设置锁用户管理列表 @@ -163,3 +163,27 @@ class AuthorizedAdministratorListPageRefreshUI { class MineInfoChangeRefreshUI { MineInfoChangeRefreshUI(); } + +/// 刷新锁数据 +class RefreshLockInfoDataEvent { + RefreshLockInfoDataEvent({required this.keyId, required this.lockId}); + + int keyId; + int lockId; +} + +/// 删除锁数据 +class DeleteLockInfoDataEvent { + DeleteLockInfoDataEvent({required this.keyId, required this.lockId}); + + int keyId; + int lockId; +} + +/// 收到新增锁数据 +class RogerThatLockInfoDataEvent { + RogerThatLockInfoDataEvent({required this.keyId, required this.lockId}); + + int keyId; + int lockId; +} diff --git a/lib/tools/push/message_constant.dart b/lib/tools/push/message_constant.dart new file mode 100644 index 00000000..c2e183fb --- /dev/null +++ b/lib/tools/push/message_constant.dart @@ -0,0 +1,10 @@ +class MessageConstant { + //钥匙状态变更 含(钥匙冻结、解冻、过期、有效期信息受更) + static const int keyStateChange = 10; + //删除钥匙(返回锁列表刷新〉 + static const int keyDelete = 20; + //收到锁(返回锁列表刷新〉 + static const int lockReceive = 30; + //收到钥匙(返回指定钥匙分组+钥匙数据〉 + static const int keyReceive = 40; +} diff --git a/lib/tools/push/message_management.dart b/lib/tools/push/message_management.dart new file mode 100644 index 00000000..b8588793 --- /dev/null +++ b/lib/tools/push/message_management.dart @@ -0,0 +1,67 @@ +import 'dart:convert'; + +import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; +import 'package:star_lock/tools/push/message_constant.dart'; + +class MessageManagement { + //分析消息数据 + static Future shunting(Map message) async { + if (message.isEmpty) { + return; + } + Map extra = {}; + if (GetPlatform.isAndroid) { + extra = _androidAnalysis(message); + AppLog.log('MessageManagement.shunting GetPlatform.isAndroid: $extra'); + } else if (GetPlatform.isIOS) { + extra = _androidAnalysis(message); + AppLog.log('MessageManagement.shunting GetPlatform.isIos: $extra'); + } else { + return; + } + if (extra.isEmpty) { + return; + } + _shuntingBus(extra); + } + + //解析 + static Map _androidAnalysis(Map data) { + // {alert: , extras: {cn.jpush.android.TYPE_PLATFORM: 0, cn.jpush.android.CONTENT_TYPE: , cn.jpush.android.MSG_ID: 18101501949885538, cn.jpush.android.EXTRA: {"eventNo":10,"keyId":530,"lockId":7}}, message: } + final Map extras = data['extras']; + final Map extra = + json.decode(extras['cn.jpush.android.EXTRA'] ?? '{}'); + return extra; + } + + //识别参数分发消息 + static void _shuntingBus(Map data) { + final int eventNo = data['eventNo'] ?? -1; + switch (eventNo) { + case MessageConstant.keyStateChange: + final int keyId = data['keyId']; + final int lockId = data['lockId']; + eventBus.fire(RefreshLockInfoDataEvent(keyId: keyId, lockId: lockId)); + break; + case MessageConstant.keyDelete: + final int keyId = data['keyId']; + final int lockId = data['lockId']; + eventBus.fire(DeleteLockInfoDataEvent(keyId: keyId, lockId: lockId)); + break; + case MessageConstant.lockReceive: + final int keyId = data['keyId']; + final int lockId = data['lockId']; + eventBus.fire(RogerThatLockInfoDataEvent(keyId: keyId, lockId: lockId)); + break; + case MessageConstant.keyReceive: + final int keyId = data['keyId']; + final int lockId = data['lockId']; + eventBus.fire(RogerThatLockInfoDataEvent(keyId: keyId, lockId: lockId)); + break; + default: + throw Exception('无法识别eventNo 参数:$eventNo'); + } + } +} diff --git a/lib/tools/xs_jPhush.dart b/lib/tools/push/xs_jPhush.dart similarity index 96% rename from lib/tools/xs_jPhush.dart rename to lib/tools/push/xs_jPhush.dart index 5d08d9bb..e1be0609 100755 --- a/lib/tools/xs_jPhush.dart +++ b/lib/tools/push/xs_jPhush.dart @@ -7,9 +7,10 @@ import 'package:star_lock/flavors.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccount/mineUnbindPhoneOrEmail_entity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/push/message_management.dart'; import 'package:star_lock/tools/storage.dart'; -import '../app_settings/app_settings.dart'; +import '../../app_settings/app_settings.dart'; class XSJPushProvider { final JPush jpush = JPush(); @@ -54,6 +55,7 @@ class XSJPushProvider { }, onReceiveMessage: (Map message) async { AppLog.log('onReceiveMessage: $message'); //这里接收自定义消息 + MessageManagement.shunting(message); }, onReceiveNotificationAuthorization: (Map message) async { AppLog.log('onReceiveNotificationAuthorization: $message'); From 111897c7a7dea4d3776f044170eff941a21a8f78 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 15 Jun 2024 15:14:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=E9=80=82=E9=85=8D=20ios=20=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tools/push/message_management.dart | 17 ++++++++++++++--- lib/tools/push/xs_jPhush.dart | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/tools/push/message_management.dart b/lib/tools/push/message_management.dart index b8588793..9ef49c7d 100644 --- a/lib/tools/push/message_management.dart +++ b/lib/tools/push/message_management.dart @@ -11,12 +11,12 @@ class MessageManagement { if (message.isEmpty) { return; } - Map extra = {}; + Map extra = {}; if (GetPlatform.isAndroid) { extra = _androidAnalysis(message); AppLog.log('MessageManagement.shunting GetPlatform.isAndroid: $extra'); } else if (GetPlatform.isIOS) { - extra = _androidAnalysis(message); + extra = _iosAnalysis(message); AppLog.log('MessageManagement.shunting GetPlatform.isIos: $extra'); } else { return; @@ -27,7 +27,7 @@ class MessageManagement { _shuntingBus(extra); } - //解析 + //android解析 static Map _androidAnalysis(Map data) { // {alert: , extras: {cn.jpush.android.TYPE_PLATFORM: 0, cn.jpush.android.CONTENT_TYPE: , cn.jpush.android.MSG_ID: 18101501949885538, cn.jpush.android.EXTRA: {"eventNo":10,"keyId":530,"lockId":7}}, message: } final Map extras = data['extras']; @@ -36,6 +36,17 @@ class MessageManagement { return extra; } + //ios解析 + static Map _iosAnalysis(Map data) { + // {content: , extras: {eventNo: 20, keyId: 580, lockId: 7}, _j_msgid: 18101504271412025} + final Map extras = data['extras']; + final Map extra = {}; + extras.forEach((Object? key, Object? value) { + extra[key!.toString()] = value; + }); + return extra; + } + //识别参数分发消息 static void _shuntingBus(Map data) { final int eventNo = data['eventNo'] ?? -1; diff --git a/lib/tools/push/xs_jPhush.dart b/lib/tools/push/xs_jPhush.dart index e1be0609..d71827d5 100755 --- a/lib/tools/push/xs_jPhush.dart +++ b/lib/tools/push/xs_jPhush.dart @@ -35,7 +35,7 @@ class XSJPushProvider { appKey: appKey, channel: 'flutter_channel', production: false, - debug: true, + debug: false, ); jpush.applyPushAuthority( From 787e2ef9eda078770ae98bec5f81b8468041bfe2 Mon Sep 17 00:00:00 2001 From: anfe <448468458@qq.com> Date: Sat, 15 Jun 2024 16:41:31 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=20ota=20=E5=8D=87?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockSet/lockEscalation/lockEscalation_logic.dart | 3 +-- lib/main/lockDetail/lockSet/lockEscalation/version_entity.dart | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart index 563c9d9e..47e04211 100755 --- a/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/lockEscalation_logic.dart @@ -17,7 +17,6 @@ import 'package:star_lock/blue/io_reply.dart'; import 'package:star_lock/blue/io_tool/io_tool.dart'; import 'package:star_lock/blue/io_tool/manager_event_bus.dart'; import 'package:star_lock/blue/sender_manage.dart'; -import 'package:star_lock/main/lockDetail/lockSet/lockEscalation/updateLockInfo_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockEscalation/version_entity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -351,10 +350,10 @@ class LockEscalationLogic extends BaseGetXController { otaIndex++; processOtaUpgrade(); } else if (reply is ConfirmationOTAUpgradeReply && reply.status == 0x00) { - closeOTADAta(); ApiRepository.to.getLockUpdateLockInfo( lockId: CommonDataManage().currentKeyInfo.lockId ?? 0, fwVersion: state.showNewVersion.value); + closeOTADAta(); showToast('固件升级完成'.tr); } else if (reply is GetStarLockStatuInfoReply) { _replyGetStarLockStatusInfo(reply); diff --git a/lib/main/lockDetail/lockSet/lockEscalation/version_entity.dart b/lib/main/lockDetail/lockSet/lockEscalation/version_entity.dart index 74e6d8e0..41fcec8e 100644 --- a/lib/main/lockDetail/lockSet/lockEscalation/version_entity.dart +++ b/lib/main/lockDetail/lockSet/lockEscalation/version_entity.dart @@ -30,6 +30,7 @@ class Data { isUpdate = json['isUpdate']; downloadUrl = json['downloadUrl']; description = json['description']; + version = json['version']; } int? isUpdate; From 738c9e19b4caed2976ea931bbfb6aec51fd1b3a7 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Sat, 15 Jun 2024 17:20:55 +0800 Subject: [PATCH 4/4] =?UTF-8?q?1=EF=BC=8C=E6=93=8D=E4=BD=9C=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=AE=8C=E5=96=84=E9=83=A8=E5=88=86=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?UI=E5=B8=83=E5=B1=80=202=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E8=AE=B0=E5=BD=95=E8=AF=BB=E5=8F=96=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=203=EF=BC=8C=E6=96=B0=E5=A2=9EPopupMenuButto?= =?UTF-8?q?n=E7=BB=84=E4=BB=B6=E5=8F=8A=E5=85=AC=E7=94=A8=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=204=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=88=91=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E3=80=81=E9=94=81=E8=AE=BE=E7=BD=AE=E2=80=94?= =?UTF-8?q?=E9=94=81=E9=9C=80=E8=81=94=E7=BD=91=E6=A0=87=E8=AF=86=20?= =?UTF-8?q?=E5=85=B3=E8=81=94=E9=94=81=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../doorLockLog/doorLockLog_logic.dart | 48 +++---- .../doorLockLog/doorLockLog_page.dart | 132 +++++++++++++----- .../lockDetail/lockDetail_logic.dart | 25 ++-- .../lockDetail/lockDetail_page.dart | 16 +-- .../lockSet/lockSet/lockSet_logic.dart | 4 +- ...pUnlockNeedMobileNetworkingLock_logic.dart | 21 ++- lib/network/api_provider_base.dart | 3 +- lib/tools/showTipView.dart | 10 +- 8 files changed, 175 insertions(+), 84 deletions(-) diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index d0184b1c..4e03962b 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -1,7 +1,6 @@ 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'; @@ -58,24 +57,24 @@ class DoorLockLogLogic extends BaseGetXController { var indexList = getList[i]; // AppLog.log("indexList:$indexList"); var indexMap = {}; - indexMap["type"] = indexList[0].toString(); + indexMap['type'] = indexList[0].toString(); int operateDate = 0; if (indexList[0] == 2) { var passwordData = indexList.sublist(7, 17); var password = utf8String(passwordData); - indexMap["user"] = password.toString(); - }else { + indexMap['user'] = password.toString(); + } else { int userNo = (indexList[1] * 256) + indexList[2]; - indexMap["user"] = userNo.toString(); + indexMap['user'] = userNo.toString(); } - indexMap["success"] = "1"; + indexMap['success'] = '1'; int time = ((0xff & indexList[(3)]) << 24 | (0xff & indexList[4]) << 16 | (0xff & indexList[5]) << 8 | (0xFF & indexList[6])); - indexMap["date"] = "${time * 1000}"; + indexMap['date'] = '${time * 1000}'; uploadList.add(indexMap); if (i == getList.length - 1) { @@ -141,13 +140,13 @@ class DoorLockLogLogic extends BaseGetXController { } //请求操作记录列表(门锁日志) - void mockNetworkDataRequest({required bool isRefresh}) async { + Future mockNetworkDataRequest({required bool isRefresh}) async { // 如果是下拉刷新,清空已有数据 if (isRefresh) { state.lockLogItemList.clear(); pageNo = 1; } - DoorLockLogEntity entity = await ApiRepository.to.lockEventList( + final DoorLockLogEntity entity = await ApiRepository.to.lockEventList( lockId: state.keyInfos.value.lockId!, lockEventType: state.dropdownValue.value, pageNo: pageNo, @@ -165,8 +164,9 @@ class DoorLockLogLogic extends BaseGetXController { /// 刷新门锁日志列表 StreamSubscription? _getDoorLockLogListRefreshUIEvent; void _getDoorLockLogListRefreshUIAction() { - _getDoorLockLogListRefreshUIEvent = - eventBus.on().listen((event) { + _getDoorLockLogListRefreshUIEvent = eventBus + .on() + .listen((DoorLockLogListRefreshUI event) { state.currentSelectDate.value = event.getDoorLockLogTime; // 设置startDate为当天的0点 state.startDate.value = DateTime( @@ -175,11 +175,11 @@ class DoorLockLogLogic extends BaseGetXController { state.currentSelectDate.value.day) .millisecondsSinceEpoch; // 设置endDate为下一天的0点,然后减去1毫秒 - state.endDate.value = (DateTime( - state.currentSelectDate.value.year, - state.currentSelectDate.value.month, - state.currentSelectDate.value.day + 1) - .subtract(const Duration(milliseconds: 1))) + state.endDate.value = DateTime( + state.currentSelectDate.value.year, + state.currentSelectDate.value.month, + state.currentSelectDate.value.day + 1) + .subtract(const Duration(milliseconds: 1)) .millisecondsSinceEpoch; pageNo = 1; @@ -188,9 +188,9 @@ class DoorLockLogLogic extends BaseGetXController { } // 查询锁记录最后时间 - void getLockRecordLastUploadDataTime() async { - LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to - .getLockRecordLastUploadDataTime( + Future getLockRecordLastUploadDataTime() async { + final LockOperatingRecordGetLastRecordTimeEntity entity = + await ApiRepository.to.getLockRecordLastUploadDataTime( lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { state.operateDate = entity.data!.operateDate! ~/ 1000; @@ -199,8 +199,8 @@ class DoorLockLogLogic extends BaseGetXController { } // 操作记录上传 - void lockRecordUploadData(List list) async { - KeyOperationRecordEntity entity = await ApiRepository.to + Future lockRecordUploadData(List list) async { + final KeyOperationRecordEntity entity = await ApiRepository.to .lockRecordUploadData( lockId: state.keyInfos.value.lockId.toString(), records: list); if (entity.errorCode!.codeIsSuccessful) { @@ -213,12 +213,12 @@ class DoorLockLogLogic extends BaseGetXController { } //清空操作记录 - void clearOperationRecordRequest() async { - KeyOperationRecordEntity entity = await ApiRepository.to + Future clearOperationRecordRequest() async { + final KeyOperationRecordEntity entity = await ApiRepository.to .clearOperationRecord( CommonDataManage().currentKeyInfo.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - showToast("清除数据成功", something: () { + showToast('清除数据成功', something: () { pageNo = 1; mockNetworkDataRequest(isRefresh: true); }); diff --git a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart index 70614ace..662a4248 100755 --- a/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart +++ b/lib/main/lockDetail/doorLockLog/doorLockLog_page.dart @@ -5,12 +5,14 @@ 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/main/lockDetail/doorLockLog/doorLockLog_state.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:star_lock/tools/showTipView.dart'; import 'package:timelines/timelines.dart'; import '../../../app_settings/app_colors.dart'; @@ -26,8 +28,8 @@ class DoorLockLogPage extends StatefulWidget { } class _DoorLockLogPageState extends State with RouteAware { - final logic = Get.put(DoorLockLogLogic()); - final state = Get.find().state; + final DoorLockLogLogic logic = Get.put(DoorLockLogLogic()); + final DoorLockLogState state = Get.find().state; @override Widget build(BuildContext context) { @@ -37,22 +39,45 @@ class _DoorLockLogPageState extends State with RouteAware { barTitle: TranslationLoader.lanKeys!.operatingRecord!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - actionsList: [ + 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), - ))), + visible: CommonDataManage().currentKeyInfo.isLockOwner == 1, + child: GestureDetector( + child: Image.asset( + 'images/icon_tips_Q.png', + width: 34.w, + height: 32.w, + color: Colors.white, + ), + onTap: () { + ShowTipView().showSureAlertDialog( + '1.锁没有联网,密码、IC卡、指纹等开门记录无法实时上传,可以点击右上角按钮,然后读取记录。\n2.只能保留一定时间内的记录,如果您需要保留历史记录,可以点击右上角按钮,然后导出记录', + tipTitle: '看不到操作记录,可能原因有', + sureStr: '我知道了'); + }, + )), + Visibility( + visible: CommonDataManage().currentKeyInfo.isLockOwner == 1, + child: PopupMenuButton( + onSelected: _onMenuItemSelected, + color: Colors.black, + itemBuilder: (BuildContext context) { + return >[ + _buildCustomPopupMenuItem('读取记录'), + const PopupMenuDivider(), + _buildCustomPopupMenuItem('清空记录'), + const PopupMenuDivider(), + _buildCustomPopupMenuItem('导出记录'), + ]; + }, + icon: Image.asset( + 'images/icon_bar_more.png', + height: 30.h, + width: 10.w, + ), + offset: Offset(0, 70.h), // 设置弹出框位置偏移量 + ), + ), ], ), body: Column( @@ -73,9 +98,47 @@ class _DoorLockLogPageState extends State with RouteAware { ); } +// + PopupMenuItem _buildCustomPopupMenuItem(String value) { + return PopupMenuItem( + value: value, + height: 46.h, + child: SizedBox( + height: 46.h, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text(value, style: TextStyle(color: Colors.white, fontSize: 22.sp)), + ], + ), + ), + ); + } + + void _onMenuItemSelected(String value) { + switch (value) { + case '读取记录': + { + logic.mockNetworkDataRequest(isRefresh: true); + } + break; + case '清空记录': + { + ShowCupertinoAlertView().showClearOperationRecordAlert( + clearClick: () { + logic.clearOperationRecordRequest(); + }); + } + break; + case '导出记录': + {} + break; + } + } + //顶部日历小部件 Widget topAdvancedCalendarWidget() { - final theme = Theme.of(context); + final ThemeData theme = Theme.of(context); return Theme( data: theme.copyWith( textTheme: theme.textTheme.copyWith( @@ -134,7 +197,7 @@ class _DoorLockLogPageState extends State with RouteAware { margin: EdgeInsets.only(top: 20.h, left: 30.w, bottom: 10.h, right: 20.w), child: Row( mainAxisAlignment: MainAxisAlignment.start, - children: [ + children: [ Obx(() => XSDropDownWidget( items: state.getDropDownItemList, value: state.dropdownTitle.value, @@ -187,11 +250,11 @@ class _DoorLockLogPageState extends State with RouteAware { return TimelineTileBuilder.fromStyle( contentsAlign: ContentsAlign.basic, itemCount: state.lockLogItemList.length, - contentsBuilder: (context, index) { - DoorLockLogDataItem timelineData = state.lockLogItemList[index]; - DateTime dateTime = + contentsBuilder: (BuildContext context, int index) { + final DoorLockLogDataItem timelineData = state.lockLogItemList[index]; + final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timelineData.operateDate!); - String formattedTime = + final String formattedTime = '${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}'; return Padding( @@ -199,7 +262,7 @@ class _DoorLockLogPageState extends State with RouteAware { child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ Text( '$formattedTime ${timelineData.username!.isNotEmpty ? "${timelineData.username}用" : ""}${timelineData.recordTypeName}', textAlign: TextAlign.left, @@ -217,14 +280,15 @@ class _DoorLockLogPageState extends State with RouteAware { Get.toNamed(Routers.videoLogDetailPage); }, child: Stack( - children: [ - timelineData.imagesUrl!.isNotEmpty - ? Image.network( - timelineData.imagesUrl!, - width: 260.w, - height: 260.h, - ) - : Container(), + children: [ + if (timelineData.imagesUrl!.isNotEmpty) + Image.network( + timelineData.imagesUrl!, + width: 260.w, + height: 260.h, + ) + else + Container(), Positioned( top: 150.h, left: 10.w, @@ -293,7 +357,9 @@ class _DoorLockLogPageState extends State with RouteAware { void didPushNext() { super.didPushNext(); logic.cancelBlueConnetctToastTimer(); - if (EasyLoading.isShow) EasyLoading.dismiss(animation: true); + if (EasyLoading.isShow) { + EasyLoading.dismiss(animation: true); + } state.ifCurrentScreen.value = false; } } diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 1f324ede..58e6d55a 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -350,18 +350,20 @@ class LockDetailLogic extends BaseGetXController { // 从服务器获取锁的时间 开锁时传入 Future getServerDatetime() async { final GetServerDatetimeEntity entity = - await ApiRepository.to.getServerDatetimeData(isUnShowLoading:true); + await ApiRepository.to.getServerDatetimeData(isUnShowLoading: true); if (entity.errorCode!.codeIsSuccessful) { - state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; - }else{ + state.differentialTime = entity.data!.date! ~/ 1000 - + DateTime.now().millisecondsSinceEpoch ~/ 1000; + } else { state.isHaveNetwork = false; } } int getUTCNetTime() { - if(state.isHaveNetwork){ - return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; - }else{ + if (state.isHaveNetwork) { + return DateTime.now().millisecondsSinceEpoch ~/ 1000 + + state.differentialTime; + } else { return 0; } } @@ -474,10 +476,10 @@ class LockDetailLogic extends BaseGetXController { // state.keyInfos.value.electricQuantity = int.parse(event.setResult); final int electricQuantity = int.tryParse(event.setResult['electricQuantity']) ?? 0; - state.electricQuantity.value =electricQuantity; + state.electricQuantity.value = electricQuantity; state.keyInfos.value.electricQuantity = electricQuantity; state.keyInfos.value.electricQuantityDate = - event.setResult['uploadElectricQuantityDate']; + event.setResult['uploadElectricQuantityDate']; } else if (event.type == 5) { // 5 远程开锁 state.keyInfos.value.lockSetting!.remoteUnlock = @@ -536,6 +538,13 @@ class LockDetailLogic extends BaseGetXController { state.LockSetChangeSetRefreshLockDetailWithTypeSubscription = eventBus .on() .listen((LockSetChangeSetRefreshLockDetailWithType event) { + //更新 开锁时是否需联网 状态 + if (event.type == 1) { + state.isOpenLockNeedOnline.value = int.parse(event.setResult); + state.keyInfos.value.lockSetting!.appUnlockOnline = + int.parse(event.setResult); + state.isOpenLockNeedOnline.refresh(); + } if (event.type == 4) { final int electricQuantity = int.tryParse(event.setResult['electricQuantity']) ?? 0; diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 196d7ba6..97891f95 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -776,18 +776,18 @@ class _LockDetailPageState extends State child: Image.asset('images/main/icon_lockDetail_needNetwork.png', width: 24.w, height: 20.w, - color: state.keyInfos.value.appUnlockOnline == 1 + color: state.isOpenLockNeedOnline.value == 1 ? AppColors.mainColor : AppColors.btnDisableColor), ), SizedBox(width: 6.w), - Text( - '手机需联网', - style: TextStyle( - fontSize: 20.sp, - color: state.keyInfos.value.appUnlockOnline == 1 - ? AppColors.mainColor - : AppColors.btnDisableColor), + Obx( + () => Text('手机需联网', + style: TextStyle( + fontSize: 20.sp, + color: state.isOpenLockNeedOnline.value == 1 + ? AppColors.mainColor + : AppColors.btnDisableColor)), ), if (add) ...[ const Spacer(), diff --git a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart index 870e4a56..ccb615d3 100755 --- a/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart +++ b/lib/main/lockDetail/lockSet/lockSet/lockSet_logic.dart @@ -5,6 +5,7 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; +import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart'; import 'package:star_lock/tools/showTipView.dart'; import '../../../../blue/blue_manage.dart'; @@ -596,7 +597,8 @@ class LockSetLogic extends BaseGetXController { final bool isXHJ = F.isXHJ; final bool isOnlyOneData = state.isOnlyOneData.value == true; - await Future.delayed(const Duration(milliseconds: 200)).then((e) { + await Future.delayed(const Duration(milliseconds: 200)) + .then((e) { if (isXHJ) { Get.close(3); } else { diff --git a/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_logic.dart b/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_logic.dart index 6e2bc08f..9d098934 100755 --- a/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_logic.dart +++ b/lib/mine/mineSet/appUnlockNeedMobileNetworkingLock/appUnlockNeedMobileNetworkingLock_logic.dart @@ -1,15 +1,20 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/lockDetail/lockDetail_logic.dart'; +import 'package:star_lock/main/lockMian/lockMain/lockMain_logic.dart'; import '../../../network/api_repository.dart'; import '../../../tools/baseGetXController.dart'; import 'appUnlockNeedMobileNetworkingLock_state.dart'; import 'selectLockListEntity.dart'; -class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController{ - final AppUnlockNeedMobileNetworkingLockState state = AppUnlockNeedMobileNetworkingLockState(); +class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController { + final AppUnlockNeedMobileNetworkingLockState state = + AppUnlockNeedMobileNetworkingLockState(); //请求锁列表 Future mockNetworkDataRequest() async { - final SelectLockListEntity entity = await ApiRepository.to.selectLockList(searchStr: state.searchController.text); + final SelectLockListEntity entity = await ApiRepository.to + .selectLockList(searchStr: state.searchController.text); List dataList = []; if (entity.errorCode!.codeIsSuccessful) { dataList = entity.data!.list!; @@ -27,9 +32,14 @@ class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController{ //APP开锁时需手机联网的锁 Future setAppUnlockMustOnlineRequest() async { final SelectLockListEntity entity = - await ApiRepository.to.setAppUnlockMustOnline(state.selectLockIdList); + await ApiRepository.to.setAppUnlockMustOnline(state.selectLockIdList); if (entity.errorCode!.codeIsSuccessful) { showToast('操作成功'); + + //刷新锁列表,更新锁详情--手机需联网标识 + if (Get.isRegistered()) { + Get.find().getStarLockInfo(); + } } } @@ -44,5 +54,4 @@ class AppUnlockNeedMobileNetworkingLockLogic extends BaseGetXController{ void onInit() { super.onInit(); } - -} \ No newline at end of file +} diff --git a/lib/network/api_provider_base.dart b/lib/network/api_provider_base.dart index c7d3977a..9ecdf678 100755 --- a/lib/network/api_provider_base.dart +++ b/lib/network/api_provider_base.dart @@ -102,7 +102,8 @@ class BaseProvider extends GetConnect with Api { EasyLoading.showToast('数据不存在', duration: 2000.milliseconds); break; case 434: //与后台约定弹出确认框提示 - ShowTipView().showSureBtnTipsAlert(T['errorMsg']); + ShowTipView() + .showSureBtnTipsAlert(tipsText: T['errorMsg'], sureText: '确定'); break; } } diff --git a/lib/tools/showTipView.dart b/lib/tools/showTipView.dart index 06606a19..9e63c642 100755 --- a/lib/tools/showTipView.dart +++ b/lib/tools/showTipView.dart @@ -23,7 +23,8 @@ class ShowTipView { content: Text(contentStr), actions: [ CupertinoDialogAction( - child: Text(sureStr ?? TranslationLoader.lanKeys!.sure!.tr), + child: Text(sureStr ?? TranslationLoader.lanKeys!.sure!.tr, + style: TextStyle(color: AppColors.mainColor)), onPressed: Get.back, ), ], @@ -93,7 +94,9 @@ class ShowTipView { ); } - void showTFViewAlertDialog(TextEditingController controller, String title, String tipTitle, Function sureClick, {List? inputFormatters, bool? isShowSuffixIcon}) { + void showTFViewAlertDialog(TextEditingController controller, String title, + String tipTitle, Function sureClick, + {List? inputFormatters, bool? isShowSuffixIcon}) { // 点击删除 开始扫描 showDialog( context: Get.context!, @@ -122,7 +125,8 @@ class ShowTipView { } // 只有一个确定按钮 - void showSureBtnTipsAlert(String tipsText) { + void showSureBtnTipsAlert( + {required String tipsText, required String sureText}) { showCupertinoDialog( context: Get.context!, builder: (BuildContext context) {