attrViewController.m 7.3 KB

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