yangguanglei 5 years ago
parent
commit
a689172a97

+ 13 - 7
ZhongJingLianMeng.xcodeproj/project.pbxproj

@@ -24,6 +24,7 @@
 		9C21622F219BF1EB00FAFE94 /* PINCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C21621D219BF1EB00FAFE94 /* PINCache.m */; };
 		9C216230219BF1EB00FAFE94 /* PINDiskCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C216220219BF1EB00FAFE94 /* PINDiskCache.m */; };
 		9C216231219BF1EB00FAFE94 /* PINMemoryCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C216222219BF1EB00FAFE94 /* PINMemoryCache.m */; };
+		9C2162FF219C056000FAFE94 /* ThirdPartyManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C2162FE219C056000FAFE94 /* ThirdPartyManager.m */; };
 		CC1CE929219BB579004F8F79 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1CE928219BB579004F8F79 /* AppDelegate.m */; };
 		CC1CE92C219BB579004F8F79 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CC1CE92B219BB579004F8F79 /* ViewController.m */; };
 		CC1CE92F219BB579004F8F79 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CC1CE92D219BB579004F8F79 /* Main.storyboard */; };
@@ -155,6 +156,8 @@
 		9C216251219BF25D00FAFE94 /* ShareSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = ShareSDK.bundle; sourceTree = "<group>"; };
 		9C216252219BF25D00FAFE94 /* ShareSDKConnector.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ShareSDKConnector.framework; sourceTree = "<group>"; };
 		9C216263219BF34300FAFE94 /* AllUrl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllUrl.h; sourceTree = "<group>"; };
+		9C2162FD219C056000FAFE94 /* ThirdPartyManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThirdPartyManager.h; sourceTree = "<group>"; };
+		9C2162FE219C056000FAFE94 /* ThirdPartyManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThirdPartyManager.m; sourceTree = "<group>"; };
 		9C72715F3CD527BAF99561AD /* Pods-ZhongJingLianMeng.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZhongJingLianMeng.release.xcconfig"; path = "Pods/Target Support Files/Pods-ZhongJingLianMeng/Pods-ZhongJingLianMeng.release.xcconfig"; sourceTree = "<group>"; };
 		B49C007A967360A581DE648D /* libPods-ZhongJingLianMeng.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ZhongJingLianMeng.a"; sourceTree = BUILT_PRODUCTS_DIR; };
 		CC1CE924219BB579004F8F79 /* ZhongJingLianMeng.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZhongJingLianMeng.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -341,6 +344,8 @@
 			children = (
 				9C216200219BF1EB00FAFE94 /* DKGlobal.h */,
 				9C216201219BF1EB00FAFE94 /* DKGlobal.m */,
+				9C2162FD219C056000FAFE94 /* ThirdPartyManager.h */,
+				9C2162FE219C056000FAFE94 /* ThirdPartyManager.m */,
 				9C216204219BF1EB00FAFE94 /* tool */,
 				9C216219219BF1EB00FAFE94 /* Vender */,
 			);
@@ -823,7 +828,7 @@
 				TargetAttributes = {
 					CC1CE923219BB579004F8F79 = {
 						CreatedOnToolsVersion = 9.2;
-						ProvisioningStyle = Manual;
+						ProvisioningStyle = Automatic;
 					};
 					CC1CE93B219BB579004F8F79 = {
 						CreatedOnToolsVersion = 9.2;
@@ -954,6 +959,7 @@
 				CC1CE9AA219BE66C004F8F79 /* EasyNavigationButton.m in Sources */,
 				9C216227219BF1EB00FAFE94 /* FileManager.m in Sources */,
 				CC1CE9A0219BE66C004F8F79 /* NSObject+EasyKVO.m in Sources */,
+				9C2162FF219C056000FAFE94 /* ThirdPartyManager.m in Sources */,
 				CC1CE975219BD0F9004F8F79 /* HWTabBarViewController.m in Sources */,
 				CC1CE9A5219BE66C004F8F79 /* EasyNavigationView+LeftButton.m in Sources */,
 				CC1CE9C8219BE7A5004F8F79 /* NSDictionary+Extention.m in Sources */,
@@ -1157,7 +1163,7 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CODE_SIGN_STYLE = Manual;
+				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_TEAM = 8SLCM67D6W;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1190,8 +1196,8 @@
 				);
 				PRODUCT_BUNDLE_IDENTIFIER = com.ZhongJingLianMeng.mobile;
 				PRODUCT_NAME = "$(TARGET_NAME)";
-				PROVISIONING_PROFILE = "c666428d-355a-496f-83c1-f623a7a5142c";
-				PROVISIONING_PROFILE_SPECIFIER = ZHONGJINGLIANMENGProfiles;
+				PROVISIONING_PROFILE = "";
+				PROVISIONING_PROFILE_SPECIFIER = "";
 				TARGETED_DEVICE_FAMILY = 1;
 			};
 			name = Debug;
