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

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, btnName: TranslationLoader.lanKeys!.send!.tr,
onClick: () { onClick: () {
if (isDemoMode == false) { 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 && if (state.emailOrPhoneController.text.isNotEmpty &&
state.keyNameController.text.isNotEmpty) { state.keyNameController.text.isNotEmpty) {
if (int.parse(widget.type) == 0) { if (int.parse(widget.type) == 0) {
// if (!startDateTime.isBefore(endDateTime) ||
if (state.effectiveDateTime.value startDateTime.isAtSameMomentAs(endDateTime)) {
.isBefore(state.failureDateTime.value)) {
logic.sendElectronicKeyRequest(context);
} else {
Toast.show(msg: '失效时间需大于生效时间'); Toast.show(msg: '失效时间需大于生效时间');
} else {
logic.sendElectronicKeyRequest(context);
} }
} else { } else {
logic.sendElectronicKeyRequest(context); logic.sendElectronicKeyRequest(context);

View File

@ -404,6 +404,17 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot); var isDemoMode = await Storage.getBool(ifIsDemoModeOrNot);
if (isDemoMode == false) { if (isDemoMode == false) {
int getWidgetNumber = int.parse(widget.type); 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) { if (getWidgetNumber == 3) {
logic.getStartDate(state.effectiveDateTime.value); logic.getStartDate(state.effectiveDateTime.value);
@ -417,11 +428,8 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
} }
// //
if (state.isPermanent.value == false) { if (state.isPermanent.value == false) {
print('自定义密码输出********有时限'); if (!startDateTime.isBefore(endDateTime) ||
if (!state.effectiveDateTime.value startDateTime.isAtSameMomentAs(endDateTime)) {
.isBefore(state.failureDateTime.value) ||
state.effectiveDateTime.value
.isAtSameMomentAs(state.failureDateTime.value)) {
Toast.show(msg: '失效时间需大于生效时间'); Toast.show(msg: '失效时间需大于生效时间');
return; return;
} }
@ -436,18 +444,16 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
// //
if (getWidgetNumber == 1) { if (getWidgetNumber == 1) {
if (!state.effectiveDateTime.value if (!startDateTime.isBefore(endDateTime) ||
.isBefore(state.failureDateTime.value) || startDateTime.isAtSameMomentAs(endDateTime)) {
state.effectiveDateTime.value
.isAtSameMomentAs(state.failureDateTime.value)) {
Toast.show(msg: '失效时间需大于生效时间'); Toast.show(msg: '失效时间需大于生效时间');
return; return;
} }
} }
// //
if (getWidgetNumber == 4) { if (getWidgetNumber == 4) {
if (!state.effectiveDateTime.value if (!startDateTime.isBefore(endDateTime) ||
.isBefore(state.failureDateTime.value)) { startDateTime.isAtSameMomentAs(endDateTime)) {
Toast.show(msg: '结束时间需大于当前时间'); Toast.show(msg: '结束时间需大于当前时间');
return; return;
} }