diff --git a/Podfile b/Podfile index 39b3990..ae305c5 100644 --- a/Podfile +++ b/Podfile @@ -6,6 +6,7 @@ inhibit_all_warnings! target "demo" do pod 'FinApplet' pod 'FinAppletExt' + pod 'WechatOpenSDK' end diff --git a/demo.xcodeproj/project.pbxproj b/demo.xcodeproj/project.pbxproj index bfb2728..8cb32cf 100644 --- a/demo.xcodeproj/project.pbxproj +++ b/demo.xcodeproj/project.pbxproj @@ -12,6 +12,9 @@ 9DD565C923EC450A0011FC4A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9DD565C823EC450A0011FC4A /* Assets.xcassets */; }; 9DD565CC23EC450A0011FC4A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9DD565CA23EC450A0011FC4A /* LaunchScreen.storyboard */; }; 9DD565CF23EC450A0011FC4A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DD565CE23EC450A0011FC4A /* main.m */; }; + A0E041B926CE6DAD00D58D47 /* demo.plist in Resources */ = {isa = PBXBuildFile; fileRef = A0E041B826CE6DAD00D58D47 /* demo.plist */; }; + A0E041BB26CE6E1F00D58D47 /* finosprite.plist in Resources */ = {isa = PBXBuildFile; fileRef = A0E041BA26CE6E1F00D58D47 /* finosprite.plist */; }; + A0E041BD26CE720900D58D47 /* servers.plist in Resources */ = {isa = PBXBuildFile; fileRef = A0E041BC26CE720900D58D47 /* servers.plist */; }; A823321F258C3B7000C1B2D5 /* FINDemoClientHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A823321D258C3B7000C1B2D5 /* FINDemoClientHelper.m */; }; A863B745257A09A300959AA1 /* FINExtensionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A863B744257A09A300959AA1 /* FINExtensionHelper.m */; }; A8BC097A258BA095001289A3 /* FINCustomMenuModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A8BC0979258BA095001289A3 /* FINCustomMenuModel.m */; }; @@ -30,6 +33,9 @@ 9DD565CB23EC450A0011FC4A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 9DD565CD23EC450A0011FC4A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9DD565CE23EC450A0011FC4A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + A0E041B826CE6DAD00D58D47 /* demo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = demo.plist; sourceTree = ""; }; + A0E041BA26CE6E1F00D58D47 /* finosprite.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = finosprite.plist; sourceTree = ""; }; + A0E041BC26CE720900D58D47 /* servers.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = servers.plist; sourceTree = ""; }; A823321D258C3B7000C1B2D5 /* FINDemoClientHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FINDemoClientHelper.m; sourceTree = ""; }; A823321E258C3B7000C1B2D5 /* FINDemoClientHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FINDemoClientHelper.h; sourceTree = ""; }; A863B743257A09A200959AA1 /* FINExtensionHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FINExtensionHelper.h; sourceTree = ""; }; @@ -86,6 +92,9 @@ 9DD565CA23EC450A0011FC4A /* LaunchScreen.storyboard */, 9DD565CD23EC450A0011FC4A /* Info.plist */, 9DD565CE23EC450A0011FC4A /* main.m */, + A0E041B826CE6DAD00D58D47 /* demo.plist */, + A0E041BA26CE6E1F00D58D47 /* finosprite.plist */, + A0E041BC26CE720900D58D47 /* servers.plist */, ); path = demo; sourceTree = ""; @@ -167,7 +176,10 @@ buildActionMask = 2147483647; files = ( 9DD565CC23EC450A0011FC4A /* LaunchScreen.storyboard in Resources */, + A0E041BB26CE6E1F00D58D47 /* finosprite.plist in Resources */, + A0E041B926CE6DAD00D58D47 /* demo.plist in Resources */, 9DD565C923EC450A0011FC4A /* Assets.xcassets in Resources */, + A0E041BD26CE720900D58D47 /* servers.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -356,26 +368,6 @@ 9DD565D323EC450A0011FC4A /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = FBEBA7E73B95B66C846E76FF /* Pods-demo.debug.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 9QCKYFU5M4; - ENABLE_BITCODE = NO; - INFOPLIST_FILE = demo/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.finogeeks.finclip.demo; - PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 9DD565D423EC450A0011FC4A /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3F2BFD149B6F799A303A07B3 /* Pods-demo.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "Apple Development"; @@ -393,6 +385,28 @@ PROVISIONING_PROFILE_SPECIFIER = ""; TARGETED_DEVICE_FAMILY = "1,2"; }; + name = Debug; + }; + 9DD565D423EC450A0011FC4A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3F2BFD149B6F799A303A07B3 /* Pods-demo.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = 9QCKYFU5M4; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = demo/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.finogeeks.finclip.demo; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = github_demo_adhoc; + TARGETED_DEVICE_FAMILY = "1,2"; + }; name = Release; }; /* End XCBuildConfiguration section */ diff --git a/demo/AppDelegate.m b/demo/AppDelegate.m index dd1aba4..41a0dfc 100644 --- a/demo/AppDelegate.m +++ b/demo/AppDelegate.m @@ -12,6 +12,7 @@ #import "FINDemoClientHelper.h" #import +#import @interface AppDelegate () @@ -23,17 +24,30 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. - NSString *appKey = @"22LyZEib0gLTQdU3MUauATBwgfnTCJjdr7FCnywmAEM="; - FATConfig *config = [FATConfig configWithAppSecret:@"bdfd76cae24d4313" appKey:appKey]; - config.apiServer = @"https://api.finclip.com"; - config.apiPrefix = @"/api/v1/mop"; + // servers.plist维护了不同应用,初始化finclip的参数(因为微信支付需要绑定一个可用的账号) + NSString *bundleId = [NSBundle mainBundle].bundleIdentifier; + NSString *path = [[NSBundle mainBundle] pathForResource:@"servers" ofType:@"plist"]; + NSDictionary *servers = [NSDictionary dictionaryWithContentsOfFile:path]; + NSDictionary *data = servers[bundleId]; + NSString *appKey = data[@"appKey"]; + NSString *appSecret = data[@"appSecret"]; + NSString *apiServer = data[@"apiServer"]; + NSString *apiPrefix = data[@"apiPrefix"]; + FATApiCryptType cryptType = [data[@"cryptType"] isEqualToString:@"MD5"] ? FATApiCryptTypeMD5 : FATApiCryptTypeSM; + FATConfig *config = [FATConfig configWithAppSecret:appSecret appKey:appKey]; + config.apiServer = apiServer; + config.apiPrefix = apiPrefix; + config.cryptType = cryptType; [[FATClient sharedClient] initWithConfig:config error:nil]; [[FATClient sharedClient] setEnableLog:YES]; [FATClient sharedClient].delegate = [FINDemoClientHelper sharedHelper]; + // 注入自定义api + [[FINExtensionHelper sharedHelper] registerCustomApis]; - [FINExtensionHelper registerCustomApis]; + // 该appID【wx85663af68a0cbbc8】绑定的应用为凡泰助手,若要生效,请修改BundleID为com.finogeeks.mop.finosprite + [WXApi registerApp:@"wx85663af68a0cbbc8" universalLink:apiServer]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [UIColor whiteColor]; @@ -43,4 +57,11 @@ return YES; } +- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { + if ([url.scheme isEqualToString:@"wx85663af68a0cbbc8"]) { + return [WXApi handleOpenURL:url delegate:(id _Nullable)[FINExtensionHelper sharedHelper]]; + } + return YES; +} + @end diff --git a/demo/FINCustomMenuModel.m b/demo/FINCustomMenuModel.m index d8e884a..d500264 100644 --- a/demo/FINCustomMenuModel.m +++ b/demo/FINCustomMenuModel.m @@ -10,7 +10,7 @@ @implementation FINCustomMenuModel -@synthesize menuId, menuIconImage, menuTitle; +@synthesize menuId, menuIconImage, menuTitle, menuType; - (id)copyWithZone:(NSZone *)zone { diff --git a/demo/FINDemoClientHelper.m b/demo/FINDemoClientHelper.m index 7902883..cd79cc8 100644 --- a/demo/FINDemoClientHelper.m +++ b/demo/FINDemoClientHelper.m @@ -13,8 +13,7 @@ static FINDemoClientHelper *instance = nil; @implementation FINDemoClientHelper -+ (instancetype)sharedHelper -{ ++ (instancetype)sharedHelper { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ instance = [[[self class] alloc] init]; @@ -22,6 +21,18 @@ static FINDemoClientHelper *instance = nil; return instance; } ++ (instancetype)allocWithZone:(struct _NSZone *)zone { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [super allocWithZone:zone]; + }); + return instance; +} + +- (id)copy { + return instance; +} + #pragma mark - FATAppletDelegate - (void)forwardAppletWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode, NSDictionary *))completion { @@ -92,12 +103,12 @@ static FINDemoClientHelper *instance = nil; - (void)customMenu:(id)customMenu inApplet:(FATAppletInfo *)appletInfo didClickAtPath:(NSString *)path { NSLog(@"自定义按钮被点击"); - if (customMenu.menuId == 1001) { + if ([customMenu.menuId isEqual:@"1001"]) { NSLog(@"客服按钮被点击"); return; } - if (customMenu.menuId == 1002) { + if ([customMenu.menuId isEqual:@"1002"]) { NSLog(@"收藏按钮被点击"); // 1.获取用户id // NSString *userId = @""; diff --git a/demo/FINExtensionHelper.h b/demo/FINExtensionHelper.h index 47a4b2c..3782569 100644 --- a/demo/FINExtensionHelper.h +++ b/demo/FINExtensionHelper.h @@ -9,7 +9,9 @@ @interface FINExtensionHelper : NSObject -+ (void)registerCustomApis; ++ (instancetype)sharedHelper; + +- (void)registerCustomApis; @end diff --git a/demo/FINExtensionHelper.m b/demo/FINExtensionHelper.m index 9a5c6d8..38d03e6 100644 --- a/demo/FINExtensionHelper.m +++ b/demo/FINExtensionHelper.m @@ -7,22 +7,154 @@ #import "FINExtensionHelper.h" #import +#import +#import +#import + +@interface FINExtensionHelper () + +// 支付时,支付的回调是异步的,故这里将小程序的回调持有,在适当的时机调用(用户可根据自己的场景自行实现自己调用的逻辑) +@property (nonatomic, copy) FATExtensionApiCallback callback; + +@end + +static FINExtensionHelper *instance = nil; @implementation FINExtensionHelper -+ (void)registerCustomApis -{ ++ (instancetype)sharedHelper { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [[FINExtensionHelper alloc] init]; + }); + return instance; +} + ++ (instancetype)allocWithZone:(struct _NSZone *)zone { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [super allocWithZone:zone]; + }); + return instance; +} + +- (id)copy { + return instance; +} + +// 注入自定义api +- (void)registerCustomApis { [[FATClient sharedClient] registerExtensionApi:@"onNative" handle:^(id param, FATExtensionApiCallback callback) { - NSString *inputText = @"床前明月光,疑是地上霜。举头望明月,低头思故乡。"; callback(FATExtensionCodeSuccess, @{@"text":inputText}); }]; [[FATClient sharedClient] fat_registerWebApi:@"user_define_native" handle:^(id param, FATExtensionApiCallback callback) { - NSString *inputText = @"鹅鹅鹅,曲项向天歌,白毛浮绿水,红掌拨清波。"; callback(FATExtensionCodeSuccess, @{@"text":inputText}); }]; + + // 注入获取用户信息 + [[FATClient sharedClient] registerExtensionApi:@"getUserProfile" handle:^(id param, FATExtensionApiCallback callback) { + NSDictionary *userInfo = @{@"nickName":@"张三",@"avatarUrl":@"",@"gender":@1,@"country":@"中国",@"province":@"广东省",@"city":@"深圳",@"language":@"zh_CN"}; + NSDictionary *resDic = @{@"userInfo":userInfo}; + callback(FATExtensionCodeSuccess,resDic); + }]; + // 注入登录方法 + [[FATClient sharedClient] registerExtensionApi:@"login" handle:^(id param, FATExtensionApiCallback callback) { + // 处理小程序登录逻辑后,调用小程序回调 + // 登录成功回调示例 + callback(FATExtensionCodeSuccess,@{@"desc":@"登录成功"}); + }]; + // 注入微信支付方法 + __weak typeof(self) weakSelf = self; + [[FATClient sharedClient] registerExtensionApi:@"requestPayment" handle:^(id param, FATExtensionApiCallback callback) { + // 支付调用,调用结果通过回调通告小程序 + [weakSelf getTestPayment:callback]; + }]; } +#pragma mark - WXPay +// 模拟向服务请求支付订单 +- (void)getTestPayment:(FATExtensionApiCallback)callback { + NSString *urlString = @"https://finclip-testing.finogeeks.club/mop/wechat-auth/api/order"; + NSURL *url = [NSURL URLWithString:urlString]; + NSMutableURLRequest *requset = [NSMutableURLRequest requestWithURL:url]; + requset.HTTPMethod = @"POST"; + __weak typeof(self) weakSelf = self; + NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:requset completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + if (httpResponse.statusCode == 200) { + NSString *appId = @"wx85663af68a0cbbc8"; + NSString *partnerId = @"1600932850"; + NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil]; + NSString *prepayId = dict[@"data"][@"prepay_id"]; + NSString *nonceStr = @"5K8264ILTKCH16CQ2502SI8ZNMTM67VS"; // 随机字符串,这里就不模拟了 + UInt32 timeStamp = [[NSDate date] timeIntervalSince1970]; + NSString *text = [NSString stringWithFormat:@"%@\n%ld\n%@\n%@\n", appId, (long)timeStamp, nonceStr, prepayId]; + NSString *sign = [weakSelf sha256:text]; + PayReq *request = [[PayReq alloc] init]; + request.partnerId = partnerId; + request.prepayId = prepayId; + request.package = @"Sign=WXPay"; + request.nonceStr = nonceStr; + request.timeStamp = timeStamp; + request.sign= sign; + dispatch_async(dispatch_get_main_queue(), ^{ + [WXApi sendReq:request completion:^(BOOL success) { + if (success) { + weakSelf.callback = callback; + } else { + callback(FATExtensionCodeFailure, nil); + } + }]; + }); + return; + } + callback(FATExtensionCodeFailure, nil); + }]; + [task resume]; +} + +// 签名加密(正常是放在后台处理,由上面的请求接口返回 +- (NSString *)sha256:(NSString *)shaStr { + NSData *data = [shaStr dataUsingEncoding:NSUTF8StringEncoding]; + uint8_t digest[CC_SHA256_DIGEST_LENGTH]; + CC_SHA256(data.bytes, (CC_LONG)data.length, digest); + NSData *adata = [[NSData alloc] initWithBytes:digest length:CC_SHA256_DIGEST_LENGTH]; + adata = [adata base64EncodedDataWithOptions:0]; + NSString *ret = [[NSString alloc] initWithData:adata encoding:NSUTF8StringEncoding]; + return ret; +} + +#pragma mark - WXApiDelegate +//发起支付请求回调 +- (void)onReq:(BaseReq *)req { + +} + +//支付结果回调 +- (void)onResp:(BaseResp *)resp { + if ([resp isKindOfClass:[PayResp class]]) { + PayResp *response = (PayResp*)resp; + //response.errCode +// WXSuccess = 0, /**< 成功 */ +// WXErrCodeCommon = -1, /**< 普通错误类型 */ +// WXErrCodeUserCancel = -2, /**< 用户点击取消并返回 */ +// WXErrCodeSentFail = -3, /**< 发送失败 */ +// WXErrCodeAuthDeny = -4, /**< 授权失败 */ +// WXErrCodeUnsupport = -5, /**< 微信不支持 */ + switch (response.errCode) { + case WXSuccess: + self.callback(FATExtensionCodeSuccess, nil); + break; + + default: + self.callback(FATExtensionCodeFailure, nil); + break; + } + } +} + + @end diff --git a/demo/Info.plist b/demo/Info.plist index 73e6371..f14de6c 100644 --- a/demo/Info.plist +++ b/demo/Info.plist @@ -16,8 +16,26 @@ $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString 1.0 + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + weixin + CFBundleURLSchemes + + wx85663af68a0cbbc8 + + + CFBundleVersion 1 + LSApplicationQueriesSchemes + + weixin + weixinULAPI + LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/demo/ViewController.m b/demo/ViewController.m index 56875dc..c7b97c7 100644 --- a/demo/ViewController.m +++ b/demo/ViewController.m @@ -8,6 +8,7 @@ #import "ViewController.h" #import +#import @interface ViewController () @@ -28,8 +29,7 @@ [self p_initSubViews]; } -- (void)p_initSubViews -{ +- (void)p_initSubViews { CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; @@ -44,32 +44,25 @@ [self.view addSubview:self.tableView]; } -- (void)p_loadData -{ - NSDictionary *startParams = nil; +- (void)p_loadData { + // 配置小程序列表 self.appletList = [[NSMutableArray alloc] init]; - - [self.appletList addObject:@{@"appId":@"5facb3a52dcbff00017469bd",@"title":@"绘图小程序"}]; - [self.appletList addObject:@{@"appId":@"5fa214a29a6a7900019b5cc1",@"title":@"官方示例小程序"}]; - [self.appletList addObject:@{@"appId":@"5fa215459a6a7900019b5cc3",@"title":@"对账单"}]; - // FAT接口测试小程序 - [self.appletList addObject:@{@"appId":@"5fc8934aefb8c600019e9747",@"title":@"自定义小程序API示例"}]; - - startParams = @{ - @"path" : @"/pages/webview/webview" - }; - [self.appletList addObject:@{@"appId":@"5fc8934aefb8c600019e9747",@"title":@"自定义H5 API示例", @"startParams":startParams}]; - [self.appletList addObject:@{@"appId":@"60c5bbf99e094f00015079ee",@"title":@"原生向小程序发送事件"}]; - //登录授权示例需要原生App注入相关方法 - [self registAppletLoginApi]; - [self.appletList addObject:@{@"appId":@"60f051ea525ea10001c0bd22",@"title":@"小程序登录授权示例"}]; + NSString *bundleId = [NSBundle mainBundle].bundleIdentifier; + NSString *appName = [bundleId componentsSeparatedByString:@"."].lastObject; + if (![appName isEqualToString:@""]) { + NSString *path = [[NSBundle mainBundle] pathForResource:appName ofType:@"plist"]; + NSArray *array = [NSArray arrayWithContentsOfFile:path]; + for (NSDictionary *dict in array) { + [self.appletList addObject:dict]; + } + } [self.tableView reloadData]; } -- (void)sendCustomEvent -{ +// 原生向小程序发送的事件 +- (void)sendCustomEvent { if (@available(iOS 10.0, *)) { - NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:3 repeats:YES block:^(NSTimer * _Nonnull timer) { + [NSTimer scheduledTimerWithTimeInterval:3 repeats:YES block:^(NSTimer * _Nonnull timer) { NSTimeInterval timestamp = [[NSDate date] timeIntervalSince1970]; [[FATClient sharedClient].nativeViewManager sendCustomEventWithDetail:@{@"timestamp":@(timestamp)} completion:^(id result, NSError *error) { NSLog(@"sendCustomEventW:%@", error); @@ -78,52 +71,12 @@ } } -- (void)registAppletLoginApi { - //注入获取用户信息 - [[FATClient sharedClient]registerExtensionApi:@"getUserProfile" handle:^(id param, FATExtensionApiCallback callback) { - NSDictionary *userInfo = @{@"nickName":@"张三",@"avatarUrl":@"",@"gender":@1,@"country":@"中国",@"province":@"广东省",@"city":@"深圳",@"language":@"zh_CN"}; - NSDictionary *resDic = @{@"userInfo":userInfo}; - callback(FATExtensionCodeSuccess,resDic); - }]; - - //注入登录方法 - [[FATClient sharedClient]registerExtensionApi:@"login" handle:^(id param, FATExtensionApiCallback callback) { - //回调给小程序结果 - UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"是否同意授权登录?" preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *agreeAction = [UIAlertAction actionWithTitle:@"允许" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - - callback(FATExtensionCodeSuccess,@{@"desc":@"登录成功"}); - - }]; - [alertVC addAction:agreeAction]; - UIAlertAction *refuseAction = [UIAlertAction actionWithTitle:@"拒绝" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { - callback(FATExtensionCodeSuccess,@{@"desc":@"登录失败"}); - }]; - [alertVC addAction:refuseAction]; - if (self.presentedViewController) { - [self.presentedViewController presentViewController:alertVC animated:YES completion:^{ - - }]; - } else { - [self presentViewController:alertVC animated:YES completion:^{ - - }]; - } - - - - }]; - -} - #pragma mark - UITableViewDataSource -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section -{ +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.appletList.count; } -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifer = @"identifer"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifer]; if (cell == nil) { @@ -132,12 +85,10 @@ NSDictionary *dict = self.appletList[indexPath.row]; cell.textLabel.text = dict[@"title"]; - return cell; } -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; NSDictionary *dict = self.appletList[indexPath.row]; diff --git a/demo/demo.plist b/demo/demo.plist new file mode 100644 index 0000000..3981c80 --- /dev/null +++ b/demo/demo.plist @@ -0,0 +1,65 @@ + + + + + + appId + 5facb3a52dcbff00017469bd + title + 绘图小程序 + startParams + + + + appId + 5fa214a29a6a7900019b5cc1 + title + 官方示例小程序 + startParams + + + + appId + 5fa215459a6a7900019b5cc3 + title + 对账单 + startParams + + + + appId + 5fc8934aefb8c600019e9747 + title + 自定义小程序API示例 + startParams + + + + appId + 5fc8934aefb8c600019e9747 + title + 自定义H5 API示例 + startParams + + path + /pages/webview/webview + + + + appId + 60c5bbf99e094f00015079ee + title + 原生向小程序发送事件 + startParams + + + + appId + 60f051ea525ea10001c0bd22 + title + 小程序登录授权示例 + startParams + + + + diff --git a/demo/finosprite.plist b/demo/finosprite.plist new file mode 100644 index 0000000..1f9da87 --- /dev/null +++ b/demo/finosprite.plist @@ -0,0 +1,14 @@ + + + + + + appId + 611cf17739245f000182fa40 + title + 小程序微信登录&支付示例 + startParams + + + + diff --git a/demo/servers.plist b/demo/servers.plist new file mode 100644 index 0000000..8dd6317 --- /dev/null +++ b/demo/servers.plist @@ -0,0 +1,32 @@ + + + + + com.finogeeks.finclip.demo + + appKey + 22LyZEib0gLTQdU3MUauATBwgfnTCJjdr7FCnywmAEM= + appSecret + bdfd76cae24d4313 + apiServer + https://api.finclip.com + apiPrefix + /api/v1/mop/ + cryptType + MD5 + + com.finogeeks.mop.finosprite + + appKey + 22LyZEib0gLTQdU3MUauAQVLIkNNhTSGIN42gXzlAsk= + appSecret + ae55433be2f62915 + apiServer + https://finchat-mop-b.finogeeks.club + apiPrefix + /api/v1/mop/ + cryptType + SM + + +