1
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user