SelfAppointmentVC.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 configNavigationBar];
  25. dataArray = [NSArray array];
  26. UIView *searchBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 60)];
  27. searchBar.backgroundColor = backGroundColor;
  28. [self.view addSubview:searchBar];
  29. [searchBar addViewWithRect:CGRectMake(5, 59, kSize.width - 10, 1) Color:KlineColor];
  30. textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 10, kSize.width - 140, 40)];
  31. textField.placeholder = @"请输入身份证号码";
  32. textField.borderStyle = UITextBorderStyleRoundedRect;
  33. [searchBar addSubview:textField];
  34. UIButton *searchBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  35. searchBtn.frame = CGRectMake(kSize.width - 100, 10, 80, 40);
  36. searchBtn.backgroundColor = [UIColor lightGrayColor];
  37. [searchBtn setTitleNormal:@"查询"];
  38. [searchBtn borderColor:KlineColor width:1 cornorRadios:5];
  39. [searchBtn target:self];
  40. [searchBar addSubview:searchBtn];
  41. mainTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStylePlain];
  42. mainTableView.y += 60;
  43. mainTableView.height -= 60;
  44. mainTableView.delegate = self;
  45. mainTableView.dataSource = self;
  46. mainTableView.rowHeight = 167;
  47. mainTableView.estimatedSectionHeaderHeight = 0;
  48. mainTableView.estimatedSectionFooterHeight = 0;
  49. [self.view addSubview:mainTableView];
  50. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, kSize.height - 50 - kNavOffSet, kSize.width, 50)];
  51. label.backgroundColor = KlineColor;
  52. [label setText:@"注:以上查询仅供参考, \n真实信息请以交警公布信息为准" Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentCenter];
  53. label.numberOfLines = 0;
  54. [self.view addSubview:label];
  55. holderV = [[HolderView alloc] initWithFrame:mainTableView.frame];
  56. [holderV freshBlock:^{
  57. [self getMyYuyueInfos];
  58. }];
  59. [self.view addSubview:holderV];
  60. [self getMyYuyueInfos];
  61. }
  62. -(void)btnClick:(UIButton *)sender
  63. {
  64. if (textField.text.length < 15) {
  65. [LoadingView showMsg:@"身份证号码有误,请核对"];
  66. return;
  67. }
  68. [self getMyYuyueInfos];
  69. }
  70. #pragma mark maintableview delegate
  71. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  72. {
  73. return dataArray.count;
  74. }
  75. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  76. {
  77. AppointmentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  78. if (cell == nil)
  79. {
  80. cell = [[[NSBundle mainBundle] loadNibNamed:@"AppointmentCell" owner:nil options:nil] firstObject];
  81. }
  82. NSDictionary *dic = dataArray[indexPath.row];
  83. cell.dataDic = dic;
  84. return cell;
  85. }
  86. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  87. {
  88. return .1;
  89. }
  90. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  91. {
  92. return .1;
  93. }
  94. #pragma mark 数据请求
  95. -(void)getMyYuyueInfos
  96. {
  97. if (![Util connectedToNetWork]) {
  98. return;
  99. }
  100. NSString *sfzhm = defUser.sfzmhm;
  101. if (textField.text.length > 0) {
  102. sfzhm = textField.text;
  103. }
  104. NSMutableArray *arr=[NSMutableArray array];
  105. [arr addPro:@"sfzhm" Value:sfzhm];
  106. [arr addPro:@"subject" Value:@""];
  107. NSString* method = @"getMyYuyueInfos";
  108. [MBProgressHUD showLoadToView:self.view];
  109. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  110. [MBProgressHUD hideHUDForView:self.view];
  111. [holderV setHidden:NO];
  112. if (!root) {
  113. [LoadingView showMsg:@"查询失败"];
  114. return;
  115. }
  116. NSString* code = root[@"code"];
  117. if (code.intValue >0)
  118. {
  119. [LoadingView showMsg:root[@"body"]];
  120. return;
  121. }
  122. if ([root[@"body"] count] < 1) {
  123. return;
  124. }
  125. dataArray = root[@"body"];
  126. [holderV setHidden:YES];
  127. [mainTableView reloadData];
  128. }];
  129. }
  130. - (void)didReceiveMemoryWarning {
  131. [super didReceiveMemoryWarning];
  132. // Dispose of any resources that can be recreated.
  133. }
  134. @end