//
//  KWMGoodsDetailsView.m
//  iCemarose
//
//  Created by 陈荣科 on 16/9/2.
//  Copyright © 2016年 kollway. All rights reserved.
//

#import "KWMGoodsDetailsView.h"
#import "KWMShopCartData.h"

@implementation KWMGoodsDetailsView

- (instancetype)init{
    if (self = [super init]) {
        [self initContentView];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder:aDecoder]) {
        [self initContentView];
    }
    return self;
}
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self initContentView];
    }
    return self;
}

- (void)awakeFromNib{
    [super awakeFromNib];
    [self initContentView];
}

- (void)initContentView{
    [[NSBundle mainBundle] loadNibNamed:@" KWMGoodsDetailsView" owner:self options:nil];
    [self addSubview:_vContent];
    self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    self.lbTitle.text = @"其他";
    _lbCount.text = @"0";
}

- (void)setCount:(NSInteger)count{
    _count = count;
    if (count > 0) {
        _lbCount.text = [NSString stringWithFormat:@"%ld",count];
        if (count > 9) {
            _lbCount.font = [UIFont systemFontOfSize:8];
        }
    }else{
        _lbCount.text = @"0";
    }
}

- (void)showTitleAndHidenShopCart:(BOOL)isShow{
    self.lbTitle.hidden = isShow;
    self.btnShopCart.hidden = !isShow;
}
- (IBAction)onClickShopCartBtn:(id)sender{
    if ([self.delegate respondsToSelector:@selector(kwm_addToShopcart)]) {
        [self.delegate kwm_addToShopcart];
    }
}
- (IBAction)onClickBackBtn:(id)sender{
    
    if ([self.delegate respondsToSelector:@selector(kwm_beBackLastVC)]) {
        [self.delegate kwm_beBackLastVC];
    }
}
@end