SelfAppointmentVC.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //
  2. // SelfAppointmentVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/5/4.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "SelfAppointmentVC.h"
  9. #import "AppointmentCell.h"
  10. #import "HolderView.h"
  11. @interface SelfAppointmentVC ()<UITableViewDelegate,UITableViewDataSource>
  12. {
  13. UITableView *mainTableView;
  14. HolderView *holderV;
  15. UITextField *textField;
  16. NSArray *dataArray;
  17. }
  18. @end
  19. @implementation SelfAppointmentVC
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. self.title = @"自主预约查询";
  23. //self.view.backgroundColor = backGroundColor;
  24. [self configNavBar];
  25. dataArray = [NSArray array];
  26. mainTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain];
  27. mainTableView.y += kNavOffSet;
  28. mainTableView.height -= kNavOffSet;
  29. mainTableView.delegate = self;
  30. mainTableView.dataSource = self;
  31. mainTableView.estimatedSectionHeaderHeight = 0;
  32. mainTableView.estimatedSectionFooterHeight = 0;
  33. [self.view addSubview:mainTableView];
  34. //type为1是从学员进入 2是从主页进入
  35. if ([_type isEqualToString:@"2"]) {
  36. UIView *searchBar = [[UIView alloc] initWithFrame:CGRectMake(0, kNavOffSet, kSize.width, 60)];
  37. searchBar.backgroundColor = backGroundColor;
  38. [self.view addSubview:searchBar];
  39. [searchBar addViewWithRect:CGRectMake(5, 59, kSize.width - 10, 1)];
  40. textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 10, kSize.width - 140, 40)];
  41. textField.placeholder = @"请输入身份证号码";
  42. textField.borderStyle = UITextBorderStyleRoundedRect;
  43. [searchBar addSubview:textField];
  44. UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  45. searchBtn.frame = CGRectMake(kSize.width - 100, 10, 80, 40);
  46. searchBtn.backgroundColor = [UIColor colorWithRed:60/255.0 green:170/255.0 blue:240/255.0 alpha:1];
  47. [searchBtn setTitle:@"查询" textColor:[UIColor whiteColor] font:Font18 fotState:UIControlStateNormal];
  48. [searchBtn borderColor:lineColor width:1 cornorRadios:5];
  49. [searchBtn target:self];
  50. [searchBar addSubview:searchBtn];
  51. mainTableView.y += 60;
  52. mainTableView.height -= 60;
  53. }
  54. holderV = [[HolderView alloc] initWithFrame:mainTableView.frame];
  55. [holderV freshBlock:^{
  56. [self getMyYuyueInfos];
  57. }];
  58. [self.view addSubview:holderV];
  59. if (_sfzhm.length >= 11) {//身份证号码肯定比手机号长吧?
  60. [self getMyYuyueInfos];
  61. }
  62. }
  63. -(void)viewDidDisappear:(BOOL)animated
  64. {
  65. [super viewDidDisappear:animated];
  66. RemoveHUD();
  67. }
  68. -(void)btnClick:(UIButton *)sender
  69. {
  70. [self.view endEditing:YES];
  71. if (textField.text.length < 15) {
  72. [LoadingView showMsg:@"身份证号码有误,请核对"];
  73. return;
  74. }
  75. [self getMyYuyueInfos];
  76. }
  77. #pragma mark maintableview delegate
  78. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  79. {
  80. return dataArray.count;
  81. }
  82. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  83. {
  84. AppointmentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  85. if (cell == nil)
  86. {
  87. cell = [[[NSBundle mainBundle] loadNibNamed:@"AppointmentCell" owner:nil options:nil] firstObject];
  88. }
  89. NSDictionary *dic = dataArray[indexPath.row];
  90. cell.dataDic = dic;
  91. return cell;
  92. }
  93. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  94. {
  95. return .1;
  96. }
  97. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  98. {
  99. return .1;
  100. }
  101. #pragma mark 数据请求
  102. //自主预约
  103. - (void)getMyYuyueInfos
  104. {
  105. if (![Util connectedToNetWork]) {
  106. showMsgUnconnect();
  107. return;
  108. }
  109. if (textField.text.length > 0) {
  110. _sfzhm = textField.text;
  111. }
  112. NSMutableArray *arr=[NSMutableArray array];
  113. [arr addPro:@"sfzhm" Value:_sfzhm];
  114. [arr addPro:@"subject" Value:@""];
  115. NSString* method = @"getMyYuyueInfos";
  116. [LoadingView showHUD];
  117. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  118. RemoveHUD();
  119. [holderV setHidden:NO];
  120. if (!root) {
  121. [LoadingView showMsg:@"查询失败"];
  122. return;
  123. }
  124. NSString* code = root[@"code"];
  125. if (code.intValue >0)
  126. {
  127. [LoadingView showMsg:root[@"body"]];
  128. return;
  129. }
  130. if ([root[@"body"] count] < 1) {
  131. [LoadingView showMsg:@"已加载全部数据"];
  132. return;
  133. }
  134. [holderV setHidden:YES];
  135. dataArray = root[@"body"];
  136. [mainTableView reloadData];
  137. }];
  138. }
  139. - (void)didReceiveMemoryWarning {
  140. [super didReceiveMemoryWarning];
  141. // Dispose of any resources that can be recreated.
  142. }
  143. @end