ASPayFinishHeadView.m 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. //
  2. // ASPayFinishHeadView.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/16.
  6. //
  7. #import "ASPayFinishHeadView.h"
  8. @interface ASPayFinishHeadView()
  9. @property (nonatomic, strong) UIView *topBackView;
  10. @property (nonatomic, strong) UIImageView *iconImage;
  11. @property (nonatomic, strong) UILabel *payStatusLab;
  12. @property (nonatomic, strong) UILabel *orderNumLab;
  13. @property (nonatomic, strong) UILabel *descLab;
  14. @property (nonatomic, strong) UIButton *topBtn;
  15. @property (nonatomic, strong) UIView *bottomBackView;
  16. @property (nonatomic, assign) float viewHeight;
  17. @end
  18. @implementation ASPayFinishHeadView
  19. - (instancetype)initWithFrame:(CGRect)frame status:(int)status desc:(NSString *)desc{
  20. if (self = [super initWithFrame:frame]) {
  21. _topBackView = [[UIView alloc] init];
  22. _topBackView.backgroundColor = Col_FFF;
  23. TT_ViewRadius(_topBackView, 4);
  24. [self addSubview:_topBackView];
  25. [_topBackView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.left.top.mas_equalTo(10);
  27. make.right.mas_equalTo(-10);
  28. }];
  29. _iconImage = [[UIImageView alloc] init];
  30. [_topBackView addSubview:_iconImage];
  31. [_iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.centerX.equalTo(_topBackView);
  33. make.top.mas_equalTo(30);
  34. make.width.height.mas_equalTo(50);
  35. }];
  36. _payStatusLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Bold size:16] textColor:_0B0B0B];
  37. _payStatusLab.textAlignment = NSTextAlignmentCenter;
  38. [_topBackView addSubview:_payStatusLab];
  39. [_payStatusLab mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.mas_equalTo(20);
  41. make.right.mas_equalTo(-20);
  42. make.top.equalTo(_iconImage.mas_bottom).offset(20);
  43. }];
  44. if (status == 0) {
  45. _descLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
  46. _descLab.numberOfLines = 0;
  47. [_topBackView addSubview:_descLab];
  48. [_descLab mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.mas_equalTo(20);
  50. make.right.mas_equalTo(-20);
  51. make.top.mas_equalTo(_payStatusLab.mas_bottom).offset(10);
  52. }];
  53. } else {
  54. _orderNumLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Bold size:12] textColor:_0B0B0B];
  55. _orderNumLab.textAlignment = NSTextAlignmentCenter;
  56. [_topBackView addSubview:_orderNumLab];
  57. [_orderNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.mas_equalTo(20);
  59. make.right.mas_equalTo(-20);
  60. make.top.mas_equalTo(_payStatusLab.mas_bottom).offset(10);
  61. }];
  62. _descLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
  63. _descLab.numberOfLines = 0;
  64. [_topBackView addSubview:_descLab];
  65. [_descLab mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.mas_equalTo(20);
  67. make.right.mas_equalTo(-20);
  68. make.top.mas_equalTo(_orderNumLab.mas_bottom).offset(10);
  69. }];
  70. }
  71. _topBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  72. _topBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
  73. _topBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
  74. [_topBtn setTitleColor:Col_000 forState:UIControlStateNormal];
  75. TT_ViewBorderRadius(_topBtn, 0, 1, Col_000);
  76. [_topBtn addTarget:self action:@selector(_topClick) forControlEvents:UIControlEventTouchUpInside];
  77. [_topBackView addSubview:_topBtn];
  78. [_topBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.top.mas_equalTo(_descLab.mas_bottom).offset(10);
  80. make.height.mas_equalTo(35);
  81. make.width.mas_equalTo(200);
  82. make.centerX.equalTo(_topBackView);
  83. make.bottom.mas_equalTo(-30);
  84. }];
  85. _bottomBackView = [[UIView alloc] init];
  86. _bottomBackView.backgroundColor = _E0FFF5;
  87. TT_ViewRadius(_bottomBackView, 4);
  88. [self addSubview:_bottomBackView];
  89. [_bottomBackView mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.top.equalTo(_topBackView.mas_bottom).offset(20);
  91. make.left.mas_equalTo(10);
  92. make.right.mas_equalTo(-10);
  93. make.height.mas_equalTo(80);
  94. }];
  95. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_bottomClick)];
  96. [_bottomBackView addGestureRecognizer:tap];
  97. UILabel *faqsLab = [UILabel labelCreateWithText:@"Faqs" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
  98. [_bottomBackView addSubview:faqsLab];
  99. [faqsLab mas_makeConstraints:^(MASConstraintMaker *make) {
  100. make.left.mas_equalTo(10);
  101. make.top.mas_equalTo(20);
  102. }];
  103. UILabel *faqsLab1 = [UILabel labelCreateWithText:@"Please contact customer service if need any help" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
  104. faqsLab1.adjustsFontSizeToFitWidth = YES;
  105. [_bottomBackView addSubview:faqsLab1];
  106. [faqsLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.left.mas_equalTo(10);
  108. make.right.mas_equalTo(-30);
  109. make.top.mas_equalTo(faqsLab.mas_bottom).offset(10);
  110. }];
  111. UIImageView *arrowRightImgV = [[UIImageView alloc] init];
  112. arrowRightImgV.image = [UIImage imageNamed:@"productList_more_right"];
  113. [_bottomBackView addSubview:arrowRightImgV];
  114. [arrowRightImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  115. make.right.mas_equalTo(-10);
  116. make.centerY.equalTo(_bottomBackView);
  117. make.width.height.mas_equalTo(14);
  118. }];
  119. float bottomHeight = 20;
  120. if (status == 0) {
  121. bottomHeight = 85;
  122. UIButton *contactBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  123. contactBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
  124. [contactBtn setTitle:@"Contact Us" forState:UIControlStateNormal];
  125. contactBtn.backgroundColor = Col_000;
  126. [contactBtn addTarget:self action:@selector(_contactBtnClick) forControlEvents:UIControlEventTouchUpInside];
  127. TT_ViewRadius(contactBtn, 4);
  128. [contactBtn setTitleColor:Col_FFF forState:UIControlStateNormal];
  129. [self addSubview:contactBtn];
  130. [contactBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.top.mas_equalTo(_bottomBackView.mas_bottom).offset(20);
  132. make.height.mas_equalTo(45);
  133. make.left.mas_equalTo(10);
  134. make.right.mas_equalTo(-10);
  135. }];
  136. _iconImage.image = [UIImage imageNamed:@"pay_failed_icon"];
  137. _payStatusLab.text = @"Payment Failed.";
  138. _descLab.text = @"Please try another card or refresh browser. Paypal gateway has rejected request. The buyer cannot pay with PayPal for this transaction(#13113: buyer cannot pay).";
  139. [_topBtn setTitle:@"Edit the payment information" forState:UIControlStateNormal];
  140. [_topBtn mas_updateConstraints:^(MASConstraintMaker *make) {
  141. make.width.mas_equalTo(260);
  142. }];
  143. } else {
  144. _iconImage.image = [UIImage imageNamed:@"pay_success_icon"];
  145. _payStatusLab.text = @"Your Order Has Been Received";
  146. _orderNumLab.text = [NSString stringWithFormat:@"Order #%@", desc];
  147. _descLab.text = [NSString stringWithFormat:@"An order confirmation email will be sent to you in about 1 hour at %@ for you to check and respond. Shipment info also will be sent to your email after the order is shipped out. Please ensure to check your spam box in case you cannot find it in your inbox. To ensure delivery, Please add Service@asteriahair.com to your email address book or safe sender list.", ASUserInfoManager.shared.userInfo.email];
  148. [_topBtn setTitle:@"Continue Shopping" forState:UIControlStateNormal];
  149. }
  150. [self layoutIfNeeded];
  151. [_bottomBackView layoutIfNeeded];
  152. self.viewHeight = CGRectGetMaxY(_bottomBackView.frame) + bottomHeight;
  153. }
  154. return self;
  155. }
  156. - (float)getViewHeight {
  157. return self.viewHeight;
  158. }
  159. - (void)_topClick {
  160. if (self.clickBlock) {
  161. self.clickBlock(1);
  162. }
  163. }
  164. - (void)_bottomClick {
  165. if (self.clickBlock) {
  166. self.clickBlock(2);
  167. }
  168. }
  169. - (void)_contactBtnClick {
  170. if (self.clickBlock) {
  171. self.clickBlock(3);
  172. }
  173. }
  174. @end