//
//  OrderExpressTableViewCell.m
//  ALand
//
//  Created by Z on 16/4/21.
//  Copyright © 2016年 Z. All rights reserved.
//

#import "OrderExpressTableViewCell.h"
#import "OrderCellView.h"
#import "JavenConsumer.h"
#import "JavenCreateInfo.h"
@interface OrderExpressTableViewCell ()
@property (nonatomic, strong) NSMutableArray *arrCellView;
@property (weak, nonatomic) IBOutlet UILabel *labelState;
@property (weak, nonatomic) IBOutlet UILabel *labelBuyer;
@property (weak, nonatomic) IBOutlet UILabel *labelDate;
@property (weak, nonatomic) IBOutlet UILabel *labelTotal;
@property (weak, nonatomic) IBOutlet UILabel *labelCommission;
@end
@implementation OrderExpressTableViewCell
- (void)awakeFromNib {
    // Initialization code
    self.arrCellView = [NSMutableArray array];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}



- (void)cellWithModel:(JavenOrderModel *)model {
    
    NSArray *arr = model.goodsDetails;
    for (OrderCellView *cellView  in self.arrCellView) {
        [cellView removeFromSuperview];
    }
    
    for (NSInteger i = 0; i < arr.count; i++) {
        OrderCellView *cellView = [OrderCellView viewWithNibName:@"OrderCellView"];
        cellView.frame = CGRectMake(0, 74 + 120 * i, self.width, 120);
        
        [cellView setupViewWithModel:arr[i]];
        
        [self.arrCellView addObject:cellView];
        [self.contentView addSubview:cellView];
    }
    
    self.labelTotal.text = [NSString stringWithFormat:@"%.2f", model.total];
    self.labelCommission.text = [NSString stringWithFormat:@"%.2f", model.commissions];
    JavenConsumer *consumer = model.consumer;
    self.labelBuyer.text = consumer.code;
    self.labelDate.text = [(JavenCreateInfo *)model.createInfo time];
    
}


- (void)cellWithViewNumber:(NSInteger)number {
    for (OrderCellView *cellView  in self.arrCellView) {
        [cellView removeFromSuperview];
    }
    
    for (NSInteger i = 0; i < number; i++) {
        OrderCellView *cellView = [OrderCellView viewWithNibName:@"OrderCellView"];
        cellView.frame = CGRectMake(0, 74 + 120 * i, self.width, 120);
        
        [self.arrCellView addObject:cellView];
        [self.contentView addSubview:cellView];
    }
    
}

- (void)setState:(NSString *)orderState {
    self.labelState.text = orderState;
}

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

    // Configure the view for the selected state
}

@end
