Skip to content

Commit

Permalink
fix: 番剧支持点击后跳转至历史epId
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Mar 21, 2024
1 parent 8e17b0d commit f67e90e
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 6 deletions.
73 changes: 71 additions & 2 deletions lib/models/bangumi/info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class BangumiInfoModel {
String? title;
int? total;
int? type;
Map? userStatus;
UserStatus? userStatus;
String? staff;

BangumiInfoModel.fromJson(Map<String, dynamic> json) {
Expand Down Expand Up @@ -121,7 +121,7 @@ class BangumiInfoModel {
title = json['title'];
total = json['total'];
type = json['type'];
userStatus = json['user_status'];
userStatus = UserStatus.fromJson(json['user_status']);
staff = json['staff'];
}
}
Expand All @@ -138,6 +138,7 @@ class EpisodeItem {
this.dimension,
this.duration,
this.enableVt,
this.epId,
this.from,
this.id,
this.isViewHide,
Expand Down Expand Up @@ -167,6 +168,7 @@ class EpisodeItem {
Map? dimension;
int? duration;
bool? enableVt;
int? epId;
String? from;
int? id;
bool? isViewHide;
Expand Down Expand Up @@ -196,6 +198,7 @@ class EpisodeItem {
dimension = json['dimension'];
duration = json['duration'];
enableVt = json['enable_vt'];
epId = json['ep_id'];
from = json['from'];
id = json['id'];
isViewHide = json['is_view_hide'];
Expand All @@ -215,3 +218,69 @@ class EpisodeItem {
vid = json['vid'];
}
}
class UserStatus {
UserStatus({
this.areaLimit,
this.banAreaShow,
this.follow,
this.followStatus,
this.login,
this.pay,
this.payPackPaid,
this.progress,
this.sponsor,
this.vipInfo,
});
int? areaLimit;
int? banAreaShow;
int? follow;
int? followStatus;
int? login;
int? pay;
int? payPackPaid;
UserProgress? progress;
int? sponsor;
VipInfo? vipInfo;
UserStatus.fromJson(Map<String, dynamic> json) {
areaLimit = json['area_limit'];
banAreaShow = json['ban_area_show'];
follow = json['follow'];
followStatus = json['follow_status'];
login = json['login'];
pay = json['pay'];
payPackPaid = json['pay_pack_paid'];
progress = UserProgress.fromJson(json['progress']);
sponsor = json['sponsor'];
vipInfo = VipInfo.fromJson(json['vip_info']);
}
}
class UserProgress {
UserProgress({
this.lastEpId,
this.lastEpIndex,
this.lastTime,
});
int? lastEpId;
String? lastEpIndex;
int? lastTime;
UserProgress.fromJson(Map<String, dynamic> json) {
lastEpId = json['last_ep_id'];
lastEpIndex = json['last_ep_index'];
lastTime = json['last_time'];
}
}
class VipInfo {
VipInfo({
this.dueDate,
this.status,
this.type,
});
int? dueDate;
int? status;
int? type;
VipInfo.fromJson(Map<String, dynamic> json) {
dueDate = json['due_date'];
status = json['status'];
type = json['type'];
}
}
15 changes: 14 additions & 1 deletion lib/pages/bangumi/widgets/bangumu_card_v.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,25 @@ class BangumiCardV extends StatelessWidget {
return;
}
EpisodeItem episode = res['data'].episodes.first;
int? epId = res['data'].userStatus?.progress?.lastEpId;
if (epId == null) {
epId = episode.epId;
} else {
for (var item in res['data'].episodes) {
if (item.epId == epId) {
episode = item;
break;
}
}
}
String bvid = episode.bvid!;
int cid = episode.cid!;
String pic = episode.cover!;
print('epId');
print(epId);
String heroTag = Utils.makeHeroTag(cid);
Get.toNamed(
'/video?bvid=$bvid&cid=$cid&seasonId=$seasonId',
'/video?bvid=$bvid&cid=$cid&seasonId=$seasonId&epId=$epId',
arguments: {
'pic': pic,
'heroTag': heroTag,
Expand Down
13 changes: 12 additions & 1 deletion lib/pages/dynamics/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,23 @@ class DynamicsController extends GetxController {
SmartDialog.dismiss();
if (res['status']) {
EpisodeItem episode = res['data'].episodes.first;
int? epId = res['data'].userStatus?.progress?.lastEpId;
if (epId == null) {
epId = episode.epId;
} else {
for (var item in res['data'].episodes) {
if (item.epId == epId) {
episode = item;
break;
}
}
}
String bvid = episode.bvid!;
int cid = episode.cid!;
String pic = episode.cover!;
String heroTag = Utils.makeHeroTag(cid);
Get.toNamed(
'/video?bvid=$bvid&cid=$cid&seasonId=${res['data'].seasonId}',
'/video?bvid=$bvid&cid=$cid&seasonId=${res['data'].seasonId}&epid=$epId',
arguments: {
'pic': pic,
'heroTag': heroTag,
Expand Down
8 changes: 7 additions & 1 deletion lib/pages/history/widgets/item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,18 @@ class HistoryItem extends StatelessWidget {
SmartDialog.dismiss();
if (res['status']) {
EpisodeItem episode = res['data'].episodes.first;
for (EpisodeItem i in res['data'].episodes) {
if (i.epId == videoItem.history.epid) {
episode = i;
break;
}
}
String bvid = episode.bvid!;
int cid = episode.cid!;
String pic = episode.cover!;
String heroTag = Utils.makeHeroTag(cid);
Get.toNamed(
'/video?bvid=$bvid&cid=$cid&seasonId=${res['data'].seasonId}',
'/video?bvid=$bvid&cid=$cid&seasonId=${res['data'].seasonId}&epid=${episode.epId}',
arguments: {
'pic': pic,
'heroTag': heroTag,
Expand Down
13 changes: 12 additions & 1 deletion lib/pages/search_panel/widgets/media_bangumi_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,23 @@ Widget searchMbangumiPanel(BuildContext context, ctr, list) {
if (res['status']) {
EpisodeItem episode =
res['data'].episodes.first;
int? epId = res['data'].userStatus?.progress?.lastEpId;
if (epId == null) {
epId = episode.epId;
} else {
for (var item in res['data'].episodes) {
if (item.epId == epId) {
episode = item;
break;
}
}
}
String bvid = episode.bvid!;
int cid = episode.cid!;
String pic = episode.cover!;
String heroTag = Utils.makeHeroTag(cid);
Get.toNamed(
'/video?bvid=$bvid&cid=$cid&seasonId=${i.seasonId}',
'/video?bvid=$bvid&cid=$cid&seasonId=${i.seasonId}&epid=$epId',
arguments: {
'pic': pic,
'heroTag': heroTag,
Expand Down

0 comments on commit f67e90e

Please sign in to comment.