MyModelController.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 "MyModelController.h"
  9. #import "MyTeamCell.h"
  10. #import "MyTeamHeader.h"
  11. static NSString *cellId = @"MyTeamCell";
  12. @interface MyModelController () <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 MyModelController
  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", @"7", @"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. _tableHeader.type = @"model";
  55. }
  56. return _tableHeader;
  57. }
  58. # pragma mark - TableView Delegate
  59. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  60. return 1;
  61. }
  62. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  63. return self.data.count;
  64. }
  65. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  66. MyTeamCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellId];
  67. if (!cell) {
  68. NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellId owner:self options:nil];
  69. cell = [nib objectAtIndex:0];
  70. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  71. cell.data = [self.data objectAtIndex:indexPath.row];
  72. }
  73. return cell;
  74. }
  75. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  76. return 70;
  77. }
  78. # pragma mark -
  79. @end