SignDetailVC.m 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. //
  2. // SignDetailVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/4/6.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "SignDetailVC.h"
  9. #import "DateView.h"
  10. #import "SignInCell.h"
  11. @interface SignDetailVC ()<UITableViewDelegate,UITableViewDataSource>
  12. {
  13. //控件
  14. UILabel *dateLabel;
  15. UIButton *dateBtn;
  16. UITableView *mainTableView;
  17. UIView *placeHolderView;
  18. //数据
  19. NSArray *signsArray;
  20. }
  21. @end
  22. @implementation SignDetailVC
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. self.title = @"签到详情";
  26. self.view.backgroundColor = backGroundColor;
  27. [self configNavigationBar];
  28. //数据初始化
  29. signsArray = [NSArray array];
  30. dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, kSize.width - 20, 60)];
  31. dateLabel.backgroundColor = backGroundColor;
  32. [dateLabel setText:@"周五 2016-04-05" Font:FontTitle TextColor:contentTextColor];
  33. [self.view addSubview:dateLabel];
  34. dateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  35. dateBtn.frame = CGRectMake(kSize.width - 120, 0, 120, 60);
  36. [dateBtn setImage:[UIImage imageNamed:@"leftvc_icon11"] withTitle:@"选择日期" Font:Font17 forState:UIControlStateNormal];
  37. [dateBtn target:self];
  38. [self.view addSubview:dateBtn];
  39. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, kSize.width - 20, 1)];
  40. label.backgroundColor = KlineColor;
  41. [self.view addSubview:label];
  42. mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 61, kSize.width, kSize.height - 125) style:UITableViewStyleGrouped];
  43. mainTableView.delegate = self;
  44. mainTableView.dataSource = self;
  45. mainTableView.rowHeight = 100;
  46. [mainTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
  47. [self.view addSubview:mainTableView];
  48. placeHolderView = [[UIView alloc] initWithFrame:mainTableView.frame];
  49. placeHolderView.backgroundColor = backGroundColor;
  50. [self.view addSubview:placeHolderView];
  51. UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(placeHolderView.width/2.0 - 50, placeHolderView.height/2.0 - 80, 100, 120)];
  52. imgView.image = [UIImage imageNamed:@"placeHolderImg"];
  53. [placeHolderView addSubview:imgView];
  54. label = [[UILabel alloc] initWithFrame:CGRectMake(0, placeHolderView.height/2.0 + 50, placeHolderView.width, 30)];
  55. label.text = @"该天还未签到哦!";
  56. label.textAlignment = NSTextAlignmentCenter;
  57. [label setFont:[UIFont scaleSize:18]];
  58. label.textColor = contentTextColor;
  59. [placeHolderView addSubview:label];
  60. //获取默认日期的签到情况
  61. if (_todaySign.count > 0) {
  62. [placeHolderView setHidden:YES];
  63. signsArray = _todaySign;
  64. [mainTableView reloadData];
  65. }else{
  66. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  67. formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
  68. [formatter setDateFormat:@"yyyy-MM-dd"];
  69. [self getStuSignDetail:[formatter stringFromDate:[NSDate date]]];
  70. }
  71. }
  72. -(void)btnClick:(UIButton *)sender
  73. {
  74. DateView* dateV = [[DateView alloc] init];
  75. [dateV setStyle:2];
  76. [dateV showWithComplete:^(NSString * result) {
  77. dateLabel.text = result;
  78. //查询这天有没有签到
  79. if (result.length > 10) {
  80. NSString *dateString = [result substringFromIndex:3];
  81. [self getStuSignDetail:dateString];
  82. }
  83. }];
  84. }
  85. #pragma mark tableView delegate
  86. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  87. {
  88. return signsArray.count;
  89. }
  90. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  91. {
  92. return 1;
  93. }
  94. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  95. {
  96. SignInCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  97. if (cell == nil)
  98. {
  99. cell = [[SignInCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  100. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  101. }
  102. cell.model = signsArray[indexPath.section];
  103. return cell;
  104. }
  105. //-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  106. //{
  107. // return 100;
  108. //}
  109. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  110. {
  111. UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, -2, kSize.width, 24)];
  112. view.backgroundColor = backGroundColor;
  113. return view;
  114. }
  115. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  116. {
  117. return 20;
  118. }
  119. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  120. {
  121. UIView *view = [UIView new];
  122. return view;
  123. }
  124. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  125. {
  126. return .1;
  127. }
  128. #pragma mark 获取学员详细
  129. - (void)getStuSignDetail:(NSString *)dateString
  130. {
  131. if (![Util connectedToNetWork]) {
  132. showMsgUnconnect();
  133. return;
  134. }
  135. placeHolderView.hidden = NO;
  136. //NSLog(@" 查看这天的详细 ---->%@",dateString);
  137. NSMutableArray *arr=[NSMutableArray array];
  138. [arr addPro:@"sfzhm" Value:defUser.sfzmhm];
  139. [arr addPro:@"crDate" Value:dateString];
  140. NSString* method = @"getStuSignDetail";
  141. [MBProgressHUD showLoadToView:self.view];
  142. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  143. [MBProgressHUD hideHUDForView:self.view];
  144. //NSLog(@"学员签到详细---->%@----->%@",arr,root);
  145. if (!root) {
  146. [LoadingView showMsg:@"查询失败"];
  147. return ;
  148. }
  149. if ([root[@"code"] isEqualToString:@"1"]) {
  150. [LoadingView showMsg:root[@"body"]];
  151. return;
  152. }
  153. if ([root[@"body"] count] == 0) {
  154. return;
  155. }
  156. signsArray = root[@"body"];
  157. [placeHolderView setHidden:YES];
  158. [mainTableView reloadData];
  159. }];
  160. }
  161. - (void)didReceiveMemoryWarning {
  162. [super didReceiveMemoryWarning];
  163. // Dispose of any resources that can be recreated.
  164. }
  165. @end