mod: 关注、粉丝页面优化
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/http/follow.dart';
|
||||
@ -7,11 +8,13 @@ import 'package:pilipala/utils/storage.dart';
|
||||
class FollowController extends GetxController {
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
int pn = 1;
|
||||
int ps = 20;
|
||||
int total = 0;
|
||||
RxList<FollowItemModel> followList = [FollowItemModel()].obs;
|
||||
late int mid;
|
||||
late String name;
|
||||
var userInfo;
|
||||
RxString loadingText = '加载中...'.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -26,23 +29,30 @@ class FollowController extends GetxController {
|
||||
Future queryFollowings(type) async {
|
||||
if (type == 'init') {
|
||||
pn = 1;
|
||||
loadingText.value == '加载中...';
|
||||
}
|
||||
if (loadingText.value == '没有更多了') {
|
||||
return;
|
||||
}
|
||||
var res = await FollowHttp.followings(
|
||||
vmid: mid,
|
||||
pn: pn,
|
||||
ps: 20,
|
||||
ps: ps,
|
||||
orderType: 'attention',
|
||||
);
|
||||
if (res['status']) {
|
||||
if (type == 'init') {
|
||||
followList.value = res['data'].list;
|
||||
total = res['data'].total;
|
||||
} else if (type == 'onRefresh') {
|
||||
followList.insertAll(0, res['data'].list);
|
||||
} else if (type == 'onLoad') {
|
||||
followList.addAll(res['data'].list);
|
||||
}
|
||||
if ((pn == 1 && total < ps) || res['data'].list.isEmpty) {
|
||||
loadingText.value = '没有更多了';
|
||||
}
|
||||
pn += 1;
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user