123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- //
- // ASOrderDetailsItemsCell.m
- // Asteria
- //
- // Created by xingyu on 2024/5/16.
- //
- #import "ASOrderDetailsItemsCell.h"
- @interface ASOrderDetailsItemsCell()
- @property (nonatomic, strong) UIImageView *goodsImage;
- @property (nonatomic, strong) UILabel *nameLab;
- @property (nonatomic, strong) UILabel *countLab;
- @property (nonatomic, strong) UILabel *realPriceLab;
- @property (nonatomic, strong) UILabel *optLab;
- @property (nonatomic, strong) UILabel *giftLab;
- @end
- @implementation ASOrderDetailsItemsCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.contentView.backgroundColor = _F8F8F8;
-
- UIView *backView = [[UIView alloc] init];
- backView.backgroundColor = Col_FFF;
- TT_ViewRadius(backView, 3);
- [self.contentView addSubview:backView];
- [backView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.top.mas_equalTo(5);
- make.right.mas_equalTo(-10);
- make.bottom.mas_equalTo(0);
- }];
-
- _goodsImage = [[UIImageView alloc] init];
- _goodsImage.contentMode = UIViewContentModeScaleAspectFill;
- TT_ViewRadius(_goodsImage, 4);
- [backView addSubview:_goodsImage];
- [_goodsImage mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.top.mas_equalTo(20);
- make.width.height.mas_equalTo(86);
- }];
-
- _nameLab = [UILabel labelCreateWithText:@"sdafhasjkfah" font:[UIFont fontWithName:Rob_Regular size:12] textColor:Col_000];
- _nameLab.numberOfLines = 2;
- [backView addSubview:_nameLab];
- [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(20);
- make.right.mas_equalTo(-10);
- make.left.equalTo(_goodsImage.mas_right).offset(10);
- }];
-
- _countLab = [UILabel labelCreateWithText:@"x1" font:[UIFont fontWithName:Rob_Bold size:14] textColor:Col_000];
- [backView addSubview:_countLab];
- [_countLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(_goodsImage.mas_bottom).offset(0);
- make.left.equalTo(_goodsImage.mas_right).offset(10);
- }];
-
- _realPriceLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Bold size:14] textColor:_0B0B0B];
- [backView addSubview:_realPriceLab];
- [_realPriceLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(_countLab);
- make.right.mas_equalTo(-10);
- }];
-
- _optLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
- _optLab.numberOfLines = 0;
- [backView addSubview:_optLab];
- [_optLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(_goodsImage.mas_bottom).offset(18);
- make.bottom.mas_equalTo(-20);
- make.right.mas_equalTo(-10);
- make.left.mas_equalTo(10);
- }];
-
- _giftLab = [UILabel labelCreateWithText:@"Gift" font:[UIFont fontWithName:Rob_Regular size:12] textColor:Col_000];
- _giftLab.textAlignment = NSTextAlignmentCenter;
- _giftLab.backgroundColor = _F0FFF9;
- [backView addSubview:_giftLab];
- [_giftLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.nameLab);
- make.bottom.equalTo(self.goodsImage);
- make.width.equalTo(@64);
- make.height.equalTo(@23);
- }];
- }
- return self;
- }
- - (void)setItemModel:(ASOrderDetailsItemModel *)itemModel {
- _itemModel = itemModel;
-
- NSString *imageAllStr = [NSString stringWithFormat:@"https:%@%@%@",HostPath,ProductImgPath,AS_String_NotNull(_itemModel.image)];
- [self.goodsImage sd_setImageWithURL:[NSURL URLWithString:imageAllStr] placeholderImage:UIImageDefaultImg_SD];
-
- NSString *nameStr = AS_String_NotNull(_itemModel.name);
-
- if([nameStr hasPrefix:@"FREE"]){
- _giftLab.hidden = NO;
- _countLab.hidden = YES;
- _realPriceLab.hidden = YES;
- }else{
- _giftLab.hidden = YES;
- _countLab.hidden = NO;
- _realPriceLab.hidden = NO;
- }
-
- _nameLab.text = AS_String_NotNull(_itemModel.name);
- _countLab.text = [NSString stringWithFormat:@"X%@", AS_String_NotNull(_itemModel.qty_ordered)];
- _realPriceLab.text = [NSString stringWithFormat:@"%@%.2f", AS_String_NotNull(_itemModel.currency_symbol), [AS_String_NotNull(_itemModel.price) floatValue]];
-
-
-
- NSArray *array = [Current_normalTool arrFromjsonStr:_itemModel.sku];
- NSString *optionStr = @"";
- for (int i = 0; i < array.count; i++) {
- NSDictionary *dic = [array objectAtIndex:i];
- optionStr = [NSString stringWithFormat:@"%@%@:%@", optionStr, dic[@"label"], dic[@"value"]];
-
- if (i < array.count - 1) {
- optionStr = [NSString stringWithFormat:@"%@ ", optionStr];
- }
- }
- self.optLab.text = optionStr;
-
- }
- @end
|