12345678910111213141516171819202122232425262728293031323334353637383940 |
- import 'dart:math';
- import 'package:flutter/cupertino.dart';
- import 'package:sport/bean/game.dart';
- import 'package:sport/provider/lib/view_state_refresh_list_model.dart';
- import 'package:sport/services/api/inject_api.dart';
- class GameInfoModel extends ChangeNotifier with InjectApi {
- /// 登录
- Future<GameInfoData> getGameInfo() async {
- dynamic data = await api.getGameAll();
- notifyListeners();
- return data;
- }
- }
- class CommentListModel extends ViewStateRefreshListModel with InjectApi {
- String id;
- String by = "like_count";
- CommentListModel(this.id, {this.by = "like_count"});
- int total = 0;
- @override
- Future<List> loadData({int pageNum = 1}) async {
- var page = await api.getPostComments(id, page: max(1, pageNum), sortBy: by);
- total = page.pageResult.count;
- return handlePage(page);
- }
- sortBy(String name) {
- if (name == "点赞最多") {
- by = "like_count";
- } else if (name == "最新评论") {
- by = "created_at";
- }
- initData();
- }
- }
|