酷店

KDPLiveRightTableViewCell.m 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. //
  2. // KDPLiveRightTableViewCell.m
  3. // KuDianProject
  4. //
  5. // Created by admin on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPLiveRightTableViewCell.h"
  9. #import "KDPLiveStatisticsModel.h"
  10. #import "KDPBaseLabel.h"
  11. @interface KDPLiveRightTableViewCell ()
  12. @property (nonatomic, strong) UIImageView *iconImageView;
  13. @property (nonatomic, strong) UILabel *titleLabel;
  14. @property (nonatomic, strong) UILabel *priceLabel;
  15. @property (nonatomic, strong) UILabel *priceDetailLabel;
  16. @property (nonatomic, strong) UILabel *profitLabel;
  17. @property (nonatomic, strong) KDPBaseLabel *profitDetailLabel;
  18. @property (nonatomic, strong) UILabel *orderLabel;
  19. @property (nonatomic, strong) UILabel *orderDetailLabel;
  20. @property (nonatomic, strong) UIImageView *profitImageView;
  21. @property (nonatomic, strong) UIView *lineView;
  22. @end
  23. @implementation KDPLiveRightTableViewCell
  24. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  25. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  26. [self setContentView];
  27. [self setContentViewConstraints];
  28. }
  29. return self;
  30. }
  31. - (void)setContentView{
  32. self.contentView.backgroundColor = [UIColor whiteColor];
  33. self.iconImageView = [[UIImageView alloc] init];
  34. self.iconImageView.layer.cornerRadius = 8;
  35. self.iconImageView.layer.masksToBounds = YES;
  36. [self.contentView addSubview:self.iconImageView];
  37. self.titleLabel = [[UILabel alloc] init];
  38. self.titleLabel.font = FONT_SYS(15);
  39. self.titleLabel.textColor = [UIColor colorWithHex:0x333333];
  40. [self.contentView addSubview:self.titleLabel];
  41. self.priceLabel = [[UILabel alloc] init];
  42. self.priceLabel.textColor = [UIColor colorWithHex:0x333333];
  43. self.priceLabel.font = FONT_SYS(18);
  44. self.priceLabel.text = @"0";
  45. self.priceLabel.textAlignment = NSTextAlignmentCenter;
  46. [self.contentView addSubview:self.priceLabel];
  47. self.priceDetailLabel = [[UILabel alloc] init];
  48. self.priceDetailLabel.textColor = [UIColor colorWithHex:0x666666];
  49. self.priceDetailLabel.font = FONT_SYS(12);
  50. self.priceDetailLabel.text = @"价格";
  51. self.priceDetailLabel.textAlignment = NSTextAlignmentCenter;
  52. [self.contentView addSubview:self.priceDetailLabel];
  53. self.profitLabel = [[UILabel alloc] init];
  54. self.profitLabel.textColor = [UIColor colorWithHex:0x333333];
  55. self.profitLabel.font = FONT_SYS(18);
  56. self.profitLabel.text = @"40%";
  57. self.profitLabel.textAlignment = NSTextAlignmentCenter;
  58. [self.contentView addSubview:self.profitLabel];
  59. self.profitDetailLabel = [[KDPBaseLabel alloc] init];
  60. self.profitDetailLabel.textColor = [UIColor colorWithHex:0x666666];
  61. self.profitDetailLabel.font = FONT_SYS(12);
  62. self.profitDetailLabel.text = @"利润";
  63. self.profitDetailLabel.textAlignment = NSTextAlignmentCenter;
  64. self.profitDetailLabel.insets = UIEdgeInsetsMake(0, 0, 0, 10);
  65. [self.contentView addSubview:self.profitDetailLabel];
  66. self.profitImageView = [[UIImageView alloc] init];
  67. [self.profitDetailLabel addSubview:self.profitImageView];
  68. self.orderLabel = [[UILabel alloc] init];
  69. self.orderLabel.textColor = [UIColor colorWithHex:0x333333];
  70. self.orderLabel.font = FONT_SYS(18);
  71. self.orderLabel.text = @"0";
  72. self.orderLabel.textAlignment = NSTextAlignmentCenter;
  73. [self.contentView addSubview:self.orderLabel];
  74. self.orderDetailLabel = [[UILabel alloc] init];
  75. self.orderDetailLabel.textColor = [UIColor colorWithHex:0x666666];
  76. self.orderDetailLabel.font = FONT_SYS(12);
  77. self.orderDetailLabel.text = @"预估订单数";
  78. self.orderDetailLabel.textAlignment = NSTextAlignmentCenter;
  79. [self.contentView addSubview:self.orderDetailLabel];
  80. self.lineView = [[UIView alloc] init];
  81. self.lineView.backgroundColor = [UIColor colorWithHex:0xF5F5F5];
  82. [self.contentView addSubview:self.lineView];
  83. }
  84. - (void)setContentViewConstraints{
  85. [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.left.equalTo(self.contentView.mas_left).offset(10);
  87. make.size.equalTo(CGSizeMake(80, 80));
  88. make.centerY.equalTo(self.contentView);
  89. }];
  90. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.left.equalTo(self.iconImageView.mas_right).offset(12);
  92. make.top.equalTo(self.iconImageView.mas_top);
  93. make.right.equalTo(self.contentView.mas_right).offset(-10);
  94. }];
  95. [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.left.equalTo(self.titleLabel.mas_left);
  97. make.width.equalTo(self.profitLabel);
  98. make.top.equalTo(self.titleLabel.mas_bottom).offset(13);
  99. }];
  100. [self.priceDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.left.equalTo(self.priceLabel);
  102. make.top.equalTo(self.priceLabel.mas_bottom).offset(6);
  103. make.width.equalTo(self.profitDetailLabel);
  104. }];
  105. [self.profitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.equalTo(self.priceLabel.mas_right);
  107. make.width.equalTo(self.orderLabel);
  108. make.top.equalTo(self.titleLabel.mas_bottom).offset(13);
  109. }];
  110. [self.profitDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.left.equalTo(self.priceDetailLabel.mas_right);
  112. make.top.equalTo(self.profitLabel.mas_bottom).offset(6);
  113. make.width.equalTo(self.orderDetailLabel);
  114. }];
  115. [self.orderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.left.equalTo(self.profitLabel.mas_right);
  117. make.width.equalTo(self.profitLabel);
  118. make.right.equalTo(self.contentView.mas_right).offset(-13);
  119. make.top.equalTo(self.titleLabel.mas_bottom).offset(13);
  120. }];
  121. [self.orderDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  122. make.left.equalTo(self.profitDetailLabel.mas_right);
  123. make.top.equalTo(self.orderLabel.mas_bottom).offset(6);
  124. make.right.equalTo(self.contentView.mas_right).offset(-13);
  125. make.width.equalTo(self.priceDetailLabel);
  126. }];
  127. [self.profitImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.size.equalTo(CGSizeMake(15, 15));
  129. make.centerY.equalTo(self.profitDetailLabel);
  130. make.left.equalTo(self.profitDetailLabel.mas_centerX).offset(7);
  131. }];
  132. [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  133. make.left.right.bottom.equalTo(self.contentView);
  134. make.height.equalTo(1);
  135. }];
  136. }
  137. - (void)configWithViewModel:(id)viewModel indexpath:(NSIndexPath *)indexPath{
  138. KDPLiveStatisticsModel *statisModel = (KDPLiveStatisticsModel *)viewModel;
  139. [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:statisModel.img]placeholderImage:[UIImage imageNamed:placholderImg]];
  140. self.titleLabel.text = statisModel.name;
  141. self.priceLabel.text = [NSString stringWithFormat:@"%.2f",[statisModel.money floatValue]];
  142. self.profitLabel.text = [NSString stringWithFormat:@"%@%%",statisModel.commission_rate];
  143. self.orderLabel.text = statisModel.predictCount;
  144. self.profitImageView.hidden = NO;
  145. if ([statisModel.commission_rate_2 integerValue] > [statisModel.commission_rate integerValue]) {
  146. self.profitImageView.image = [UIImage imageNamed:@"up_icon"];
  147. self.profitDetailLabel.insets = UIEdgeInsetsMake(0, 0, 0, 10);
  148. } else if ([statisModel.commission_rate integerValue] == [statisModel.commission_rate_2 integerValue]){
  149. self.profitDetailLabel.insets = UIEdgeInsetsMake(0, 0, 0, 0);
  150. self.profitImageView.hidden = YES;
  151. } else{
  152. self.profitDetailLabel.insets = UIEdgeInsetsMake(0, 0, 0, 10);
  153. self.profitImageView.image = [UIImage imageNamed:@"down_icon"];
  154. }
  155. }
  156. @end