feat: 播放处理,个人中心,

This commit is contained in:
chengsiwen committed 2026-06-30 16:05:17 +08:00
1 parent e59ac2177b
commit 4ccea08472
37 files changed
+1425 -115

No files matched your search

+82 -17
View File
@@ -1,4 +1,3 @@
import 'package:skywood/global/request/api_const.dart';
import 'package:skywood/global/request/app_request.dart';
import 'package:skywood/global/tool/sky_log.dart';
@@ -8,7 +7,6 @@ import 'package:skywood/utils/models/drama/skywood_drama.dart';
import 'package:skywood/utils/models/drama/skywood_home.dart';
class PlayClient {
static Future<List<SkywoodHome>> getHomeData() {
return AppRequest.get(ApiStringPlay.getHomeModules).then((value) {
if (value.isSuccess) {
@@ -42,6 +40,20 @@ class PlayClient {
});
}
static Future<List<SkywoodDrama>> getCategoriesDetail({
required int categoryId,
int page = 1,
int pageSize = 20,
}) {
return AppRequest.fetchPage<SkywoodDrama>(
ApiStringPlay.getCategoriesDetail,
page: page,
pageSize: pageSize,
extraParams: {'category_id': categoryId},
fromJson: (json) => SkywoodDrama.fromJson(json),
);
}
// getSearchHots
static Future<List<SkywoodDrama>> getSearchHots() {
return AppRequest.get(ApiStringPlay.getSearchHots).then((value) {
@@ -54,29 +66,53 @@ class PlayClient {
});
}
// search
static Future<List<SkywoodDrama>> search({required String keyword}) {
return AppRequest.get(ApiStringPlay.getSearch, queryParameters: {
'search': keyword,
}).then((value) {
if (value.isSuccess) {
SkyLog.print('getSearchHots: ${value.data}');
List list = parseDataForList(value.data);
return list.map((e) => SkywoodDrama.fromJson(e)).toList();
}
return [];
});
}
//getCollections
static Future<List> getCollections({
int page = 1, int pageSize = 10
static Future<List<SkywoodDrama>> getCollections({
int page = 1,
int pageSize = 10,
}) {
Map<String, dynamic> params = _setPage(page: page, pageSize: pageSize);
return AppRequest.get(ApiStringPlay.getCollections, queryParameters: params).then((value) {
return AppRequest.get(
ApiStringPlay.getCollections,
queryParameters: params,
).then((value) {
if (value.isSuccess) {
SkyLog.print('getCollections: ${value.data}');
List list = parseDataForList(value.data);
return list.map((e) => SkywoodDrama.fromJson(e)).toList();
}
return [];
});
}
// getHistory
static Future<List> getHistory({
int page = 1, int pageSize = 10
static Future<List<SkywoodDrama>> getHistory({
int page = 1,
int pageSize = 10,
}) {
Map<String, dynamic> params = _setPage(page: page, pageSize: pageSize);
return AppRequest.get(ApiStringPlay.getHistories, queryParameters: params).then((value) {
return AppRequest.get(
ApiStringPlay.getHistories,
queryParameters: params,
).then((value) {
if (value.isSuccess) {
SkyLog.print('getHistory: ${value.data}');
List list = parseDataForList(value.data);
return list.map((e) => SkywoodDrama.fromJson(e)).toList();
}
return [];
});
@@ -90,19 +126,48 @@ class PlayClient {
Map<String, dynamic> params = {};
params['short_play_id'] = shortPlayId;
params['short_play_video_id'] = shortPlayVideoId;
return AppRequest.get(ApiStringPlay.getVideoDetail, queryParameters: params).then((value) {
return AppRequest.get(
ApiStringPlay.getVideoDetail,
queryParameters: params,
).then((value) {
if (value.isSuccess) {
SkyLog.print('getVideoDetail: ${value.data}');
SkyLog.print('getVideoDetail: ${value.data['data']}');
return SkywoodDetail.fromJson(value.data['data']);
}
return null;
});
}
// collect
static Future<bool> collect({
required int shortPlayId,
required int videoId,
}) {
Map<String, dynamic> params = {};
params['short_play_id'] = shortPlayId;
params['video_id'] = videoId;
return AppRequest.post(ApiStringPlay.collect, data: params).then((value) {
SkyLog.print('collecttttt: ${value.data}');
if (value.isSuccess) {}
return value.isSuccess;
});
}
// cancelCollect
static Future<bool> cancelCollect({required int shortPlayId}) {
Map<String, dynamic> params = {};
params['short_play_id'] = shortPlayId;
return AppRequest.post(ApiStringPlay.cancelCollect, data: params).then((
value,
) {
SkyLog.print('cancelCollectttt: ${value.data}');
if (value.isSuccess) {}
return value.isSuccess;
});
}
static Map<String, dynamic> _setPage({int page = 1, int pageSize = 10}) {
return {
'current_page': page,
'page_size': pageSize,
};
return {'current_page': page, 'page_size': pageSize};
}
static List parseDataForList(Map<String, dynamic> data) {
@@ -110,4 +175,4 @@ class PlayClient {
List? listData = map['list'];
return listData ?? [];
}
}
}
+11
View File
@@ -3,6 +3,7 @@ import 'package:skywood/global/request/api_const.dart';
import 'package:skywood/global/request/app_request.dart';
import 'package:skywood/global/tool/sky_log.dart';
import 'package:skywood/utils/models/user/register_bean.dart';
import 'package:skywood/utils/models/user/skywood_user.dart';
class UserClient {
@@ -27,4 +28,14 @@ class UserClient {
return null;
});
}
static Future<SkywoodUser?> getUserInfo() {
return AppRequest.get(ApiString.userInfo).then((value) {
if (value.isSuccess) {
SkyLog.print(value.data, tag: 'getUserInfo');
return SkywoodUser.fromJson(value.data['data']);
}
return null;
});
}
}
+7 -7
View File
@@ -57,15 +57,15 @@ class ApiString {
class ApiStringPlay {
// getRecommandsList GET /getRecommands 推荐列表,分页参数 current_page/page_size,可带 revolution
// getVideoDetail GET /getVideoDetails 获取剧详情,query: short_play_id, video_id
/// getVideoDetail GET /getVideoDetails 获取剧详情,query: short_play_id, video_id
// getDetailsRecommand GET /getDetailsRecommand 详情页推荐列表;注意方法参数 page/pageSize/data 当前没有传入请求
static const String getRecommandsList = "/getRecommands";
static const String getVideoDetail = "/getVideoDetails";
static const String getDetailsRecommand = "/getDetailsRecommand";
/// getHomeModules GET /home/all-modules 首页全部模块数据
///=== getHomeModules GET /home/all-modules 首页全部模块数据
// getRankingList POST /homeRanking 首页榜单,body 带 type,支持 most_trending/top_searched/new_releases
/// getCategoriesList GET /getCategories 分类列表
///=== getCategoriesList GET /getCategories 分类列表
// getCategoriesDetail GET /videoList 分类详情/剧列表,分页 + extraParams
// getWaterflowList POST /newShortPlay 首页瀑布流,分页 + extraParams
static const String getHomeModules = "/home/all-modules";
@@ -76,10 +76,10 @@ class ApiStringPlay {
/// getSearchHots GET /search/hots 搜索热门列表
// getSearch GET /search 关键词搜索,query: search
// collect POST /collect 收藏,body: short_play_id, video_id
// cancelCollect POST /cancelCollect 取消收藏,body: short_play_id
// getMyCollections GET /myCollections 我的收藏列表,分页
// getMyHistorys GET /myHistorys 播放历史列表,分页
///==== collect POST /collect 收藏,body: short_play_id, video_id
///==== cancelCollect POST /cancelCollect 取消收藏,body: short_play_id
///==== getMyCollections GET /myCollections 我的收藏列表,分页
///==== getMyHistorys GET /myHistorys 播放历史列表,分页
// getNoticeNum POST /noticeNum 获取通知数量
// versionControl GET /customer/versionControl 版本检查
// getLanguges GET /languges 获取语言列表,接口名拼写就是 languges