ASCheckoutBottomView.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // ASCheckoutBottomView.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/10.
  6. //
  7. #import "ASCheckoutBottomView.h"
  8. @interface ASCheckoutBottomView()
  9. @property (nonatomic, strong) UILabel *titleLab;
  10. @property (nonatomic, strong) UIImageView *titleImageView;
  11. @end
  12. @implementation ASCheckoutBottomView
  13. - (instancetype)initWithFrame:(CGRect)frame {
  14. if (self = [super initWithFrame:frame]) {
  15. self.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  16. [self addSubview:self.backView];
  17. [self.backView addSubview:self.titleLab];
  18. [self.backView addSubview:self.titleImageView];
  19. [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
  20. make.left.mas_equalTo(10);
  21. make.right.mas_equalTo(-10);
  22. make.top.mas_equalTo(15);
  23. make.height.mas_equalTo(45);
  24. }];
  25. [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.center.equalTo(self.backView);
  27. }];
  28. [self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.center.equalTo(self.backView);
  30. make.width.mas_equalTo(103);
  31. make.height.mas_equalTo(38);
  32. }];
  33. self.backView.userInteractionEnabled = YES;
  34. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_payClickAction)];
  35. [self.backView addGestureRecognizer:tap];
  36. }
  37. return self;
  38. }
  39. - (void)setBottomPayStyle:(NSString *)payCode {
  40. if ([payCode isEqualToString:@"paypal_express"]) {//paypal
  41. self.titleImageView.hidden = NO;
  42. self.titleLab.hidden = YES;
  43. self.titleImageView.image = [UIImage imageNamed:@"checkout_pay_paypal"];
  44. self.backView.backgroundColor = [UIColor colorWithHexString:@"#FFC43A"];
  45. }
  46. // else if ([payCode isEqualToString:@"stripe_payments"]) {//visa
  47. //
  48. // } else if ([payCode isEqualToString:@"afterpay_payment"]) {//afterpay
  49. //
  50. // } else if ([payCode isEqualToString:@"klarna_kco"]) {//klarna
  51. //
  52. // }
  53. else {
  54. self.titleImageView.hidden = YES;
  55. self.titleLab.hidden = NO;
  56. self.titleLab.text = @"pay securely now";
  57. self.backView.backgroundColor = [UIColor colorWithHexString:@"#B2000F"];
  58. }
  59. }
  60. - (void)_payClickAction {
  61. if (self.bottomBlock) {
  62. self.bottomBlock();
  63. }
  64. }
  65. - (UIView *)backView {
  66. if (!_backView) {
  67. _backView = [[UIView alloc] init];
  68. TT_ViewRadius(_backView, 4);
  69. }
  70. return _backView;
  71. }
  72. -(UILabel *)titleLab{
  73. if(!_titleLab){
  74. _titleLab = [UILabel labelCreateWithText:@"pay securely now" font:[UIFont fontWithName:Rob_Regular size:16] textColor:Col_FFF];
  75. _titleLab.adjustsFontSizeToFitWidth = YES;
  76. }
  77. return _titleLab;
  78. }
  79. - (UIImageView *)titleImageView{
  80. if(!_titleImageView){
  81. _titleImageView = [[UIImageView alloc] init];
  82. _titleImageView.contentMode = UIViewContentModeScaleAspectFit;
  83. }
  84. return _titleImageView;
  85. }
  86. @end