ASCheckoutPointApplyCell.m 7.2 KB

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