opt: bangumi progress
This commit is contained in:
@ -301,10 +301,6 @@ class Api {
|
|||||||
static const String bangumiList =
|
static const String bangumiList =
|
||||||
'/pgc/season/index/result?st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1©right=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&season_type=1&pagesize=20&type=1';
|
'/pgc/season/index/result?st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1©right=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&season_type=1&pagesize=20&type=1';
|
||||||
|
|
||||||
// 我的订阅
|
|
||||||
static const String bangumiFollow =
|
|
||||||
'/x/space/bangumi/follow/list?type=1&follow_status=0&pn=1&ps=15&ts=1691544359969';
|
|
||||||
|
|
||||||
// 黑名单
|
// 黑名单
|
||||||
static const String blackLst = '/x/relation/blacks';
|
static const String blackLst = '/x/relation/blacks';
|
||||||
|
|
||||||
@ -607,4 +603,7 @@ class Api {
|
|||||||
|
|
||||||
/// 更新追番状态
|
/// 更新追番状态
|
||||||
static const String updateBangumiStatus = '/pgc/web/follow/status/update';
|
static const String updateBangumiStatus = '/pgc/web/follow/status/update';
|
||||||
|
|
||||||
|
/// 番剧点赞投币收藏状态
|
||||||
|
static const String bangumiActionStatus = '/pgc/season/episode/community';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,8 +21,19 @@ class BangumiHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future bangumiFollow({int? mid}) async {
|
static Future getRecentBangumi({
|
||||||
var res = await Request().get(Api.bangumiFollow, data: {'vmid': mid});
|
int? mid,
|
||||||
|
int type = 1,
|
||||||
|
int pn = 1,
|
||||||
|
int ps = 20,
|
||||||
|
}) async {
|
||||||
|
var res = await Request().get(Api.getRecentBangumiApi, data: {
|
||||||
|
'vmid': mid,
|
||||||
|
'type': type,
|
||||||
|
'follow_status': 0,
|
||||||
|
'pn': pn,
|
||||||
|
'ps': ps,
|
||||||
|
});
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
return {
|
return {
|
||||||
'status': true,
|
'status': true,
|
||||||
@ -81,4 +92,17 @@ class BangumiHttp {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取番剧点赞投币收藏状态
|
||||||
|
static Future bangumiActionStatus({required int epId}) async {
|
||||||
|
var res = await Request().get(
|
||||||
|
Api.bangumiActionStatus,
|
||||||
|
data: {'ep_id': epId},
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true, 'data': res.data['data']};
|
||||||
|
} else {
|
||||||
|
return {'status': false, 'data': [], 'msg': res.data['message']};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,6 +47,7 @@ class BangumiListItemModel {
|
|||||||
this.title,
|
this.title,
|
||||||
this.titleIcon,
|
this.titleIcon,
|
||||||
this.progress,
|
this.progress,
|
||||||
|
this.progressIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
String? badge;
|
String? badge;
|
||||||
@ -66,8 +67,8 @@ class BangumiListItemModel {
|
|||||||
String? subTitle;
|
String? subTitle;
|
||||||
String? title;
|
String? title;
|
||||||
String? titleIcon;
|
String? titleIcon;
|
||||||
|
|
||||||
String? progress;
|
String? progress;
|
||||||
|
int? progressIndex;
|
||||||
|
|
||||||
BangumiListItemModel.fromJson(Map<String, dynamic> json) {
|
BangumiListItemModel.fromJson(Map<String, dynamic> json) {
|
||||||
badge = json['badge'] == '' ? null : json['badge'];
|
badge = json['badge'] == '' ? null : json['badge'];
|
||||||
@ -87,7 +88,9 @@ class BangumiListItemModel {
|
|||||||
subTitle = json['sub_title'];
|
subTitle = json['sub_title'];
|
||||||
title = json['title'];
|
title = json['title'];
|
||||||
titleIcon = json['title_icon'];
|
titleIcon = json['title_icon'];
|
||||||
|
|
||||||
progress = json['progress'];
|
progress = json['progress'];
|
||||||
|
progressIndex = int.parse(
|
||||||
|
RegExp(r'第(\d+)话').firstMatch(json['progress'] ?? '第1话')?.group(1) ??
|
||||||
|
'0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ class BangumiController extends GetxController {
|
|||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
RxList<BangumiListItemModel> bangumiList = <BangumiListItemModel>[].obs;
|
RxList<BangumiListItemModel> bangumiList = <BangumiListItemModel>[].obs;
|
||||||
RxList<BangumiListItemModel> bangumiFollowList = <BangumiListItemModel>[].obs;
|
RxList<BangumiListItemModel> bangumiFollowList = <BangumiListItemModel>[].obs;
|
||||||
|
RxInt total = 0.obs;
|
||||||
int _currentPage = 1;
|
int _currentPage = 1;
|
||||||
bool isLoadingMore = true;
|
bool isLoadingMore = true;
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
@ -54,9 +55,10 @@ class BangumiController extends GetxController {
|
|||||||
if (userInfo == null) {
|
if (userInfo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var result = await BangumiHttp.bangumiFollow(mid: userInfo.mid);
|
var result = await BangumiHttp.getRecentBangumi(mid: userInfo.mid);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
bangumiFollowList.value = result['data'].list;
|
bangumiFollowList.value = result['data'].list;
|
||||||
|
total.value = result['data'].total;
|
||||||
} else {}
|
} else {}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,12 +79,8 @@ class BangumiIntroController extends GetxController {
|
|||||||
// 获取番剧简介&选集
|
// 获取番剧简介&选集
|
||||||
Future queryBangumiIntro() async {
|
Future queryBangumiIntro() async {
|
||||||
if (userLogin) {
|
if (userLogin) {
|
||||||
// 获取点赞状态
|
// 获取点赞投币收藏状态
|
||||||
queryHasLikeVideo();
|
bangumiActionStatus();
|
||||||
// 获取投币状态
|
|
||||||
queryHasCoinVideo();
|
|
||||||
// 获取收藏状态
|
|
||||||
queryHasFavVideo();
|
|
||||||
}
|
}
|
||||||
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
@ -94,26 +90,15 @@ class BangumiIntroController extends GetxController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取点赞状态
|
// 获取番剧点赞投币收藏状态
|
||||||
Future queryHasLikeVideo() async {
|
Future bangumiActionStatus() async {
|
||||||
var result = await VideoHttp.hasLikeVideo(bvid: bvid);
|
var result = await BangumiHttp.bangumiActionStatus(epId: epId!);
|
||||||
// data num 被点赞标志 0:未点赞 1:已点赞
|
|
||||||
hasLike.value = result["data"] == 1 ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取投币状态
|
|
||||||
Future queryHasCoinVideo() async {
|
|
||||||
var result = await VideoHttp.hasCoinVideo(bvid: bvid);
|
|
||||||
hasCoin.value = result["data"]['multiply'] == 0 ? false : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取收藏状态
|
|
||||||
Future queryHasFavVideo() async {
|
|
||||||
var result = await VideoHttp.hasFavVideo(aid: IdUtils.bv2av(bvid));
|
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
hasFav.value = result["data"]['favoured'];
|
hasLike.value = result['data']['like'] == 1;
|
||||||
|
hasCoin.value = result['data']['coin_number'] != 0;
|
||||||
|
hasFav.value = result['data']['favorite'] == 1;
|
||||||
} else {
|
} else {
|
||||||
hasFav.value = false;
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +106,7 @@ class BangumiIntroController extends GetxController {
|
|||||||
Future actionLikeVideo() async {
|
Future actionLikeVideo() async {
|
||||||
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
|
var result = await VideoHttp.likeVideo(bvid: bvid, type: !hasLike.value);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
SmartDialog.showToast(!hasLike.value ? '点赞成功 👍' : '取消赞');
|
SmartDialog.showToast(!hasLike.value ? '点赞成功' : '取消赞');
|
||||||
hasLike.value = !hasLike.value;
|
hasLike.value = !hasLike.value;
|
||||||
bangumiDetail.value.stat!['likes'] =
|
bangumiDetail.value.stat!['likes'] =
|
||||||
bangumiDetail.value.stat!['likes'] + (!hasLike.value ? 1 : -1);
|
bangumiDetail.value.stat!['likes'] + (!hasLike.value ? 1 : -1);
|
||||||
@ -158,7 +143,7 @@ class BangumiIntroController extends GetxController {
|
|||||||
var res = await VideoHttp.coinVideo(
|
var res = await VideoHttp.coinVideo(
|
||||||
bvid: bvid, multiply: _tempThemeValue);
|
bvid: bvid, multiply: _tempThemeValue);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast('投币成功 👏');
|
SmartDialog.showToast('投币成功');
|
||||||
hasCoin.value = true;
|
hasCoin.value = true;
|
||||||
bangumiDetail.value.stat!['coins'] =
|
bangumiDetail.value.stat!['coins'] =
|
||||||
bangumiDetail.value.stat!['coins'] +
|
bangumiDetail.value.stat!['coins'] +
|
||||||
@ -196,9 +181,11 @@ class BangumiIntroController extends GetxController {
|
|||||||
addMediaIdsNew = [];
|
addMediaIdsNew = [];
|
||||||
delMediaIdsNew = [];
|
delMediaIdsNew = [];
|
||||||
// 重新获取收藏状态
|
// 重新获取收藏状态
|
||||||
queryHasFavVideo();
|
bangumiActionStatus();
|
||||||
SmartDialog.showToast('✅ 操作成功');
|
SmartDialog.showToast('操作成功');
|
||||||
Get.back();
|
Get.back();
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,9 +76,14 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Obx(
|
||||||
'最近追番',
|
() => 0 != _bangumidController.total.value
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
? Text(
|
||||||
|
'我的追番(${_bangumidController.total.value})',
|
||||||
|
style:
|
||||||
|
Theme.of(context).textTheme.titleMedium,
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|||||||
@ -25,6 +25,7 @@ class BangumiCardV extends StatelessWidget {
|
|||||||
RoutePush.bangumiPush(
|
RoutePush.bangumiPush(
|
||||||
bangumiItem.seasonId,
|
bangumiItem.seasonId,
|
||||||
null,
|
null,
|
||||||
|
progressIndex: bangumiItem.progressIndex,
|
||||||
heroTag: heroTag,
|
heroTag: heroTag,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import 'package:pilipala/utils/utils.dart';
|
|||||||
class RoutePush {
|
class RoutePush {
|
||||||
// 番剧跳转
|
// 番剧跳转
|
||||||
static Future<void> bangumiPush(int? seasonId, int? epId,
|
static Future<void> bangumiPush(int? seasonId, int? epId,
|
||||||
{String? heroTag}) async {
|
{String? heroTag, int? progressIndex}) async {
|
||||||
SmartDialog.showLoading<dynamic>(msg: '获取中...');
|
SmartDialog.showLoading<dynamic>(msg: '获取中...');
|
||||||
try {
|
try {
|
||||||
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
||||||
@ -19,7 +19,10 @@ class RoutePush {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final BangumiInfoModel bangumiDetail = result['data'];
|
final BangumiInfoModel bangumiDetail = result['data'];
|
||||||
final EpisodeItem episode = bangumiDetail.episodes!.first;
|
EpisodeItem episode = bangumiDetail.episodes!.first;
|
||||||
|
if (progressIndex != null && progressIndex >= 1) {
|
||||||
|
episode = bangumiDetail.episodes![progressIndex - 1];
|
||||||
|
}
|
||||||
final int epId = episode.id!;
|
final int epId = episode.id!;
|
||||||
final int cid = episode.cid!;
|
final int cid = episode.cid!;
|
||||||
final String bvid = episode.bvid!;
|
final String bvid = episode.bvid!;
|
||||||
|
|||||||
Reference in New Issue
Block a user