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(); // 获取锁消息设置 void getLockNoticeSetting() async { 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天未开门 state.isDoorNotShut.value = entity.data!.doorNotCloseState! == 0 ? false : true; //门未关好 state.isTamperAlarm.value = entity.data!.tamperAlarmState! == 0 ? false : true; //防拆报警 state.isLowBattery.value = entity.data!.lowElecNoticeState! == 0 ? state.notifyDisable : state.notifyEnable; //低电量提醒 state.isSomeoneRing.value = entity.data!.doorbellNoticeState! == 0 ? false : true; //有人按门铃 state.isSomeoneAppeared.value = entity.data!.someoneAtDoorNoticeState! == 0 ? false : true; //有人出现在门口 } } //设置门未关好 void updateDoorNotCloseSetting() async { MsgNotificationEntity entity = await ApiRepository.to.updateDoorNotCloseSetting( lockId: state.getLockId.value, doorNotCloseState: state.isDoorNotShut.value ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { showToast(state.settingSuccess); } } //有人按门铃 void updateDoorbellNoticeStateSetting() async { MsgNotificationEntity entity = await ApiRepository.to.updateDoorbellNoticeStateSetting( lockId: state.getLockId.value, doorbellNoticeState: state.isSomeoneRing.value ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { showToast(state.settingSuccess); } } //有人出现在门口 void updateSomeoneAtDoorNoticeStateSetting() async { MsgNotificationEntity entity = await ApiRepository.to.updateSomeoneAtDoorNoticeStateSetting( lockId: state.getLockId.value, someoneAtDoorNoticeState: state.isSomeoneAppeared.value ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { showToast(state.settingSuccess); } } //设置防拆报警通知 void updateTamperAlarmStateSetting() async { MsgNotificationEntity entity = await ApiRepository.to.updateTamperAlarmStateSetting( lockId: state.getLockId.value, tamperAlarmState: state.isTamperAlarm.value ? 1 : 0, ); if (entity.errorCode!.codeIsSuccessful) { showToast(state.settingSuccess); } } }