62 lines
1.6 KiB
Dart
62 lines
1.6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:talk/network/NetworkConfig.dart';
|
|
import 'package:talk/network/RequestCenter.dart';
|
|
|
|
import '../../beans/account_bean.dart';
|
|
import '../../beans/user_info_bean.dart';
|
|
import '../../network/BaseEntity.dart';
|
|
|
|
class MeModel {
|
|
StreamController streamController = StreamController.broadcast();
|
|
|
|
MeModel() {
|
|
setUp();
|
|
}
|
|
|
|
void setUp() {}
|
|
|
|
///用户信息
|
|
Future<void> getUserInfo() async {
|
|
RequestCenter.instance.requestGet(NetworkConfig.getUserInfo, {}, (BaseEntity dataEntity) {
|
|
if (dataEntity.code == 0) {
|
|
UserInfoBean userInfoBean = UserInfoBean.fromJson(dataEntity.data);
|
|
NetworkConfig.userInfoBean = userInfoBean;
|
|
|
|
streamController.sink.add({
|
|
'code': "getUserInfo", //有数据
|
|
'data': userInfoBean,
|
|
});
|
|
} else {
|
|
streamController.sink.add({
|
|
'code': "error", //
|
|
'data': dataEntity.message,
|
|
});
|
|
}
|
|
}, (ErrorEntity errorEntity) {
|
|
print("errorEntity==${errorEntity.message}");
|
|
});
|
|
}
|
|
|
|
///账户信息
|
|
Future<void> getMyAccount() async {
|
|
RequestCenter.instance.requestGet(NetworkConfig.getMyAccount, {}, (BaseEntity dataEntity) {
|
|
if (dataEntity.code == 0) {
|
|
AccountBean accountBean = AccountBean.fromJson(dataEntity.data);
|
|
|
|
streamController.sink.add({
|
|
'code': "getMyAccount", //有数据
|
|
'data': accountBean,
|
|
});
|
|
} else {
|
|
streamController.sink.add({
|
|
'code': "error", //
|
|
'data': dataEntity.message,
|
|
});
|
|
}
|
|
}, (ErrorEntity errorEntity) {
|
|
print("errorEntity==${errorEntity.message}");
|
|
});
|
|
}
|
|
}
|