// // YOUPAIMyNetworkVC.m // MSYOUPAI // // Created by xiaohaoran on 2022/3/11. // Copyright © 2022 MS. All rights reserved. // #import "YOUPAIMyNetworkVC.h" #import "YOUPAIHRGuildCenterDetailCell.h" #import "YOUPAIHRGuildCenterDetailHeaderView.h" #import "YOUPAIHRMembershipApplicationVC.h" #import "LZAlertWindow.h" #import "UIViewController+TFPresent.h" #import "UIScrollView+LZRefresh.h" #import "YOUPAIHRGuildCenterDetailModel.h" #import "YOUPAIApplyOutWindow.h" #import "YOUPAICancellationApplicationVC.h" #import "YOUPAIMyNetworkCell.h" #import "YOUPAIMyNetworkModel.h" @interface YOUPAIMyNetworkVC () @property(nonatomic,strong)UITableView *youpaiptableView; @property (nonatomic, assign) NSInteger youpaippage; @property (nonatomic, strong) NSMutableArray *youpaipdataSource; @property(nonatomic,copy)NSString *total_people;//我邀请的人 @property(nonatomic,strong)UILabel *allIncomeLabel;//总收益 @end @implementation YOUPAIMyNetworkVC -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.navigationController.navigationBarHidden = YES; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; self.navigationController.navigationBarHidden = NO; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; self.title = @"我的人脉"; [self youpaifloadNavView]; [self youpaiptableView]; @weakify(self); [self.youpaiptableView setRefreshHeaderWithBlock:^{ @strongify(self); [self youpaifrequestRankListWithStatus:kRefreshHeader]; }]; [self.youpaiptableView.mj_header beginRefreshing]; } -(void)loadNoStatusView{ UIButton *noStatusBtn = [UIButton new]; [self.view addSubview:noStatusBtn]; [noStatusBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.mas_equalTo(-TabbarHeight); make.centerX.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(280, 49)); }]; [noStatusBtn setTitle:@"马上邀请" forState:UIControlStateNormal]; [noStatusBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; noStatusBtn.titleLabel.font = [UIFont systemFontOfSize:18]; [noStatusBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(280, 49) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:1] forState:UIControlStateNormal]; noStatusBtn.layer.cornerRadius = 24.5; noStatusBtn.clipsToBounds = YES; [noStatusBtn addTarget:self action:@selector(inviteMoreBtnClick) forControlEvents:UIControlEventTouchUpInside]; } -(void)youpaifloadNavView{ UIImageView *navView = [UIImageView new]; [self.view addSubview:navView]; [navView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.top.mas_equalTo(0); make.height.mas_equalTo(255); }]; navView.contentMode = UIViewContentModeScaleToFill; navView.image = [UIImage imageNamed:@"vqu_images_MyNetWork_headerViewBg"]; navView.userInteractionEnabled = YES; //返回 UIButton *cancelBtn = [UIButton new]; [navView addSubview:cancelBtn ]; [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.mas_equalTo(StatusBarHeight); make.size.mas_equalTo(CGSizeMake(40, 40)); }]; [cancelBtn setImage:[UIImage imageNamed:@"vqu_images_D_cancel"] forState:UIControlStateNormal]; //title UILabel *titleLabel = [UILabel new]; [navView addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(cancelBtn); make.centerX.mas_equalTo(0); }]; titleLabel.font = LCBoldFont(17); titleLabel.textColor = [UIColor whiteColor]; titleLabel.text = @"我的人脉"; //总收益 UILabel *allIncomeLabel = [UILabel new]; self.allIncomeLabel = allIncomeLabel; [navView addSubview:allIncomeLabel]; [allIncomeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(titleLabel.mas_bottom).offset(56); make.centerX.mas_equalTo(0); }]; allIncomeLabel.textColor = LCWhiteColor; allIncomeLabel.font = LCBoldFont(36); allIncomeLabel.textAlignment = NSTextAlignmentCenter; // UILabel *allIncomeShowLabel = [UILabel new]; [navView addSubview:allIncomeShowLabel]; [allIncomeShowLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(allIncomeLabel.mas_bottom).offset(8); make.centerX.mas_equalTo(0); }]; allIncomeShowLabel.textColor = LCWhiteColor; allIncomeShowLabel.font = [UIFont systemFontOfSize:14]; allIncomeShowLabel.text = @"总收益(元)"; allIncomeShowLabel.textAlignment = NSTextAlignmentCenter; //事件 [cancelBtn addTarget: self action:@selector(youpaifcancelButtonClick) forControlEvents:UIControlEventTouchUpInside]; } -(void)youpaifcancelButtonClick{ [self.navigationController popViewControllerAnimated:YES]; } /// 设置加载更多 - (void)youpaifrefreshFooterWithHidden:(BOOL)hidden{ @weakify(self); [self.youpaiptableView setRefreshFooter:hidden withBlock:^{ @strongify(self); [self youpaifrequestRankListWithStatus:kRefreshFooter]; }]; } - (void)youpaifrequestRankListWithStatus:(kRefreshStatus)status{ if (status == kRefreshFooter) { self.youpaippage ++; }else{ self.youpaippage = 0; } @weakify(self); NSMutableDictionary *dict = [NSMutableDictionary new]; [dict setObject:@(self.youpaippage) forKey:@"after_key"]; // [dict setObject:@"" forKey:@"begin_time"]; // [dict setObject:@"" forKey:@"end_time"]; [LCHttpHelper requestWithURLString:Contacts_overview parameters:dict needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { @strongify(self); [self.youpaiptableView endRefreshing:kRefreshAll]; NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) {//成功 if (status != kRefreshFooter) { [self.youpaipdataSource removeAllObjects]; } NSDictionary *data = [dict objectForKey:@"data"]; self.total_people = [NSString stringWithFormat:@"我的邀请(%@人)",data[@"total_people"]]; self.allIncomeLabel.text = data[@"total_income"]; NSArray *arr = data[@"list"]; [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { YOUPAIMyNetworkModel *model = [YOUPAIMyNetworkModel mj_objectWithKeyValues:obj]; [self.youpaipdataSource addObject:model]; }]; [self.youpaiptableView reloadData]; NSInteger youpaiptotalPage = [data[@"after_key"] integerValue]; [self youpaifrefreshFooterWithHidden:self.youpaippage >= youpaiptotalPage]; if (self.youpaipdataSource.count != 0) { [self.youpaiptableView lz_hideEmptyView]; }else{ self.allIncomeLabel.text = @"0.00"; [self loadNoStatusView]; [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无数据"]; } } } failure:^(NSError *error) { @strongify(self); [self.youpaiptableView endRefreshing:kRefreshAll]; }]; } #pragma mark UITableViewDelegate&UITableViewDataSource -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 61; } -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView* headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 61)]; headerView.backgroundColor = [UIColor whiteColor]; //我的邀请 UILabel *myinviteLabel = [UILabel new]; [headerView addSubview:myinviteLabel]; [myinviteLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(12); make.centerY.mas_equalTo(0); }]; myinviteLabel.text = self.total_people; myinviteLabel.font = LCBoldFont(14); myinviteLabel.textColor = LZ273145Color; //邀请跟多 UIButton *inviteMoreBtn = [UIButton new]; [headerView addSubview:inviteMoreBtn]; [inviteMoreBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-12); make.centerY.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(75, 27)); }]; [inviteMoreBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(75, 27) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:1] forState:UIControlStateNormal]; [inviteMoreBtn setTitle:@"邀请更多" forState:UIControlStateNormal]; [inviteMoreBtn setTitleColor:LCWhiteColor forState:UIControlStateNormal]; inviteMoreBtn.titleLabel.font = [UIFont systemFontOfSize:12]; inviteMoreBtn.layer.cornerRadius = 15; inviteMoreBtn.clipsToBounds = YES; [inviteMoreBtn addTarget:self action:@selector(inviteMoreBtnClick) forControlEvents:UIControlEventTouchUpInside]; return headerView; } -(void)inviteMoreBtnClick{ ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init]; vc.contentUrl = self.youpaipinviteUrl; [self.navigationController pushViewController:vc animated:YES]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 97; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.youpaipdataSource.count; } -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *CellIdentifier = @"YOUPAIMyNetworkCell"; YOUPAIMyNetworkCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];; if (cell == nil) { cell = [[YOUPAIMyNetworkCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; cell.backgroundColor = LZFAFAFCColor; YOUPAIMyNetworkModel *model = self.youpaipdataSource[indexPath.row]; cell.model = model; return cell; } -(UITableView *)youpaiptableView{ if (_youpaiptableView == nil) { _youpaiptableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain]; [self.view addSubview:_youpaiptableView]; [_youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(255); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(-SafeHeight); }]; _youpaiptableView.delegate = self; _youpaiptableView.dataSource = self; _youpaiptableView.backgroundColor = [UIColor whiteColor]; _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone; _youpaiptableView.showsVerticalScrollIndicator = NO; _youpaiptableView.showsHorizontalScrollIndicator = NO; if (@available(iOS 15.0, *)) { _youpaiptableView.sectionHeaderTopPadding = 0; } } return _youpaiptableView; } -(NSMutableArray *)youpaipdataSource{ if (_youpaipdataSource == nil) { _youpaipdataSource = [NSMutableArray new]; } return _youpaipdataSource; } @end