71 lines
2.1 KiB
Dart
Executable File
71 lines
2.1 KiB
Dart
Executable File
import 'dart:async';
|
|
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
|
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.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> getUserInfoRequest() async {
|
|
final MinePersonInfoEntity entity = await ApiRepository.to.getUserInfo();
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
state.mineInfoData.value = entity.data!;
|
|
state.isVip.value = state.mineInfoData.value.isVip! == 1;
|
|
Storage.setBool(saveIsVip, state.isVip.value);
|
|
}
|
|
}
|
|
|
|
//删除账号请求
|
|
Future<void> userLogoutRequest() async {
|
|
final LoginEntity entity = await ApiRepository.to.userLogout(deviceld: '');
|
|
if (entity.errorCode!.codeIsSuccessful) {}
|
|
}
|
|
|
|
/// 刷新电子钥匙列表
|
|
StreamSubscription? _mineInfoChangeRefreshUIEvent;
|
|
void _mineInfoChangeRefreshUIAction() {
|
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
|
_mineInfoChangeRefreshUIEvent = eventBus
|
|
.on<MineInfoChangeRefreshUI>()
|
|
.listen((MineInfoChangeRefreshUI event) {
|
|
getMineInfoData();
|
|
});
|
|
}
|
|
|
|
Future<void> getMineInfoData() async {
|
|
final String? 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())!;
|
|
state.userHeadUrl.value = (await Storage.getHeadUrl())!;
|
|
}
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
|
|
_mineInfoChangeRefreshUIAction();
|
|
}
|
|
|
|
@override
|
|
Future<void> onInit() async {
|
|
super.onInit();
|
|
getMineInfoData();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
super.onClose();
|
|
_mineInfoChangeRefreshUIEvent?.cancel();
|
|
}
|
|
}
|