game_info_model.dart 941 B

123456789101112131415161718192021222324252627282930313233343536
  1. import 'dart:math';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:sport/bean/game.dart';
  4. import 'package:sport/provider/lib/view_state_refresh_list_model.dart';
  5. import 'package:sport/services/api/inject_api.dart';
  6. class GameInfoModel extends ChangeNotifier with InjectApi {
  7. /// 登录
  8. Future<GameInfoData> getGameInfo() async {
  9. dynamic data = await api.getGameAll();
  10. notifyListeners();
  11. return data;
  12. }
  13. }
  14. class CommentListModel extends ViewStateRefreshListModel with InjectApi {
  15. String id;
  16. String by = "like_count";
  17. CommentListModel(this.id, {this.by = "like_count"});
  18. @override
  19. Future<List> loadData({int pageNum = 1}) async {
  20. return handlePage(await api.getPostComments(id, page: max(1, pageNum), sortBy: by));
  21. }
  22. sortBy(String name) {
  23. if (name == "点赞最多") {
  24. by = "like_count";
  25. } else if (name == "最新评论") {
  26. by = "created_at";
  27. }
  28. initData();
  29. }
  30. }