// // ASCheckoutPointApplyCell.m // Asteria // // Created by xingyu on 2024/5/8. // #import "ASCheckoutPointApplyCell.h" @implementation ASCheckoutPointData @end @interface ASCheckoutPointApplyCell () @property (nonatomic, strong) UIView *bgView; @property (nonatomic, strong) UILabel *titleLab; @property (nonatomic, strong) TT_CustonTF *codeTF; @property (nonatomic, strong) UIButton *applyBtn; @property (nonatomic, strong) QMUILabel *pointDesLab; @end @implementation ASCheckoutPointApplyCell - (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]; 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.pointDesLab]; [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.right.mas_equalTo(-100); }]; [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(KScreenWidth-20-95); }]; [self.applyBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.top.bottom.equalTo(applyTmpV); make.width.mas_equalTo(self.applyBtn.mj_w); }]; [self.pointDesLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(20); make.width.mas_equalTo(KScreenWidth-60); 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 points count" duration:2 position:CSToastPositionCenter]; return; } if(btn.selected == NO){ self.pointCellData.usePoint = self.codeTF.text; if(self.currencyparameterClose){ self.currencyparameterClose(0,self.pointCellData); } }else{ self.pointCellData.usePoint = @""; if(self.currencyparameterClose){ self.currencyparameterClose(1, self.pointCellData); } } } - (void)configData:(id)Data{ ASCheckoutPointData *model = (ASCheckoutPointData *)Data; self.pointCellData = model; if([model.usePoint integerValue] > 0){ self.codeTF.text = MM_str(model.usePoint); self.applyBtn.selected = YES; }else{ self.codeTF.text = @""; self.applyBtn.selected = NO; } NSString *pointStr = [NSString stringWithFormat:@"You have %@ Reward Points available.", model.pointBalance]; NSString *pointLastStr = [NSString stringWithFormat:@"%@ point = %@%@. Input points value below to redeem.", model.pointScale, model.priceSymbol, model.priceScale]; NSMutableAttributedString *couponStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@", pointStr, pointLastStr]]; // couponStr.color = [UIColor colorWithHexString:@"#B2B2B2"]; // couponStr.font = [UIFont fontWithName:Rob_Regular size:12]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setLineSpacing:8];//设置距离 [couponStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [pointStr length])]; self.pointDesLab.attributedText = couponStr; } #pragma mark - **************** lazy **************** -(UIView *)bgView{ if(!_bgView){ _bgView = [[UIView alloc]init]; _bgView.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"]; _bgView.layer.cornerRadius = 4; _bgView.clipsToBounds = YES; } return _bgView; } -(UILabel *)titleLab{ if(!_titleLab){ _titleLab = [[UILabel alloc]init]; _titleLab.text = @"Redeem Your Reward Points"; _titleLab.textColor = [UIColor colorWithHexString:@"#000000"]; _titleLab.adjustsFontSizeToFitWidth = YES; _titleLab.font = [UIFont fontWithName:Rob_Bold size:16]; } return _titleLab; } -(TT_CustonTF *)codeTF{ if(!_codeTF){ _codeTF = [[TT_CustonTF alloc] init]; _codeTF.keyboardType = UIKeyboardTypeNumberPad; _codeTF.placeholder = @"Enter Your Reward Points"; _codeTF.font = [UIFont fontWithName:Rob_Regular size:14]; } return _codeTF; } -(UIButton *)applyBtn{ if(!_applyBtn){ _applyBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _applyBtn.frame = CGRectMake(0, 0, 95, 45); [_applyBtn setTitle:@"APPLY" forState:UIControlStateNormal]; [self.applyBtn setTitle:@"CANCEL" forState:UIControlStateSelected]; _applyBtn.backgroundColor = [UIColor colorWithHexString:@"#0B0B0B"]; [_applyBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal]; [_applyBtn addTarget:self action:@selector(handle_ApplyEvent:) forControlEvents:UIControlEventTouchUpInside]; _applyBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16]; _applyBtn.layer.cornerRadius = 4; } return _applyBtn; } -(QMUILabel *)pointDesLab{ if(!_pointDesLab){ _pointDesLab = [[QMUILabel alloc]init]; _pointDesLab.numberOfLines = 0; _pointDesLab.font = [UIFont fontWithName:Rob_Regular size:12]; _pointDesLab.textColor = [UIColor colorWithHexString:@"#B2B2B2"]; _pointDesLab.preferredMaxLayoutWidth =KScreenWidth-40; } return _pointDesLab; } @end