84 lines
2.4 KiB
Dart
84 lines
2.4 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:talk/network/NetworkConfig.dart';
|
|
import 'package:talk/network/RequestCenter.dart';
|
|
|
|
import '../../beans/account_bean.dart';
|
|
import '../../beans/mall_bean.dart';
|
|
import '../../beans/transaction_records_bean.dart';
|
|
import '../../network/BaseEntity.dart';
|
|
|
|
class ShopModel {
|
|
StreamController streamController = StreamController.broadcast();
|
|
|
|
ShopModel() {
|
|
setUp();
|
|
}
|
|
|
|
void setUp() {}
|
|
|
|
///账户信息
|
|
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}");
|
|
});
|
|
}
|
|
|
|
///交易记录
|
|
Future<void> getTransactionRecords() async {
|
|
RequestCenter.instance.requestGet(NetworkConfig.getTransactionRecords, {}, (BaseEntity dataEntity) {
|
|
if (dataEntity.code == 0) {
|
|
List<TransactionRecordsBean> data =
|
|
(dataEntity.data as List<dynamic>).map((e) => TransactionRecordsBean.fromJson(e as Map<String, dynamic>)).toList();
|
|
|
|
streamController.sink.add({
|
|
'code': "getTransactionRecords", //有数据
|
|
'data': data,
|
|
});
|
|
} else {
|
|
streamController.sink.add({
|
|
'code': "error", //
|
|
'data': dataEntity.message,
|
|
});
|
|
}
|
|
}, (ErrorEntity errorEntity) {
|
|
print("errorEntity==${errorEntity.message}");
|
|
});
|
|
}
|
|
|
|
///货币商城
|
|
Future<void> getMallItem() async {
|
|
RequestCenter.instance.requestGet(NetworkConfig.getMallItem, {}, (BaseEntity dataEntity) {
|
|
if (dataEntity.code == 0) {
|
|
MallBean mallBean = MallBean.fromJson(dataEntity.data);
|
|
|
|
streamController.sink.add({
|
|
'code': "getMallItem", //有数据
|
|
'data': mallBean,
|
|
});
|
|
} else {
|
|
streamController.sink.add({
|
|
'code': "error", //
|
|
'data': dataEntity.message,
|
|
});
|
|
}
|
|
}, (ErrorEntity errorEntity) {
|
|
print("errorEntity==${errorEntity.message}");
|
|
});
|
|
}
|
|
}
|