// // MyTeamController.m // model // // Created by Drew on 2018/10/29. // Copyright © 2018 Mine. All rights reserved. // #import "MyMemberController.h" #import "MyTeamCell.h" #import "MyTeamHeader.h" static NSString *cellId = @"MyTeamCell"; @interface MyMemberController () @property (weak, nonatomic) IBOutlet UITableView *tableView; @property(nonatomic,strong) NSMutableArray* data; @property(nonatomic, strong) MyTeamHeader* tableHeader; @end @implementation MyMemberController - (void)viewDidLoad { [super viewDidLoad]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.tableHeaderView = self.tableHeader; [self getData]; } - (void)getData { ModelUser *modelUser = [ModelUser user]; NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:modelUser.pk, @"memberpk", @"8", @"type", nil]; [YanCNetWorkManager requestPostWithURLStr:Url_myTeam(PublicUrl) parameters:dic finish:^(id responese) { BOOL success = [responese[@"success"] intValue] == 1; if (success) { self.tableHeader.introduceNum = [responese[@"introduceNum"] stringValue]; self.tableHeader.totalCoin = [responese[@"totalCoin"] stringValue]; [self.data addObjectsFromArray:responese[@"introduceList"]]; [self.tableView reloadData]; } else { [MBProgressHUD showInfo:@"请求失败!"]; } } enError:^(NSError *error) { }]; } - (NSMutableArray *)data { if (!_data) { _data = [NSMutableArray arrayWithCapacity:0]; } return _data; } - (UIView *)tableHeader { if(!_tableHeader){ _tableHeader = [[MyTeamHeader alloc] init]; _tableHeader.frame = CGRectMake(0, 0, ScreenWidth, 107); } return _tableHeader; } # pragma mark - TableView Delegate -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.data.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MyTeamCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellId]; if (!cell) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellId owner:self options:nil]; cell = [nib objectAtIndex:0]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.data = [self.data objectAtIndex:indexPath.row]; } return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 70; } # pragma mark - @end