123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- //
- // 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 ()<UITableViewDelegate,UITableViewDataSource>{
-
- 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; i<arr.count; i++) {
- YOUPAIHRsendRankModel *model = arr[i];
- if ([model.youpaipid isEqualToString:idStr]) {
- model.youpaipis_follow = isfollow;
- index = [NSIndexPath indexPathForRow:i inSection:0];
- [arrM addObject:index];
-
-
- }
-
- }
- [UIView performWithoutAnimation:^{
- [self.youpaiptableView reloadRowsAtIndexPaths:arrM withRowAnimation:UITableViewRowAnimationFade];
- }];
-
-
- }
-
- }
- #pragma mark UITableViewDelegate&UITableViewDataSource
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
-
- YOUPAIHRsendRankModel *model = self.youpaipdataArr[indexPath.row];
- YOUPAILZUserShowVC *showVC = [[YOUPAILZUserShowVC alloc]init];
- showVC.youpaipuserId = model.youpaipid;
- [self.navigationController pushViewController:showVC animated:YES];
-
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- return 75;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return self.youpaipdataArr.count;
- }
- -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAIHRLiveRankDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HRAccompanyRankDetailID"];
- if (cell == nil) {
- cell = [[YOUPAIHRLiveRankDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"HRAccompanyRankDetailID"];
- }
- YOUPAIHRsendRankModel *model = self.youpaipdataArr[indexPath.row];
- cell.youpaipuserModel = model;
- cell.backgroundColor = UIColor.clearColor;
-
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
-
- return cell;
- }
- -(UITableView *)youpaiptableView{
- if (!_youpaiptableView) {
- _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
- [self.view addSubview:_youpaiptableView];
- [_youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.right.mas_equalTo(0);
- }];
- _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _youpaiptableView.showsVerticalScrollIndicator = NO;
- _youpaiptableView.showsHorizontalScrollIndicator = NO;
- _youpaiptableView.delegate = self;
- _youpaiptableView.dataSource = self;
- _youpaiptableView.backgroundColor = UIColor.clearColor;
- [_youpaiptableView registerClass:[YOUPAIHRLiveRankDetailCell class] forCellReuseIdentifier:@"HRAccompanyRankDetailID"];
- _youpaiptableView.tableFooterView = [UIView new];
- if (@available(iOS 15.0, *)) {
- _youpaiptableView.sectionHeaderTopPadding = 0;
- }
- }
- return _youpaiptableView;
- }
- #pragma 获取数据
- -(void)youpaifgift_rankData{
-
- NSMutableDictionary *mutDict = [NSMutableDictionary new];
- [mutDict setObject:[NSString stringWithFormat:@"%d",nextpage] forKey:@"page"];
- [mutDict setObject:@"1" forKey:@"type"];
- [mutDict setObject:self.youpaiptype forKey:@"status"];
- [LCHttpHelper requestWithURLString:Gift_rank parameters:mutDict needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- [self.youpaiptableView.mj_header endRefreshing];
- NSDictionary *dic = dict[@"data"];
- NSMutableArray *arrM = [NSMutableArray new];
- if (self.view.tag == 1) {
-
- NSArray *arr = dic[@"list"];
- [self.youpaiptableView lz_hideEmptyView];
- if (arr.count == 0) {
- [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无记录"];
- }
- if (arr.count<=0) {
- [self.youpaipdataArr removeAllObjects];
- [self.youpaiptableView reloadData];
- return ;
- }
- [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-
- YOUPAIHRsendRankModel *noticModel = [YOUPAIHRsendRankModel mj_objectWithKeyValues:obj];
- [self.youpaipdataArr addObject:noticModel];
- [arrM addObject:noticModel];
-
- }];
- if (self->nextpage == 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
|