This commit is contained in:
2025-11-14 16:34:01 +08:00
parent eacac8425c
commit 66a1ddef66
16 changed files with 262 additions and 55 deletions

View File

@@ -4,7 +4,7 @@
#import "KBJfPay.h"
#import "KBJfPayCell.h"
#import "FGIAPProductsFilter.h"
static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
@interface KBJfPay () <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@@ -34,12 +34,15 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
@property (nonatomic, strong) NSArray<NSDictionary *> *data; // @{coins, price}
@property (nonatomic, assign) NSInteger selectedIndex; //
@property (nonatomic, strong) FGIAPProductsFilter *filter;
@end
@implementation KBJfPay
- (void)viewDidLoad {
[super viewDidLoad];
self.filter = [[FGIAPProductsFilter alloc] init];
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_bg_icon"]];
self.bgImageView.contentMode = UIViewContentModeScaleAspectFill;
self.kb_navView.backgroundColor = [UIColor clearColor];
@@ -51,12 +54,12 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
//
self.data = @[
@{ @"coins": @690, @"price": @"$6.90" },
@{ @"coins": @1280, @"price": @"$12.90" },
@{ @"coins": @3290, @"price": @"$32.90" },
@{ @"coins": @4990, @"price": @"$49.90" },
@{ @"coins": @9990, @"price": @"$99.90" },
@{ @"coins": @19990,@"price": @"$199.90" },
@{ @"coins": @690, @"price": @"$6.90",@"product_id" : @"100_coin" },
@{ @"coins": @1280, @"price": @"$12.90" ,@"product_id" : @"vip_a_week" },
@{ @"coins": @3290, @"price": @"$32.90" ,@"product_id" : @"100_coin" },
@{ @"coins": @4990, @"price": @"$49.90" ,@"product_id" : @"100_coin" },
@{ @"coins": @9990, @"price": @"$99.90" ,@"product_id" : @"100_coin" },
@{ @"coins": @19990,@"price": @"$199.90" ,@"product_id" : @"100_coin" },
];
self.selectedIndex = 1; //
@@ -234,11 +237,20 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
#pragma mark - Actions
- (void)onTapPayButton {
// UI
if (self.selectedIndex >= 0 && self.selectedIndex < self.data.count) {
NSDictionary *item = self.data[self.selectedIndex];
NSString *msg = [NSString stringWithFormat:@"购买:%@ Coins %@", item[@"coins"], item[@"price"]];
[KBHUD showInfo:msg];
}
// if (self.selectedIndex >= 0 && self.selectedIndex < self.data.count) {
// NSDictionary *item = self.data[self.selectedIndex];
// NSString *msg = [NSString stringWithFormat:@"购买:%@ Coins %@", item[@"coins"], item[@"price"]];
// [KBHUD showInfo:msg];
// }
NSString *productId = @"com.yolo.vip.1month";
/// 2.
[self.filter requestProductsWith:[NSSet setWithObject:productId] completion:^(NSArray<SKProduct *> * _Nonnull products) {
NSLog(@"=====");
/// 3.
// [[FGIAPManager shared].iap buyProduct:products.firstObject onCompletion:^(NSString * _Nonnull message, FGIAPManagerPurchaseRusult result) {
// [self.view makeToast:message];
// }];
}];
}
- (void)agreementButtonAction{