diff --git a/lib/http/api.dart b/lib/http/api.dart index 77731b6d..fcf272fd 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -517,8 +517,11 @@ class Api { /// 我的订阅 static const userSubFolder = '/x/v3/fav/folder/collected/list'; - /// 我的订阅详情 - static const userSubFolderDetail = '/x/space/fav/season/list'; + /// 我的订阅-合集详情 + static const favSeasonList = '/x/space/fav/season/list'; + + /// 我的订阅-播单详情 + static const favResourceList = '/x/v3/fav/resource/list'; /// 发送私信 static const String sendMsg = '${HttpString.tUrl}/web_im/v1/web_im/send_msg'; @@ -526,6 +529,9 @@ class Api { /// 排行榜 static const String getRankApi = "/x/web-interface/ranking/v2"; - /// 取消订阅 - static const String cancelSub = '/x/v3/fav/season/unfav'; + /// 取消订阅-合集 + static const String unfavSeason = '/x/v3/fav/season/unfav'; + + /// 取消订阅-播单 + static const String unfavFolder = '/x/v3/fav/folder/unfav'; } diff --git a/lib/http/user.dart b/lib/http/user.dart index 3b325343..166ab59b 100644 --- a/lib/http/user.dart +++ b/lib/http/user.dart @@ -334,13 +334,33 @@ class UserHttp { } } - static Future userSubFolderDetail({ - required int seasonId, + static Future favSeasonList({ + required int id, required int pn, required int ps, }) async { - var res = await Request().get(Api.userSubFolderDetail, data: { - 'season_id': seasonId, + var res = await Request().get(Api.favSeasonList, data: { + 'season_id': id, + 'ps': ps, + 'pn': pn, + }); + if (res.data['code'] == 0) { + return { + 'status': true, + 'data': SubDetailModelData.fromJson(res.data['data']) + }; + } else { + return {'status': false, 'msg': res.data['message']}; + } + } + + static Future favResourceList({ + required int id, + required int pn, + required int ps, + }) async { + var res = await Request().get(Api.favResourceList, data: { + 'media_id': id, 'ps': ps, 'pn': pn, }); @@ -355,15 +375,26 @@ class UserHttp { } // 取消订阅 - static Future cancelSub({required int seasonId}) async { - var res = await Request().post( - Api.cancelSub, - queryParameters: { - 'platform': 'web', - 'season_id': seasonId, - 'csrf': await Request.getCsrf(), - }, - ); + static Future cancelSub({required int id, required int type}) async { + late dynamic res; + if (type == 11) { + res = await Request().post( + Api.unfavFolder, + queryParameters: { + 'media_id': id, + 'csrf': await Request.getCsrf(), + }, + ); + } else { + res = await Request().post( + Api.unfavSeason, + queryParameters: { + 'platform': 'web', + 'season_id': id, + 'csrf': await Request.getCsrf(), + }, + ); + } if (res.data['code'] == 0) { return {'status': true}; } else { diff --git a/lib/pages/subscription/controller.dart b/lib/pages/subscription/controller.dart index 3ccd138f..8731f36c 100644 --- a/lib/pages/subscription/controller.dart +++ b/lib/pages/subscription/controller.dart @@ -66,7 +66,8 @@ class SubController extends GetxController { ), TextButton( onPressed: () async { - var res = await UserHttp.cancelSub(seasonId: subFolderItem.id!); + var res = await UserHttp.cancelSub( + id: subFolderItem.id!, type: subFolderItem.type!); if (res['status']) { subFolderData.value.list!.remove(subFolderItem); subFolderData.update((val) {}); diff --git a/lib/pages/subscription/widgets/item.dart b/lib/pages/subscription/widgets/item.dart index e78a4dd5..b94b7698 100644 --- a/lib/pages/subscription/widgets/item.dart +++ b/lib/pages/subscription/widgets/item.dart @@ -24,7 +24,7 @@ class SubItem extends StatelessWidget { arguments: subFolderItem, parameters: { 'heroTag': heroTag, - 'seasonId': subFolderItem.id.toString(), + 'id': subFolderItem.id.toString(), }, ), child: Padding( @@ -77,6 +77,14 @@ class VideoContent extends StatelessWidget { @override Widget build(BuildContext context) { + // subFolderItem.type == 11:播单 + // subFolderItem.type == 21:合集 + // 其它:其它 + String typeString = subFolderItem.type == 11 + ? '播单' + : subFolderItem.type == 21 + ? '合集' + : '其它:${subFolderItem.type}'; return Expanded( child: Stack( children: [ @@ -95,7 +103,7 @@ class VideoContent extends StatelessWidget { ), const SizedBox(height: 2), Text( - '合集 UP主:${subFolderItem.upper!.name!}', + '[$typeString] UP主:${subFolderItem.upper!.name!}', textAlign: TextAlign.start, style: TextStyle( fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, diff --git a/lib/pages/subscription_detail/controller.dart b/lib/pages/subscription_detail/controller.dart index a15a4ae2..75138bfc 100644 --- a/lib/pages/subscription_detail/controller.dart +++ b/lib/pages/subscription_detail/controller.dart @@ -7,7 +7,7 @@ import '../../models/user/sub_folder.dart'; class SubDetailController extends GetxController { late SubFolderItemData item; - late int seasonId; + late int id; late String heroTag; int currentPage = 1; bool isLoadingMore = false; @@ -15,12 +15,14 @@ class SubDetailController extends GetxController { RxList subList = [].obs; RxString loadingText = '加载中...'.obs; int mediaCount = 0; + RxInt playCount = 0.obs; @override void onInit() { item = Get.arguments; + if (playCount.value == 0) playCount.value = item.viewCount!; if (Get.parameters.keys.isNotEmpty) { - seasonId = int.parse(Get.parameters['seasonId']!); + id = int.parse(Get.parameters['id']!); heroTag = Get.parameters['heroTag']!; } super.onInit(); @@ -32,16 +34,28 @@ class SubDetailController extends GetxController { return; } isLoadingMore = true; - var res = await UserHttp.userSubFolderDetail( - seasonId: seasonId, - ps: 20, - pn: currentPage, - ); + late Map res; + if (item.type! == 11) { + res = await UserHttp.favResourceList( + id: id, + ps: 20, + pn: currentPage, + ); + } else { + res = await UserHttp.favSeasonList(// item.type! == 21 + id: id, + ps: 20, + pn: currentPage, + ); + } if (res['status']) { subInfo.value = res['data'].info; if (currentPage == 1 && type == 'init') { subList.value = res['data'].medias; mediaCount = res['data'].info.mediaCount; + if (item.type == 11) { + playCount.value = res['data'].info.cntInfo!['play']; + } } else if (type == 'onLoad') { subList.addAll(res['data'].medias); } diff --git a/lib/pages/subscription_detail/view.dart b/lib/pages/subscription_detail/view.dart index 960bf7f8..b25c75d8 100644 --- a/lib/pages/subscription_detail/view.dart +++ b/lib/pages/subscription_detail/view.dart @@ -26,12 +26,12 @@ class _SubDetailPageState extends State { Get.put(SubDetailController()); late StreamController titleStreamC; // a late Future _futureBuilderFuture; - late String seasonId; + late String id; @override void initState() { super.initState(); - seasonId = Get.parameters['seasonId']!; + id = Get.parameters['id']!; _futureBuilderFuture = _subDetailController.queryUserSubFolderDetail(); titleStreamC = StreamController(); _controller.addListener( @@ -162,14 +162,17 @@ class _SubDetailPageState extends State { ), ), const SizedBox(height: 4), - Text( - '${Utils.numFormat(_subDetailController.item.viewCount)}次播放', - style: TextStyle( - fontSize: Theme.of(context) - .textTheme - .labelSmall! - .fontSize, - color: Theme.of(context).colorScheme.outline), + Obx( + () => Text( + '${Utils.numFormat(_subDetailController.playCount.value)}次播放', + style: TextStyle( + fontSize: Theme.of(context) + .textTheme + .labelSmall! + .fontSize, + color: + Theme.of(context).colorScheme.outline), + ), ), ], ),