// // MessageFansVC.m // YBVideo // // Created by YunBao on 2018/7/24. // Copyright © 2018年 cat. All rights reserved. // #import "MessageFansVC.h" #import "MessageFansModel.h" #import "MessageFansCell.h" #import "YBCenterVC.h" @interface MessageFansVC () { int _paging; } @property(nonatomic,strong)UITableView *tableView; @property(nonatomic,strong)NSMutableArray *dateArray; @property(nonatomic,strong)NSArray *models; @end @implementation MessageFansVC -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self pullData]; } - (UIStatusBarStyle)preferredStatusBarStyle { if (@available(iOS 13.0,*)) { return UIStatusBarStyleDarkContent; } return UIStatusBarStyleDefault; } - (void)viewDidLoad { [super viewDidLoad]; self.titleL.text = YZMsg(@"粉丝"); self.subNavi.backgroundColor = UIColor.whiteColor; self.titleL.textColor = UIColor.blackColor; [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0]; self.naviLine.hidden = NO; self.naviLine.backgroundColor = RGB(245, 245, 245); self.dateArray = [NSMutableArray array]; self.models = [NSArray array]; _paging = 1; [self.view addSubview:self.tableView]; } - (NSArray *)models { NSMutableArray *m_array = [NSMutableArray array]; for (NSDictionary *dic in _dateArray) { MessageFansModel *model = [MessageFansModel modelWithDic:dic]; [m_array addObject:model]; } _models = m_array; return _models; } #pragma mark - 数据 -(void)refreshFooter { _paging +=1; [self pullData]; } -(void)pullData { NSString *url = [NSString stringWithFormat:@"Message.fansLists&uid=%@&token=%@&p=%d",[Config getOwnID],[Config getOwnToken],_paging]; [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) { [_tableView.mj_header endRefreshing]; [_tableView.mj_footer endRefreshing]; if (code == 0) { NSArray *infoA = [NSArray arrayWithArray:info]; if (_paging==1) { [_dateArray removeAllObjects]; } if (infoA.count==0) { [_tableView.mj_footer endRefreshingWithNoMoreData]; }else{ [_dateArray addObjectsFromArray:infoA]; } if (_dateArray.count<=0) { [PublicView showTextNoData:_tableView text1:@"" text2:YZMsg(@"你还没有收获粉丝") centerY:0.8]; }else { [PublicView hiddenTextNoData:_tableView]; } [_tableView reloadData]; }else { [MBProgressHUD showPop:msg]; } } Fail:^(id fail) { }]; } #pragma mark - UITableViewDelegate、UITableViewDataSource -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 80; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.models.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ MessageFansCell *cell = [MessageFansCell cellWithTab:tableView andIndexPath:indexPath]; cell.model = _models[indexPath.row]; cell.backgroundColor = UIColor.whiteColor; cell.selectedBackgroundView = [[UIImageView alloc]initWithImage:[PublicObj getImgWithColor:UIColor.whiteColor]]; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; MessageFansModel *model = _models[indexPath.row]; YBCenterVC *center = [[YBCenterVC alloc]init]; center.otherUid = model.uidStr; center.isPush = YES; //[self.navigationController pushViewController:center animated:YES]; [[YBBaseAppDelegate sharedAppDelegate] pushViewController:center animated:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } #pragma mark - set/get -(UITableView *)tableView { if (!_tableView) { _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,64+statusbarHeight, _window_width, _window_height - 64-statusbarHeight)style:UITableViewStylePlain]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; _tableView.backgroundColor = UIColor.whiteColor; YBWeakSelf; _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ _paging = 1; [weakSelf pullData]; }]; MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(refreshFooter)]; _tableView.mj_footer = footer; [footer setTitle:YZMsg(@"数据加载中...") forState:MJRefreshStateRefreshing]; [footer setTitle:@"" forState:MJRefreshStateIdle];//YZMsg(@"没有更多了哦~") footer.stateLabel.font = [UIFont systemFontOfSize:15.0f]; footer.automaticallyHidden = YES; } return _tableView; } #pragma mark - 导航 @end