@@ -1202,7 +1208,7 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CODE_SIGN_STYLE = Manual;
+				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_TEAM = 8SLCM67D6W;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1235,8 +1241,8 @@
 				);
 				PRODUCT_BUNDLE_IDENTIFIER = com.ZhongJingLianMeng.mobile;
 				PRODUCT_NAME = "$(TARGET_NAME)";
-				PROVISIONING_PROFILE = "c666428d-355a-496f-83c1-f623a7a5142c";
-				PROVISIONING_PROFILE_SPECIFIER = ZHONGJINGLIANMENGProfiles;
+				PROVISIONING_PROFILE = "";
+				PROVISIONING_PROFILE_SPECIFIER = "";
 				TARGETED_DEVICE_FAMILY = 1;
 			};
 			name = Release;

BIN
ZhongJingLianMeng.xcworkspace/xcuserdata/vindesel.xcuserdatad/UserInterfaceState.xcuserstate


+ 24 - 0
ZhongJingLianMeng/category/Common/ThirdPartyManager.h

@@ -0,0 +1,24 @@
+//
+//  ThirdPartyManager.h
+//  H+
+//
+//  Created by alex on 2017/12/5.
+//  Copyright © 2017年 vinDesel. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "WXApi.h"
+#import <AlipaySDK/AlipaySDK.h>
+//#import "QYSDK.h"
+
+@interface ThirdPartyManager : NSObject<WXApiDelegate>
+
++ (instancetype)sharedManager;
+
+- (BOOL) WXOpenUrl:(NSURL*)url;
+- (void) AliPayOpenUrl:(NSURL*)url;
+- (void) doWXPay:(NSDictionary*)params;
+- (void) doAliPay:(NSString*)payinfo;
+//- (void) registerQIYUCallback:(void(^)(NSInteger count)) callback;
+- (void)sendWXAuthRequest;
+@end

+ 199 - 0
ZhongJingLianMeng/category/Common/ThirdPartyManager.m

