MyMemberController.m 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // MyTeamController.m
  3. // model
  4. //
  5. // Created by Drew on 2018/10/29.
  6. // Copyright © 2018 Mine. All rights reserved.
  7. //
  8. #import "MyMemberController.h"
  9. #import "MyTeamCell.h"
  10. #import "MyTeamHeader.h"
  11. static NSString *cellId = @"MyTeamCell";
  12. @interface MyMemberController () <UITableViewDelegate, UITableViewDataSource>
  13. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  14. @property(nonatomic,strong) NSMutableArray* data;
  15. @property(nonatomic, strong) MyTeamHeader* tableHeader;
  16. @end
  17. @implementation MyMemberController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.tableView.delegate = self;
  21. self.tableView.dataSource = self;
  22. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  23. self.tableView.tableHeaderView = self.tableHeader;
  24. [self getData];
  25. }
  26. - (void)getData {
  27. ModelUser *modelUser = [ModelUser user];
  28. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:modelUser.pk, @"memberpk", @"8", @"type", nil];
  29. [YanCNetWorkManager requestPostWithURLStr:Url_myTeam(PublicUrl)
  30. parameters:dic
  31. finish:^(id responese) {
  32. BOOL success = [responese[@"success"] intValue] == 1;
  33. if (success) {
  34. self.tableHeader.introduceNum = [responese[@"introduceNum"] stringValue];
  35. self.tableHeader.totalCoin = [responese[@"totalCoin"] stringValue];
  36. [self.data addObjectsFromArray:responese[@"introduceList"]];
  37. [self.tableView reloadData];
  38. } else {
  39. [MBProgressHUD showInfo:@"请求失败!"];
  40. }
  41. } enError:^(NSError *error) {
  42. }];
  43. }
  44. - (NSMutableArray *)data {
  45. if (!_data) {
  46. _data = [NSMutableArray arrayWithCapacity:0];
  47. }
  48. return _data;
  49. }
  50. - (UIView *)tableHeader {
  51. if(!_tableHeader){
  52. _tableHeader = [[MyTeamHeader alloc] init];
  53. _tableHeader.frame = CGRectMake(0, 0, ScreenWidth, 107);
  54. }
  55. return _tableHeader;
  56. }
  57. # pragma mark - TableView Delegate
  58. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  59. return 1;
  60. }
  61. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  62. return self.data.count;
  63. }
  64. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  65. MyTeamCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellId];
  66. if (!cell) {
  67. NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellId owner:self options:nil];
  68. cell = [nib objectAtIndex:0];
  69. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  70. cell.data = [self.data objectAtIndex:indexPath.row];
  71. }
  72. return cell;
  73. }
  74. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  75. return 70;
  76. }
  77. # pragma mark -
  78. @end