import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'msgNotification_state.dart'; class MsgNotificationLogic extends BaseGetXController { final MsgNotificationState state = MsgNotificationState(); // 获取锁消息设置 Future getLockNoticeSetting() async { final MsgNotificationEntity entity = await ApiRepository.to.getLockNoticeSetting( lockId: state.getLockId.value, ); if (entity.errorCode!.codeIsSuccessful) { state.msgNoticeInfo.value = entity.data!; state.nDaysNotOpenDoor.value = entity.data!.dayNotOpenDoorState! == 0 ? state.notifyDisable : state.notifyEnable; //N天未开门 if (entity.data!.doorNotCloseState! == 0) { state.isDoorNotShut.value = false; } else { state.isDoorNotShut.value = true; } //门未关好 if (entity.data!.tamperAlarmState! == 0) { state.isTamperAlarm.value = false; } else { state.isTamperAlarm.value = true; } //防拆报警 state.isLowBattery.value = entity.data!.lowElecNoticeState! == 0 ? state.notifyDisable : state.notifyEnable; //低电量提醒 if (entity.data!.doorbellNoticeState! == 0) { state.isSomeoneRing.value = false; } else { state.isSomeoneRing.value = true; } //有人按门铃 if (entity.data!.someoneAtDoorNoticeState! == 0) { state.isSomeoneAppeared.value = false; } else { state.isSomeoneAppeared.value = true; } //有人出现在门口 } } //设置门未关好 Future updateDoorNotCloseSetting() async { final MsgNotificationEntity entity = await ApiRepository.to.updateDoorNotCloseSetting( lockId: state.getLockId.value, doorNotCloseState: state.isDoorNotShut.value ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { showToast(state.settingSuccess); } } //有人按门铃 Future updateDoorbellNoticeStateSetting() async { final MsgNotificationEntity entity = await ApiRepository.to.updateDoorbellNoticeStateSetting( lockId: state.getLockId.value, doorbellNoticeState: state.isSomeoneRing.value ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { showToast(state.settingSuccess); } } //有人出现在门口 Future updateSomeoneAtDoorNoticeStateSetting() async { final MsgNotificationEntity entity = await ApiRepository.to.updateSomeoneAtDoorNoticeStateSetting( lockId: state.getLockId.value, someoneAtDoorNoticeState: state.isSomeoneAppeared.value ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { showToast(state.settingSuccess); } } //设置防拆报警通知 Future updateTamperAlarmStateSetting() async { final MsgNotificationEntity entity = await ApiRepository.to.updateTamperAlarmStateSetting( lockId: state.getLockId.value, tamperAlarmState: state.isTamperAlarm.value ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { showToast(state.settingSuccess); } } }