mod: merge main
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/api.dart';
|
||||
import 'package:pilipala/http/init.dart';
|
||||
import 'package:pilipala/http/video.dart';
|
||||
import 'package:pilipala/models/model_rec_video_item.dart';
|
||||
|
||||
class HomeController extends GetxController {
|
||||
@ -17,28 +16,27 @@ class HomeController extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
queryRcmdFeed('init');
|
||||
// queryRcmdFeed('init');
|
||||
}
|
||||
|
||||
// 获取推荐
|
||||
Future queryRcmdFeed(type) async {
|
||||
var res = await Request().get(
|
||||
Api.recommendList,
|
||||
data: {'feed_version': "V3", 'ps': count, 'fresh_idx': _currentPage},
|
||||
var res = await VideoHttp.rcmdVideoList(
|
||||
ps: count,
|
||||
freshIdx: _currentPage,
|
||||
);
|
||||
List<RecVideoItemModel> list = [];
|
||||
for (var i in res.data['data']['item']) {
|
||||
list.add(RecVideoItemModel.fromJson(i));
|
||||
if (res['status']) {
|
||||
if (type == 'init') {
|
||||
videoList.value = res['data'];
|
||||
} else if (type == 'onRefresh') {
|
||||
videoList.insertAll(0, res['data']);
|
||||
} else if (type == 'onLoad') {
|
||||
videoList.addAll(res['data']);
|
||||
}
|
||||
_currentPage += 1;
|
||||
}
|
||||
if (type == 'init') {
|
||||
videoList.value = list;
|
||||
} else if (type == 'onRefresh') {
|
||||
videoList.insertAll(0, list);
|
||||
} else if (type == 'onLoad') {
|
||||
videoList.addAll(list);
|
||||
}
|
||||
_currentPage += 1;
|
||||
isLoadingMore = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
// 下拉刷新
|
||||
@ -48,7 +46,6 @@ class HomeController extends GetxController {
|
||||
|
||||
// 上拉加载
|
||||
Future onLoad() async {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
queryRcmdFeed('onLoad');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user