mod: 首页推荐视频
This commit is contained in:
@ -2,14 +2,16 @@ 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/models/models_rec_video_item.dart';
|
||||
|
||||
class HomeController extends GetxController {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
int count = 12;
|
||||
int _currentPage = 1;
|
||||
int crossAxisCount = 2;
|
||||
RxList videoList = [].obs;
|
||||
RxList<RecVideoItemModel> videoList = [RecVideoItemModel()].obs;
|
||||
bool isLoadingMore = false;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@ -22,13 +24,17 @@ class HomeController extends GetxController {
|
||||
Api.recommendList,
|
||||
data: {'feed_version': "V3", 'ps': count, 'fresh_idx': _currentPage},
|
||||
);
|
||||
var data = res.data['data']['item'];
|
||||
List<RecVideoItemModel> list = [];
|
||||
for (var i in res.data['data']['item']) {
|
||||
print(i);
|
||||
list.add(RecVideoItemModel.fromJson(i));
|
||||
}
|
||||
if (type == 'init') {
|
||||
videoList.value = data;
|
||||
videoList.value = list;
|
||||
} else if (type == 'onRefresh') {
|
||||
videoList.insertAll(0, data);
|
||||
videoList.insertAll(0, list);
|
||||
} else if (type == 'onLoad') {
|
||||
videoList.addAll(data);
|
||||
videoList.addAll(list);
|
||||
}
|
||||
_currentPage += 1;
|
||||
isLoadingMore = false;
|
||||
|
||||
Reference in New Issue
Block a user