// // YOUPAIHRAccompanyRankDetailVC.m // VQU // // Created by xiaohaoran on 2021/10/19. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIHRAccompanyRankDetailVC.h" #import "YOUPAIHRsendRankModel.h" #import "YOUPAIHRLiveRankDetailCell.h" #import "YOUPAILZUserShowVC.h" @interface YOUPAIHRAccompanyRankDetailVC (){ int ispage; int nextpage; } @property(nonatomic,strong)UITableView *youpaiptableView; @property(nonatomic,strong)NSMutableArray *youpaipdataArr;//数据源 @end @implementation YOUPAIHRAccompanyRankDetailVC - (void)dealloc{ [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaifchangeFollowStateNotification:) name:@"ChangeFollowState" object:nil]; [self youpaiptableView]; [self youpaifRefreshUI]; } -(void)youpaifRefreshUI{ nextpage = 1; self.view.tag = 1; @weakify(self); self.youpaiptableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ @strongify(self); self->nextpage = 1; [self youpaifgift_rankData]; }]; // 上拉刷新 self.youpaiptableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ @strongify(self); if (self->nextpage< self->ispage) { self.view.tag = 2; self->nextpage = self->nextpage+1; [self youpaifgift_rankData]; }else { [self.youpaiptableView.mj_footer endRefreshing]; // [self.tableView.mj_footer endRefreshingWithNoMoreData]; } }]; [self.youpaiptableView.mj_header beginRefreshing]; } - (void)youpaifchangeFollowStateNotification:(NSNotification *)notification{ NSDictionary *dict = [notification userInfo]; NSString *idStr = dict[@"follow_uid"]; NSInteger isfollow = [dict[@"is_follow"] intValue]; NSArray *arr = self.youpaipdataArr; if (arr.count>0) { NSIndexPath *index; NSMutableArray *arrM = [NSMutableArray new]; for (int i = 0; inextpage == 1) { self.youpaipdataArr = arrM; self->nextpage = [dict[@"data"][@"page"] intValue]; self->ispage = [dict[@"data"][@"total_page"] intValue]; [self.youpaiptableView reloadData]; } }else{ NSArray *arr = dic[@"list"]; if (arr.count<=0) { return ; } [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { YOUPAIHRsendRankModel *noticModel = [YOUPAIHRsendRankModel mj_objectWithKeyValues:obj]; [self.youpaipdataArr addObject:noticModel]; }]; self->nextpage = [dict[@"data"][@"page"] intValue]; self->ispage = [dict[@"data"][@"total_page"] intValue]; [self.youpaiptableView reloadData]; [self.youpaiptableView.mj_header endRefreshing]; [self.youpaiptableView.mj_footer endRefreshing]; } } } failure:^(NSError *error) { [self.youpaiptableView.mj_header endRefreshing]; [self.youpaiptableView.mj_footer endRefreshing]; }]; } -(NSMutableArray *)youpaipdataArr{ if (_youpaipdataArr == nil) { _youpaipdataArr = [NSMutableArray new]; } return _youpaipdataArr; } #pragma mark - JXCategoryListContainerView - (UIView *)listView{ return self.view; } @end