123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // ASOrderDetailsPriceCell.m
- // Asteria
- //
- // Created by xingyu on 2024/5/16.
- //
- #import "ASOrderDetailsPriceCell.h"
- @interface ASOrderDetailsPriceCell()
- @property (nonatomic, strong) UIView *backView;
- @end
- @implementation ASOrderDetailsPriceCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
-
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.contentView.backgroundColor = _F8F8F8;
-
- _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(-20);
- }];
-
- }
- return self;
- }
- - (void)setOrderModel:(ASOrderDetailsModel *)orderModel {
- _orderModel = orderModel;
-
- NSMutableArray *listArr = [[NSMutableArray alloc] initWithCapacity:1];
-
- //subtotal
- if (AS_String_valid(_orderModel.subtotal)) {
- NSDictionary *dic = @{@"title":@"Subtotal", @"value":[NSString stringWithFormat:@"%@%.2f", _orderModel.currency_symbol, [_orderModel.subtotal floatValue]]};
- [listArr addObject:dic];
- }
- //优惠券
- if (AS_String_valid(_orderModel.discount_amount) && ![_orderModel.discount_amount isEqualToString:@"0"]) {
-
- float discount_amount = fabsf([_orderModel.discount_amount floatValue]);
-
- NSDictionary *dic = @{@"title":@"Discount", @"value":[NSString stringWithFormat:@"-%@%.2lf", _orderModel.currency_symbol, discount_amount]};
- [listArr addObject:dic];
- }
-
- //地址
- if (AS_String_valid(_orderModel.shipping_tax_amount)) {
- NSDictionary *dic = @{@"title":@"Shipping & Handling", @"value":[NSString stringWithFormat:@"%@%.2f", _orderModel.currency_symbol, [_orderModel.shipping_tax_amount floatValue]]};
- [listArr addObject:dic];
- }
-
- //丢件险
- if (AS_String_valid(_orderModel.amextrafee_fee_amount)) {
- NSDictionary *dic = @{@"title":@"Extra Fee (Insurance For Lost)", @"value":[NSString stringWithFormat:@"%@%.2f", _orderModel.currency_symbol, [_orderModel.amextrafee_fee_amount floatValue]]};
- [listArr addObject:dic];
- }
-
- //积分抵扣
- if (AS_String_valid(_orderModel.mw_rwrdpoints_amnt) && [AS_String_NotNull(_orderModel.mw_rwrdpoints_amnt) floatValue] > 0) {
- NSDictionary *dic = @{@"title":[NSString stringWithFormat:@"Reward Points(%@)", _orderModel.mw_rwrdpoints_amnt], @"value":[NSString stringWithFormat:@"-%@%@", _orderModel.currency_symbol, _orderModel.mw_rwrdpoints_cur_amnt]};
- [listArr addObject:dic];
- }
-
- UILabel *tempLab = nil;
-
- for (int i = 0; i < listArr.count; i++) {
- NSDictionary *dic = listArr[i];
-
- UILabel *rightLab = [UILabel labelCreateWithText:dic[@"value"] font:[UIFont fontWithName:Rob_Regular size:14] textColor:_0B0B0B];
- rightLab.textAlignment = NSTextAlignmentRight;
- [_backView addSubview:rightLab];
- if (i == 0) {
- [rightLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(20);
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(19);
- }];
- } else {
- [rightLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(tempLab.mas_bottom).offset(10);
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(19);
- }];
- }
- tempLab = rightLab;
-
- UILabel *leftLab = [UILabel labelCreateWithText:dic[@"title"] font:[UIFont fontWithName:Rob_Regular size:14] textColor:_0B0B0B];
- [_backView addSubview:leftLab];
- [leftLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(rightLab);;
- make.left.mas_equalTo(10);
- make.right.equalTo(rightLab.mas_left).offset(-6);
- }];
- }
-
- UIView *lineView1 = [[UIView alloc] init];
- lineView1.backgroundColor = _F4F4F4;
- [_backView addSubview:lineView1];
- [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(1);
- make.top.equalTo(tempLab.mas_bottom).offset(20);
- }];
-
-
- UILabel *grandRightLab = [UILabel labelCreateWithText:[NSString stringWithFormat:@"%@%.2f", _orderModel.currency_symbol, [_orderModel.grand_total floatValue]] font:[UIFont fontWithName:Rob_Bold size:24] textColor:Col_000];
- grandRightLab.textAlignment = NSTextAlignmentRight;
- [_backView addSubview:grandRightLab];
- [grandRightLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(lineView1.mas_bottom).offset(15);
- make.right.mas_equalTo(-10);
- make.height.mas_equalTo(30);
- make.bottom.mas_equalTo(-15);
- }];
-
- UILabel *grandLeftLab = [UILabel labelCreateWithText:@"Grand Total" font:[UIFont fontWithName:Rob_Bold size:14] textColor:Col_000];
- [_backView addSubview:grandLeftLab];
- [grandLeftLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(grandRightLab);;
- make.left.mas_equalTo(10);
- make.right.equalTo(grandRightLab.mas_left).offset(-6);
- }];
-
-
- }
- @end
|