From 4950c8d8fed3314fcfe977b554d7683b8869a30d Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Fri, 15 Dec 2023 14:41:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=9F=E6=95=88=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=92=8C=E5=A4=B1=E6=95=88=E6=97=B6=E9=97=B4=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=AF=94=E8=BE=83=E5=88=A4=E6=96=AD=E7=94=9F=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sendElectronicKey_page.dart | 21 ++++++++++---- .../passwordKey_perpetual_page.dart | 28 +++++++++++-------- 2 files changed, 33 insertions(+), 16 deletions(-) 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; }