2023-09-07 18:36:16 +08:00

37 lines
1.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:star_lock/tools/baseGetXController.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/toast.dart';
import 'lockSoundSet_state.dart';
class LockSoundSetLogic extends BaseGetXController {
LockSoundSetState state = LockSoundSetState();
// 配置锁的常开模式设置 -> 锁声音设置
void setLockSetGeneralSetting() async{
int isOn;
int type;
if(state.isOpenLockSound.value == false){
// 音量关了的时候
isOn = 2; type = 6;
}else{
// 音量开了的时候
isOn = state.lockSoundLevel.value; type = 8;
}
var entity = await ApiRepository.to.setLockSetGeneralSettingData(
lockId: state.getKeyInfosData.value.lockId.toString(),
changeType:"1",
isOn:isOn.toString(), // 1-开启、2-关闭; 设置音量1到5;
type:type.toString(), // 6-锁声音开关 8-音量、
);
if(entity.errorCode!.codeIsSuccessful){
eventBus.fire(RefreshLockListInfoDataEvent());
//
state.getKeyInfosData.value.lockSound = state.isOpenLockSound.value == true ? 1 :2;
state.getKeyInfosData.value.volume = state.lockSoundLevel.value;
eventBus.fire(PassCurrentLockInformationEvent(state.getKeyInfosData.value));
Toast.show(msg: "操作成功");
}
}
}