feat: 观看记录查询
This commit is contained in:
44
lib/pages/history/controller.dart
Normal file
44
lib/pages/history/controller.dart
Normal file
@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/user.dart';
|
||||
import 'package:pilipala/models/user/history.dart';
|
||||
|
||||
class HistoryController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
RxList<HisListItem> historyList = [HisListItem()].obs;
|
||||
bool isLoadingMore = false;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
queryHistoryList();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
Future queryHistoryList({type = 'init'}) async {
|
||||
int max = 0;
|
||||
int viewAt = 0;
|
||||
if (type == 'onload') {
|
||||
max = historyList.last.history!.oid!;
|
||||
viewAt = historyList.last.viewAt!;
|
||||
}
|
||||
isLoadingMore = true;
|
||||
var res = await UserHttp.historyList(max, viewAt);
|
||||
isLoadingMore = false;
|
||||
if (res['status']) {
|
||||
if (type == 'onload') {
|
||||
historyList.addAll(res['data'].list);
|
||||
} else {
|
||||
historyList.value = res['data'].list;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Future onLoad() async {
|
||||
queryHistoryList(type: 'onload');
|
||||
}
|
||||
|
||||
Future onRefresh() async {
|
||||
queryHistoryList(type: 'onRefresh');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user