酷店

KDPLiveLeftTableViewCell.m 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //
  2. // KDPLiveLeftTableViewCell.m
  3. // KuDianProject
  4. //
  5. // Created by admin on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPLiveLeftTableViewCell.h"
  9. #import "KDPLiveListModel.h"
  10. @implementation KDPLiveLeftTableViewCell
  11. {
  12. UILabel *_timeLabel;
  13. UIButton *_checkOrderBtn;
  14. UIImageView *_iconImageView;
  15. UILabel *_goodCountLabel;
  16. UILabel *_goodDetailLabel;
  17. UILabel *_orderLabel;
  18. UILabel *_orderDetailLabel;
  19. UILabel *_investLabel;
  20. UILabel *_investDetailLabel;
  21. }
  22. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  23. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  24. [self setContentView];
  25. [self setContentViewConstraints];
  26. }
  27. return self;
  28. }
  29. - (void)setContentView{
  30. self.contentView.backgroundColor = [UIColor whiteColor];
  31. _timeLabel = [[UILabel alloc] init];
  32. _timeLabel.font = FONT_SYS(12);
  33. _timeLabel.textColor = [UIColor colorWithHex:0x333333];
  34. _timeLabel.text = @"直播时间:2019-07-03 20:00:00";
  35. [self.contentView addSubview:_timeLabel];
  36. _checkOrderBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  37. [_checkOrderBtn setTitle:@"查看订单>" forState:UIControlStateNormal];
  38. [_checkOrderBtn setTitleColor:[UIColor colorWithHex:0xFF235F] forState:UIControlStateNormal];
  39. _checkOrderBtn.titleLabel.font = FONT_SYS(12);
  40. [_checkOrderBtn addTarget:self action:@selector(checkOrderAction:) forControlEvents:UIControlEventTouchUpInside];
  41. _checkOrderBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  42. _checkOrderBtn.showsTouchWhenHighlighted = NO;
  43. [self.contentView addSubview:_checkOrderBtn];
  44. _iconImageView = [[UIImageView alloc] init];
  45. [self.contentView addSubview:_iconImageView];
  46. _goodCountLabel = [[UILabel alloc] init];
  47. _goodCountLabel.textColor = [UIColor colorWithHex:0x333333];
  48. _goodCountLabel.font = FONT_SYS(20);
  49. _goodCountLabel.text = @"100";
  50. _goodCountLabel.textAlignment = NSTextAlignmentCenter;
  51. [self.contentView addSubview:_goodCountLabel];
  52. _goodDetailLabel = [[UILabel alloc] init];
  53. _goodDetailLabel.textColor = [UIColor colorWithHex:0x666666];
  54. _goodDetailLabel.font = FONT_SYS(12);
  55. _goodDetailLabel.textAlignment = NSTextAlignmentCenter;
  56. _goodDetailLabel.text = @"上架商品数";
  57. [self.contentView addSubview:_goodDetailLabel];
  58. _orderLabel = [[UILabel alloc] init];
  59. _orderLabel.textColor = [UIColor colorWithHex:0x333333];
  60. _orderLabel.font = FONT_SYS(20);
  61. _orderLabel.text = @"100";
  62. _orderLabel.textAlignment = NSTextAlignmentCenter;
  63. [self.contentView addSubview:_orderLabel];
  64. _orderDetailLabel = [[UILabel alloc] init];
  65. _orderDetailLabel.textColor = [UIColor colorWithHex:0x666666];
  66. _orderDetailLabel.font = FONT_SYS(12);
  67. _orderDetailLabel.textAlignment = NSTextAlignmentCenter;
  68. _orderDetailLabel.text = @"订单数";
  69. [self.contentView addSubview:_orderDetailLabel];
  70. _investLabel = [[UILabel alloc] init];
  71. _investLabel.textColor = [UIColor colorWithHex:0x333333];
  72. _investLabel.font = FONT_SYS(20);
  73. _investLabel.text = @"100";
  74. _investLabel.textAlignment = NSTextAlignmentCenter;
  75. [self.contentView addSubview:_investLabel];
  76. _investDetailLabel = [[UILabel alloc] init];
  77. _investDetailLabel.textColor = [UIColor colorWithHex:0x666666];
  78. _investDetailLabel.font = FONT_SYS(12);
  79. _investDetailLabel.textAlignment = NSTextAlignmentCenter;
  80. _investDetailLabel.text = @"预估收益";
  81. [self.contentView addSubview:_investDetailLabel];
  82. }
  83. - (void)setContentViewConstraints{
  84. self.backgroundColor = [UIColor clearColor];
  85. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.edges.equalTo(UIEdgeInsetsMake(0, 10, 6, 10));
  87. }];
  88. self.contentView.layer.cornerRadius = 6;
  89. self.contentView.layer.masksToBounds = YES;
  90. [_checkOrderBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.top.equalTo(self.contentView.mas_top).offset(7);
  92. make.size.equalTo(CGSizeMake(70, 17));
  93. make.right.equalTo(self.contentView.mas_right).offset(-9);
  94. }];
  95. [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.left.equalTo(self.contentView.mas_left).offset(8);
  97. make.centerY.equalTo(self->_checkOrderBtn);
  98. make.right.equalTo(self->_checkOrderBtn.mas_left).offset(-10);
  99. }];
  100. [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.left.equalTo(self->_timeLabel.mas_left);
  102. make.top.equalTo(self->_checkOrderBtn.mas_bottom).offset(18);
  103. make.size.equalTo(CGSizeMake(80, 80));
  104. }];
  105. [_goodCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.equalTo(self->_iconImageView.mas_right);
  107. make.top.equalTo(self->_iconImageView.mas_top).offset(15);
  108. make.width.equalTo(self->_orderLabel.mas_width);
  109. }];
  110. [_goodDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.left.equalTo(self->_goodCountLabel);
  112. make.top.equalTo(self->_goodCountLabel.mas_bottom).offset(6);
  113. make.width.equalTo(self->_orderDetailLabel);
  114. }];
  115. [_orderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.left.equalTo(self->_goodCountLabel.mas_right);
  117. make.top.equalTo(self->_iconImageView.mas_top).offset(15);
  118. make.width.equalTo(self->_investLabel.mas_width);
  119. }];
  120. [_orderDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.equalTo(self->_goodDetailLabel.mas_right);
  122. make.top.equalTo(self->_orderLabel.mas_bottom).offset(6);
  123. make.width.equalTo(self->_investDetailLabel);
  124. }];
  125. [_investLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.left.equalTo(self->_orderLabel.mas_right);
  127. make.top.equalTo(self->_iconImageView.mas_top).offset(15);
  128. make.width.equalTo(self->_goodCountLabel);
  129. make.right.equalTo(self.contentView.mas_right);
  130. }];
  131. [_investDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.left.equalTo(self->_orderDetailLabel.mas_right);
  133. make.top.equalTo(self->_goodCountLabel.mas_bottom).offset(6);
  134. make.width.equalTo(self->_goodDetailLabel);
  135. make.right.equalTo(self.contentView.mas_right);
  136. }];
  137. [self.contentView layoutIfNeeded];
  138. // 虚线
  139. CAShapeLayer *dotteShapeLayer = [CAShapeLayer layer];
  140. CGMutablePathRef dotteshapePath = CGPathCreateMutable();
  141. // 设置虚线颜色
  142. [dotteShapeLayer setStrokeColor:[UIColor colorWithHex:0xC5C5C5].CGColor];
  143. dotteShapeLayer.lineWidth = 0.3f;
  144. NSArray *dottehShapeArr = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:4],[NSNumber numberWithInt:4],[NSNumber numberWithInt:4],[NSNumber numberWithInt:4],[NSNumber numberWithInt:4], nil];
  145. [dotteShapeLayer setLineDashPattern:dottehShapeArr];
  146. CGPathMoveToPoint(dotteshapePath, NULL, _timeLabel.left,_timeLabel.bottom+5);
  147. CGPathAddLineToPoint(dotteshapePath, NULL, _checkOrderBtn.right, _timeLabel.bottom+5);
  148. [dotteShapeLayer setPath:dotteshapePath];
  149. CGPathRelease(dotteshapePath);
  150. [self.contentView.layer addSublayer:dotteShapeLayer];
  151. }
  152. - (void)configWithViewModel:(id)viewModel indexpath:(NSIndexPath *)indexPath{
  153. KDPLiveListModel *model = (KDPLiveListModel*)viewModel;
  154. _timeLabel.text = [NSString stringWithFormat:@"直播时间:%@",model.show_time];
  155. _goodCountLabel.text = model.goods_num;
  156. _orderLabel.text = model.order_num;
  157. [_iconImageView sd_setImageWithURL:[NSURL URLWithString:model.show_img]placeholderImage:[UIImage imageNamed:placholderImg]];
  158. _investLabel.text = model.pre_rebate;
  159. }
  160. - (void)checkOrderAction:(UIButton *)sender{
  161. if (self.orderClickBlock) {
  162. self.orderClickBlock(sender);
  163. }
  164. }
  165. @end