123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- //
- // SignDetailVC.m
- // jiaPei
- //
- // Created by apple on 16/4/6.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "SignDetailVC.h"
- #import "DateView.h"
- #import "SignInCell.h"
- @interface SignDetailVC ()<UITableViewDelegate,UITableViewDataSource>
- {
- //控件
- UILabel *dateLabel;
- UIButton *dateBtn;
- UITableView *mainTableView;
- UIView *placeHolderView;
-
- //数据
- NSArray *signsArray;
- }
- @end
- @implementation SignDetailVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.title = @"签到详情";
- self.view.backgroundColor = backGroundColor;
- [self configNavigationBar];
-
- //数据初始化
- signsArray = [NSArray array];
-
- dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, kSize.width - 20, 60)];
- dateLabel.backgroundColor = backGroundColor;
- [dateLabel setText:@"周五 2016-04-05" Font:FontTitle TextColor:contentTextColor];
- [self.view addSubview:dateLabel];
-
- dateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- dateBtn.frame = CGRectMake(kSize.width - 120, 0, 120, 60);
- [dateBtn setImage:[UIImage imageNamed:@"leftvc_icon11"] withTitle:@"选择日期" Font:Font17 forState:UIControlStateNormal];
- [dateBtn target:self];
- [self.view addSubview:dateBtn];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, kSize.width - 20, 1)];
- label.backgroundColor = KlineColor;
- [self.view addSubview:label];
-
- mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 61, kSize.width, kSize.height - 125) style:UITableViewStyleGrouped];
- mainTableView.delegate = self;
- mainTableView.dataSource = self;
- mainTableView.rowHeight = 100;
- [mainTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
- [self.view addSubview:mainTableView];
-
- placeHolderView = [[UIView alloc] initWithFrame:mainTableView.frame];
- placeHolderView.backgroundColor = backGroundColor;
- [self.view addSubview:placeHolderView];
- UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(placeHolderView.width/2.0 - 50, placeHolderView.height/2.0 - 80, 100, 120)];
- imgView.image = [UIImage imageNamed:@"placeHolderImg"];
- [placeHolderView addSubview:imgView];
-
- label = [[UILabel alloc] initWithFrame:CGRectMake(0, placeHolderView.height/2.0 + 50, placeHolderView.width, 30)];
- label.text = @"该天还未签到哦!";
- label.textAlignment = NSTextAlignmentCenter;
- [label setFont:[UIFont scaleSize:18]];
- label.textColor = contentTextColor;
- [placeHolderView addSubview:label];
- //获取默认日期的签到情况
- if (_todaySign.count > 0) {
-
- [placeHolderView setHidden:YES];
- signsArray = _todaySign;
- [mainTableView reloadData];
- }else{
-
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- [self getStuSignDetail:[formatter stringFromDate:[NSDate date]]];
- }
- }
- -(void)btnClick:(UIButton *)sender
- {
- DateView* dateV = [[DateView alloc] init];
- [dateV setStyle:2];
- [dateV showWithComplete:^(NSString * result) {
-
- dateLabel.text = result;
-
- //查询这天有没有签到
- if (result.length > 10) {
- NSString *dateString = [result substringFromIndex:3];
- [self getStuSignDetail:dateString];
- }
- }];
- }
- #pragma mark tableView delegate
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return signsArray.count;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 1;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- SignInCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil)
- {
- cell = [[SignInCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
-
- cell.model = signsArray[indexPath.section];
-
- return cell;
- }
- //-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- //{
- // return 100;
- //}
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, -2, kSize.width, 24)];
- view.backgroundColor = backGroundColor;
- return view;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 20;
- }
- -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- {
- UIView *view = [UIView new];
- return view;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return .1;
- }
- #pragma mark 获取学员详细
- - (void)getStuSignDetail:(NSString *)dateString
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
- placeHolderView.hidden = NO;
- //NSLog(@" 查看这天的详细 ---->%@",dateString);
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"sfzhm" Value:defUser.sfzmhm];
- [arr addPro:@"crDate" Value:dateString];
-
- NSString* method = @"getStuSignDetail";
-
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
- //NSLog(@"学员签到详细---->%@----->%@",arr,root);
- if (!root) {
- [LoadingView showMsg:@"查询失败"];
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- [LoadingView showMsg:root[@"body"]];
- return;
- }
- if ([root[@"body"] count] == 0) {
- return;
- }
-
- signsArray = root[@"body"];
- [placeHolderView setHidden:YES];
- [mainTableView reloadData];
- }];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|