MOActivityCenterVC.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. //
  2. // MOActivityCenterVC.m
  3. // KoKoLive
  4. //
  5. // Created by SuperC on 2024/10/11.
  6. //
  7. #import "MOActivityCenterVC.h"
  8. #import "MOActivityCenterCell.h"
  9. @interface MOActivityCenterVC ()
  10. @property (weak, nonatomic) IBOutlet UIImageView *bgImgView;
  11. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  12. @property (nonatomic, strong) NSArray *dataArr;
  13. /** 没有更多的数据视图 */
  14. @property (nonatomic, strong) MONoMoreDataView *noMoreDataView;
  15. @end
  16. @implementation MOActivityCenterVC
  17. - (void)viewWillAppear:(BOOL)animated
  18. {
  19. [super viewWillAppear:animated];
  20. [self.navigationController setNavigationBarHidden:NO animated:animated];
  21. [self mo_setNavLeftItemWithImage:[UIImage imageNamed:@"icon_new_left_gray"] andBackgroundImg:[UIImage imageNamed:@"icon_mine_base_bg"]];
  22. }
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. // Do any additional setup after loading the view from its nib.
  26. self.navigationItem.title = @"Event";
  27. [self setupUI];
  28. [self getSquareBannerListDataWith:8];
  29. }
  30. - (void)setupUI{
  31. NSArray *colorArr = @[[MOTools colorWithHexString:@"#EEF2FD" alpha:1.0],[MOTools colorWithHexString:@"#FAFAFC" alpha:1.0]];
  32. UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, SCREENWIDTH, (SCREENHEIGHT - NAV_BAR_HEIGHT)) Colors:colorArr GradientType:1];
  33. [self.bgImgView setImage:image];
  34. self.tableView.estimatedRowHeight = 0;
  35. self.tableView.estimatedSectionHeaderHeight = 0;
  36. self.tableView.estimatedSectionFooterHeight = 0;
  37. //iOS15适配
  38. if (@available(iOS 15.0, *))
  39. {
  40. self.tableView.sectionHeaderTopPadding = 0;
  41. }
  42. self.tableView.contentInset = UIEdgeInsetsMake(10, 0, 0, 0);
  43. [self.tableView registerNib:[UINib nibWithNibName:@"MOActivityCenterCell" bundle:nil] forCellReuseIdentifier:MOActivityCenterCell_ID];
  44. self.tableView.backgroundView = self.noMoreDataView;
  45. }
  46. - (void)getSquareBannerListDataWith:(NSInteger)type{
  47. WEAKSELF
  48. //banner分类(1=首页图片,2=直播间图片,3=New页图片,4=启动页图片,5=开播页图片,6=语音列表图片,7=充值页广告,8=活动页广告)
  49. NSDictionary *dict = @{@"category":@(8)};
  50. if (self.category) {
  51. dict = @{@"category": self.category};
  52. }
  53. [kHttpManager getBaseBannerListWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  54. if(kCode_Success){
  55. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  56. MOBannerData *baseModel = [MOBannerData modelObjectWithDictionary:data[@"data"]];
  57. weakSelf.dataArr = [baseModel.JumpList copy];
  58. [weakSelf.tableView reloadData];
  59. weakSelf.noMoreDataView.isHaveData = (weakSelf.dataArr.count > 0) ? YES : NO;
  60. }
  61. else{
  62. kShowNetError(data)
  63. }
  64. }];
  65. }
  66. #pragma mark - UITableViewDelegate,UITableViewDataSource
  67. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  68. return 1;
  69. }
  70. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  71. return self.dataArr.count;
  72. }
  73. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  74. return 120;
  75. }
  76. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  77. MOJumpList *jumpModel = self.dataArr[indexPath.row];
  78. MOActivityCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:MOActivityCenterCell_ID];
  79. cell.cellModel = jumpModel;
  80. cell.cellClickBlock = ^(MOJumpList * _Nonnull cellModel) {
  81. SendObjNotification(@"MOSquareListVC_H5Jump", cellModel);
  82. };
  83. return cell;
  84. }
  85. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  86. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  87. }
  88. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  89. return 0.01;
  90. }
  91. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  92. return 0.01;
  93. }
  94. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  95. UIView *view = [[UIView alloc] init];
  96. view.backgroundColor = [UIColor clearColor];
  97. return view;
  98. }
  99. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  100. UIView *view = [[UIView alloc] init];
  101. view.backgroundColor = [UIColor clearColor];
  102. return view;
  103. }
  104. - (MONoMoreDataView *)noMoreDataView{
  105. if(!_noMoreDataView){
  106. _noMoreDataView = [MONoMoreDataView new];
  107. }
  108. return _noMoreDataView;
  109. }
  110. @end