fansViewController.m 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. #import "fansViewController.h"
  2. #import "fans.h"
  3. #import "fansModel.h"
  4. #import "YBCenterVC.h"
  5. #import "AFNetworking.h"
  6. @interface fansViewController()<UITableViewDelegate,UITableViewDataSource,guanzhu>
  7. {
  8. NSInteger a;
  9. int setvisfans;
  10. int _paging;
  11. }
  12. @property(nonatomic,strong)NSString *navTitle;
  13. @property(nonatomic,strong)NSString *noData1;
  14. @property(nonatomic,strong)NSString *noData2;
  15. @property(nonatomic,strong)NSArray *fansmodels;
  16. @property(nonatomic,strong)NSMutableArray *allArray;
  17. @property(nonatomic,strong)UITableView *tableView;
  18. @end
  19. @implementation fansViewController
  20. -(NSArray *)fansmodels{
  21. NSMutableArray *array = [NSMutableArray array];
  22. for (NSDictionary *dic in self.allArray) {
  23. fansModel *model = [fansModel modelWithDic:dic];
  24. [array addObject:model];
  25. }
  26. _fansmodels = array;
  27. return _fansmodels;
  28. }
  29. - (UIStatusBarStyle)preferredStatusBarStyle {
  30. if (@available(iOS 13.0,*)) {
  31. return UIStatusBarStyleDarkContent;
  32. }
  33. return UIStatusBarStyleDefault;
  34. }
  35. - (void)viewWillAppear:(BOOL)animated
  36. {
  37. [super viewWillAppear:animated];
  38. setvisfans = 1;
  39. [self request];
  40. }
  41. - (void)viewWillDisappear:(BOOL)animated
  42. {
  43. [super viewWillDisappear:animated];
  44. setvisfans = 0;
  45. }
  46. - (void)viewDidLoad {
  47. [super viewDidLoad];
  48. self.navigationController.interactivePopGestureRecognizer.delegate = (id) self;
  49. [self.view setBackgroundColor:UIColor.whiteColor];
  50. self.subNavi.backgroundColor = UIColor.whiteColor;
  51. self.titleL.textColor = UIColor.blackColor;
  52. [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0];
  53. self.naviLine.hidden = NO;
  54. self.naviLine.backgroundColor = RGB(245, 245, 245);
  55. _paging = 1;
  56. if ([_fensiUid isEqual:[Config getOwnID]]) {
  57. _navTitle = YZMsg(@"我的粉丝");
  58. _noData1 = YZMsg(@"你还没有粉丝");
  59. _noData2 = YZMsg(@"赶快邀请小伙伴来关注你吧");
  60. }else{
  61. _navTitle = YZMsg(@"TA的粉丝");
  62. _noData1 = YZMsg(@"TA还没有任何粉丝");
  63. _noData2 = @"";
  64. }
  65. self.titleL.text = _navTitle;
  66. self.allArray = [NSMutableArray array];
  67. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,64+statusbarHeight, _window_width, _window_height - 64-statusbarHeight) style:UITableViewStylePlain];
  68. self.tableView.delegate = self;
  69. self.tableView.dataSource = self;
  70. self.tableView.backgroundColor = UIColor.whiteColor;
  71. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  72. YBWeakSelf;
  73. _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  74. _paging = 1;
  75. [weakSelf request];
  76. }];
  77. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  78. _paging +=1;
  79. [weakSelf request];
  80. }];
  81. [self.view addSubview:self.tableView];
  82. [self.view setBackgroundColor:Normal_Color];
  83. //指示器显示
  84. // [PublicView indictorShow];
  85. // [self request];
  86. }
  87. -(void)request {
  88. [YBNetworking postWithUrl:@"User.getFansList" Dic:@{@"touid":self.fensiUid,@"p":@(_paging)} Suc:^(int code, id info, NSString *msg) {
  89. [_tableView.mj_footer endRefreshing];
  90. [_tableView.mj_header endRefreshing];
  91. if (code == 0) {
  92. if (_paging == 1) {
  93. [_allArray removeAllObjects];
  94. }
  95. NSArray *infoA = [NSArray arrayWithArray:info];
  96. if (infoA.count<=0) {
  97. [_tableView.mj_footer endRefreshingWithNoMoreData];
  98. }else{
  99. [_allArray addObjectsFromArray:infoA];
  100. }
  101. if (_allArray.count == 0) {
  102. [PublicView showTextNoData:_tableView text1:_noData1 text2:_noData2 centerY:0.8];
  103. }else{
  104. [PublicView hiddenTextNoData:_tableView];
  105. }
  106. [_tableView reloadData];
  107. }else{
  108. [MBProgressHUD showPop:msg];
  109. }
  110. } Fail:^(id fail) {
  111. [_tableView.mj_footer endRefreshing];
  112. [_tableView.mj_header endRefreshing];
  113. }];
  114. }
  115. /*
  116. -(void)requestOr
  117. {
  118. AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
  119. NSString *url = [purl stringByAppendingFormat:@"?service=User.getFansList&uid=%@&touid=%@&p=%@",[Config getOwnID],self.fensiUid,@"1"];
  120. YBWeakSelf;
  121. [session GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) {
  122. //NSLog(@"%@",responseObject);
  123. NSNumber *number = [responseObject valueForKey:@"ret"] ;
  124. if([number isEqualToNumber:[NSNumber numberWithInt:200]])
  125. {
  126. NSArray *data = [responseObject valueForKey:@"data"];
  127. NSNumber *code = [data valueForKey:@"code"];
  128. if([code isEqualToNumber:[NSNumber numberWithInt:0]])
  129. {
  130. NSArray *info = [data valueForKey:@"info"];
  131. self.allArray = info;//关注信息复制给数据源
  132. [self.tableView reloadData];
  133. //如果数据为空
  134. if (self.allArray.count == 0) {
  135. [PublicView showTextNoData:self.tableView text1:weakSelf.noData1 text2:weakSelf.noData2];
  136. }else{
  137. [PublicView hiddenTextNoData:self.tableView];
  138. }
  139. }
  140. else{
  141. [PublicView showTextNoData:self.tableView text1:weakSelf.noData1 text2:weakSelf.noData2];
  142. }
  143. }
  144. else
  145. {
  146. [PublicView showTextNoData:self.tableView text1:weakSelf.noData1 text2:weakSelf.noData2];
  147. }
  148. //指示器消失
  149. [PublicView indictorHide];
  150. }
  151. failure:^(NSURLSessionDataTask *task, NSError *error)
  152. {
  153. //指示器消失
  154. [PublicView indictorHide];
  155. if (self.allArray.count == 0) {
  156. [PublicView showTextNoData:self.tableView text1:weakSelf.noData1 text2:weakSelf.noData2];
  157. }
  158. }];
  159. }
  160. */
  161. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  162. return self.fansmodels.count;
  163. }
  164. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  165. {
  166. fans *cell = [fans cellWithTableView:tableView];
  167. cell.backgroundColor = UIColor.whiteColor;
  168. fansModel *model = self.fansmodels[indexPath.row];
  169. cell.model = model;
  170. cell.guanzhuDelegate = self;
  171. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  172. return cell;
  173. }
  174. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  175. return 90;
  176. }
  177. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  178. fansModel *model = _fansmodels[indexPath.row];
  179. YBCenterVC *center = [[YBCenterVC alloc]init];
  180. center.otherUid = model.uid;
  181. center.isPush = YES;
  182. //[self.navigationController pushViewController:center animated:YES];
  183. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:center animated:YES];
  184. }
  185. -(void)doGuanzhu:(NSString *)st{
  186. [self request];
  187. }
  188. @end