新增恢复购买

This commit is contained in:
2025-12-16 16:25:50 +08:00
parent e8a980ff5b
commit 6800864866
8 changed files with 81 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
@property (nonatomic, strong) NSArray<KBPayProductModel *> *plans; //
@property (nonatomic, assign) NSInteger selectedIndex; //
@property (nonatomic, strong) UIButton *closeButton; //
@property (nonatomic, strong) UIButton *restoreButton;
@property (nonatomic, strong) UIImageView *bgImageView; //
// Header
@property (nonatomic, strong) KBVipPayHeaderView *sizingHeader;
@@ -86,6 +87,13 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
make.left.equalTo(self.view).offset(15);
make.width.height.mas_equalTo(36);
}];
[self.view addSubview:self.restoreButton];
[self.restoreButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.closeButton);
make.right.equalTo(self.view).offset(-15);
make.width.mas_equalTo(123);
make.height.mas_equalTo(32);
}];
// Header
self.headerHeight = [self kb_calcHeaderHeightForWidth:KB_SCREEN_WIDTH];
@@ -217,6 +225,20 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
[KBHUD showInfo:KBLocalized(@"Open agreement")];
}
- (void)onTapRestoreButton {
[KBHUD show];
__weak typeof(self) weakSelf = self;
[[KBStoreKitBridge shared] restorePurchasesWithCompletion:^(BOOL success, NSString * _Nullable message) {
dispatch_async(dispatch_get_main_queue(), ^{
__strong typeof(weakSelf) self = weakSelf;
(void)self;
[KBHUD dismiss];
NSString *tip = message.length ? message : (success ? KBLocalized(@"Success") : KBLocalized(@"Failed"));
[KBHUD showInfo:tip];
});
}];
}
#pragma mark - UICollectionView DataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
@@ -351,6 +373,25 @@ static NSString * const kKBVipReviewListCellId = @"kKBVipReviewListCellId";
return _closeButton;
}
- (UIButton *)restoreButton {
if (!_restoreButton) {
_restoreButton = [UIButton buttonWithType:UIButtonTypeCustom];
_restoreButton.backgroundColor = [[UIColor colorWithHex:0xF6F7FB] colorWithAlphaComponent:0.72];
_restoreButton.layer.cornerRadius = 8;
_restoreButton.layer.masksToBounds = YES;
UIImage *icon = [UIImage imageNamed:@"pay_resh_icon"];
[_restoreButton setImage:icon forState:UIControlStateNormal];
[_restoreButton setTitle:KBLocalized(@"Resume Purchase") forState:UIControlStateNormal];
[_restoreButton setTitleColor:[UIColor colorWithHex:0x02BEAC] forState:UIControlStateNormal];
_restoreButton.titleLabel.font = [KBFont medium:10];
_restoreButton.contentEdgeInsets = UIEdgeInsetsMake(0, 12, 0, 12);
_restoreButton.imageEdgeInsets = UIEdgeInsetsMake(0, -4, 0, 4);
_restoreButton.titleEdgeInsets = UIEdgeInsetsMake(0, 6, 0, -6);
[_restoreButton addTarget:self action:@selector(onTapRestoreButton) forControlEvents:UIControlEventTouchUpInside];
}
return _restoreButton;
}
- (UIButton *)payButton {
if (!_payButton) {
_payButton = [UIButton buttonWithType:UIButtonTypeCustom];