SelfAppointmentVC.m 4.7 KB

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