110 lines
3.3 KiB
Dart
110 lines
3.3 KiB
Dart
import 'dart:async';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/appRouters.dart';
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
|
import 'package:star_lock/mine/mineSet/lockUserManage/expireLockList/expireLockListEntity.dart';
|
|
import 'package:star_lock/mine/mineSet/mineSet/mineSet_state.dart';
|
|
import 'package:star_lock/tools/storage.dart';
|
|
import '../../../../network/api_repository.dart';
|
|
import '../../../../tools/baseGetXController.dart';
|
|
import '../../../blue/blue_manage.dart';
|
|
import '../../../tools/eventBusEventManage.dart';
|
|
import '../../../tools/toast.dart';
|
|
|
|
class MineSetLogic extends BaseGetXController {
|
|
final MineSetState state = MineSetState();
|
|
//用户信息
|
|
Future<void> userSettingsInfoRequest() async {
|
|
var entity = await ApiRepository.to.userSettingsInfo();
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
state.userInfoData.value = entity.data!;
|
|
state.userSetting.value = entity.data!.userSettings!;
|
|
state.lockScreen.value = entity.data!.userSettings!.lockScreen!;
|
|
state.hideExpiredAccessFlag.value =
|
|
entity.data!.userSettings!.hideExpiredAccessFlag!;
|
|
|
|
//提示音
|
|
if (entity.data!.alertMode == 1) {
|
|
state.isPrompTone.value = true;
|
|
} else {
|
|
state.isPrompTone.value = false;
|
|
}
|
|
//触摸开锁
|
|
if (entity.data!.userSettings!.touchUnlockFlag! == 1) {
|
|
state.isTouchUnlock.value = true;
|
|
} else {
|
|
state.isTouchUnlock.value = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
//更新提示音
|
|
Future<void> updatePrompToneRequest() async {
|
|
ExpireLockListEntity entity = await ApiRepository.to
|
|
.setAlertMode('1', state.isPrompTone.value == true ? '1' : '2');
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
Toast.show(msg: "设置成功");
|
|
userSettingsInfoRequest();
|
|
}
|
|
}
|
|
|
|
//退出登录请求
|
|
Future<void> userLogoutRequest() async {
|
|
LoginEntity entity = await ApiRepository.to.userLogout();
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
logOut();
|
|
BlueManage().stopScan();
|
|
BlueManage().disconnect(BlueManage().connectDeviceMacAddress);
|
|
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
|
|
}
|
|
}
|
|
|
|
///退出登录
|
|
void logOut() async {
|
|
Storage.clearAll();
|
|
// await Storage.setString('userLoginData', '');
|
|
}
|
|
|
|
//更新触摸开锁
|
|
Future<void> updateTouchUnlockRequest() async {
|
|
ExpireLockListEntity entity = await ApiRepository.to
|
|
.setTouchUnlockFlag(state.isTouchUnlock.value == true ? '1' : '2');
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
Toast.show(msg: "设置成功");
|
|
userSettingsInfoRequest();
|
|
}
|
|
}
|
|
|
|
// 下级界面修改成功后传递数据
|
|
StreamSubscription? _getNumberEvent;
|
|
void _initLoadDataAction() {
|
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
|
_getNumberEvent =
|
|
eventBus.on<ChangeLanguageBlockLastLanguageEvent>().listen((event) {
|
|
state.currentLanguage.value = event.languageTitle;
|
|
});
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
// TODO: implement onReady
|
|
super.onReady();
|
|
|
|
_initLoadDataAction();
|
|
}
|
|
|
|
@override
|
|
void onInit() {
|
|
// TODO: implement onInit
|
|
super.onInit();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
// TODO: implement onClose
|
|
super.onClose();
|
|
|
|
_getNumberEvent!.cancel();
|
|
}
|
|
}
|