ASCheckoutPointApplyCell.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. //
  2. // ASCheckoutPointApplyCell.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/8.
  6. //
  7. #import "ASCheckoutPointApplyCell.h"
  8. @implementation ASCheckoutPointData
  9. @end
  10. @interface ASCheckoutPointApplyCell ()
  11. @property (nonatomic, strong) UIView *bgView;
  12. @property (nonatomic, strong) UILabel *titleLab;
  13. @property (nonatomic, strong) TT_CustonTF *codeTF;
  14. @property (nonatomic, strong) UIButton *applyBtn;
  15. @property (nonatomic, strong) QMUILabel *pointDesLab;
  16. @end
  17. @implementation ASCheckoutPointApplyCell
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. // Initialization code
  21. }
  22. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  23. [super setSelected:selected animated:animated];
  24. // Configure the view for the selected state
  25. }
  26. - (void)setupSubviewS{ //height 200
  27. self.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  28. [self.contentView addSubview:self.bgView];
  29. [self.bgView addSubview:self.titleLab];
  30. UIView *applyTmpV = [[UIView alloc]init];
  31. applyTmpV.layer.borderColor = [UIColor colorWithHexString:@"#0B0B0B"].CGColor;
  32. applyTmpV.layer.cornerRadius = 4;
  33. applyTmpV.layer.borderWidth = 1;
  34. applyTmpV.clipsToBounds = YES;
  35. [self.bgView addSubview:applyTmpV];
  36. [applyTmpV addSubview:self.codeTF];
  37. [applyTmpV addSubview:self.applyBtn];
  38. [self.bgView addSubview:self.pointDesLab];
  39. [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.top.mas_equalTo(10);
  41. make.right.mas_equalTo(-10);
  42. make.bottom.mas_equalTo(0);
  43. }];
  44. [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.mas_equalTo(10);
  46. make.top.mas_equalTo(20);
  47. make.height.mas_equalTo(20);
  48. make.right.mas_equalTo(-100);
  49. }];
  50. [applyTmpV mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.equalTo(self.titleLab.mas_bottom).offset(20);
  52. make.left.mas_equalTo(10);
  53. make.right.mas_equalTo(-10);
  54. make.height.mas_equalTo(45);
  55. }];
  56. [self.codeTF mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.top.bottom.equalTo(applyTmpV);
  58. make.width.mas_equalTo(KScreenWidth-20-95);
  59. }];
  60. [self.applyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.right.top.bottom.equalTo(applyTmpV);
  62. make.width.mas_equalTo(self.applyBtn.mj_w);
  63. }];
  64. [self.pointDesLab mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.mas_equalTo(20);
  66. make.width.mas_equalTo(KScreenWidth-60);
  67. make.top.equalTo(applyTmpV.mas_bottom).offset(10);
  68. make.bottom.mas_equalTo(-20);
  69. }];
  70. }
  71. #pragma mark - **************** handle_ApplyEvent ****************
  72. -(void)handle_ApplyEvent:(UIButton *)btn{
  73. if( self.codeTF.text.length == 0){
  74. [[Current_normalTool topViewController].view makeToast:@"Please fill in the points count" duration:2 position:CSToastPositionCenter];
  75. return;
  76. }
  77. if(btn.selected == NO){
  78. self.pointCellData.usePoint = self.codeTF.text;
  79. if(self.currencyparameterClose){
  80. self.currencyparameterClose(0,self.pointCellData);
  81. }
  82. }else{
  83. self.pointCellData.usePoint = @"";
  84. if(self.currencyparameterClose){
  85. self.currencyparameterClose(1, self.pointCellData);
  86. }
  87. }
  88. }
  89. - (void)configData:(id)Data{
  90. ASCheckoutPointData *model = (ASCheckoutPointData *)Data;
  91. self.pointCellData = model;
  92. if([model.usePoint integerValue] > 0){
  93. self.codeTF.text = MM_str(model.usePoint);
  94. self.applyBtn.selected = YES;
  95. }else{
  96. self.codeTF.text = @"";
  97. self.applyBtn.selected = NO;
  98. }
  99. NSString *pointStr = [NSString stringWithFormat:@"You have %@ Reward Points available.", model.pointBalance];
  100. NSString *pointLastStr = [NSString stringWithFormat:@"%@ point = %@%@. Input points value below to redeem.", model.pointScale, model.priceSymbol, model.priceScale];
  101. NSMutableAttributedString *couponStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@", pointStr, pointLastStr]];
  102. // couponStr.color = [UIColor colorWithHexString:@"#B2B2B2"];
  103. // couponStr.font = [UIFont fontWithName:Rob_Regular size:12];
  104. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  105. [paragraphStyle setLineSpacing:8];//设置距离
  106. [couponStr addAttribute:NSParagraphStyleAttributeName
  107. value:paragraphStyle
  108. range:NSMakeRange(0, [pointStr length])];
  109. self.pointDesLab.attributedText = couponStr;
  110. }
  111. #pragma mark - **************** lazy ****************
  112. -(UIView *)bgView{
  113. if(!_bgView){
  114. _bgView = [[UIView alloc]init];
  115. _bgView.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
  116. _bgView.layer.cornerRadius = 4;
  117. _bgView.clipsToBounds = YES;
  118. }
  119. return _bgView;
  120. }
  121. -(UILabel *)titleLab{
  122. if(!_titleLab){
  123. _titleLab = [[UILabel alloc]init];
  124. _titleLab.text = @"Redeem Your Reward Points";
  125. _titleLab.textColor = [UIColor colorWithHexString:@"#000000"];
  126. _titleLab.adjustsFontSizeToFitWidth = YES;
  127. _titleLab.font = [UIFont fontWithName:Rob_Bold size:16];
  128. }
  129. return _titleLab;
  130. }
  131. -(TT_CustonTF *)codeTF{
  132. if(!_codeTF){
  133. _codeTF = [[TT_CustonTF alloc] init];
  134. _codeTF.keyboardType = UIKeyboardTypeNumberPad;
  135. _codeTF.placeholder = @"Enter Your Reward Points";
  136. _codeTF.font = [UIFont fontWithName:Rob_Regular size:14];
  137. }
  138. return _codeTF;
  139. }
  140. -(UIButton *)applyBtn{
  141. if(!_applyBtn){
  142. _applyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  143. _applyBtn.frame = CGRectMake(0, 0, 95, 45);
  144. [_applyBtn setTitle:@"APPLY" forState:UIControlStateNormal];
  145. [self.applyBtn setTitle:@"CANCEL" forState:UIControlStateSelected];
  146. _applyBtn.backgroundColor = [UIColor colorWithHexString:@"#0B0B0B"];
  147. [_applyBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
  148. [_applyBtn addTarget:self action:@selector(handle_ApplyEvent:) forControlEvents:UIControlEventTouchUpInside];
  149. _applyBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
  150. _applyBtn.layer.cornerRadius = 4;
  151. }
  152. return _applyBtn;
  153. }
  154. -(QMUILabel *)pointDesLab{
  155. if(!_pointDesLab){
  156. _pointDesLab = [[QMUILabel alloc]init];
  157. _pointDesLab.numberOfLines = 0;
  158. _pointDesLab.font = [UIFont fontWithName:Rob_Regular size:12];
  159. _pointDesLab.textColor = [UIColor colorWithHexString:@"#B2B2B2"];
  160. _pointDesLab.preferredMaxLayoutWidth =KScreenWidth-40;
  161. }
  162. return _pointDesLab;
  163. }
  164. @end