// // MyCartCouponCell.m // Asteria // // Created by 王猛 on 2024/2/1. // #import "MyCartCouponCell.h" @implementation MyCartCouponCellData @end @interface MyCartCouponCell () @property (nonatomic, strong) UIView *bgView; @property (nonatomic, strong) UILabel *titleLab; @property (nonatomic, strong) UILabel *priceLab; @property (nonatomic, strong) TT_CustonTF *codeTF; @property (nonatomic, strong) UIButton *applyBtn; @property (nonatomic, strong) QMUILabel *couponDesLab; @end @implementation MyCartCouponCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (void)setupSubviewS{ //height 200 self.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"]; [self.contentView addSubview:self.bgView]; [self.bgView addSubview:self.titleLab]; [self.bgView addSubview:self.priceLab]; UIView *applyTmpV = [[UIView alloc]init]; applyTmpV.layer.borderColor = [UIColor colorWithHexString:@"#0B0B0B"].CGColor; applyTmpV.layer.cornerRadius = 4; applyTmpV.layer.borderWidth = 1; applyTmpV.clipsToBounds = YES; [self.bgView addSubview:applyTmpV]; [applyTmpV addSubview:self.codeTF]; [applyTmpV addSubview:self.applyBtn]; [self.bgView addSubview:self.couponDesLab]; [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.mas_equalTo(10); make.right.mas_equalTo(-10); make.bottom.mas_equalTo(0); }]; [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.mas_equalTo(20); make.height.mas_equalTo(20); make.width.mas_equalTo(150); }]; [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.titleLab.mas_right).offset(20); make.right.mas_equalTo(-10); make.top.mas_equalTo(20); make.height.mas_equalTo(20); }]; [applyTmpV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.titleLab.mas_bottom).offset(20); make.left.mas_equalTo(10); make.right.mas_equalTo(-10); make.height.mas_equalTo(45); }]; [self.codeTF mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.bottom.equalTo(applyTmpV); make.width.mas_equalTo(self.codeTF.mj_w); }]; [self.applyBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.top.bottom.equalTo(applyTmpV); make.width.mas_equalTo(self.applyBtn.mj_w); }]; [self.couponDesLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.width.mas_equalTo(KScreenWidth-40); make.top.equalTo(applyTmpV.mas_bottom).offset(10); make.bottom.mas_equalTo(-20); }]; } #pragma mark - **************** handle_ApplyEvent **************** -(void)handle_ApplyEvent:(UIButton *)btn{ if( self.codeTF.text.length == 0){ [[Current_normalTool topViewController].view makeToast:@"Please fill in the coupon code first" duration:2 position:CSToastPositionCenter]; return; } if(btn.selected == NO){ self.cellData.coupon_code = self.codeTF.text; if(self.currencyparameterClose){ self.currencyparameterClose(0,self.cellData); } }else{ self.cellData.coupon_code = @""; if(self.currencyparameterClose){ self.currencyparameterClose(1, self.cellData); } } } - (void)configData:(id)Data{ MyCartCouponCellData *model = (MyCartCouponCellData *)Data; self.cellData = model; NSString *disountStr = @""; if([model.discount_amount floatValue] <0.00){ CGFloat temF =fabsf([model.discount_amount floatValue]); disountStr = [NSString stringWithFormat:@"-%@%.2f",model.currency_symbol,temF]; } self.priceLab.text = disountStr; if(![model.coupon_code isEmpty] && model.coupon_code.length>0){ self.codeTF.text = MM_str(model.coupon_code); self.applyBtn.selected = YES; }else{ self.codeTF.text = @""; self.applyBtn.selected = NO; } NSMutableAttributedString *couponStr = [[NSMutableAttributedString alloc]init]; for (int i=0; i