LiveRankVC.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // LiveRankVC.m
  3. // YBVideo
  4. //
  5. // Created by ybRRR on 2021/2/27.
  6. // Copyright © 2021 cat. All rights reserved.
  7. //
  8. #import "LiveRankVC.h"
  9. #import "LiveRankCell.h"
  10. #import "YBCheckLiveObj.h"
  11. #import "YBCenterVC.h"
  12. @interface LiveRankVC ()<UITableViewDelegate, UITableViewDataSource,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
  13. @property (nonatomic, strong)UITableView *rankTable;
  14. @property (nonatomic, strong)NSMutableArray *dataArr;
  15. @end
  16. @implementation LiveRankVC
  17. - (UIStatusBarStyle)preferredStatusBarStyle {
  18. if (@available(iOS 13.0,*)) {
  19. return UIStatusBarStyleDarkContent;
  20. }
  21. return UIStatusBarStyleDefault;
  22. }
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. self.titleL.text = YZMsg(@"直播榜单");
  26. self.dataArr = [NSMutableArray array];
  27. self.view.backgroundColor =UIColor.whiteColor;// RGB(250, 250, 250);
  28. self.subNavi.backgroundColor = UIColor.whiteColor;
  29. self.titleL.textColor = UIColor.blackColor;
  30. [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0];
  31. self.naviLine.hidden = NO;
  32. self.naviLine.backgroundColor = RGB(245, 245, 245);
  33. [self.view addSubview:self.rankTable];
  34. [self getWeekShowLists];
  35. }
  36. -(void)getWeekShowLists{
  37. [YBNetworking postWithUrl:@"Home.getWeekShowLists" Dic:nil Suc:^(int code, id info, NSString *msg) {
  38. [_rankTable.mj_header endRefreshing];
  39. if (code == 0) {
  40. _dataArr = info;
  41. [_rankTable reloadData];
  42. }
  43. } Fail:^(id fail) {
  44. }];
  45. }
  46. -(UITableView *)rankTable {
  47. if (!_rankTable) {
  48. //5个像素间隔
  49. _rankTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 75+statusbarHeight, _window_width, _window_height-75-statusbarHeight-ShowDiff) style:UITableViewStylePlain];
  50. _rankTable.delegate = self;
  51. _rankTable.dataSource = self;
  52. _rankTable.separatorStyle = UITableViewCellSeparatorStyleNone;
  53. _rankTable.backgroundColor = UIColor.whiteColor;
  54. _rankTable.emptyDataSetSource = self;
  55. _rankTable.emptyDataSetDelegate = self;
  56. _rankTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  57. [self getWeekShowLists];
  58. }];
  59. }
  60. return _rankTable;
  61. }
  62. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  63. {
  64. return _dataArr.count;
  65. }
  66. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  67. {
  68. return 50;
  69. }
  70. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  71. {
  72. LiveRankCell *cell = [LiveRankCell cellWithTab:tableView andIndexPath:indexPath];
  73. if (indexPath.row < 3) {
  74. cell.numImg.image = [UIImage imageNamed:[NSString stringWithFormat:@"live_rank%ld",indexPath.row+1]];
  75. cell.numLb.hidden = YES;
  76. }else{
  77. cell.numLb.hidden = NO;
  78. cell.numLb.text = [NSString stringWithFormat:@"%ld",indexPath.row+1];
  79. }
  80. cell.rankData = _dataArr[indexPath.row];
  81. return cell;
  82. }
  83. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  84. {
  85. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  86. NSDictionary *rankDic = _dataArr[indexPath.row];
  87. if ([minstr([rankDic valueForKey:@"islive"]) isEqual:@"1"]) {
  88. [YBCheckLiveObj checkLiveManeger].liveUid = minstr([rankDic valueForKey:@"uid"]);
  89. [YBCheckLiveObj checkLiveManeger].liveStream = minstr([rankDic valueForKey:@"stream"]);
  90. [YBCheckLiveObj checkLiveManeger].currentIndex = 0;
  91. [YBCheckLiveObj checkLiveManeger].listArray = nil;
  92. [[YBCheckLiveObj checkLiveManeger] checkLiving];
  93. }else{
  94. YBCenterVC *center = [[YBCenterVC alloc]init];
  95. center.otherUid = minstr([rankDic valueForKey:@"uid"]);;
  96. center.isPush = YES;
  97. //[self.navigationController pushViewController:center animated:YES];
  98. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:center animated:YES];
  99. }
  100. }
  101. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  102. NSString *text = YZMsg(@"暂无数据");
  103. NSDictionary *attributes = @{NSFontAttributeName: ybNodataFont,
  104. NSForegroundColorAttributeName: ybNodataCol};
  105. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  106. }
  107. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView{
  108. return -naviHight;
  109. }
  110. - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
  111. return YES;
  112. }
  113. @end