解决生效时间和失效时间无法比较判断生效问题

This commit is contained in:
Daisy 2023-12-15 14:41:14 +08:00
parent f0a90edb6e
commit 4950c8d8fe
2 changed files with 33 additions and 16 deletions

View File

@ -271,16 +271,27 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
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);

View File

@ -404,6 +404,17 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
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<PasswordKeyPerpetualPage> {
}
//
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<PasswordKeyPerpetualPage> {
//
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;
}