shop_model.dart 975 B

1234567891011121314151617181920212223242526272829303132333435
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:sport/bean/user_friend.dart';
  3. import 'package:sport/provider/lib/view_state_list_model.dart';
  4. import 'package:sport/services/api/inject_api.dart';
  5. import 'package:sport/bean/shop.dart';
  6. import 'lib/view_state_model.dart';
  7. import 'lib/view_state_refresh_list_model.dart';
  8. class ShopModel extends ViewStateModel with InjectApi {
  9. ShopIndex? shop;
  10. init() async {
  11. try {
  12. ShopIndex? shopIndex = (await api.getShopIndex()).data;
  13. // return shopIndex;
  14. shop = shopIndex;
  15. setIdle();
  16. } catch (e) {
  17. print(e);
  18. setEmpty();
  19. }
  20. return shop;
  21. }
  22. }
  23. class ScoreModel extends ViewStateRefreshListModel<ScoreListData> with InjectApi{
  24. List<ScoreListData> scoreList = [];
  25. @override
  26. Future<List<ScoreListData>> loadData({int pageNum=0}) async{
  27. List<ScoreListData>? _list = (await api.getScoreIndex()).data?.data;
  28. scoreList = _list ?? [];
  29. return scoreList;
  30. }
  31. }