diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index 840c39c1..51952e6c 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -271,16 +271,27 @@ class _SendElectronicKeyPageState extends State { btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () { if (isDemoMode == false) { + DateTime startDateTime = DateTime( + state.effectiveDateTime.value.year, + state.effectiveDateTime.value.month, + state.effectiveDateTime.value.day, + state.effectiveDateTime.value.hour, + state.effectiveDateTime.value.minute); + DateTime endDateTime = DateTime( + state.failureDateTime.value.year, + state.failureDateTime.value.month, + state.failureDateTime.value.day, + state.failureDateTime.value.hour, + state.failureDateTime.value.minute); //发送钥匙请求 if (state.emailOrPhoneController.text.isNotEmpty && state.keyNameController.text.isNotEmpty) { if (int.parse(widget.type) == 0) { - //失效时间大于生效时间 - if (state.effectiveDateTime.value - .isBefore(state.failureDateTime.value)) { - logic.sendElectronicKeyRequest(context); - } else { + if (!startDateTime.isBefore(endDateTime) || + startDateTime.isAtSameMomentAs(endDateTime)) { Toast.show(msg: '失效时间需大于生效时间'); + } else { + logic.sendElectronicKeyRequest(context); } } else { logic.sendElectronicKeyRequest(context); diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index a289ca23..ed892ae4 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -404,6 +404,17 @@ class _PasswordKeyPerpetualPageState extends State { var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); if (isDemoMode == false) { int getWidgetNumber = int.parse(widget.type); + DateTime startDateTime = DateTime( + state.effectiveDateTime.value.year, + state.effectiveDateTime.value.month, + state.effectiveDateTime.value.day, + state.effectiveDateTime.value.hour); + DateTime endDateTime = DateTime( + state.failureDateTime.value.year, + state.failureDateTime.value.month, + state.failureDateTime.value.day, + state.failureDateTime.value.hour); + //自定义密码 if (getWidgetNumber == 3) { logic.getStartDate(state.effectiveDateTime.value); @@ -417,11 +428,8 @@ class _PasswordKeyPerpetualPageState extends State { } //非永久 须有时限 if (state.isPermanent.value == false) { - print('自定义密码输出********有时限'); - if (!state.effectiveDateTime.value - .isBefore(state.failureDateTime.value) || - state.effectiveDateTime.value - .isAtSameMomentAs(state.failureDateTime.value)) { + if (!startDateTime.isBefore(endDateTime) || + startDateTime.isAtSameMomentAs(endDateTime)) { Toast.show(msg: '失效时间需大于生效时间'); return; } @@ -436,18 +444,16 @@ class _PasswordKeyPerpetualPageState extends State { //限时 if (getWidgetNumber == 1) { - if (!state.effectiveDateTime.value - .isBefore(state.failureDateTime.value) || - state.effectiveDateTime.value - .isAtSameMomentAs(state.failureDateTime.value)) { + if (!startDateTime.isBefore(endDateTime) || + startDateTime.isAtSameMomentAs(endDateTime)) { Toast.show(msg: '失效时间需大于生效时间'); return; } } //循环密码 if (getWidgetNumber == 4) { - if (!state.effectiveDateTime.value - .isBefore(state.failureDateTime.value)) { + if (!startDateTime.isBefore(endDateTime) || + startDateTime.isAtSameMomentAs(endDateTime)) { Toast.show(msg: '结束时间需大于当前时间'); return; }