| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- //
- // 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 ()<UITableViewDelegate,UITableViewDataSource>
- {
- 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
|