//
//  OrderTableViewCell.m
//  ALand
//
//  Created by Z on 16/3/30.
//  Copyright © 2016年 Z. All rights reserved.
//

#import "OrderTableViewCell.h"
#import "OrderCellView.h"
#import "JavenConsumer.h"
#import "JavenCreateInfo.h"
@interface OrderTableViewCell ()
@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 OrderTableViewCell

- (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];
    self.labelBuyer.text = model.address.telephone;
    self.labelDate.text = [(JavenCreateInfo *)model.createInfo time];
    
}

- (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
