63 lines
1.8 KiB
Dart
63 lines
1.8 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
|
import 'package:star_lock/network/api_repository.dart';
|
|
|
|
import '../../tools/baseGetXController.dart';
|
|
import '../../tools/eventBusEventManage.dart';
|
|
import '../../tools/storage.dart';
|
|
import 'starLockMine_state.dart';
|
|
|
|
class StarLockMineLogic extends BaseGetXController {
|
|
final StarLockMineState state = StarLockMineState();
|
|
|
|
//删除账号请求
|
|
Future<void> userLogoutRequest() async {
|
|
LoginEntity entity = await ApiRepository.to.userLogout(deviceld: '');
|
|
if (entity.errorCode!.codeIsSuccessful) {}
|
|
}
|
|
|
|
/// 刷新电子钥匙列表
|
|
StreamSubscription? _mineInfoChangeRefreshUIEvent;
|
|
void _mineInfoChangeRefreshUIAction() {
|
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
|
_mineInfoChangeRefreshUIEvent = eventBus.on<MineInfoChangeRefreshUI>().listen((event) {
|
|
getMineInfoData();
|
|
});
|
|
}
|
|
|
|
getMineInfoData() async {
|
|
final data = await Storage.getString(saveUserLoginData);
|
|
if (data != null && data.isNotEmpty) {
|
|
state.userNickName.value = (await Storage.getNickname())!;
|
|
state.userMobile.value = (await Storage.getMobile())! ?? '';
|
|
state.userEmail.value = (await Storage.getEmail())!;
|
|
Get.log("userNickName:${state.userNickName.value} userMobile:${state.userMobile.value} userEmail:${state.userEmail.value}");
|
|
}
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
print("ready home");
|
|
super.onReady();
|
|
|
|
_mineInfoChangeRefreshUIAction();
|
|
}
|
|
|
|
@override
|
|
Future<void> onInit() async {
|
|
print("init home");
|
|
super.onInit();
|
|
|
|
getMineInfoData();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
print("close home");
|
|
super.onClose();
|
|
_mineInfoChangeRefreshUIEvent?.cancel();
|
|
}
|
|
}
|