酷店

KDPOrderDetailTableViewCell.m 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // KDPOrderDetailTableViewCell.m
  3. // KuDianProject
  4. //
  5. // Created by admin on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPOrderDetailTableViewCell.h"
  9. #import "KDPLiveDetailModel.h"
  10. @interface KDPOrderDetailTableViewCell ()
  11. @property (nonatomic, strong) UILabel *timeLabel;
  12. @property (nonatomic, strong) UIImageView *iconImageView;
  13. @property (nonatomic, strong) UILabel *goodTitleLabel;
  14. @property (nonatomic, strong) UILabel *createTimeLabel;
  15. @property (nonatomic, strong) UILabel *endTimeLabel;
  16. @property (nonatomic, strong) UILabel *payMonny;
  17. @property (nonatomic, strong) UILabel *commMonny; // 佣金
  18. @property (nonatomic, strong) CAShapeLayer *dotteShapeLayer;
  19. @end
  20. @implementation KDPOrderDetailTableViewCell
  21. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  22. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  23. [self setContentView];
  24. [self setContentViewConstraints];
  25. }
  26. return self;
  27. }
  28. - (void)setContentView{
  29. self.contentView.backgroundColor = [UIColor whiteColor];
  30. self.contentView.layer.cornerRadius = 6;
  31. self.contentView.layer.masksToBounds = YES;
  32. self.iconImageView = [[UIImageView alloc] init];
  33. self.iconImageView.layer.cornerRadius = 8;
  34. self.iconImageView.layer.masksToBounds = YES;
  35. [self.contentView addSubview:self.iconImageView];
  36. self.timeLabel = [[UILabel alloc] init];
  37. self.timeLabel.textColor = [UIColor colorWithHex:0x333333];
  38. self.timeLabel.font = FONT_SYS(12);
  39. [self.contentView addSubview:self.timeLabel];
  40. self.goodTitleLabel = [[UILabel alloc] init];
  41. self.goodTitleLabel.textColor = [UIColor colorWithHex:0x333333];
  42. self.goodTitleLabel.font = FONT_SYS(15);
  43. [self.contentView addSubview:self.goodTitleLabel];
  44. self.createTimeLabel = [[UILabel alloc] init];
  45. self.createTimeLabel.textColor = [UIColor colorWithHex:0x999999];
  46. self.createTimeLabel.font = FONT_SYS(12);
  47. [self.contentView addSubview:self.createTimeLabel];
  48. self.endTimeLabel = [[UILabel alloc] init];
  49. self.endTimeLabel.textColor = [UIColor colorWithHex:0x999999];
  50. self.endTimeLabel.font = FONT_SYS(12);
  51. [self.contentView addSubview:self.endTimeLabel];
  52. self.payMonny = [[UILabel alloc] init];
  53. self.payMonny.textColor = [UIColor colorWithHex:0x666666];
  54. self.payMonny.font = FONT_SYS(12);
  55. [self.contentView addSubview:self.payMonny];
  56. self.commMonny = [[UILabel alloc] init];
  57. [self.contentView addSubview:self.commMonny];
  58. }
  59. - (void)setContentViewConstraints{
  60. self.backgroundColor = [UIColor clearColor];
  61. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.edges.equalTo(UIEdgeInsetsMake(0, 10, 6, 10));
  63. }];
  64. [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.equalTo(self.contentView.mas_left).offset(8);
  66. make.top.equalTo(self.contentView.mas_top).offset(7);
  67. make.size.equalTo(CGSizeMake(SCREEN_WIDTH-30, 17));
  68. }];
  69. [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.left.equalTo(self.contentView.mas_left).offset(8);
  71. make.bottom.equalTo(self.contentView.mas_bottom).offset(-8);
  72. make.size.equalTo(CGSizeMake(80, 80));
  73. }];
  74. [self.goodTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.left.equalTo(self.iconImageView.mas_right).offset(6);
  76. make.top.equalTo(self.iconImageView.mas_top).offset(5);
  77. make.right.equalTo(self.contentView.mas_right).offset(-10);
  78. }];
  79. [self.createTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.left.equalTo(self.goodTitleLabel);
  81. make.top.equalTo(self.goodTitleLabel.mas_bottom).offset(9);
  82. make.width.equalTo(130);
  83. }];
  84. [self.endTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.left.equalTo(self.createTimeLabel.mas_right).offset(10);
  86. make.right.equalTo(self.contentView.mas_right).offset(-10);
  87. make.top.equalTo(self.createTimeLabel);
  88. }];
  89. [self.payMonny mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.left.equalTo(self.goodTitleLabel);
  91. make.top.equalTo(self.createTimeLabel.mas_bottom).offset(10);
  92. make.width.equalTo(self.createTimeLabel);
  93. }];
  94. [self.commMonny mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.left.right.equalTo(self.endTimeLabel);
  96. make.top.equalTo(self.payMonny);
  97. }];
  98. // 虚线
  99. self.dotteShapeLayer = [CAShapeLayer layer];
  100. CGMutablePathRef dotteshapePath = CGPathCreateMutable();
  101. // 设置虚线颜色
  102. [self.dotteShapeLayer setStrokeColor:[UIColor colorWithHex:0xC5C5C5].CGColor];
  103. self.dotteShapeLayer.lineWidth = 0.3f;
  104. NSArray *dottehShapeArr = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:4],[NSNumber numberWithInt:4],[NSNumber numberWithInt:4],[NSNumber numberWithInt:4],[NSNumber numberWithInt:4], nil];
  105. [self.dotteShapeLayer setLineDashPattern:dottehShapeArr];
  106. CGPathMoveToPoint(dotteshapePath, NULL, 8,29);
  107. CGPathAddLineToPoint(dotteshapePath, NULL, self.contentView.width-7, 29);
  108. [self.dotteShapeLayer setPath:dotteshapePath];
  109. CGPathRelease(dotteshapePath);
  110. [self.contentView.layer addSublayer:self.dotteShapeLayer];
  111. }
  112. - (void)configWithViewModel:(id)viewModel indexpath:(NSIndexPath *)indexPath{
  113. KDPLiveDetailModel *detailModel = (KDPLiveDetailModel *)viewModel;
  114. [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:detailModel.img]placeholderImage:[UIImage imageNamed:placholderImg]];
  115. self.goodTitleLabel.text = detailModel.name;
  116. self.createTimeLabel.text = [NSString stringWithFormat:@"创建日:%@",detailModel.order_create_at];
  117. self.endTimeLabel.text = [NSString stringWithFormat:@"结算日:%@",detailModel.order_balance_at];
  118. self.payMonny.text = [NSString stringWithFormat:@"付款金额:¥%@",detailModel.money];
  119. NSString *string = [NSString stringWithFormat:@"结算佣金:¥%@",detailModel.rebate];
  120. NSMutableAttributedString *commAtt = [[NSMutableAttributedString alloc] initWithString:string attributes:@{NSForegroundColorAttributeName:[UIColor baseColor],NSFontAttributeName:FONT_SYS(12)}];
  121. [commAtt addAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x666666]} range:[string rangeOfString:@"结算佣金:"]];
  122. [self.commMonny setAttributedText:commAtt];
  123. self.timeLabel.text = self.liveTime;
  124. if (indexPath.row == 0) {
  125. self.timeLabel.hidden = NO;
  126. } else{
  127. self.timeLabel.hidden = YES;
  128. }
  129. if (indexPath.row == 0) {
  130. self.dotteShapeLayer.hidden = NO;
  131. } else{
  132. self.dotteShapeLayer.hidden = YES;
  133. }
  134. }
  135. @end