|
|
@@ -9,18 +9,33 @@
|
|
|
#import "HJMyIntegralExchangePayViewController.h"
|
|
|
#import "HJMyIntegralExchangePayHeaderView.h"
|
|
|
#import "HJMyIntegralExchangePayTypeView.h"
|
|
|
+#import "HJMyIntegralGetOrderAPI.h"
|
|
|
+#import "HJMyIntegralWechatPayAPI.h"
|
|
|
+#import "HJMyIntegralAlipayPayAPI.h"
|
|
|
#import "WechatPay.h"
|
|
|
#import "AlipayPay.h"
|
|
|
|
|
|
-@interface HJMyIntegralExchangePayViewController ()<FBScrollLayoutViewDelegate,UIGestureRecognizerDelegate>
|
|
|
+@interface HJMyIntegralExchangePayViewController ()
|
|
|
+<
|
|
|
+FBScrollLayoutViewDelegate,
|
|
|
+UIGestureRecognizerDelegate,
|
|
|
+FBAPIManagerDelegate,
|
|
|
+FBAPIManagerInterceptor
|
|
|
+>
|
|
|
|
|
|
@property (nonatomic, strong) FBScrollLayoutView *scrollLayoutView;
|
|
|
@property (nonatomic, strong) HJMyIntegralExchangePayHeaderView *headerView;
|
|
|
@property (nonatomic, strong) HJMyIntegralExchangePayTypeView *walletPayView;
|
|
|
@property (nonatomic, strong) HJMyIntegralExchangePayTypeView *WeChatPayView;
|
|
|
@property (nonatomic, strong) HJMyIntegralExchangePayTypeView *AliPayView;
|
|
|
+
|
|
|
@property (nonatomic, strong) UIButton *makeSureBtn;
|
|
|
|
|
|
+@property (nonatomic, strong) HJMyIntegralGetOrderAPI *getOrderAPI;
|
|
|
+@property (nonatomic, strong) HJMyIntegralWechatPayAPI *WechatPayAPI;
|
|
|
+@property (nonatomic, strong) HJMyIntegralAlipayPayAPI *AlipayPayAPI;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@end
|
|
|
|
|
|
@@ -46,6 +61,68 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+#pragma mark - FBAPIManagerInterceptor
|
|
|
+
|
|
|
+- (BOOL)manager:(FBBaseAPIManager *)manager shouldStartCallAPIWithParams:(NSDictionary *)params {
|
|
|
+
|
|
|
+ [self.view fb_showLoading];
|
|
|
+ return YES;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)managerShouldFinishCallAPI:(FBBaseAPIManager *)manager {
|
|
|
+
|
|
|
+ [self.view fb_dismiss];
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark - FBAPIManagerDelegate
|
|
|
+
|
|
|
+- (void)managerCallAPIDidSuccess:(FBBaseAPIManager *)manager {
|
|
|
+
|
|
|
+ if (manager == self.getOrderAPI)
|
|
|
+ {
|
|
|
+ id orderData = [manager fetchDataWithBox:nil];
|
|
|
+ if (self.WeChatPayView.selectBtn.selected)
|
|
|
+ {
|
|
|
+ self.WechatPayAPI.orderId = orderData[@"data"][@"mpMemberOrder"][@"id"];
|
|
|
+ [self.WechatPayAPI start];
|
|
|
+ }
|
|
|
+ if (self.AliPayView.selectBtn.selected)
|
|
|
+ {
|
|
|
+ self.AlipayPayAPI.orderId = orderData[@"data"][@"mpMemberOrder"][@"id"];
|
|
|
+ [self.AlipayPayAPI start];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (manager == self.WechatPayAPI)
|
|
|
+ {
|
|
|
+ id WechatPayData = [manager fetchDataWithBox:nil];
|
|
|
+ NSLog(@"%@",WechatPayData);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (manager == self.AlipayPayAPI)
|
|
|
+ {
|
|
|
+ id AlipayPayData = [manager fetchDataWithBox:nil];
|
|
|
+ [self AlipayPay:AlipayPayData[@"data"][@"resultStr"]];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)managerCallAPIDidFailed:(FBBaseAPIManager *)manager {
|
|
|
+
|
|
|
+ FBAPIManagerErrorType type = manager.errorType;
|
|
|
+
|
|
|
+ if (type == FBAPIManagerErrorTypeNoContent)
|
|
|
+ {
|
|
|
+ id fetchData = [manager fetchDataWithBox:nil];
|
|
|
+
|
|
|
+ if ([fetchData isKindOfClass:[NSDictionary class]])
|
|
|
+ {
|
|
|
+ [self.view fb_showFailureWithStatus:fetchData[@"errmsg"]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ [self.view fb_showFailureWithStatus:manager.errorMessage];
|
|
|
+ }
|
|
|
+}
|
|
|
#pragma mark - FBScrollLayoutViewDelegate
|
|
|
|
|
|
- (void)scrollLayoutViewMakeConstraints:(FBScrollLayoutView *)scrollLayoutView {
|
|
|
@@ -94,6 +171,7 @@
|
|
|
}
|
|
|
|
|
|
#pragma mark - setter and getter
|
|
|
+
|
|
|
- (void)backButtonClick:(UIButton *)btn {
|
|
|
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
|
@@ -124,20 +202,80 @@
|
|
|
|
|
|
if (self.WeChatPayView.selectBtn.selected)
|
|
|
{
|
|
|
- [[WechatPay shareWeChatPay] weixinPayOrderDict:@{} andPayResult:^(PayReultType reslutType) {
|
|
|
-
|
|
|
-
|
|
|
- }];
|
|
|
-
|
|
|
+ self.getOrderAPI.pay_type = @"0";
|
|
|
+ [self.getOrderAPI start];
|
|
|
}
|
|
|
else if (self.AliPayView.selectBtn.selected)
|
|
|
{
|
|
|
- [[AlipayPay shareAliPay] aliProductInfo:@"xjixsijjijijxsijisaija" andPayResult:^(PayReultType reslutType) {
|
|
|
-
|
|
|
- }];
|
|
|
+ self.getOrderAPI.pay_type = @"1";
|
|
|
+
|
|
|
+ [self.getOrderAPI start];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#pragma mark - private metnod
|
|
|
+/* 微信支付 */
|
|
|
+- (void)WechatPay:(NSDictionary *)dict{
|
|
|
+
|
|
|
+ [[WechatPay shareWeChatPay] weixinPayOrderDict:@{} andPayResult:^(PayReultType reslutType) {
|
|
|
+
|
|
|
+ switch (reslutType)
|
|
|
+ {
|
|
|
+ case Pay_result_type_failed:
|
|
|
+ {
|
|
|
+ NSLog(@"失败");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Pay_result_type_cancel:
|
|
|
+ {
|
|
|
+ NSLog(@"取消");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Pay_result_type_succeed:
|
|
|
+ {
|
|
|
+ NSLog(@"成功");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+/* 支付宝支付 */
|
|
|
+- (void)AlipayPay:(NSString *)alipay {
|
|
|
+
|
|
|
+ NSLog(@"alipay::::1%@",alipay);
|
|
|
+ [[AlipayPay shareAliPay] aliProductInfo:alipay andPayResult:^(PayReultType reslutType) {
|
|
|
+
|
|
|
+ }];
|
|
|
+ [AlipayPay shareAliPay].resultBlock = ^(PayReultType reslutType) {
|
|
|
+
|
|
|
+ switch (reslutType)
|
|
|
+ {
|
|
|
+ case Pay_result_type_failed:
|
|
|
+ {
|
|
|
+ NSLog(@"失败");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Pay_result_type_cancel:
|
|
|
+ {
|
|
|
+ NSLog(@"取消");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Pay_result_type_succeed:
|
|
|
+ {
|
|
|
+ NSLog(@"成功");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - setter and getter
|
|
|
|
|
|
- (FBScrollLayoutView *)scrollLayoutView {
|
|
|
@@ -218,6 +356,37 @@
|
|
|
}
|
|
|
return _makeSureBtn;
|
|
|
}
|
|
|
+
|
|
|
+- (HJMyIntegralGetOrderAPI *)getOrderAPI {
|
|
|
+
|
|
|
+ if (_getOrderAPI == nil)
|
|
|
+ {
|
|
|
+ _getOrderAPI = [[HJMyIntegralGetOrderAPI alloc]init];
|
|
|
+ _getOrderAPI.APIManagerDelegate = self;
|
|
|
+ _getOrderAPI.APIManagerInterceptor = self;
|
|
|
+ }
|
|
|
+ return _getOrderAPI;
|
|
|
+}
|
|
|
+- (HJMyIntegralWechatPayAPI *)WechatPayAPI {
|
|
|
+
|
|
|
+ if (_WechatPayAPI == nil)
|
|
|
+ {
|
|
|
+ _WechatPayAPI = [[HJMyIntegralWechatPayAPI alloc]init];
|
|
|
+ _WechatPayAPI.APIManagerDelegate = self;
|
|
|
+ _WechatPayAPI.APIManagerInterceptor = self;
|
|
|
+ }
|
|
|
+ return _WechatPayAPI;
|
|
|
+}
|
|
|
+- (HJMyIntegralAlipayPayAPI *)AlipayPayAPI {
|
|
|
+
|
|
|
+ if (_AlipayPayAPI == nil)
|
|
|
+ {
|
|
|
+ _AlipayPayAPI = [[HJMyIntegralAlipayPayAPI alloc]init];
|
|
|
+ _AlipayPayAPI.APIManagerDelegate = self;
|
|
|
+ _AlipayPayAPI.APIManagerInterceptor = self;
|
|
|
+ }
|
|
|
+ return _AlipayPayAPI;
|
|
|
+}
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|