|
@@ -0,0 +1,211 @@
|
|
|
+//
|
|
|
+// ASPayFinishHeadView.m
|
|
|
+// Asteria
|
|
|
+//
|
|
|
+// Created by xingyu on 2024/5/16.
|
|
|
+//
|
|
|
+
|
|
|
+#import "ASPayFinishHeadView.h"
|
|
|
+
|
|
|
+@interface ASPayFinishHeadView()
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIView *topBackView;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIImageView *iconImage;
|
|
|
+@property (nonatomic, strong) UILabel *payStatusLab;
|
|
|
+@property (nonatomic, strong) UILabel *orderNumLab;
|
|
|
+@property (nonatomic, strong) UILabel *descLab;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIButton *topBtn;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIView *bottomBackView;
|
|
|
+
|
|
|
+@property (nonatomic, assign) float viewHeight;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation ASPayFinishHeadView
|
|
|
+
|
|
|
+- (instancetype)initWithFrame:(CGRect)frame status:(int)status desc:(NSString *)desc{
|
|
|
+ if (self = [super initWithFrame:frame]) {
|
|
|
+
|
|
|
+ _topBackView = [[UIView alloc] init];
|
|
|
+ _topBackView.backgroundColor = Col_FFF;
|
|
|
+ TT_ViewRadius(_topBackView, 4);
|
|
|
+ [self addSubview:_topBackView];
|
|
|
+ [_topBackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.top.mas_equalTo(10);
|
|
|
+ make.right.mas_equalTo(-10);
|
|
|
+ }];
|
|
|
+
|
|
|
+ _iconImage = [[UIImageView alloc] init];
|
|
|
+ [_topBackView addSubview:_iconImage];
|
|
|
+ [_iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerX.equalTo(_topBackView);
|
|
|
+ make.top.mas_equalTo(30);
|
|
|
+ make.width.height.mas_equalTo(50);
|
|
|
+ }];
|
|
|
+
|
|
|
+ _payStatusLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Bold size:16] textColor:_0B0B0B];
|
|
|
+ _payStatusLab.textAlignment = NSTextAlignmentCenter;
|
|
|
+ [_topBackView addSubview:_payStatusLab];
|
|
|
+ [_payStatusLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(20);
|
|
|
+ make.right.mas_equalTo(-20);
|
|
|
+ make.top.equalTo(_iconImage.mas_bottom).offset(20);
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (status == 0) {
|
|
|
+ _descLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
|
|
|
+ _descLab.numberOfLines = 0;
|
|
|
+ [_topBackView addSubview:_descLab];
|
|
|
+ [_descLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(20);
|
|
|
+ make.right.mas_equalTo(-20);
|
|
|
+ make.top.mas_equalTo(_payStatusLab.mas_bottom).offset(10);
|
|
|
+ }];
|
|
|
+ } else {
|
|
|
+ _orderNumLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Bold size:12] textColor:_0B0B0B];
|
|
|
+ _orderNumLab.textAlignment = NSTextAlignmentCenter;
|
|
|
+ [_topBackView addSubview:_orderNumLab];
|
|
|
+ [_orderNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(20);
|
|
|
+ make.right.mas_equalTo(-20);
|
|
|
+ make.top.mas_equalTo(_payStatusLab.mas_bottom).offset(10);
|
|
|
+ }];
|
|
|
+
|
|
|
+ _descLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
|
|
|
+ _descLab.numberOfLines = 0;
|
|
|
+ [_topBackView addSubview:_descLab];
|
|
|
+ [_descLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(20);
|
|
|
+ make.right.mas_equalTo(-20);
|
|
|
+ make.top.mas_equalTo(_orderNumLab.mas_bottom).offset(10);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+
|
|
|
+ _topBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ _topBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
|
|
|
+ _topBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
|
|
|
+ [_topBtn setTitleColor:Col_000 forState:UIControlStateNormal];
|
|
|
+ TT_ViewBorderRadius(_topBtn, 0, 1, Col_000);
|
|
|
+ [_topBtn addTarget:self action:@selector(_topClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [_topBackView addSubview:_topBtn];
|
|
|
+ [_topBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.mas_equalTo(_descLab.mas_bottom).offset(10);
|
|
|
+ make.height.mas_equalTo(35);
|
|
|
+ make.width.mas_equalTo(200);
|
|
|
+ make.centerX.equalTo(_topBackView);
|
|
|
+ make.bottom.mas_equalTo(-30);
|
|
|
+ }];
|
|
|
+
|
|
|
+ _bottomBackView = [[UIView alloc] init];
|
|
|
+ _bottomBackView.backgroundColor = _E0FFF5;
|
|
|
+ TT_ViewRadius(_bottomBackView, 4);
|
|
|
+ [self addSubview:_bottomBackView];
|
|
|
+ [_bottomBackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(_topBackView.mas_bottom).offset(20);
|
|
|
+ make.left.mas_equalTo(10);
|
|
|
+ make.right.mas_equalTo(-10);
|
|
|
+ make.height.mas_equalTo(80);
|
|
|
+ }];
|
|
|
+ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_bottomClick)];
|
|
|
+ [_bottomBackView addGestureRecognizer:tap];
|
|
|
+
|
|
|
+ UILabel *faqsLab = [UILabel labelCreateWithText:@"Faqs" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
|
|
|
+ [_bottomBackView addSubview:faqsLab];
|
|
|
+ [faqsLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(10);
|
|
|
+ make.top.mas_equalTo(20);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UILabel *faqsLab1 = [UILabel labelCreateWithText:@"Please contact customer service if need any help" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
|
|
|
+ faqsLab1.adjustsFontSizeToFitWidth = YES;
|
|
|
+ [_bottomBackView addSubview:faqsLab1];
|
|
|
+ [faqsLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(10);
|
|
|
+ make.right.mas_equalTo(-30);
|
|
|
+ make.top.mas_equalTo(faqsLab.mas_bottom).offset(10);
|
|
|
+ }];
|
|
|
+
|
|
|
+ UIImageView *arrowRightImgV = [[UIImageView alloc] init];
|
|
|
+ arrowRightImgV.image = [UIImage imageNamed:@"productList_more_right"];
|
|
|
+ [_bottomBackView addSubview:arrowRightImgV];
|
|
|
+ [arrowRightImgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.right.mas_equalTo(-10);
|
|
|
+ make.centerY.equalTo(_bottomBackView);
|
|
|
+ make.width.height.mas_equalTo(14);
|
|
|
+ }];
|
|
|
+
|
|
|
+ float bottomHeight = 20;
|
|
|
+ if (status == 0) {
|
|
|
+ bottomHeight = 85;
|
|
|
+
|
|
|
+ UIButton *contactBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ contactBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
|
|
|
+ [contactBtn setTitle:@"Contact Us" forState:UIControlStateNormal];
|
|
|
+ contactBtn.backgroundColor = Col_000;
|
|
|
+ [contactBtn addTarget:self action:@selector(_contactBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ TT_ViewRadius(contactBtn, 4);
|
|
|
+ [contactBtn setTitleColor:Col_FFF forState:UIControlStateNormal];
|
|
|
+ [self addSubview:contactBtn];
|
|
|
+ [contactBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.mas_equalTo(_bottomBackView.mas_bottom).offset(20);
|
|
|
+ make.height.mas_equalTo(45);
|
|
|
+ make.left.mas_equalTo(10);
|
|
|
+ make.right.mas_equalTo(-10);
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ _iconImage.image = [UIImage imageNamed:@"pay_failed_icon"];
|
|
|
+ _payStatusLab.text = @"Payment Failed.";
|
|
|
+ _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).";
|
|
|
+ [_topBtn setTitle:@"Edit the payment information" forState:UIControlStateNormal];
|
|
|
+
|
|
|
+ [_topBtn mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.mas_equalTo(260);
|
|
|
+ }];
|
|
|
+
|
|
|
+ } else {
|
|
|
+ _iconImage.image = [UIImage imageNamed:@"pay_success_icon"];
|
|
|
+ _payStatusLab.text = @"Your Order Has Been Received";
|
|
|
+ _orderNumLab.text = @"Order #123";
|
|
|
+ _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).";
|
|
|
+ [_topBtn setTitle:@"Continue Shopping" forState:UIControlStateNormal];
|
|
|
+ }
|
|
|
+
|
|
|
+ [self layoutIfNeeded];
|
|
|
+ [_bottomBackView layoutIfNeeded];
|
|
|
+
|
|
|
+ self.viewHeight = CGRectGetMaxY(_bottomBackView.frame) + bottomHeight;
|
|
|
+
|
|
|
+ }
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (float)getViewHeight {
|
|
|
+ return self.viewHeight;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)_topClick {
|
|
|
+ if (self.clickBlock) {
|
|
|
+ self.clickBlock(1);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)_bottomClick {
|
|
|
+ if (self.clickBlock) {
|
|
|
+ self.clickBlock(2);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)_contactBtnClick {
|
|
|
+ if (self.clickBlock) {
|
|
|
+ self.clickBlock(3);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@end
|