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