CoachListVC.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // CoachListVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/8.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "CoachListVC.h"
  9. #import "CoachDetail.h"
  10. @interface CoachListVC ()
  11. @end
  12. @implementation CoachListVC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.navigationItem.title = @"教练列表";
  16. [self getData];
  17. __weak typeof(self) weakSelf = self;
  18. self.holdervBlock = ^{
  19. [weakSelf getData];
  20. };
  21. }
  22. -(void)getData{
  23. NSMutableDictionary * mDic = [[NSMutableDictionary alloc]init];
  24. [mDic setValue:defUser.userDict[@"dqbh"] forKey:@"dqbh"];
  25. [mDic setValue:defUser.userDict[@"qxbh"] forKey:@"qxbh"];
  26. [mDic setValue:defUser.userDict[@"school"] forKey:@"schoolId"];
  27. [mDic setValue:@"" forKey:@"name"];
  28. [mDic setValue:@"" forKey:@"idcard"];
  29. [mDic setValue:@"" forKey:@"mobile"];
  30. self.requsetDic = mDic;
  31. [self getDataWithDic:mDic method:@"coachs" block:^(NSDictionary *successdic) {
  32. NSArray * arr = successdic[@"body"];
  33. if (arr.count != 0) {
  34. self.holderV.hidden = YES;
  35. }
  36. for (NSDictionary * dic in arr) {
  37. if (![self.sectionTitles containsObject:dic[@"ZM"]]) {
  38. [self.sectionTitles addObject:dic[@"ZM"]];
  39. [self.dataSource addObject:[NSMutableArray new]];
  40. }
  41. }
  42. //排序
  43. [self.sectionTitles sortUsingSelector:@selector(compare:)];
  44. for (NSDictionary * dic in arr) {
  45. NSInteger location = [self.sectionTitles indexOfObject:dic[@"ZM"]];
  46. [self.dataSource[location] addObject:dic];
  47. }
  48. [self.tableView reloadData];
  49. }];
  50. }
  51. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  52. {
  53. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId" forIndexPath:indexPath];
  54. if ([self.dataSource[indexPath.section] count] > 0) {
  55. cell.textLabel.text = self.dataSource[indexPath.section][indexPath.row][@"TCI_NAME"];
  56. }
  57. return cell;
  58. }
  59. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  60. CoachDetail * coachvc = [[CoachDetail alloc]init];
  61. [self.requsetDic setValue:self.dataSource[indexPath.section][indexPath.row][@"TCI_IDCARD"] forKey:@"idcard"];
  62. coachvc.requesetDic = self.requsetDic;
  63. coachvc.coachNum = self.dataSource[indexPath.section][indexPath.row][@"TCI_COACHNUM"];
  64. [self navPushHideTabbarToVC:coachvc];
  65. }
  66. - (void)didReceiveMemoryWarning {
  67. [super didReceiveMemoryWarning];
  68. // Dispose of any resources that can be recreated.
  69. }
  70. /*
  71. #pragma mark - Navigation
  72. // In a storyboard-based application, you will often want to do a little preparation before navigation
  73. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  74. // Get the new view controller using [segue destinationViewController].
  75. // Pass the selected object to the new view controller.
  76. }
  77. */
  78. @end