import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/lockSet/faceUnlock/faceUnlock_state.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; class FaceUnlockLogic extends BaseGetXController { final FaceUnlockState state = FaceUnlockState(); // 获取锁设置信息 Future getLockSettingInfoData() async { LockSetInfoEntity entity = await ApiRepository.to.getLockSettingInfoData( lockId: state.lockSetInfoData.value.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { state.lockSetInfoData.value = entity.data!; state.faceOn.value = entity.data!.lockSettingInfo!.faceSwitch == 0 ? false : true; state.autoBright.value = entity.data!.lockSettingInfo!.faceAutoLightScreen == 0 ? false : true; state.senseDistance.value = entity.data!.lockSettingInfo!.faceInductionDistance! == 0 ? '远距离'.tr : '近距离'.tr; state.antiMisoperation.value = entity.data!.lockSettingInfo!.faceAntiMistakeOpen!; } return entity; } //设置面容开锁开关 void updateFaceSwitch() async { var entity = await ApiRepository.to.updateFaceSwitch( lockId: state.lockSetInfoData.value.lockId ?? 0, faceSwitch: state.faceOn.value == false ? 0 : 1, ); if (entity.errorCode!.codeIsSuccessful) { showToast('设置成功'.tr); } } //设置自动亮屏开关 void updateFaceConfig() async { var entity = await ApiRepository.to.updateFaceAutoLightScreen( lockId: state.lockSetInfoData.value.lockId ?? 0, faceAutoLightScreen: state.autoBright.value == false ? 0 : 1, ); if (entity.errorCode!.codeIsSuccessful) { showToast('设置成功'.tr); } } //设置面容感应距离 void updateFaceSenseDistance() async { var entity = await ApiRepository.to.updateFaceSenseDistance( lockId: state.lockSetInfoData.value.lockId ?? 0, faceInductionDistance: state.senseDistance.value == '远距离'.tr ? 0 : 1, ); if (entity.errorCode!.codeIsSuccessful) { showToast('设置成功'.tr); } } //设置面容防误开 void updateFacePreventMisrun() async { var entity = await ApiRepository.to.updateFacePreventMisrun( lockId: state.lockSetInfoData.value.lockId ?? 0, faceAntiMistakeOpen: state.antiMisoperation.value, ); if (entity.errorCode!.codeIsSuccessful) { showToast('设置成功'); } } }