// // MOActivityCenterVC.m // KoKoLive // // Created by SuperC on 2024/10/11. // #import "MOActivityCenterVC.h" #import "MOActivityCenterCell.h" @interface MOActivityCenterVC () @property (weak, nonatomic) IBOutlet UIImageView *bgImgView; @property (weak, nonatomic) IBOutlet UITableView *tableView; @property (nonatomic, strong) NSArray *dataArr; /** 没有更多的数据视图 */ @property (nonatomic, strong) MONoMoreDataView *noMoreDataView; @end @implementation MOActivityCenterVC - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:animated]; [self mo_setNavLeftItemWithImage:[UIImage imageNamed:@"icon_new_left_gray"] andBackgroundImg:[UIImage imageNamed:@"icon_mine_base_bg"]]; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. self.navigationItem.title = @"Event"; [self setupUI]; [self getSquareBannerListDataWith:8]; } - (void)setupUI{ NSArray *colorArr = @[[MOTools colorWithHexString:@"#EEF2FD" alpha:1.0],[MOTools colorWithHexString:@"#FAFAFC" alpha:1.0]]; UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, SCREENWIDTH, (SCREENHEIGHT - NAV_BAR_HEIGHT)) Colors:colorArr GradientType:1]; [self.bgImgView setImage:image]; self.tableView.estimatedRowHeight = 0; self.tableView.estimatedSectionHeaderHeight = 0; self.tableView.estimatedSectionFooterHeight = 0; //iOS15适配 if (@available(iOS 15.0, *)) { self.tableView.sectionHeaderTopPadding = 0; } self.tableView.contentInset = UIEdgeInsetsMake(10, 0, 0, 0); [self.tableView registerNib:[UINib nibWithNibName:@"MOActivityCenterCell" bundle:nil] forCellReuseIdentifier:MOActivityCenterCell_ID]; self.tableView.backgroundView = self.noMoreDataView; } - (void)getSquareBannerListDataWith:(NSInteger)type{ WEAKSELF //banner分类(1=首页图片,2=直播间图片,3=New页图片,4=启动页图片,5=开播页图片,6=语音列表图片,7=充值页广告,8=活动页广告) NSDictionary *dict = @{@"category":@(8)}; if (self.category) { dict = @{@"category": self.category}; } [kHttpManager getBaseBannerListWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) { if(kCode_Success){ MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]); MOBannerData *baseModel = [MOBannerData modelObjectWithDictionary:data[@"data"]]; weakSelf.dataArr = [baseModel.JumpList copy]; [weakSelf.tableView reloadData]; weakSelf.noMoreDataView.isHaveData = (weakSelf.dataArr.count > 0) ? YES : NO; } else{ kShowNetError(data) } }]; } #pragma mark - UITableViewDelegate,UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.dataArr.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 120; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ MOJumpList *jumpModel = self.dataArr[indexPath.row]; MOActivityCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:MOActivityCenterCell_ID]; cell.cellModel = jumpModel; cell.cellClickBlock = ^(MOJumpList * _Nonnull cellModel) { SendObjNotification(@"MOSquareListVC_H5Jump", cellModel); }; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 0.01; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 0.01; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView *view = [[UIView alloc] init]; view.backgroundColor = [UIColor clearColor]; return view; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ UIView *view = [[UIView alloc] init]; view.backgroundColor = [UIColor clearColor]; return view; } - (MONoMoreDataView *)noMoreDataView{ if(!_noMoreDataView){ _noMoreDataView = [MONoMoreDataView new]; } return _noMoreDataView; } @end