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

#import "CommodityListCollectionViewCell.h"
#import "NSDate+FormatterAdditions.h"
#import "addCommodityRequestModel.h"
#import "MBLabelWithFontAdapter.h"
@interface CommodityListCollectionViewCell ()
@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *labelTitle;
@property (weak, nonatomic) IBOutlet UILabel *labelPrice;
@property (weak, nonatomic) IBOutlet UILabel *labelOriginalPrice;
@property (nonatomic, strong) CommotityListModel *model;
@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *labelBrokerageRate; //佣金
@property (weak, nonatomic) IBOutlet UILabel *labelSalesVolume; //销量


@end

@implementation CommodityListCollectionViewCell

- (void)cellWithModel:(CommotityListModel *)model {
    self.labelPrice.text = [NSString stringWithFormat:@"%.0f",model.price];
    [self.imageViewTop sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:kPlaceHolderImage];
    self.labelOriginalPrice.text = [NSString stringWithFormat:@"￥%.0f", model.originalPrice];
    self.labelBrokerageRate.text = [NSString stringWithFormat:@"￥%.2f", model.commission];
    self.labelSalesVolume.text = [NSString stringWithFormat:@"销量：%.0f", model.salesVolume];

    self.labelTitle.text = model.name;
    self.model = model;
}


- (IBAction)shareAction:(id)sender {
    UserInfo *userInfo = [UserInfo shareInstance];
    WS(weakSelf)
    [userInfo checkGoodIsAddedWithGoodUuid:self.model.uuid result:^(BOOL isAdded) {
        if (isAdded) {
            [[ShareInstance shareInstace] shareGoodsWithGoodsModel:self.model image:self.imageViewTop.image];
        }else{
            [MBProgressHUD Javen_showError:@"请先添加到店铺！" onView:weakSelf.window delay:0.7 complete:nil];
        }
    }];
}


- (void)awakeFromNib {
    // Initialization code
}

@end