@@ -0,0 +1,199 @@
+//
+//  ThirdPartyManager.m
+//  H+
+//
+//  Created by alex on 2017/12/5.
+//  Copyright © 2017年 vinDesel. All rights reserved.
+//
+
+#import "ThirdPartyManager.h"
+#import "HttpRequestManger.h"
+//#import "OrderPaySuccessNewViewController.h"
+//#import "BindPhoneViewController.h"
+//#import "AuthKit.h"
+
+@interface ThirdPartyManager()
+@property (copy, nonatomic) void(^receiveMessage)(NSInteger count);
+@property (strong, nonatomic) HttpRequestManger *sessionManager;
+@end
+
+@implementation ThirdPartyManager
+- (HttpRequestManger*) sessionManager{
+    if (!_sessionManager) {
+        _sessionManager = [[HttpRequestManger alloc]init];
+    }
+    return _sessionManager;
+}
+
++ (ThirdPartyManager*)sharedManager{
+    static ThirdPartyManager *manager;
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        manager = [[self alloc]init];
+    });
+    return manager;
+}
+
+//- (void) registerQIYUCallback:(void(^)(NSInteger count)) callback{
+//    [[QYSDK sharedSDK].conversationManager setDelegate:self];
+//    self.receiveMessage = callback;
+//}
+
+- (void)sendWXAuthRequest{
+    SendAuthReq *req = [[SendAuthReq alloc] init];
+    req.scope = @"snsapi_userinfo";
+    req.openID = WEIXIN_APPKEY;
+    [WXApi sendAuthReq:req viewController:[DKGlobal sharedInstance].currentViewController delegate:self];
+}
+
+- (void)doWXPay:(NSDictionary*)params {
+    if ([WXApi isWXAppInstalled]) {
+        PayReq *request = [[PayReq alloc] init];
+        request.partnerId = [params objectForKeySafely:@"partnerid"];
+        request.prepayId = [params objectForKeySafely:@"prepayid"];
+        request.package = [params objectForKeySafely:@"package"];
+        request.nonceStr = [params objectForKeySafely:@"noncestr"];
+        request.timeStamp = [[params objectForKeySafely:@"timestamp"] intValue];
+        request.sign = [params objectForKeySafely:@"sign"];
+        [WXApi sendReq:request];
+    }else{
+        [ToastView showToast:@"未安装微信"];
+    }
+}
+
+- (void)doAliPay:(NSString*)payinfo
+{
+    [[AlipaySDK defaultService] payOrder:payinfo fromScheme:alipayScheme callback:^(NSDictionary *resultDic) {
+        NSInteger code = [[resultDic objectForKeySafely:@"resultStatus"] integerValue];
+        if (code == 9000) {
+            [[NSNotificationCenter defaultCenter]postNotificationName:@"OnPaymentSuccessNotification" object:nil];
+        }else{
+            [ToastView showToast:[resultDic objectForKeySafely:@"memo"]];
+        }
+    }];
+}
+- (BOOL) WXOpenUrl:(NSURL*)url
+{
+    return [WXApi handleOpenURL:url delegate:self];
+}
+
+- (void) AliPayOpenUrl:(NSURL*)url{
+    [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
+        NSInteger code = [[resultDic objectForKeySafely:@"resultStatus"] integerValue];
+        if (code == 9000) {
+            [[NSNotificationCenter defaultCenter]postNotificationName:@"OnPaymentSuccessNotification" object:nil];
+        }else{
+            [ToastView showToast:[resultDic objectForKeySafely:@"memo"]];
+            [self postToHouTaiErrorAccount:[DKGlobal sharedInstance].phone PayMethod:@"1" Code:[NSString stringWithFormat:@"%ld",(long)code] Message:[NSString stringWithFormat:@"%@",[resultDic objectForKeySafely:@"result"]]];
+        }
+    }];
+}
+
+- (void)onResp:(BaseResp *)resp {
+    if([resp isKindOfClass:[PayResp class]]){
+        switch (resp.errCode) {
+            case WXSuccess:{
+                [[NSNotificationCenter defaultCenter]postNotificationName:@"OnPaymentSuccessNotification" object:nil];
+                break;
+            }
+            default:{
+                [ToastView showToast:@"微信支付未完成"];
+                [self postToHouTaiErrorAccount:[DKGlobal sharedInstance].phone PayMethod:@"0" Code:[NSString stringWithFormat:@"%d",resp.errCode] Message:resp.errStr];
+                break;
+            }
+        }
+    }
+//    else if ([resp isKindOfClass:[SendAuthResp class]]) {
+//        SendAuthResp *authResp = (SendAuthResp *)resp;
+//        if (authResp.errCode == WXSuccess) {
+//            NSDictionary *paramsForToken = @{@"appid":wxappid,
+//                                             @"secret":wxsecret,
+//                                             @"code":authResp.code?authResp.code:@"",
+//                                             @"grant_type":@"authorization_code"};
+//            [ProgressHUD show];
+//            [[HttpRequestManger sharedManager]sendGetHttpRequestWithUrl:wxaccesstoken params:paramsForToken progress:nil success:^(id response) {
+//                NSString *access_token = [response objectForKeySafely:@"access_token"];
+//                NSString *openid = [response objectForKeySafely:@"openid"];
+//                NSDictionary *paramsForInfo = @{@"access_token":access_token?access_token:@"",
+//                                                @"openid":openid?openid:@""};
+//                [[HttpRequestManger sharedManager]sendGetHttpRequestWithUrl:wxuserinfo params:paramsForInfo progress:nil success:^(id response) {
+//                    NSString *unionid = [response objectForKeySafely:@"unionid"];
+//                    NSString *nickname = [response objectForKeySafely:@"nickname"];
+//                    NSString *headimgurl = [response objectForKeySafely:@"headimgurl"];
+//                    [[HttpRequestManger sharedManager] sendGetHttpRequestWithUrl:user_get_sign params:nil progress:nil success:^(id response) {
+//                        NSString *sign = [response objectForKeySafely:@"data"];
+//                        NSDictionary *paramsForLogin = @{@"unionid":unionid?unionid:@"",
+//                                                         @"sign":sign?sign:@""};
+//                        [[HttpRequestManger sharedManager]sendPostHttpRequestWithUrl:user_wx_login params:paramsForLogin bodyBlock:nil progress:nil success:^(NSDictionary *response) {
+//                            [ProgressHUD hide];
+//                            NSDictionary *data = [response objectForKeySafely:@"data"];
+//                            NSString *token = [data objectForKeySafely:@"token"];
+//                            if (token.length > 0) {
+//                                [[AuthKit sharedInstance] persistAccount:data];
+//                                [[Utility sharedInstance].rootNavController popToRootViewControllerAnimated:YES];
+//                            }else{
+//                                [ToastView showToast:@"授权登录失败"];
+//                            }
+//                        } failure:^(NSError *error) {
+//                            [ProgressHUD hide];
+//                            if (error.code == 1) {
+//                                BindPhoneViewController *controller = [[BindPhoneViewController alloc]initWithNibName:@"BindPhoneViewController" bundle:nil];
+//                                controller.unionId = unionid;
+//                                controller.nickName = nickname;
+//                                controller.avatar = headimgurl;
+//                                controller.hidesBottomBarWhenPushed = YES;
+//                                [[Utility sharedInstance].rootNavController pushViewController:controller animated:YES];
+//                            }else{
+//                                [ToastView showToast:@"授权登录失败"];
+//                            }
+//                        }];
+//                    } failure:^(NSError *error) {
+//                        [ProgressHUD hide];
+//                        [ToastView showToast:@"授权登录失败"];
+//                    }];
+//                } failure:^(NSError *error) {
+//                    [ProgressHUD hide];
+//                    [ToastView showToast:@"授权登录失败"];
+//                }];
+//            } failure:^(NSError *error) {
+//                [ProgressHUD hide];
+//                [ToastView showToast:@"授权登录失败"];
+//            }];
+//        }else{
+//            [ToastView showToast:@"取消授权登录"];
+//        }
+//    }else if([resp isKindOfClass:[SendMessageToWXResp class]]){
+//        if (resp.errCode == WXSuccess) {
+//            [ToastView showToast:@"分享成功"];
+//        }
+//    }
+}
+
+//- (void)onReceiveMessage:(QYMessageInfo *)message{
+//    QYConversationManager *manager = [[QYSDK sharedSDK] conversationManager];
+//    if (self.receiveMessage) {
+//        self.receiveMessage(manager.allUnreadCount);
+//    }
+//}
+- (void)postToHouTaiErrorAccount:(NSString *)account PayMethod:(NSString *)payMethod Code:(NSString *)code Message:(NSString *)msg
+{
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    params[@"account"] = account;
+    params[@"payMethod"] = payMethod;
+    params[@"code"] = code;
+    params[@"msg"] = msg;
+    [self.sessionManager sendPostHttpRequestWithUrl:errorToPost params:params bodyBlock:nil progress:nil success:^(NSDictionary *response) {
+        DebugLog(@"发送错误成功");
+    } failure:^(NSError *error) {
+        DebugLog(@"发送错误失败");
+    }];
+}
+- (void)dealloc {
+    if (_sessionManager) {
+        [_sessionManager cancelAllTask];
+    }
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    DebugLog(@"%@没有造成循环引用", [self class]);
+}
+
+@end