123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- //
- // 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) UILabel *priceLab;
- @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 addSubview:self.priceLab];
-
- [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);
- }];
-
- [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.titleLab.mas_right).offset(20);
- make.right.mas_equalTo(-10);
- make.centerY.mas_equalTo(self.titleLab);
- }];
-
- [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(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 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;
- }
-
- if ([model.usePrice floatValue] > 0.00) {
- self.priceLab.text = [NSString stringWithFormat:@"-%@%@", model.priceSymbol, model.usePrice];
- } else {
- self.priceLab.text = @"";
- }
-
-
- 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;
- }
- -(UILabel *)priceLab{
- if(!_priceLab){
- _priceLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Bold size:14] textColor:_0B0B0B];
- _priceLab.textAlignment = NSTextAlignmentRight;
- _priceLab.adjustsFontSizeToFitWidth = YES;
- }
- return _priceLab;
- }
- -(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
|