口袋优选

KBPotentialFansViewController.m 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // KBPotentialFansViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/12.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBPotentialFansViewController.h"
  9. #import "KBChildFansModel.h"
  10. #import "KBPotentialFansCell.h"
  11. @interface KBPotentialFansViewController ()<UITableViewDelegate, UITableViewDataSource>
  12. @property (nonatomic, strong) UITableView *tableView;
  13. @property (nonatomic, strong) NSMutableArray *dataArr;
  14. @property (nonatomic )NSInteger page;
  15. @end
  16. @implementation KBPotentialFansViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self request];
  20. [self configTableView];
  21. }
  22. - (void)configTableView {
  23. self.page = 1;
  24. [self.view addSubview:self.tableView];
  25. }
  26. - (void)backAction {
  27. [self.navigationController popViewControllerAnimated:YES];
  28. }
  29. #pragma mark - request
  30. - (void)request {
  31. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/fansList",BaseURL];
  32. NSDictionary *dic=@{
  33. @"type":@(3),
  34. @"page":@(self.page),
  35. @"member_type":@"0"
  36. };
  37. [KBHttp post:url params:dic success:^(id json) {
  38. NSArray *arr = [NSArray yy_modelArrayWithClass:[KBPotentialModel class] json:json[@"data"]];
  39. if (arr.count>0) {
  40. [self.dataArr addObjectsFromArray:arr];
  41. [self.tableView.mj_footer endRefreshing];
  42. }else {
  43. [self setUpNoDataView];
  44. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  45. }
  46. [self.tableView reloadData];
  47. } failure:^(NSError *error) {
  48. [self.tableView.mj_footer endRefreshing];
  49. }];
  50. }
  51. - (void)setUpNoDataView {
  52. self.tableView.showNoDataView = YES;
  53. self.tableView.defaultNoDataText = @"您还没有任何记录";
  54. self.tableView.defaultNoDataImage = [UIImage imageNamed:@"noData"];
  55. }
  56. #pragma mark -------- UITableView Delegate -----
  57. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  58. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  59. [cell setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 15)];
  60. }
  61. }
  62. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  63. return self.dataArr.count;
  64. }
  65. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  66. return 67;
  67. }
  68. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  69. return 0.1;
  70. }
  71. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  72. return 0.1;
  73. }
  74. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  75. KBPotentialModel *model = self.dataArr[indexPath.row];
  76. KBPotentialFansCell *cell = [KBPotentialFansCell cellWithTableView:tableView];
  77. cell.model = model;
  78. return cell;
  79. }
  80. #pragma mark ------- layzer ------
  81. - (UITableView *)tableView {
  82. if (!_tableView) {
  83. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-40) style:UITableViewStylePlain];
  84. _tableView.estimatedSectionHeaderHeight = 0;
  85. _tableView.estimatedSectionFooterHeight = 0;
  86. _tableView.sectionFooterHeight = 0;
  87. _tableView.sectionHeaderHeight = 0;
  88. _tableView.delegate = self;
  89. _tableView.dataSource = self;
  90. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  91. _tableView.backgroundColor = [UIColor yhGrayColor];
  92. _tableView.bounces = YES;
  93. _tableView.showsVerticalScrollIndicator = NO;
  94. _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  95. kWeak(self);
  96. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  97. self.page++;
  98. [selfWeak request];
  99. }];
  100. _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
  101. }
  102. return _tableView;
  103. }
  104. - (void)didReceiveMemoryWarning {
  105. [super didReceiveMemoryWarning];
  106. // Dispose of any resources that can be recreated.
  107. }
  108. -(NSMutableArray *)dataArr{
  109. if (!_dataArr) {
  110. _dataArr=[NSMutableArray array];
  111. }
  112. return _dataArr;
  113. }
  114. @end