ASOrderDetailsItemsCell.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // ASOrderDetailsItemsCell.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/16.
  6. //
  7. #import "ASOrderDetailsItemsCell.h"
  8. @interface ASOrderDetailsItemsCell()
  9. @property (nonatomic, strong) UIImageView *goodsImage;
  10. @property (nonatomic, strong) UILabel *nameLab;
  11. @property (nonatomic, strong) UILabel *countLab;
  12. @property (nonatomic, strong) UILabel *realPriceLab;
  13. @property (nonatomic, strong) UILabel *priceLab;
  14. @property (nonatomic, strong) UILabel *optLab;
  15. @end
  16. @implementation ASOrderDetailsItemsCell
  17. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  18. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  19. self.selectionStyle = UITableViewCellSelectionStyleNone;
  20. self.contentView.backgroundColor = _F8F8F8;
  21. UIView *backView = [[UIView alloc] init];
  22. backView.backgroundColor = Col_FFF;
  23. TT_ViewRadius(backView, 3);
  24. [self.contentView addSubview:backView];
  25. [backView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.left.mas_equalTo(10);
  27. make.top.mas_equalTo(5);
  28. make.right.mas_equalTo(-10);
  29. make.bottom.mas_equalTo(0);
  30. }];
  31. _goodsImage = [[UIImageView alloc] init];
  32. _goodsImage.contentMode = UIViewContentModeScaleAspectFill;
  33. TT_ViewRadius(_goodsImage, 4);
  34. [backView addSubview:_goodsImage];
  35. [_goodsImage mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.mas_equalTo(10);
  37. make.top.mas_equalTo(20);
  38. make.width.height.mas_equalTo(86);
  39. }];
  40. _nameLab = [UILabel labelCreateWithText:@"sdafhasjkfah" font:[UIFont fontWithName:Rob_Regular size:12] textColor:Col_000];
  41. _nameLab.numberOfLines = 2;
  42. [backView addSubview:_nameLab];
  43. [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.top.mas_equalTo(20);
  45. make.right.mas_equalTo(-10);
  46. make.left.equalTo(_goodsImage.mas_right).offset(10);
  47. }];
  48. _countLab = [UILabel labelCreateWithText:@"x1" font:[UIFont fontWithName:Rob_Bold size:14] textColor:Col_000];
  49. [backView addSubview:_countLab];
  50. [_countLab mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.bottom.mas_equalTo(_goodsImage.mas_bottom).offset(0);
  52. make.left.equalTo(_goodsImage.mas_right).offset(10);
  53. }];
  54. _priceLab = [UILabel labelCreateWithText:@"123" font:[UIFont fontWithName:Rob_Regular size:12] textColor:[UIColor colorWithHexString:@"#8c8c8c"]];
  55. [backView addSubview:_priceLab];
  56. [_priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.centerY.mas_equalTo(_countLab);
  58. make.right.mas_equalTo(-10);
  59. }];
  60. _realPriceLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Bold size:14] textColor:_0B0B0B];
  61. [backView addSubview:_realPriceLab];
  62. [_realPriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.centerY.mas_equalTo(_countLab);
  64. make.right.mas_equalTo(_priceLab.mas_left).offset(-6);
  65. }];
  66. _optLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
  67. _optLab.numberOfLines = 0;
  68. [backView addSubview:_optLab];
  69. [_optLab mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.top.mas_equalTo(_goodsImage.mas_bottom).offset(18);
  71. make.bottom.mas_equalTo(-20);
  72. make.right.mas_equalTo(-10);
  73. make.left.mas_equalTo(10);
  74. }];
  75. }
  76. return self;
  77. }
  78. - (void)setItemModel:(ASOrderDetailsItemModel *)itemModel {
  79. _itemModel = itemModel;
  80. NSString *imageAllStr = [NSString stringWithFormat:@"https:%@%@%@",HostPath,ProductImgPath,AS_String_NotNull(_itemModel.image)];
  81. [self.goodsImage sd_setImageWithURL:[NSURL URLWithString:imageAllStr] placeholderImage:UIImageDefaultImg_SD];
  82. _nameLab.text = AS_String_NotNull(_itemModel.name);
  83. _countLab.text = [NSString stringWithFormat:@"X%@", AS_String_NotNull(_itemModel.qty_ordered)];
  84. _realPriceLab.text = [NSString stringWithFormat:@"%@%@", AS_String_NotNull(_itemModel.currency_symbol), AS_String_NotNull(_itemModel.price)];
  85. NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",AS_String_NotNull(_itemModel.currency_symbol), AS_String_NotNull(_itemModel.original_price)]];
  86. [priceAtr addAttribute:NSStrikethroughStyleAttributeName
  87. value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
  88. range:NSMakeRange(0, priceAtr.length)];
  89. _priceLab.attributedText = priceAtr;
  90. NSArray *array = [Current_normalTool arrFromjsonStr:_itemModel.sku];
  91. NSString *optionStr = @"";
  92. for (int i = 0; i < array.count; i++) {
  93. NSDictionary *dic = [array objectAtIndex:i];
  94. optionStr = [NSString stringWithFormat:@"%@%@:%@", optionStr, dic[@"label"], dic[@"value"]];
  95. if (i < array.count - 1) {
  96. optionStr = [NSString stringWithFormat:@"%@ ", optionStr];
  97. }
  98. }
  99. self.optLab.text = optionStr;
  100. }
  101. @end