基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

54 lines
1.4 KiB

  1. import 'dart:async';
  2. import 'dart:convert' as convert;
  3. import 'package:zhiying_base_widget/pages/withdraw_page/models/withdraw_model.dart';
  4. import 'package:zhiying_comm/util/base_bloc.dart';
  5. import 'package:zhiying_comm/zhiying_comm.dart';
  6. class WithdrawBloc extends BlocBase {
  7. WithdrawModel _model;
  8. StreamController<WithdrawModel> _dataController =
  9. StreamController<WithdrawModel>();
  10. Stream<WithdrawModel> get outData => _dataController.stream;
  11. @override
  12. void dispose() {
  13. _dataController.close();
  14. _dataController = null;
  15. }
  16. void loadData(String skipIdentifier) async {
  17. NetUtil.request('/api/v1/mod/${skipIdentifier.toString()}',
  18. method: NetMethod.GET, onCache: (data) {
  19. _loadData(data);
  20. }, onSuccess: (data) {
  21. _loadData(data);
  22. });
  23. }
  24. void _loadData(dynamic data) {
  25. try {
  26. Map<String, dynamic> json = Map<String, dynamic>.from(data);
  27. if (json == null || json.length == 0) {
  28. return;
  29. }
  30. List mods = json['mod_list'];
  31. if (mods.first != null) {
  32. json = Map<String, dynamic>.from(mods.first);
  33. String d = json['data'];
  34. if (json.containsKey('data')) {
  35. String d = json['data'];
  36. Map<String, dynamic> da =
  37. Map<String, dynamic>.from(convert.jsonDecode(d));
  38. _model = WithdrawModel.fromJson(da);
  39. _dataController.add(_model);
  40. }
  41. }
  42. } catch (err) {
  43. Logger.error(err);
  44. }
  45. }
  46. }