JXCollectionViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. //
  2. // JXCollectionViewController.m
  3. // AICity
  4. //
  5. // Created by TogetherWatch on 2025-10-20.
  6. //
  7. #import "JXCollectionViewController.h"
  8. #import "JXAPIService.h"
  9. #import "JXDrama.h"
  10. #import "JXEpisodeInfo.h"
  11. #import "JXInteraction.h"
  12. #import "JXShortDramaCell.h"
  13. #import "videoItemsCell.h"
  14. #import "videoItemsNavCell.h"
  15. // Cell复用标识符
  16. //static NSString * const kEpisodeCellIdentifier = @"JXEpisodeCell";
  17. @interface JXCollectionViewController () <UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
  18. #pragma mark - UI组件
  19. @property (nonatomic, strong) UIView *headerView;
  20. @property (strong, nonatomic) UIImageView *headImg;
  21. @property (nonatomic, strong) UILabel *titleLabel;
  22. @property (nonatomic, strong) UILabel *statsLabel;
  23. @property (nonatomic, strong) UIButton *closeButton;
  24. @property (nonatomic, strong) UIView *rangePickerView;
  25. @property (nonatomic, strong) UIButton *rangeButton1;
  26. @property (nonatomic, strong) UIButton *rangeButton2;
  27. @property (nonatomic, strong) UIButton *rangeButton3;
  28. @property (nonatomic, strong) UICollectionView *collectionView;
  29. @property (nonatomic, strong) UICollectionView *collectionViewNav;
  30. @property (strong, nonatomic) NSMutableArray *navArray;
  31. #pragma mark - 数据
  32. @property (nonatomic, copy) NSString *dramaId;
  33. @property (nonatomic, strong) JXDrama *drama;
  34. @property (nonatomic, strong) NSArray<JXEpisodeInfo *> *episodes;
  35. @property (nonatomic, strong) NSArray<JXEpisodeInfo *> *filteredEpisodes;
  36. @property (nonatomic, assign) NSInteger selectedRange; // 0=全部, 1=1-50, 2=51-100
  37. @end
  38. @implementation JXCollectionViewController
  39. #pragma mark - 初始化
  40. - (instancetype)initWithDramaId:(NSString *)dramaId {
  41. self = [super init];
  42. if (self) {
  43. _dramaId = dramaId;
  44. _selectedRange = 0;
  45. }
  46. return self;
  47. }
  48. #pragma mark - 生命周期
  49. - (void)viewDidLoad {
  50. [super viewDidLoad];
  51. self.view.backgroundColor = [UIColor whiteColor];
  52. [self setupUI];
  53. [self loadData];
  54. }
  55. #pragma mark - UI设置
  56. - (void)setupUI {
  57. // 顶部标题栏
  58. [self setupHeader];
  59. // 集数范围选择器
  60. // [self setupRangePicker];
  61. [self setupCollectionViewnav];
  62. // 剧集列表
  63. [self setupCollectionView];
  64. }
  65. - (void)setupHeader {
  66. self.headerView = [[UIView alloc] init];
  67. self.headerView.backgroundColor = [UIColor whiteColor];
  68. [self.view addSubview:self.headerView];
  69. //图片
  70. self.headImg = [[UIImageView alloc] init];
  71. self.headImg.image = [UIImage imageNamed:@"icon 2.1"];
  72. [self.headerView addSubview:self.headImg];
  73. // 标题
  74. self.titleLabel = [[UILabel alloc] init];
  75. self.titleLabel.text = @"合集";
  76. self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
  77. self.titleLabel.textColor = [UIColor blackColor];
  78. [self.headerView addSubview:self.titleLabel];
  79. // 统计信息
  80. self.statsLabel = [[UILabel alloc] init];
  81. self.statsLabel.text = @"正在加载...";
  82. self.statsLabel.font = [UIFont systemFontOfSize:14];
  83. self.statsLabel.textColor = [UIColor grayColor];
  84. [self.headerView addSubview:self.statsLabel];
  85. // 关闭按钮
  86. self.closeButton = [UIButton buttonWithType:UIButtonTypeSystem];
  87. [self.closeButton setImage:[UIImage systemImageNamed:@"xmark"] forState:UIControlStateNormal];
  88. self.closeButton.tintColor = [UIColor grayColor];
  89. [self.closeButton addTarget:self action:@selector(handleClose) forControlEvents:UIControlEventTouchUpInside];
  90. [self.headerView addSubview:self.closeButton];
  91. // 约束
  92. self.headerView.translatesAutoresizingMaskIntoConstraints = NO;
  93. self.headImg.translatesAutoresizingMaskIntoConstraints = NO;
  94. self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
  95. self.statsLabel.translatesAutoresizingMaskIntoConstraints = NO;
  96. self.closeButton.translatesAutoresizingMaskIntoConstraints = NO;
  97. [NSLayoutConstraint activateConstraints:@[
  98. [self.headerView.topAnchor constraintEqualToAnchor:self.view.topAnchor],
  99. [self.headerView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
  100. [self.headerView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
  101. [self.headerView.heightAnchor constraintEqualToConstant:80],
  102. [self.headImg.topAnchor constraintEqualToAnchor:self.headerView.topAnchor constant:14.5],
  103. [self.headImg.leadingAnchor constraintEqualToAnchor:self.headerView.leadingAnchor constant:16],
  104. [self.headImg.widthAnchor constraintEqualToConstant:17],
  105. [self.headImg.heightAnchor constraintEqualToConstant:16.5],
  106. [self.titleLabel.topAnchor constraintEqualToAnchor:self.headerView.topAnchor constant:14.5],
  107. [self.titleLabel.leadingAnchor constraintEqualToAnchor:self.headerView.leadingAnchor constant:41],
  108. [self.titleLabel.heightAnchor constraintEqualToConstant:16.5],
  109. [self.statsLabel.topAnchor constraintEqualToAnchor:self.titleLabel.bottomAnchor constant:10],
  110. [self.statsLabel.leadingAnchor constraintEqualToAnchor:self.headerView.leadingAnchor constant:16],
  111. [self.closeButton.trailingAnchor constraintEqualToAnchor:self.headerView.trailingAnchor constant:-16],
  112. [self.closeButton.centerYAnchor constraintEqualToAnchor:self.titleLabel.centerYAnchor],
  113. [self.closeButton.widthAnchor constraintEqualToConstant:30],
  114. [self.closeButton.heightAnchor constraintEqualToConstant:30]
  115. ]];
  116. }
  117. - (void)setupRangePicker {
  118. // self.rangePickerView = [[UIView alloc] init];
  119. // self.rangePickerView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.0];
  120. // [self.view addSubview:self.rangePickerView];
  121. // // 全部
  122. // self.rangeButton1 = [self createRangeButtonWithTitle:@"全部" tag:0];
  123. // [self.rangePickerView addSubview:self.rangeButton1];
  124. //
  125. // // 1-50
  126. // self.rangeButton2 = [self createRangeButtonWithTitle:@"1-50集" tag:1];
  127. // [self.rangePickerView addSubview:self.rangeButton2];
  128. //
  129. // // 51-100
  130. // self.rangeButton3 = [self createRangeButtonWithTitle:@"51-100集" tag:2];
  131. // [self.rangePickerView addSubview:self.rangeButton3];
  132. //
  133. // // 默认选中"全部"
  134. // [self selectRangeButton:self.rangeButton1];
  135. //
  136. // // 约束
  137. // self.rangePickerView.translatesAutoresizingMaskIntoConstraints = NO;
  138. // self.rangeButton1.translatesAutoresizingMaskIntoConstraints = NO;
  139. // self.rangeButton2.translatesAutoresizingMaskIntoConstraints = NO;
  140. // self.rangeButton3.translatesAutoresizingMaskIntoConstraints = NO;
  141. //
  142. // [NSLayoutConstraint activateConstraints:@[
  143. // [self.rangePickerView.topAnchor constraintEqualToAnchor:self.headerView.bottomAnchor],
  144. // [self.rangePickerView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
  145. // [self.rangePickerView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
  146. // [self.rangePickerView.heightAnchor constraintEqualToConstant:50],
  147. //
  148. // [self.rangeButton1.leadingAnchor constraintEqualToAnchor:self.rangePickerView.leadingAnchor constant:16],
  149. // [self.rangeButton1.centerYAnchor constraintEqualToAnchor:self.rangePickerView.centerYAnchor],
  150. // [self.rangeButton1.widthAnchor constraintEqualToConstant:80],
  151. // [self.rangeButton1.heightAnchor constraintEqualToConstant:32],
  152. //
  153. // [self.rangeButton2.leadingAnchor constraintEqualToAnchor:self.rangeButton1.trailingAnchor constant:12],
  154. // [self.rangeButton2.centerYAnchor constraintEqualToAnchor:self.rangePickerView.centerYAnchor],
  155. // [self.rangeButton2.widthAnchor constraintEqualToConstant:80],
  156. // [self.rangeButton2.heightAnchor constraintEqualToConstant:32],
  157. //
  158. // [self.rangeButton3.leadingAnchor constraintEqualToAnchor:self.rangeButton2.trailingAnchor constant:12],
  159. // [self.rangeButton3.centerYAnchor constraintEqualToAnchor:self.rangePickerView.centerYAnchor],
  160. // [self.rangeButton3.widthAnchor constraintEqualToConstant:80],
  161. // [self.rangeButton3.heightAnchor constraintEqualToConstant:32]
  162. // ]];
  163. }
  164. //- (UIButton *)createRangeButtonWithTitle:(NSString *)title tag:(NSInteger)tag {
  165. // UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
  166. // [button setTitle:title forState:UIControlStateNormal];
  167. // button.titleLabel.font = [UIFont systemFontOfSize:14];
  168. // button.layer.cornerRadius = 16;
  169. // button.layer.borderWidth = 1.0;
  170. // button.tag = tag;
  171. // [button addTarget:self action:@selector(handleRangeButtonTap:) forControlEvents:UIControlEventTouchUpInside];
  172. // return button;
  173. //}
  174. - (void)setupCollectionViewnav{
  175. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  176. layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  177. layout.minimumLineSpacing = 6;
  178. layout.minimumInteritemSpacing = 6;
  179. layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);
  180. self.collectionViewNav = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  181. self.collectionViewNav.backgroundColor = [UIColor whiteColor];
  182. self.collectionViewNav.delegate = self;
  183. self.collectionViewNav.dataSource = self;
  184. [self.collectionViewNav registerNib:[UINib nibWithNibName:NSStringFromClass(videoItemsNavCell.class) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass(videoItemsNavCell.class)];
  185. [self.view addSubview:self.collectionViewNav];
  186. // 约束
  187. self.collectionViewNav.translatesAutoresizingMaskIntoConstraints = NO;
  188. [NSLayoutConstraint activateConstraints:@[
  189. [self.collectionViewNav.topAnchor constraintEqualToAnchor:self.headerView.bottomAnchor],
  190. [self.collectionViewNav.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
  191. [self.collectionViewNav.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
  192. [self.collectionViewNav.heightAnchor constraintEqualToConstant:31],
  193. ]];
  194. }
  195. - (void)setupCollectionView {
  196. UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
  197. layout.scrollDirection = UICollectionViewScrollDirectionVertical;
  198. layout.minimumLineSpacing = 0;
  199. layout.minimumInteritemSpacing = 0;
  200. layout.sectionInset = UIEdgeInsetsMake(16, 16, 16, 16);
  201. self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
  202. self.collectionView.backgroundColor = [UIColor whiteColor];
  203. self.collectionView.delegate = self;
  204. self.collectionView.dataSource = self;
  205. [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass(videoItemsCell.class) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass(videoItemsCell.class)];
  206. [self.view addSubview:self.collectionView];
  207. // 约束
  208. self.collectionView.translatesAutoresizingMaskIntoConstraints = NO;
  209. [NSLayoutConstraint activateConstraints:@[
  210. [self.collectionView.topAnchor constraintEqualToAnchor:self.collectionViewNav.bottomAnchor],
  211. [self.collectionView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
  212. [self.collectionView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
  213. [self.collectionView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor]
  214. ]];
  215. }
  216. #pragma mark - 数据加载
  217. - (void)loadData {
  218. // 获取短剧详情和剧集列表
  219. [[JXAPIService sharedService] getDramaDetailWithDramaId:self.dramaId
  220. success:^(id response) {
  221. NSDictionary *dramaDict = response[@"data"];
  222. // 解析短剧信息
  223. // self.drama = [[JXDrama alloc] initWithDictionary:dramaDict];
  224. self.drama = [JXDrama mj_objectWithKeyValues:dramaDict context:nil];
  225. // 解析剧集列表
  226. NSArray *episodesArray = dramaDict[@"episodes"];
  227. NSMutableArray *episodes = [NSMutableArray array];
  228. for (NSDictionary *dict in episodesArray) {
  229. JXEpisodeInfo *episode = [[JXEpisodeInfo alloc] initWithDictionary:dict];
  230. [episodes addObject:episode];
  231. }
  232. self.episodes = episodes;
  233. // 更新UI
  234. [self updateUI];
  235. [self filterEpisodesByRange:self.selectedRange];
  236. } failure:^(NSError *error) {
  237. NSLog(@"[JXCollection] 加载失败: %@", error.localizedDescription);
  238. }];
  239. }
  240. - (void)updateUI {
  241. // self.titleLabel.text = self.drama.title;
  242. // self.statsLabel.text = [NSString stringWithFormat:@"共%ld集 · %@ 播放",
  243. // (long)self.drama.totalEpisodes,
  244. // [JXShortDramaCell formattedCountWithCount:self.drama.viewCount]];
  245. self.statsLabel.text = [NSString stringWithFormat:@"%@ 播放 · 已更新至%ld集 · ", [JXShortDramaCell formattedCountWithCount:self.drama.viewCount], (long)self.drama.totalEpisodes];
  246. }
  247. #pragma mark - 筛选逻辑
  248. - (void)filterEpisodesByRange:(NSInteger)range {
  249. NSInteger all = self.drama.totalEpisodes == 0 ? 95 :self.drama.totalEpisodes;
  250. if (all == 0) {
  251. return;
  252. }
  253. for (int i = 1; i < all; i=i+20) {
  254. [self.navArray addObject: [NSString stringWithFormat:@"%d",i]];
  255. }
  256. NSString *str = self.navArray[range];
  257. NSPredicate *predicate;
  258. if (self.drama.totalEpisodes < 20) {
  259. predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"episodeNumber >= %@ AND episodeNumber <= %ld",str,self.drama.totalEpisodes]];
  260. }else{
  261. predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"episodeNumber >= %@ AND episodeNumber <= %d",str,str.intValue+20]];
  262. }
  263. self.filteredEpisodes = [self.episodes filteredArrayUsingPredicate:predicate];
  264. [self.collectionViewNav reloadData];
  265. [self.collectionView reloadData];
  266. }
  267. //- (void)handleRangeButtonTap:(UIButton *)sender {
  268. // [self selectRangeButton:sender];
  269. // self.selectedRange = sender.tag;
  270. // [self filterEpisodesByRange:self.selectedRange];
  271. //}
  272. - (void)selectRangeButton:(UIButton *)button {
  273. // 重置所有按钮
  274. for (UIButton *btn in @[self.rangeButton1, self.rangeButton2, self.rangeButton3]) {
  275. btn.selected = NO;
  276. [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
  277. btn.backgroundColor = [UIColor whiteColor];
  278. btn.layer.borderColor = [UIColor lightGrayColor].CGColor;
  279. }
  280. // 选中当前按钮
  281. button.selected = YES;
  282. [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  283. button.backgroundColor = [UIColor systemBlueColor];
  284. button.layer.borderColor = [UIColor systemBlueColor].CGColor;
  285. }
  286. #pragma mark - UICollectionViewDataSource
  287. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  288. if (collectionView == self.collectionViewNav) {
  289. return self.navArray.count;
  290. }
  291. return self.navArray.count ? 20 : 0; //写死的,后面要改
  292. // return self.filteredEpisodes.count ;
  293. }
  294. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  295. if (collectionView == self.collectionViewNav) {
  296. videoItemsNavCell *cell1 = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(videoItemsNavCell.class) forIndexPath:indexPath];
  297. cell1.layer.cornerRadius = 5;
  298. if (self.selectedRange == indexPath.row) {
  299. cell1.backgroundColor = [UIColor colorWithRed:255/255.0 green:240/255.0 blue:234/255.0 alpha:1];
  300. cell1.labelT.textColor = [UIColor colorWithRed:255/255.0 green:112/255.0 blue:48/255.0 alpha:1];
  301. }else{
  302. cell1.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1];
  303. cell1.labelT.textColor = [UIColor colorWithRed:140/255.0 green:140/255.0 blue:140/255.0 alpha:1];
  304. }
  305. NSString *str = self.navArray[indexPath.row];
  306. if (indexPath.row == self.navArray.count -1) {
  307. cell1.labelT.text = [NSString stringWithFormat:@"%@-%ld",str,self.drama.totalEpisodes];
  308. }else{
  309. cell1.labelT.text = [NSString stringWithFormat:@"%@-%d",str,str.intValue+19];
  310. }
  311. return cell1;
  312. }
  313. videoItemsCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(videoItemsCell.class) forIndexPath:indexPath];
  314. // JXEpisodeInfo *episode = self.filteredEpisodes[indexPath.item];
  315. // 临时简单展示(后续可创建自定义Cell)
  316. // cell.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.0];
  317. // cell.layer.cornerRadius = 8;
  318. // 清除旧标签
  319. // for (UIView *subview in cell.contentView.subviews) {
  320. // [subview removeFromSuperview];
  321. // }
  322. //
  323. // // 第X集标签
  324. // UILabel *label = [[UILabel alloc] init];
  325. // label.text = [NSString stringWithFormat:@"第%ld集", (long)episode.episodeNumber];
  326. // label.font = [UIFont boldSystemFontOfSize:14];
  327. // label.textColor = [UIColor blackColor];
  328. // label.textAlignment = NSTextAlignmentCenter;
  329. // [cell.contentView addSubview:label];
  330. //
  331. // // VIP标识
  332. // if (episode.isPaid) {
  333. // UILabel *vipLabel = [[UILabel alloc] init];
  334. // vipLabel.text = @"VIP";
  335. // vipLabel.font = [UIFont boldSystemFontOfSize:10];
  336. // vipLabel.textColor = [UIColor systemOrangeColor];
  337. // vipLabel.textAlignment = NSTextAlignmentCenter;
  338. // [cell.contentView addSubview:vipLabel];
  339. //
  340. // vipLabel.translatesAutoresizingMaskIntoConstraints = NO;
  341. // [NSLayoutConstraint activateConstraints:@[
  342. // [vipLabel.topAnchor constraintEqualToAnchor:cell.contentView.topAnchor constant:4],
  343. // [vipLabel.trailingAnchor constraintEqualToAnchor:cell.contentView.trailingAnchor constant:-4]
  344. // ]];
  345. // }
  346. //
  347. // // 约束
  348. // label.translatesAutoresizingMaskIntoConstraints = NO;
  349. // [NSLayoutConstraint activateConstraints:@[
  350. // [label.centerXAnchor constraintEqualToAnchor:cell.contentView.centerXAnchor],
  351. // [label.centerYAnchor constraintEqualToAnchor:cell.contentView.centerYAnchor]
  352. // ]];
  353. return cell;
  354. }
  355. #pragma mark - UICollectionViewDelegateFlowLayout
  356. - (CGSize)collectionView:(UICollectionView *)collectionView
  357. layout:(UICollectionViewLayout *)collectionViewLayout
  358. sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  359. if (collectionView == self.collectionViewNav) {
  360. return CGSizeMake(60, 31);
  361. }
  362. CGFloat width = collectionView.bounds.size.width; // 3列
  363. return CGSizeMake(width, 93);
  364. }
  365. #pragma mark - UICollectionViewDelegate
  366. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  367. if (collectionView == self.collectionViewNav) {
  368. self.selectedRange = indexPath.row;
  369. NSString *str = self.navArray[indexPath.row];
  370. NSPredicate *predicate;
  371. if (indexPath.row == self.navArray.count -1) {
  372. predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"episodeNumber >= %@ AND episodeNumber <= %ld",str,self.drama.totalEpisodes]];
  373. }else{
  374. predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"episodeNumber >= %@ AND episodeNumber <= %d",str,str.intValue+20]];
  375. }
  376. self.filteredEpisodes = [self.episodes filteredArrayUsingPredicate:predicate];
  377. [self.collectionViewNav reloadData];
  378. [self.collectionView reloadData];
  379. return ;
  380. }
  381. if (self.filteredEpisodes.count > 0 && (self.filteredEpisodes.count >= indexPath.item)) {
  382. JXEpisodeInfo *episode = self.filteredEpisodes[indexPath.item];
  383. NSLog(@"[JXCollection] 选择剧集: %ld", (long)episode.episodeNumber);
  384. if ([self.delegate respondsToSelector:@selector(collectionViewControllerDidSelectEpisode:)]) {
  385. [self.delegate collectionViewControllerDidSelectEpisode:episode.episodeId];
  386. }
  387. [self dismissViewControllerAnimated:YES completion:nil];
  388. }else{
  389. //测试一下
  390. if ([self.delegate respondsToSelector:@selector(collectionViewControllerDidSelectEpisode:)]) {
  391. [self.delegate collectionViewControllerDidSelectEpisode:@"1"];
  392. }
  393. [self dismissViewControllerAnimated:YES completion:nil];
  394. }
  395. }
  396. - (NSMutableArray *)navArray{
  397. if (!_navArray) {
  398. _navArray = [NSMutableArray array];
  399. }
  400. return _navArray;
  401. }
  402. #pragma mark - 关闭
  403. - (void)handleClose {
  404. [self dismissViewControllerAnimated:YES completion:nil];
  405. }
  406. @end