MessageFansVC.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //
  2. // MessageFansVC.m
  3. // YBVideo
  4. //
  5. // Created by YunBao on 2018/7/24.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "MessageFansVC.h"
  9. #import "MessageFansModel.h"
  10. #import "MessageFansCell.h"
  11. #import "YBCenterVC.h"
  12. @interface MessageFansVC ()<UITableViewDelegate,UITableViewDataSource>
  13. {
  14. int _paging;
  15. }
  16. @property(nonatomic,strong)UITableView *tableView;
  17. @property(nonatomic,strong)NSMutableArray *dateArray;
  18. @property(nonatomic,strong)NSArray *models;
  19. @end
  20. @implementation MessageFansVC
  21. -(void)viewWillAppear:(BOOL)animated {
  22. [super viewWillAppear:animated];
  23. [self pullData];
  24. }
  25. - (UIStatusBarStyle)preferredStatusBarStyle {
  26. if (@available(iOS 13.0,*)) {
  27. return UIStatusBarStyleDarkContent;
  28. }
  29. return UIStatusBarStyleDefault;
  30. }
  31. - (void)viewDidLoad {
  32. [super viewDidLoad];
  33. self.titleL.text = YZMsg(@"粉丝");
  34. self.subNavi.backgroundColor = UIColor.whiteColor;
  35. self.titleL.textColor = UIColor.blackColor;
  36. [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0];
  37. self.naviLine.hidden = NO;
  38. self.naviLine.backgroundColor = RGB(245, 245, 245);
  39. self.dateArray = [NSMutableArray array];
  40. self.models = [NSArray array];
  41. _paging = 1;
  42. [self.view addSubview:self.tableView];
  43. }
  44. - (NSArray *)models {
  45. NSMutableArray *m_array = [NSMutableArray array];
  46. for (NSDictionary *dic in _dateArray) {
  47. MessageFansModel *model = [MessageFansModel modelWithDic:dic];
  48. [m_array addObject:model];
  49. }
  50. _models = m_array;
  51. return _models;
  52. }
  53. #pragma mark - 数据
  54. -(void)refreshFooter {
  55. _paging +=1;
  56. [self pullData];
  57. }
  58. -(void)pullData {
  59. NSString *url = [NSString stringWithFormat:@"Message.fansLists&uid=%@&token=%@&p=%d",[Config getOwnID],[Config getOwnToken],_paging];
  60. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  61. [_tableView.mj_header endRefreshing];
  62. [_tableView.mj_footer endRefreshing];
  63. if (code == 0) {
  64. NSArray *infoA = [NSArray arrayWithArray:info];
  65. if (_paging==1) {
  66. [_dateArray removeAllObjects];
  67. }
  68. if (infoA.count==0) {
  69. [_tableView.mj_footer endRefreshingWithNoMoreData];
  70. }else{
  71. [_dateArray addObjectsFromArray:infoA];
  72. }
  73. if (_dateArray.count<=0) {
  74. [PublicView showTextNoData:_tableView text1:@"" text2:YZMsg(@"你还没有收获粉丝") centerY:0.8];
  75. }else {
  76. [PublicView hiddenTextNoData:_tableView];
  77. }
  78. [_tableView reloadData];
  79. }else {
  80. [MBProgressHUD showPop:msg];
  81. }
  82. } Fail:^(id fail) {
  83. }];
  84. }
  85. #pragma mark - UITableViewDelegate、UITableViewDataSource
  86. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  87. return 80;
  88. }
  89. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  90. return self.models.count;
  91. }
  92. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  93. MessageFansCell *cell = [MessageFansCell cellWithTab:tableView andIndexPath:indexPath];
  94. cell.model = _models[indexPath.row];
  95. cell.backgroundColor = UIColor.whiteColor;
  96. cell.selectedBackgroundView = [[UIImageView alloc]initWithImage:[PublicObj getImgWithColor:UIColor.whiteColor]];
  97. return cell;
  98. }
  99. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  100. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  101. MessageFansModel *model = _models[indexPath.row];
  102. YBCenterVC *center = [[YBCenterVC alloc]init];
  103. center.otherUid = model.uidStr;
  104. center.isPush = YES;
  105. //[self.navigationController pushViewController:center animated:YES];
  106. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:center animated:YES];
  107. }
  108. - (void)didReceiveMemoryWarning {
  109. [super didReceiveMemoryWarning];
  110. }
  111. #pragma mark - set/get
  112. -(UITableView *)tableView {
  113. if (!_tableView) {
  114. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,64+statusbarHeight, _window_width, _window_height - 64-statusbarHeight)style:UITableViewStylePlain];
  115. _tableView.delegate = self;
  116. _tableView.dataSource = self;
  117. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  118. _tableView.backgroundColor = UIColor.whiteColor;
  119. YBWeakSelf;
  120. _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  121. _paging = 1;
  122. [weakSelf pullData];
  123. }];
  124. MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(refreshFooter)];
  125. _tableView.mj_footer = footer;
  126. [footer setTitle:YZMsg(@"数据加载中...") forState:MJRefreshStateRefreshing];
  127. [footer setTitle:@"" forState:MJRefreshStateIdle];//YZMsg(@"没有更多了哦~")
  128. footer.stateLabel.font = [UIFont systemFontOfSize:15.0f];
  129. footer.automaticallyHidden = YES;
  130. }
  131. return _tableView;
  132. }
  133. #pragma mark - 导航
  134. @end