//
//  ApplyTableViewCell.m
//  gaotingshan
//
//  Created by MacBook Dq01 on 16/5/24.
//  Copyright © 2016年 Xu Mengzhu. All rights reserved.
//

#import "ApplyTableViewCell.h"
#import "PersoListModel.h"

#define KMargin 10

@implementation ApplyTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //cell布局 4个Label
        self.width = [UIScreen mainScreen].bounds.size.width - 2*KMargin;
        
        [self addSubview:self.organizerNameLabel];
        [self addSubview:self.iphoneLabel];
        [self addSubview:self.isPassLabel];
        [self addSubview:self.dateLabel];
        
    }
    return self;
}

- (UILabel *)organizerNameLabel {
    if (!_organizerNameLabel) {
        _organizerNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width/6.0, 30)];
        _organizerNameLabel.textAlignment = NSTextAlignmentCenter;
        _organizerNameLabel.font = [UIFont systemFontOfSize:10];
//        _organizerNameLabel.backgroundColor = [UIColor cyanColor];

    }
    return _organizerNameLabel;
}

- (UILabel *)iphoneLabel {
    if (!_iphoneLabel) {
        _iphoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_organizerNameLabel.frame), 0, (self.frame.size.width/6.0)*2, 30)];
        _iphoneLabel.textAlignment = NSTextAlignmentCenter;
        _iphoneLabel.font = [UIFont systemFontOfSize:12];
//        _iphoneLabel.backgroundColor = [UIColor blueColor];

    }
    return _iphoneLabel;
}

- (UILabel *)isPassLabel {
    if (!_isPassLabel) {
        _isPassLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_iphoneLabel.frame), 0, self.frame.size.width/6.0, 30)];
        _isPassLabel.textAlignment = NSTextAlignmentCenter;
        _isPassLabel.font = [UIFont systemFontOfSize:12];
        _isPassLabel.textColor = [UIColor blueColor];
//        _isPassLabel.backgroundColor = [UIColor orangeColor];
        
    }
    return _isPassLabel;
}

- (UILabel *)dateLabel {
    if (!_dateLabel) {
        _dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_isPassLabel.frame), 0, (self.frame.size.width/6.0)*2, 30)];
        _dateLabel.textAlignment = NSTextAlignmentCenter;
        _dateLabel.font = [UIFont systemFontOfSize:12];
//        _dateLabel.backgroundColor = [UIColor purpleColor];
        
    }
    return _dateLabel;
}

- (void)show:(PersoListModel *)persoList {

    _organizerNameLabel.text = persoList.userName;
    NSLog(@"uesrNmae:%@", persoList.userName);
    _iphoneLabel.text = persoList.userPhone;
    
     _isPassLabel.text = @"已通过";
    
    
    //以下是对活动状态的处理
//    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
//    NSString *str = [formatter stringFromNumber:persoList.applyStatus];
//    if ([str isEqualToString:@"1"]) {
//        _isPassLabel.text = @"已通过";
//    }
    
    //以下是对活动时间的处理（后台数据太坑，累死哥了！！！）
//    NSString *time = [NSString stringWithFormat:@"%@", persoList.applyTime];
//    NSLog(@"applyTimeL%@", persoList.applyTime);
//    NSLog(@"time:%@", time);
//    NSLog(@"length:%ld", (unsigned long)time.length);
//    NSRange range = {0, 10};
//    NSString *setTime = [time substringWithRange:range];
//    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
//    NSNumber *number = [numberFormatter numberFromString:setTime];
//    NSDate *date = [NSDate dateWithTimeIntervalSince1970:number.floatValue];
//    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//    [dateFormatter setDateFormat:@"YYYY-MM-dd"];
//    NSString *eventStartTime =[dateFormatter stringFromDate:date];
 //   _dateLabel.text = eventStartTime;

    _dateLabel.text = persoList.teamName;
}

///////////////////////／／／／／／／／
- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
