mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 我的订阅新增播单支持
This commit is contained in:
@@ -517,8 +517,11 @@ class Api {
|
|||||||
/// 我的订阅
|
/// 我的订阅
|
||||||
static const userSubFolder = '/x/v3/fav/folder/collected/list';
|
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';
|
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 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';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,13 +334,33 @@ class UserHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future userSubFolderDetail({
|
static Future favSeasonList({
|
||||||
required int seasonId,
|
required int id,
|
||||||
required int pn,
|
required int pn,
|
||||||
required int ps,
|
required int ps,
|
||||||
}) async {
|
}) async {
|
||||||
var res = await Request().get(Api.userSubFolderDetail, data: {
|
var res = await Request().get(Api.favSeasonList, data: {
|
||||||
'season_id': seasonId,
|
'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,
|
'ps': ps,
|
||||||
'pn': pn,
|
'pn': pn,
|
||||||
});
|
});
|
||||||
@@ -355,15 +375,26 @@ class UserHttp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 取消订阅
|
// 取消订阅
|
||||||
static Future cancelSub({required int seasonId}) async {
|
static Future cancelSub({required int id, required int type}) async {
|
||||||
var res = await Request().post(
|
late dynamic res;
|
||||||
Api.cancelSub,
|
if (type == 11) {
|
||||||
queryParameters: {
|
res = await Request().post(
|
||||||
'platform': 'web',
|
Api.unfavFolder,
|
||||||
'season_id': seasonId,
|
queryParameters: {
|
||||||
'csrf': await Request.getCsrf(),
|
'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) {
|
if (res.data['code'] == 0) {
|
||||||
return {'status': true};
|
return {'status': true};
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ class SubController extends GetxController {
|
|||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var res = await UserHttp.cancelSub(seasonId: subFolderItem.id!);
|
var res = await UserHttp.cancelSub(
|
||||||
|
id: subFolderItem.id!, type: subFolderItem.type!);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
subFolderData.value.list!.remove(subFolderItem);
|
subFolderData.value.list!.remove(subFolderItem);
|
||||||
subFolderData.update((val) {});
|
subFolderData.update((val) {});
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class SubItem extends StatelessWidget {
|
|||||||
arguments: subFolderItem,
|
arguments: subFolderItem,
|
||||||
parameters: {
|
parameters: {
|
||||||
'heroTag': heroTag,
|
'heroTag': heroTag,
|
||||||
'seasonId': subFolderItem.id.toString(),
|
'id': subFolderItem.id.toString(),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -77,6 +77,14 @@ class VideoContent extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// subFolderItem.type == 11:播单
|
||||||
|
// subFolderItem.type == 21:合集
|
||||||
|
// 其它:其它
|
||||||
|
String typeString = subFolderItem.type == 11
|
||||||
|
? '播单'
|
||||||
|
: subFolderItem.type == 21
|
||||||
|
? '合集'
|
||||||
|
: '其它:${subFolderItem.type}';
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@@ -95,7 +103,7 @@ class VideoContent extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Text(
|
Text(
|
||||||
'合集 UP主:${subFolderItem.upper!.name!}',
|
'[$typeString] UP主:${subFolderItem.upper!.name!}',
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import '../../models/user/sub_folder.dart';
|
|||||||
class SubDetailController extends GetxController {
|
class SubDetailController extends GetxController {
|
||||||
late SubFolderItemData item;
|
late SubFolderItemData item;
|
||||||
|
|
||||||
late int seasonId;
|
late int id;
|
||||||
late String heroTag;
|
late String heroTag;
|
||||||
int currentPage = 1;
|
int currentPage = 1;
|
||||||
bool isLoadingMore = false;
|
bool isLoadingMore = false;
|
||||||
@@ -15,12 +15,14 @@ class SubDetailController extends GetxController {
|
|||||||
RxList<SubDetailMediaItem> subList = <SubDetailMediaItem>[].obs;
|
RxList<SubDetailMediaItem> subList = <SubDetailMediaItem>[].obs;
|
||||||
RxString loadingText = '加载中...'.obs;
|
RxString loadingText = '加载中...'.obs;
|
||||||
int mediaCount = 0;
|
int mediaCount = 0;
|
||||||
|
RxInt playCount = 0.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
item = Get.arguments;
|
item = Get.arguments;
|
||||||
|
if (playCount.value == 0) playCount.value = item.viewCount!;
|
||||||
if (Get.parameters.keys.isNotEmpty) {
|
if (Get.parameters.keys.isNotEmpty) {
|
||||||
seasonId = int.parse(Get.parameters['seasonId']!);
|
id = int.parse(Get.parameters['id']!);
|
||||||
heroTag = Get.parameters['heroTag']!;
|
heroTag = Get.parameters['heroTag']!;
|
||||||
}
|
}
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -32,16 +34,28 @@ class SubDetailController extends GetxController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isLoadingMore = true;
|
isLoadingMore = true;
|
||||||
var res = await UserHttp.userSubFolderDetail(
|
late Map<String,dynamic> res;
|
||||||
seasonId: seasonId,
|
if (item.type! == 11) {
|
||||||
ps: 20,
|
res = await UserHttp.favResourceList(
|
||||||
pn: currentPage,
|
id: id,
|
||||||
);
|
ps: 20,
|
||||||
|
pn: currentPage,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
res = await UserHttp.favSeasonList(// item.type! == 21
|
||||||
|
id: id,
|
||||||
|
ps: 20,
|
||||||
|
pn: currentPage,
|
||||||
|
);
|
||||||
|
}
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
subInfo.value = res['data'].info;
|
subInfo.value = res['data'].info;
|
||||||
if (currentPage == 1 && type == 'init') {
|
if (currentPage == 1 && type == 'init') {
|
||||||
subList.value = res['data'].medias;
|
subList.value = res['data'].medias;
|
||||||
mediaCount = res['data'].info.mediaCount;
|
mediaCount = res['data'].info.mediaCount;
|
||||||
|
if (item.type == 11) {
|
||||||
|
playCount.value = res['data'].info.cntInfo!['play'];
|
||||||
|
}
|
||||||
} else if (type == 'onLoad') {
|
} else if (type == 'onLoad') {
|
||||||
subList.addAll(res['data'].medias);
|
subList.addAll(res['data'].medias);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
|||||||
Get.put(SubDetailController());
|
Get.put(SubDetailController());
|
||||||
late StreamController<bool> titleStreamC; // a
|
late StreamController<bool> titleStreamC; // a
|
||||||
late Future _futureBuilderFuture;
|
late Future _futureBuilderFuture;
|
||||||
late String seasonId;
|
late String id;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
seasonId = Get.parameters['seasonId']!;
|
id = Get.parameters['id']!;
|
||||||
_futureBuilderFuture = _subDetailController.queryUserSubFolderDetail();
|
_futureBuilderFuture = _subDetailController.queryUserSubFolderDetail();
|
||||||
titleStreamC = StreamController<bool>();
|
titleStreamC = StreamController<bool>();
|
||||||
_controller.addListener(
|
_controller.addListener(
|
||||||
@@ -162,14 +162,17 @@ class _SubDetailPageState extends State<SubDetailPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Obx(
|
||||||
'${Utils.numFormat(_subDetailController.item.viewCount)}次播放',
|
() => Text(
|
||||||
style: TextStyle(
|
'${Utils.numFormat(_subDetailController.playCount.value)}次播放',
|
||||||
fontSize: Theme.of(context)
|
style: TextStyle(
|
||||||
.textTheme
|
fontSize: Theme.of(context)
|
||||||
.labelSmall!
|
.textTheme
|
||||||
.fontSize,
|
.labelSmall!
|
||||||
color: Theme.of(context).colorScheme.outline),
|
.fontSize,
|
||||||
|
color:
|
||||||
|
Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user