BlackListVC.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // BlackListVC.m
  3. // YBVideo
  4. //
  5. // Created by YunBao on 2018/7/30.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "BlackListVC.h"
  9. #import "fansModel.h"
  10. #import "BlackListCell.h"
  11. #import "YBCenterVC.h"
  12. @interface BlackListVC ()<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 BlackListVC
  21. -(void)viewWillAppear:(BOOL)animated {
  22. [super viewWillAppear:animated];
  23. [self pullData];
  24. }
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.titleL.text = YZMsg(@"黑名单");
  28. self.dateArray = [NSMutableArray array];
  29. _paging = 1;
  30. [self.view addSubview:self.tableView];
  31. }
  32. #pragma mark -
  33. - (NSArray *)models {
  34. NSMutableArray *m_array = [NSMutableArray array];
  35. for (NSDictionary *dic in _dateArray) {
  36. fansModel *model = [fansModel modelWithDic:dic];
  37. [m_array addObject:model];
  38. }
  39. _models = m_array;
  40. return _models;
  41. }
  42. -(void)pullData {
  43. NSString *url = [NSString stringWithFormat:@"User.getBlackList&uid=%@&token=%@&touid=%@&p=%d",[Config getOwnID],[Config getOwnToken],[Config getOwnID],_paging];
  44. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  45. [_tableView.mj_header endRefreshing];
  46. [_tableView.mj_footer endRefreshing];
  47. if (code == 0) {
  48. NSArray *infoA = [NSArray arrayWithArray:info];
  49. if (_paging == 1) {
  50. [_dateArray removeAllObjects];
  51. }
  52. if (infoA.count<=0) {
  53. [_tableView.mj_footer endRefreshingWithNoMoreData];
  54. }else {
  55. [_dateArray addObjectsFromArray:infoA];
  56. }
  57. if (_dateArray.count<=0) {
  58. [PublicView showTextNoData:_tableView text1:@"" text2:YZMsg(@"暂无数据") centerY:0.8];
  59. }else{
  60. [PublicView hiddenTextNoData:_tableView];
  61. }
  62. [_tableView reloadData];
  63. }else {
  64. [MBProgressHUD showPop:msg];
  65. }
  66. } Fail:^(id fail) {
  67. }];
  68. }
  69. #pragma mark - UITableViewDelegate、UITableViewDataSource
  70. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  71. return 80;
  72. }
  73. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  74. return self.models.count;
  75. }
  76. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  77. BlackListCell *cell = [BlackListCell cellWithTab:tableView andIndexPath:indexPath];
  78. cell.model = _models[indexPath.row];
  79. cell.backgroundColor = CellRow_Cor;
  80. YBWeakSelf;
  81. cell.blackEvent = ^(NSString *type) {
  82. [weakSelf pullData];
  83. };
  84. cell.selectedBackgroundView = [[UIImageView alloc]initWithImage:[PublicObj getImgWithColor:SelCell_Col]];
  85. return cell;
  86. }
  87. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  88. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  89. fansModel *model = _models[indexPath.row];
  90. YBCenterVC *center = [[YBCenterVC alloc]init];
  91. center.otherUid = model.uid;
  92. center.isPush = YES;
  93. //[self.navigationController pushViewController:center animated:YES];
  94. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:center animated:YES];
  95. }
  96. #pragma mark - set/get
  97. -(UITableView *)tableView {
  98. if (!_tableView) {
  99. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,64+statusbarHeight, _window_width, _window_height - 64-statusbarHeight-ShowDiff)style:UITableViewStylePlain];
  100. _tableView.delegate = self;
  101. _tableView.dataSource = self;
  102. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  103. _tableView.backgroundColor = Normal_Color;
  104. YBWeakSelf;
  105. _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  106. _paging = 1;
  107. [weakSelf pullData];
  108. }];
  109. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  110. _paging +=1;
  111. [weakSelf pullData];
  112. }];
  113. }
  114. return _tableView;
  115. }
  116. - (void)didReceiveMemoryWarning {
  117. [super didReceiveMemoryWarning];
  118. }
  119. #pragma mark - 导航
  120. @end