123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- //
- // KDPLiveLeftTableViewCell.m
- // KuDianProject
- //
- // Created by admin on 2019/7/9.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPLiveLeftTableViewCell.h"
- #import "KDPLiveListModel.h"
- @implementation KDPLiveLeftTableViewCell
- {
- UILabel *_timeLabel;
- UIButton *_checkOrderBtn;
- UIImageView *_iconImageView;
- UILabel *_goodCountLabel;
- UILabel *_goodDetailLabel;
- UILabel *_orderLabel;
- UILabel *_orderDetailLabel;
- UILabel *_investLabel;
- UILabel *_investDetailLabel;
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- [self setContentView];
- [self setContentViewConstraints];
- }
- return self;
- }
- - (void)setContentView{
- self.contentView.backgroundColor = [UIColor whiteColor];
- _timeLabel = [[UILabel alloc] init];
- _timeLabel.font = FONT_SYS(12);
- _timeLabel.textColor = [UIColor colorWithHex:0x333333];
- _timeLabel.text = @"直播时间:2019-07-03 20:00:00";
- [self.contentView addSubview:_timeLabel];
-
- _checkOrderBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_checkOrderBtn setTitle:@"查看订单>" forState:UIControlStateNormal];
- [_checkOrderBtn setTitleColor:[UIColor colorWithHex:0xFF235F] forState:UIControlStateNormal];
- _checkOrderBtn.titleLabel.font = FONT_SYS(12);
- [_checkOrderBtn addTarget:self action:@selector(checkOrderAction:) forControlEvents:UIControlEventTouchUpInside];
- _checkOrderBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- _checkOrderBtn.showsTouchWhenHighlighted = NO;
- [self.contentView addSubview:_checkOrderBtn];
-
- _iconImageView = [[UIImageView alloc] init];
- [self.contentView addSubview:_iconImageView];
-
- _goodCountLabel = [[UILabel alloc] init];
- _goodCountLabel.textColor = [UIColor colorWithHex:0x333333];
- _goodCountLabel.font = FONT_SYS(20);
- _goodCountLabel.text = @"100";
- _goodCountLabel.textAlignment = NSTextAlignmentCenter;
- [self.contentView addSubview:_goodCountLabel];
-
- _goodDetailLabel = [[UILabel alloc] init];
- _goodDetailLabel.textColor = [UIColor colorWithHex:0x666666];
- _goodDetailLabel.font = FONT_SYS(12);
- _goodDetailLabel.textAlignment = NSTextAlignmentCenter;
- _goodDetailLabel.text = @"上架商品数";
- [self.contentView addSubview:_goodDetailLabel];
-
- _orderLabel = [[UILabel alloc] init];
- _orderLabel.textColor = [UIColor colorWithHex:0x333333];
- _orderLabel.font = FONT_SYS(20);
- _orderLabel.text = @"100";
- _orderLabel.textAlignment = NSTextAlignmentCenter;
- [self.contentView addSubview:_orderLabel];
-
- _orderDetailLabel = [[UILabel alloc] init];
- _orderDetailLabel.textColor = [UIColor colorWithHex:0x666666];
- _orderDetailLabel.font = FONT_SYS(12);
- _orderDetailLabel.textAlignment = NSTextAlignmentCenter;
- _orderDetailLabel.text = @"订单数";
- [self.contentView addSubview:_orderDetailLabel];
-
- _investLabel = [[UILabel alloc] init];
- _investLabel.textColor = [UIColor colorWithHex:0x333333];
- _investLabel.font = FONT_SYS(20);
- _investLabel.text = @"100";
- _investLabel.textAlignment = NSTextAlignmentCenter;
- [self.contentView addSubview:_investLabel];
-
- _investDetailLabel = [[UILabel alloc] init];
- _investDetailLabel.textColor = [UIColor colorWithHex:0x666666];
- _investDetailLabel.font = FONT_SYS(12);
- _investDetailLabel.textAlignment = NSTextAlignmentCenter;
- _investDetailLabel.text = @"预估收益";
- [self.contentView addSubview:_investDetailLabel];
-
- }
- - (void)setContentViewConstraints{
- self.backgroundColor = [UIColor clearColor];
- [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(UIEdgeInsetsMake(0, 10, 6, 10));
- }];
- self.contentView.layer.cornerRadius = 6;
- self.contentView.layer.masksToBounds = YES;
- [_checkOrderBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView.mas_top).offset(7);
- make.size.equalTo(CGSizeMake(70, 17));
- make.right.equalTo(self.contentView.mas_right).offset(-9);
- }];
- [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView.mas_left).offset(8);
- make.centerY.equalTo(self->_checkOrderBtn);
- make.right.equalTo(self->_checkOrderBtn.mas_left).offset(-10);
- }];
- [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self->_timeLabel.mas_left);
- make.top.equalTo(self->_checkOrderBtn.mas_bottom).offset(18);
- make.size.equalTo(CGSizeMake(80, 80));
- }];
- [_goodCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self->_iconImageView.mas_right);
- make.top.equalTo(self->_iconImageView.mas_top).offset(15);
- make.width.equalTo(self->_orderLabel.mas_width);
- }];
- [_goodDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self->_goodCountLabel);
- make.top.equalTo(self->_goodCountLabel.mas_bottom).offset(6);
- make.width.equalTo(self->_orderDetailLabel);
- }];
-
- [_orderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self->_goodCountLabel.mas_right);
- make.top.equalTo(self->_iconImageView.mas_top).offset(15);
- make.width.equalTo(self->_investLabel.mas_width);
- }];
- [_orderDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self->_goodDetailLabel.mas_right);
- make.top.equalTo(self->_orderLabel.mas_bottom).offset(6);
- make.width.equalTo(self->_investDetailLabel);
- }];
-
- [_investLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self->_orderLabel.mas_right);
- make.top.equalTo(self->_iconImageView.mas_top).offset(15);
- make.width.equalTo(self->_goodCountLabel);
- make.right.equalTo(self.contentView.mas_right);
- }];
- [_investDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self->_orderDetailLabel.mas_right);
- make.top.equalTo(self->_goodCountLabel.mas_bottom).offset(6);
- make.width.equalTo(self->_goodDetailLabel);
- make.right.equalTo(self.contentView.mas_right);
- }];
- [self.contentView layoutIfNeeded];
- // 虚线
- CAShapeLayer *dotteShapeLayer = [CAShapeLayer layer];
- CGMutablePathRef dotteshapePath = CGPathCreateMutable();
- // 设置虚线颜色
- [dotteShapeLayer setStrokeColor:[UIColor colorWithHex:0xC5C5C5].CGColor];
- dotteShapeLayer.lineWidth = 0.3f;
- NSArray *dottehShapeArr = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:4],[NSNumber numberWithInt:4],[NSNumber numberWithInt:4],[NSNumber numberWithInt:4],[NSNumber numberWithInt:4], nil];
- [dotteShapeLayer setLineDashPattern:dottehShapeArr];
- CGPathMoveToPoint(dotteshapePath, NULL, _timeLabel.left,_timeLabel.bottom+5);
- CGPathAddLineToPoint(dotteshapePath, NULL, _checkOrderBtn.right, _timeLabel.bottom+5);
- [dotteShapeLayer setPath:dotteshapePath];
- CGPathRelease(dotteshapePath);
- [self.contentView.layer addSublayer:dotteShapeLayer];
-
- }
- - (void)configWithViewModel:(id)viewModel indexpath:(NSIndexPath *)indexPath{
- KDPLiveListModel *model = (KDPLiveListModel*)viewModel;
- _timeLabel.text = [NSString stringWithFormat:@"直播时间:%@",model.show_time];
- _goodCountLabel.text = model.goods_num;
- _orderLabel.text = model.order_num;
- [_iconImageView sd_setImageWithURL:[NSURL URLWithString:model.show_img]placeholderImage:[UIImage imageNamed:placholderImg]];
- _investLabel.text = model.pre_rebate;
-
- }
- - (void)checkOrderAction:(UIButton *)sender{
- if (self.orderClickBlock) {
- self.orderClickBlock(sender);
- }
- }
- @end
|