Commit 33bbaab3fff5158823f3e95476ee4221d7412fd9

Authored by zhangxiaowen
1 parent 7b2ee585

no message

CNLiveServices.podspec
@@ -32,11 +32,6 @@ TODO: Add long description of the pod here. @@ -32,11 +32,6 @@ TODO: Add long description of the pod here.
32 32
33 s.source_files = 'CNLiveServices/Classes/CNLiveServices.h' 33 s.source_files = 'CNLiveServices/Classes/CNLiveServices.h'
34 34
35 - # 环境  
36 - s.subspec 'Environment' do |ss|  
37 - ss.source_files = 'CNLiveServices/Classes/Environment/*.{h,m}'  
38 - end  
39 -  
40 # 首页 35 # 首页
41 s.subspec 'Home' do |ss| 36 s.subspec 'Home' do |ss|
42 ss.source_files = 'CNLiveServices/Classes/Home/*.{h,m}' 37 ss.source_files = 'CNLiveServices/Classes/Home/*.{h,m}'
@@ -74,5 +69,6 @@ TODO: Add long description of the pod here. @@ -74,5 +69,6 @@ TODO: Add long description of the pod here.
74 # s.public_header_files = 'Pod/Classes/**/*.h' 69 # s.public_header_files = 'Pod/Classes/**/*.h'
75 # s.frameworks = 'UIKit', 'MapKit' 70 # s.frameworks = 'UIKit', 'MapKit'
76 s.dependency 'BeeHive' 71 s.dependency 'BeeHive'
77 - 72 + s.dependency 'CNLiveEnvironment'
  73 +
78 end 74 end
CNLiveServices/Classes/CNLiveServices.h
@@ -11,9 +11,6 @@ @@ -11,9 +11,6 @@
11 11
12 #import "BeeHive.h" 12 #import "BeeHive.h"
13 13
14 -//环境  
15 -#import "CNLiveEnvironmentServiceProtocol.h"  
16 -  
17 //首页 14 //首页
18 #import "CNLiveHomeServiceProtocol.h" 15 #import "CNLiveHomeServiceProtocol.h"
19 16
CNLiveServices/Classes/Environment/CNLiveEnvironmentServiceProtocol.h deleted 100644 → 0
1 -//  
2 -// CNLiveEnvironmentServiceProtocol.h  
3 -// TestBH  
4 -//  
5 -// Created by CNLive-zxw on 2019/7/22.  
6 -// Copyright © 2019 XW. All rights reserved.  
7 -//  
8 -  
9 -#import <Foundation/Foundation.h>  
10 -#import "BHServiceProtocol.h"  
11 -  
12 -typedef NS_ENUM(NSInteger, CNLiveEnvironmentType) {  
13 - CNLiveDebugInHouse = 0,//测试企业环境  
14 - CNLiveProductionInHouse = 1,//正式企业环境  
15 - CNLiveDebugAppStore = 2,//测试商店环境  
16 - CNLiveProductionAppStore = 3 //正式商店环境  
17 -  
18 -};  
19 -  
20 -@protocol CNLiveEnvironmentServiceProtocol <NSObject, BHServiceProtocol>  
21 -- (void)setEnvironment:(CNLiveEnvironmentType)isEnvironment;  
22 -  
23 -  
24 -@end  
Example/CNLiveServices.xcodeproj/project.pbxproj
@@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
15 0833CE9A22EFE03200AA3B2C /* CNUserAgreementWebController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0833CE9922EFE03200AA3B2C /* CNUserAgreementWebController.m */; }; 15 0833CE9A22EFE03200AA3B2C /* CNUserAgreementWebController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0833CE9922EFE03200AA3B2C /* CNUserAgreementWebController.m */; };
16 084124BC22E70027006699C6 /* CNLiveDetailsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 084124BB22E70027006699C6 /* CNLiveDetailsViewController.m */; }; 16 084124BC22E70027006699C6 /* CNLiveDetailsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 084124BB22E70027006699C6 /* CNLiveDetailsViewController.m */; };
17 084124C622E702C6006699C6 /* CNLiveFoundViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 084124C522E702C6006699C6 /* CNLiveFoundViewController.m */; }; 17 084124C622E702C6006699C6 /* CNLiveFoundViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 084124C522E702C6006699C6 /* CNLiveFoundViewController.m */; };
  18 + 084356B5231CFDBA006BD702 /* CNLiveUserInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 084356B4231CFDBA006BD702 /* CNLiveUserInfoModel.m */; };
  19 + 084356B8231D10F8006BD702 /* CNLiveUserRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 084356B7231D10F8006BD702 /* CNLiveUserRequest.m */; };
18 0882D6A422E5AE1B000859E7 /* CNLiveLoginService.m in Sources */ = {isa = PBXBuildFile; fileRef = 0882D6A322E5AE1B000859E7 /* CNLiveLoginService.m */; }; 20 0882D6A422E5AE1B000859E7 /* CNLiveLoginService.m in Sources */ = {isa = PBXBuildFile; fileRef = 0882D6A322E5AE1B000859E7 /* CNLiveLoginService.m */; };
19 0882D6A722E5AEB2000859E7 /* CNLoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0882D6A622E5AEB2000859E7 /* CNLoginViewController.m */; }; 21 0882D6A722E5AEB2000859E7 /* CNLoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0882D6A622E5AEB2000859E7 /* CNLoginViewController.m */; };
20 0882D6AA22E5AEDB000859E7 /* CNLiveLoginModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 0882D6A922E5AEDB000859E7 /* CNLiveLoginModule.m */; }; 22 0882D6AA22E5AEDB000859E7 /* CNLiveLoginModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 0882D6A922E5AEDB000859E7 /* CNLiveLoginModule.m */; };
@@ -65,6 +67,13 @@ @@ -65,6 +67,13 @@
65 084124BB22E70027006699C6 /* CNLiveDetailsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveDetailsViewController.m; sourceTree = "<group>"; }; 67 084124BB22E70027006699C6 /* CNLiveDetailsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveDetailsViewController.m; sourceTree = "<group>"; };
66 084124C422E702C6006699C6 /* CNLiveFoundViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveFoundViewController.h; sourceTree = "<group>"; }; 68 084124C422E702C6006699C6 /* CNLiveFoundViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveFoundViewController.h; sourceTree = "<group>"; };
67 084124C522E702C6006699C6 /* CNLiveFoundViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveFoundViewController.m; sourceTree = "<group>"; }; 69 084124C522E702C6006699C6 /* CNLiveFoundViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveFoundViewController.m; sourceTree = "<group>"; };
  70 + 084356B3231CFDBA006BD702 /* CNLiveUserInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveUserInfoModel.h; sourceTree = "<group>"; };
  71 + 084356B4231CFDBA006BD702 /* CNLiveUserInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveUserInfoModel.m; sourceTree = "<group>"; };
  72 + 084356B6231D10F8006BD702 /* CNLiveUserRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveUserRequest.h; sourceTree = "<group>"; };
  73 + 084356B7231D10F8006BD702 /* CNLiveUserRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveUserRequest.m; sourceTree = "<group>"; };
  74 + 084356B9231D1128006BD702 /* CNLiveUserTypeDef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveUserTypeDef.h; sourceTree = "<group>"; };
  75 + 084356BA231D19A4006BD702 /* CNLiveUserUrl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveUserUrl.h; sourceTree = "<group>"; };
  76 + 084356BB231D1DDE006BD702 /* CNLiveUserCenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveUserCenter.h; sourceTree = "<group>"; };
68 0882D6A222E5AE1B000859E7 /* CNLiveLoginService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveLoginService.h; sourceTree = "<group>"; }; 77 0882D6A222E5AE1B000859E7 /* CNLiveLoginService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLiveLoginService.h; sourceTree = "<group>"; };
69 0882D6A322E5AE1B000859E7 /* CNLiveLoginService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveLoginService.m; sourceTree = "<group>"; }; 78 0882D6A322E5AE1B000859E7 /* CNLiveLoginService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNLiveLoginService.m; sourceTree = "<group>"; };
70 0882D6A522E5AEB2000859E7 /* CNLoginViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLoginViewController.h; sourceTree = "<group>"; }; 79 0882D6A522E5AEB2000859E7 /* CNLoginViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CNLoginViewController.h; sourceTree = "<group>"; };
@@ -195,8 +204,15 @@ @@ -195,8 +204,15 @@
195 084124C822E72DE4006699C6 /* Model */ = { 204 084124C822E72DE4006699C6 /* Model */ = {
196 isa = PBXGroup; 205 isa = PBXGroup;
197 children = ( 206 children = (
  207 + 084356B9231D1128006BD702 /* CNLiveUserTypeDef.h */,
198 08A5392F22FC22C000CDA315 /* CNLiveUserInfoManager.h */, 208 08A5392F22FC22C000CDA315 /* CNLiveUserInfoManager.h */,
199 08A5393022FC22C000CDA315 /* CNLiveUserInfoManager.m */, 209 08A5393022FC22C000CDA315 /* CNLiveUserInfoManager.m */,
  210 + 084356B3231CFDBA006BD702 /* CNLiveUserInfoModel.h */,
  211 + 084356B4231CFDBA006BD702 /* CNLiveUserInfoModel.m */,
  212 + 084356B6231D10F8006BD702 /* CNLiveUserRequest.h */,
  213 + 084356B7231D10F8006BD702 /* CNLiveUserRequest.m */,
  214 + 084356BA231D19A4006BD702 /* CNLiveUserUrl.h */,
  215 + 084356BB231D1DDE006BD702 /* CNLiveUserCenter.h */,
200 ); 216 );
201 path = Model; 217 path = Model;
202 sourceTree = "<group>"; 218 sourceTree = "<group>";
@@ -405,6 +421,7 @@ @@ -405,6 +421,7 @@
405 developmentRegion = English; 421 developmentRegion = English;
406 hasScannedForEncodings = 0; 422 hasScannedForEncodings = 0;
407 knownRegions = ( 423 knownRegions = (
  424 + English,
408 en, 425 en,
409 Base, 426 Base,
410 "zh-Hans", 427 "zh-Hans",
@@ -474,13 +491,21 @@ @@ -474,13 +491,21 @@
474 ); 491 );
475 inputPaths = ( 492 inputPaths = (
476 "${PODS_ROOT}/Target Support Files/Pods-CNLiveServices_Example/Pods-CNLiveServices_Example-frameworks.sh", 493 "${PODS_ROOT}/Target Support Files/Pods-CNLiveServices_Example/Pods-CNLiveServices_Example-frameworks.sh",
  494 + "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework",
477 "${BUILT_PRODUCTS_DIR}/BeeHive/BeeHive.framework", 495 "${BUILT_PRODUCTS_DIR}/BeeHive/BeeHive.framework",
  496 + "${BUILT_PRODUCTS_DIR}/CNLiveEnvironment/CNLiveEnvironment.framework",
  497 + "${BUILT_PRODUCTS_DIR}/CNLiveRequestBastKit/CNLiveRequestBastKit.framework",
  498 + "${BUILT_PRODUCTS_DIR}/MJExtension/MJExtension.framework",
478 ); 499 );
479 name = "[CP] Embed Pods Frameworks"; 500 name = "[CP] Embed Pods Frameworks";
480 outputFileListPaths = ( 501 outputFileListPaths = (
481 ); 502 );
482 outputPaths = ( 503 outputPaths = (
  504 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework",
483 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BeeHive.framework", 505 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/BeeHive.framework",
  506 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveEnvironment.framework",
  507 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CNLiveRequestBastKit.framework",
  508 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MJExtension.framework",
484 ); 509 );
485 runOnlyForDeploymentPostprocessing = 0; 510 runOnlyForDeploymentPostprocessing = 0;
486 shellPath = /bin/sh; 511 shellPath = /bin/sh;
@@ -527,8 +552,10 @@ @@ -527,8 +552,10 @@
527 08109F1E22FC3CBC0008A577 /* CNLiveFoundService.m in Sources */, 552 08109F1E22FC3CBC0008A577 /* CNLiveFoundService.m in Sources */,
528 0833CE9A22EFE03200AA3B2C /* CNUserAgreementWebController.m in Sources */, 553 0833CE9A22EFE03200AA3B2C /* CNUserAgreementWebController.m in Sources */,
529 0882D6A422E5AE1B000859E7 /* CNLiveLoginService.m in Sources */, 554 0882D6A422E5AE1B000859E7 /* CNLiveLoginService.m in Sources */,
  555 + 084356B8231D10F8006BD702 /* CNLiveUserRequest.m in Sources */,
530 0882D6B822E5B3D1000859E7 /* CNLiveHomeViewController.m in Sources */, 556 0882D6B822E5B3D1000859E7 /* CNLiveHomeViewController.m in Sources */,
531 084124C622E702C6006699C6 /* CNLiveFoundViewController.m in Sources */, 557 084124C622E702C6006699C6 /* CNLiveFoundViewController.m in Sources */,
  558 + 084356B5231CFDBA006BD702 /* CNLiveUserInfoModel.m in Sources */,
532 08A5393122FC22C000CDA315 /* CNLiveUserInfoManager.m in Sources */, 559 08A5393122FC22C000CDA315 /* CNLiveUserInfoManager.m in Sources */,
533 6003F59A195388D20070C39A /* main.m in Sources */, 560 6003F59A195388D20070C39A /* main.m in Sources */,
534 ); 561 );
Example/CNLiveServices/Found/CNLiveFoundViewController.m
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 // 7 //
8 8
9 #import "CNLiveFoundViewController.h" 9 #import "CNLiveFoundViewController.h"
  10 +#import "CNLiveUserInfoManager.h"
10 11
11 @interface CNLiveFoundViewController () 12 @interface CNLiveFoundViewController ()
12 13
@@ -28,6 +29,9 @@ @@ -28,6 +29,9 @@
28 [btn0 setTitle:@"回调传值" forState:UIControlStateNormal]; 29 [btn0 setTitle:@"回调传值" forState:UIControlStateNormal];
29 [btn0 addTarget:self action:@selector(testButtonClicked) forControlEvents:UIControlEventTouchUpInside]; 30 [btn0 addTarget:self action:@selector(testButtonClicked) forControlEvents:UIControlEventTouchUpInside];
30 [self.view addSubview:btn0]; 31 [self.view addSubview:btn0];
  32 +
  33 + NSLog(@"姓名:%@, ID:%@, Token:%@, Head:%@",User_Name,User_ID,User_Token, User_Head);
  34 +
31 35
32 } 36 }
33 37
Example/CNLiveServices/Home/CNLiveHomeViewController.m
@@ -59,7 +59,7 @@ @@ -59,7 +59,7 @@
59 59
60 - (void)testButtonClicked1 { 60 - (void)testButtonClicked1 {
61 id<CNLiveUserAgreementServiceProtocol> agreement = [[BeeHive shareInstance] createService:@protocol(CNLiveUserAgreementServiceProtocol)]; 61 id<CNLiveUserAgreementServiceProtocol> agreement = [[BeeHive shareInstance] createService:@protocol(CNLiveUserAgreementServiceProtocol)];
62 - [[agreement class] jumpToAgreementH5WithType:CNAgreementUser]; 62 + [[agreement class] jumpToAgreementH5WithType:CNAgreementCancellation];
63 63
64 } 64 }
65 65
Example/CNLiveServices/Login/Controller/CNLoginViewController.m
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 #import "CNLoginViewController.h" 9 #import "CNLoginViewController.h"
10 #import "CNLiveServices.h" 10 #import "CNLiveServices.h"
11 #import "CNLiveUserInfoManager.h" 11 #import "CNLiveUserInfoManager.h"
  12 +#import "CNLiveUserRequest.h"
12 13
13 @interface CNLoginViewController () 14 @interface CNLoginViewController ()
14 15
@@ -32,13 +33,13 @@ @@ -32,13 +33,13 @@
32 self.view.backgroundColor = [UIColor whiteColor]; 33 self.view.backgroundColor = [UIColor whiteColor];
33 self.title = @"登录"; 34 self.title = @"登录";
34 35
35 -// UIButton *btn0 = [UIButton buttonWithType:UIButtonTypeCustom];  
36 -// btn0.frame = CGRectMake(0, 0, 100, 100);  
37 -// btn0.center = CGPointMake(self.view.center.x, self.view.center.y-120);  
38 -// btn0.backgroundColor = [UIColor redColor];  
39 -// [btn0 setTitle:@"进入协议" forState:UIControlStateNormal];  
40 -// [btn0 addTarget:self action:@selector(testButtonClicked) forControlEvents:UIControlEventTouchUpInside];  
41 -// [self.view addSubview:btn0]; 36 + UIButton *btn0 = [UIButton buttonWithType:UIButtonTypeCustom];
  37 + btn0.frame = CGRectMake(0, 0, 100, 100);
  38 + btn0.center = CGPointMake(self.view.center.x, self.view.center.y-120);
  39 + btn0.backgroundColor = [UIColor redColor];
  40 + [btn0 setTitle:@"进入协议" forState:UIControlStateNormal];
  41 + [btn0 addTarget:self action:@selector(testButtonClicked0) forControlEvents:UIControlEventTouchUpInside];
  42 + [self.view addSubview:btn0];
42 43
43 UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom]; 44 UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
44 btn1.frame = CGRectMake(0, 0, 100, 100); 45 btn1.frame = CGRectMake(0, 0, 100, 100);
@@ -50,19 +51,27 @@ @@ -50,19 +51,27 @@
50 51
51 } 52 }
52 53
53 -- (void)testButtonClicked {  
54 -// id<CNLiveHomeServiceProtocol> home = [[BeeHive shareInstance] createService:@protocol(CNLiveHomeServiceProtocol)];  
55 -// [home pushToHomeViewController];  
56 - 54 +- (void)testButtonClicked0 {
57 id<CNLiveUserAgreementServiceProtocol> agreement = [[BeeHive shareInstance] createService:@protocol(CNLiveUserAgreementServiceProtocol)]; 55 id<CNLiveUserAgreementServiceProtocol> agreement = [[BeeHive shareInstance] createService:@protocol(CNLiveUserAgreementServiceProtocol)];
58 - [agreement jumpToAgreementH5WithType:CNAgreementUser]; 56 + [[agreement class] jumpToAgreementH5WithType:CNAgreementUser];
59 57
60 } 58 }
61 59
62 - (void)testButtonClicked1 { 60 - (void)testButtonClicked1 {
63 - [CNLiveUserInfoManager manager].isLogin = YES; 61 +
  62 + [CNLiveUserRequest loginWithUserName:nil password:nil fromId:nil success:^(id _Nonnull result) {
  63 +
  64 + } failure:^(NSDictionary * _Nonnull errorDic) {
  65 +
  66 + }];
  67 +
  68 +
  69 +// NSDictionary *dic = @{@"token":@"zxwqwer",@"id":@"123",@"pic":@"http://asdsa",@"name":@"张晓文"};
  70 + NSDictionary *dic = @{@"token":@"zxwqwer",@"id":@"123",@"name":@"张晓文",@"pic":@""};
  71 +
  72 + [[CNLiveUserInfoManager manager] defaultConfiguration:dic];
64 [self dismissViewControllerAnimated:YES completion:^{ 73 [self dismissViewControllerAnimated:YES completion:^{
65 - self.completeBlock? self.completeBlock(YES):@""; 74 + self.completeBlock? self.completeBlock(User_Login):@"";
66 75
67 }]; 76 }];
68 } 77 }
Example/CNLiveServices/Login/Model/CNLiveUserCenter.h 0 → 100644
  1 +//
  2 +// CNLiveUserCenter.h
  3 +// CNLiveServices
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/2.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#ifndef CNLiveUserCenter_h
  10 +#define CNLiveUserCenter_h
  11 +
  12 +// 枚举值
  13 +#import "CNLiveUserTypeDef.h"
  14 +// 用户相关的请求
  15 +#import "CNLiveUserRequest.h"
  16 +// 本地化用户数据
  17 +#import "CNLiveUserInfoManager.h"
  18 +
  19 +#endif /* CNLiveUserCenter_h */
Example/CNLiveServices/Login/Model/CNLiveUserInfoManager.h
@@ -6,14 +6,63 @@ @@ -6,14 +6,63 @@
6 // Copyright © 2019 153993236@qq.com. All rights reserved. 6 // Copyright © 2019 153993236@qq.com. All rights reserved.
7 // 7 //
8 8
  9 +/**
  10 + * 保存用户信息
  11 + */
  12 +
9 #import <Foundation/Foundation.h> 13 #import <Foundation/Foundation.h>
  14 +#import "CNLiveUserTypeDef.h"
10 15
11 NS_ASSUME_NONNULL_BEGIN 16 NS_ASSUME_NONNULL_BEGIN
  17 +// Token
  18 +#define User_Token [CNLiveUserInfoManager manager].token?[CNLiveUserInfoManager manager].token:@""
  19 +// 用户id
  20 +#define User_ID [CNLiveUserInfoManager manager].ID?[CNLiveUserInfoManager manager].ID:@""
  21 +// 用户手机号
  22 +#define User_Tel [CNLiveUserInfoManager manager].tel?[CNLiveUserInfoManager manager].tel:@""
  23 +// 用户名字
  24 +#define User_Name [CNLiveUserInfoManager manager].name?[CNLiveUserInfoManager manager].name:@""
  25 +// 用户性别
  26 +#define User_Sex [CNLiveUserInfoManager manager].sex?[CNLiveUserInfoManager manager].sex:@""
  27 +// 默认头像
  28 +#define Default_Head @"默认头像"
  29 +// 用户头像
  30 +#define User_Head [CNLiveUserInfoManager manager].pic?[CNLiveUserInfoManager manager].pic:Default_Head
  31 +// 用户简介
  32 +#define User_Introduction [CNLiveUserInfoManager manager].introduction?[CNLiveUserInfoManager manager].introduction:@""
  33 +// 用户是否登录
  34 +#define User_Login [CNLiveUserInfoManager manager].isLogin
12 35
13 @interface CNLiveUserInfoManager : NSObject 36 @interface CNLiveUserInfoManager : NSObject
14 -@property (nonatomic, assign) BOOL isLogin; 37 +
  38 +@property (nonatomic, copy, readonly) NSString * __nullable token;
  39 +@property (nonatomic, copy, readonly) NSString * __nullable ID;
  40 +@property (nonatomic, copy, readonly) NSString * __nullable name;
  41 +@property (nonatomic, copy, readonly) NSString * __nullable tel;
  42 +@property (nonatomic, copy, readonly) NSString * __nullable pic;
  43 +@property (nonatomic, copy, readonly) NSString * __nullable sex;
  44 +@property (nonatomic, copy, readonly) NSString * __nullable introduction;
  45 +@property (nonatomic, assign, readonly) BOOL isLogin;
  46 +
15 + (instancetype)manager; 47 + (instancetype)manager;
16 48
  49 +/**
  50 + * 配置用户信息
  51 + *
  52 + * dic 用户信息字典
  53 + */
  54 +- (void)defaultConfiguration:(NSDictionary *)dic;
  55 +
  56 +/**
  57 + * 更新用户信息
  58 + */
  59 +- (void)updateUserInfo:(CNLiveUserInfoType)type info:(NSString *)info;
  60 +
  61 +/**
  62 + * 退出登录,删除用户信息
  63 + */
  64 +- (void)removeUserInfo;
  65 +
17 @end 66 @end
18 67
19 NS_ASSUME_NONNULL_END 68 NS_ASSUME_NONNULL_END
Example/CNLiveServices/Login/Model/CNLiveUserInfoManager.m
@@ -7,11 +7,24 @@ @@ -7,11 +7,24 @@
7 // 7 //
8 8
9 #import "CNLiveUserInfoManager.h" 9 #import "CNLiveUserInfoManager.h"
  10 +#import "MJExtension.h"
  11 +#import "CNLiveUserInfoModel.h"
  12 +
10 @interface CNLiveUserInfoManager() 13 @interface CNLiveUserInfoManager()
  14 +@property (nonatomic, copy, readwrite) NSString * __nullable token;
  15 +@property (nonatomic, copy, readwrite) NSString * __nullable ID;
  16 +@property (nonatomic, copy, readwrite) NSString * __nullable tel;
  17 +@property (nonatomic, copy, readwrite) NSString * __nullable name;
  18 +@property (nonatomic, copy, readwrite) NSString * __nullable pic;
  19 +@property (nonatomic, copy, readwrite) NSString * __nullable sex;
  20 +@property (nonatomic, copy, readwrite) NSString * __nullable introduction;
11 21
  22 +@property (nonatomic, strong) CNLiveUserInfoModel * __nullable model;
12 @end 23 @end
13 24
14 @implementation CNLiveUserInfoManager 25 @implementation CNLiveUserInfoManager
  26 +NSString * const CNLiveUserInfo = @"CNLiveUserInfo";
  27 +
15 static CNLiveUserInfoManager *_instance = nil; 28 static CNLiveUserInfoManager *_instance = nil;
16 29
17 /** 30 /**
@@ -40,6 +53,112 @@ static CNLiveUserInfoManager *_instance = nil; @@ -40,6 +53,112 @@ static CNLiveUserInfoManager *_instance = nil;
40 - (nonnull id)mutableCopyWithZone:(nullable NSZone *)zone { 53 - (nonnull id)mutableCopyWithZone:(nullable NSZone *)zone {
41 return _instance; 54 return _instance;
42 } 55 }
  56 +- (instancetype)init{
  57 + if (self = [super init]) {
  58 + NSDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:CNLiveUserInfo];
  59 + if (dic != nil) {
  60 + [self defaultConfiguration:dic];
  61 + }
  62 + }
  63 + return self;
  64 +}
  65 +
  66 +/**
  67 + * 用户是否登录成功
  68 + */
  69 +- (BOOL)isLogin{
  70 + if(self.ID && ![self.ID isEqualToString:@""] && self.name && ![self.name isEqualToString:@""] && self.token && ![self.token isEqualToString:@""]){
  71 + return YES;
  72 + }
  73 + return NO;
  74 +}
  75 +
  76 +/**
  77 + * 配置用户信息
  78 + *
  79 + * dic 用户信息字典
  80 + */
  81 +- (void)defaultConfiguration:(NSDictionary *)dic {
  82 + [[NSUserDefaults standardUserDefaults] setObject:dic forKey:CNLiveUserInfo];
  83 + [[NSUserDefaults standardUserDefaults] synchronize];
  84 +
  85 + CNLiveUserInfoModel *model = [CNLiveUserInfoModel mj_objectWithKeyValues:dic];
  86 + self.model = model;
  87 + self.token = model.token;
  88 + self.ID = model.ID;
  89 + self.name = model.name;
  90 + self.pic = model.pic;
  91 +}
  92 +
  93 +/**
  94 + * 更新用户信息
  95 + */
  96 +- (void)updateUserInfo:(CNLiveUserInfoType)type info:(NSString *)info{
  97 + NSMutableDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:CNLiveUserInfo];
  98 + if (dic != nil) {
  99 + switch (type) {
  100 + case CNLiveUserInfoTypeTel:
  101 + {
  102 + dic[@"tel"] = info;
  103 + _instance.tel = info;
  104 + _instance.model.tel = info;
  105 +
  106 + }
  107 + break;
  108 + case CNLiveUserInfoTypeName:
  109 + {
  110 + dic[@"name"] = info;
  111 + _instance.name = info;
  112 + _instance.model.name = info;
  113 +
  114 + }
  115 + break;
  116 + case CNLiveUserInfoTypeHead:
  117 + {
  118 + dic[@"pic"] = info;
  119 + _instance.pic = info;
  120 + _instance.model.pic = info;
  121 +
  122 + }
  123 + break;
  124 + case CNLiveUserInfoTypeSex:
  125 + {
  126 + dic[@"sex"] = info;
  127 + _instance.sex = info;
  128 + _instance.model.sex = info;
  129 +
  130 + }
  131 + break;
  132 + case CNLiveUserInfoTypeIntroduction:
  133 + {
  134 + dic[@"introduction"] = info;
  135 + _instance.introduction = info;
  136 + _instance.model.introduction = info;
  137 +
  138 + }
  139 + break;
  140 + }
  141 + [[NSUserDefaults standardUserDefaults] setObject:dic forKey:CNLiveUserInfo];
  142 + [[NSUserDefaults standardUserDefaults] synchronize];
  143 + }
  144 +}
  145 +
  146 +/**
  147 + * 退出登录,删除用户信息
  148 + */
  149 +- (void)removeUserInfo{
  150 + [[NSUserDefaults standardUserDefaults] setObject:nil forKey:CNLiveUserInfo];
  151 + [[NSUserDefaults standardUserDefaults] synchronize];
  152 +
  153 + self.model = nil;
  154 + self.token = nil;
  155 + self.ID = nil;
  156 + self.name = nil;
  157 + self.pic = nil;
  158 + self.sex = nil;
  159 + self.introduction = nil;
  160 +
  161 +}
43 162
44 163
45 @end 164 @end
Example/CNLiveServices/Login/Model/CNLiveUserInfoModel.h 0 → 100644
  1 +//
  2 +// CNLiveUserInfoModel.h
  3 +// CNLiveServices_Example
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/2.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +
  11 +NS_ASSUME_NONNULL_BEGIN
  12 +
  13 +@interface CNLiveUserInfoModel : NSObject
  14 +@property (nonatomic, copy) NSString *token;
  15 +@property (nonatomic, copy) NSString *ID;
  16 +@property (nonatomic, copy) NSString *tel;
  17 +@property (nonatomic, copy) NSString *name;
  18 +@property (nonatomic, copy) NSString *pic;
  19 +@property (nonatomic, copy) NSString *sex;
  20 +@property (nonatomic, copy) NSString *introduction;
  21 +
  22 +@end
  23 +
  24 +NS_ASSUME_NONNULL_END
Example/CNLiveServices/Login/Model/CNLiveUserInfoModel.m 0 → 100644
  1 +//
  2 +// CNLiveUserInfoModel.m
  3 +// CNLiveServices_Example
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/2.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveUserInfoModel.h"
  10 +
  11 +@implementation CNLiveUserInfoModel
  12 +
  13 ++ (NSDictionary *)mj_replacedKeyFromPropertyName {
  14 + return @{@"ID":@"id"};
  15 +}
  16 +
  17 +@end
Example/CNLiveServices/Login/Model/CNLiveUserRequest.h 0 → 100644
  1 +//
  2 +// CNLiveUserRequest.h
  3 +// CNLiveServices_Example
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/2.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import <Foundation/Foundation.h>
  10 +#import "CNLiveUserTypeDef.h"
  11 +
  12 +NS_ASSUME_NONNULL_BEGIN
  13 +
  14 +@interface CNLiveUserRequest : NSObject
  15 +
  16 +/**
  17 + @abstract 初始化
  18 + @param appId 注册成功获得应用ID
  19 + @param appKey 注册成功获得应用key
  20 + @param appSecret 注册成功获得应用secret
  21 + @param isTestEnvironment 测试环境开关
  22 + @warning 必传参数
  23 + 必须在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用
  24 + */
  25 ++ (void)setAppId:(NSString *)appId appKey:(NSString *)appKey appSecret:(NSString *)appSecret isTestEnvironment:(BOOL)isTestEnvironment;
  26 +
  27 +
  28 +/**
  29 + @abstract 发送验证码
  30 + @param type 发送验证码类型(详见CodeType)
  31 + @param mobile 手机号
  32 + @param success 成功回调
  33 + @param failure 失败回调
  34 + */
  35 ++ (void)verificationCodeType:(CNLiveCodeType)type mobile:(NSString *)mobile success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  36 +
  37 +
  38 +/**
  39 + @abstract 注册
  40 + @param userName 邮箱或手机
  41 + @param password 密码
  42 + @param verificationCode 手机验证码(手机号注册时必填)
  43 + @param invitationCode 邀请码(非必填)
  44 + @param fromId 渠道ID(非必填)
  45 + @param success 成功回调
  46 + @param failure 失败回调
  47 + */
  48 ++ (void)registerWithUserName:(NSString *)userName password:(NSString *)password verificationCode:(NSString *)verificationCode invitationCode:(NSString * _Nullable)invitationCode fromId:(NSString * _Nullable)fromId success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  49 +
  50 +
  51 +/**
  52 + @abstract 快捷登录
  53 + @param userName 手机号
  54 + @param verificationCode 验证码
  55 + @param fromId 渠道ID(非必填)
  56 + @param success 成功回调
  57 + @param failure 失败回调
  58 + */
  59 ++ (void)shortcutLoginWithUserName:(NSString *)userName verificationCode:(NSString *)verificationCode fromId:(NSString * _Nullable)fromId success:(void (^)(id))success failure :(void (^)(NSDictionary *))failure;
  60 +
  61 +
  62 +/**
  63 + @abstract 登录
  64 + @param userName 手机号或邮箱
  65 + @param password 密码
  66 + @param fromId 渠道ID(非必填)
  67 + @param success 成功回调
  68 + @param failure 失败回调
  69 + */
  70 ++ (void)loginWithUserName:(NSString *)userName password:(NSString *)password fromId:(NSString * _Nullable)fromId success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  71 +
  72 +
  73 +/**
  74 + @abstract 修改用户单项信息
  75 + @param type 修改类型(name-昵称, sex-性别, tel-手机号, head-头像, introduction-简介)
  76 + @param uid 用户ID
  77 + @param info 对应的信息(注sex对应f/m/n)
  78 + @param success 成功回调
  79 + @param failure 失败回调
  80 + */
  81 ++ (void)updateUserInfoType:(CNLiveUserInfoType)type uid:(NSString *)uid info:(NSString *)info success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  82 +
  83 +
  84 +@end
  85 +
  86 +NS_ASSUME_NONNULL_END
Example/CNLiveServices/Login/Model/CNLiveUserRequest.m 0 → 100644
  1 +//
  2 +// CNLiveUserRequest.m
  3 +// CNLiveServices_Example
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/2.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#import "CNLiveUserRequest.h"
  10 +#import "CNLiveUserUrl.h"
  11 +
  12 +#define User_AppId [CNLiveUserRequest manager].appId?[CNLiveUserRequest manager].appId:@""
  13 +#define User_AppKey [CNLiveUserRequest manager].appKey?[CNLiveUserRequest manager].appKey:@""
  14 +#define User_AppSecret [CNLiveUserRequest manager].appSecret?[CNLiveUserRequest manager].appSecret:@""
  15 +#define User_TestEnvironment [CNLiveUserRequest manager].isTestEnvironment
  16 +
  17 +@interface CNLiveUserRequest()
  18 +
  19 +@property (nonatomic, copy) NSString *appId;
  20 +@property (nonatomic, copy) NSString *appKey;
  21 +@property (nonatomic, copy) NSString *appSecret;
  22 +@property (nonatomic, assign) BOOL isTestEnvironment;
  23 +
  24 +@end
  25 +
  26 +@implementation CNLiveUserRequest
  27 +static CNLiveUserRequest *_instance = nil;
  28 +
  29 +/**
  30 + * @abstract 单例初始化
  31 + */
  32 ++ (instancetype)manager{
  33 + static dispatch_once_t once;
  34 + dispatch_once(&once, ^{
  35 + _instance = [[CNLiveUserRequest alloc]init];
  36 + });
  37 + return _instance;
  38 +}
  39 +
  40 ++ (id)allocWithZone:(struct _NSZone *)zone{
  41 + static dispatch_once_t onceToken;
  42 + dispatch_once(&onceToken, ^{
  43 + _instance = [super allocWithZone:zone];
  44 + });
  45 + return _instance;
  46 +}
  47 +
  48 +- (nonnull id)copyWithZone:(nullable NSZone *)zone {
  49 + return _instance;
  50 +}
  51 +
  52 +- (nonnull id)mutableCopyWithZone:(nullable NSZone *)zone {
  53 + return _instance;
  54 +}
  55 +
  56 +/**
  57 + @abstract 初始化
  58 + @param appId 注册成功获得应用ID
  59 + @param appKey 注册成功获得应用key
  60 + @param appSecret 注册成功获得应用secret
  61 + @param isTestEnvironment 测试环境开关
  62 + @warning 必传参数
  63 + 必须在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; 方法中调用
  64 + */
  65 ++ (void)setAppId:(NSString *)appId appKey:(NSString *)appKey appSecret:(NSString *)appSecret isTestEnvironment:(BOOL)isTestEnvironment{
  66 + CNLiveUserRequest *manager = [CNLiveUserRequest manager];
  67 + manager.appId = appId;
  68 + manager.appKey = appKey;
  69 + manager.appSecret = appSecret;
  70 + manager.isTestEnvironment = isTestEnvironment;
  71 +
  72 +}
  73 +
  74 +
  75 +/**
  76 + @abstract 发送验证码
  77 + @param type 发送验证码类型(详见CodeType)
  78 + @param mobile 手机号
  79 + @param success 成功回调
  80 + @param failure 失败回调
  81 + */
  82 ++ (void)verificationCodeType:(CNLiveCodeType)type mobile:(NSString *)mobile success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure{
  83 + NSString *url = (User_TestEnvironment)?CNLive_User_Code_Test:CNLive_User_Code;
  84 +
  85 +}
  86 +
  87 +
  88 +/**
  89 + @abstract 注册
  90 + @param userName 邮箱或手机
  91 + @param password 密码
  92 + @param verificationCode 手机验证码(手机号注册时必填)
  93 + @param invitationCode 邀请码(非必填)
  94 + @param fromId 渠道ID(非必填)
  95 + @param success 成功回调
  96 + @param failure 失败回调
  97 + */
  98 ++ (void)registerWithUserName:(NSString *)userName password:(NSString *)password verificationCode:(NSString *)verificationCode invitationCode:(NSString * _Nullable)invitationCode fromId:(NSString * _Nullable)fromId success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure{
  99 + NSString *url = (User_TestEnvironment)?CNLive_User_Register_Test:CNLive_User_Register;
  100 +
  101 +}
  102 +
  103 +
  104 +/**
  105 + @abstract 快捷登录
  106 + @param userName 手机号
  107 + @param verificationCode 验证码
  108 + @param fromId 渠道ID(非必填)
  109 + @param success 成功回调
  110 + @param failure 失败回调
  111 + */
  112 ++ (void)shortcutLoginWithUserName:(NSString *)userName verificationCode:(NSString *)verificationCode fromId:(NSString * _Nullable)fromId success:(void (^)(id))success failure :(void (^)(NSDictionary *))failure{
  113 + NSString *url = (User_TestEnvironment)?CNLive_User_SLogin_Test:CNLive_User_SLogin;
  114 +
  115 +}
  116 +
  117 +
  118 +/**
  119 + @abstract 登录
  120 + @param userName 手机号或邮箱
  121 + @param password 密码
  122 + @param fromId 渠道ID(非必填)
  123 + @param success 成功回调
  124 + @param failure 失败回调
  125 + */
  126 ++ (void)loginWithUserName:(NSString *)userName password:(NSString *)password fromId:(NSString * _Nullable)fromId success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure{
  127 + NSString *url = (User_TestEnvironment)?CNLive_User_Login_Test:CNLive_User_Login;
  128 +
  129 +}
  130 +
  131 +
  132 +/**
  133 + @abstract 修改用户单项信息
  134 + @param type 修改类型(name-昵称, sex-性别, tel-手机号, head-头像, introduction-简介)
  135 + @param uid 用户ID
  136 + @param info 对应的信息(注sex对应f/m/n)
  137 + @param success 成功回调
  138 + @param failure 失败回调
  139 + */
  140 ++ (void)updateUserInfoType:(CNLiveUserInfoType)type uid:(NSString *)uid info:(NSString *)info success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure {
  141 + NSString *url = (User_TestEnvironment)?CNLive_User_Update_Test:CNLive_User_Update;
  142 +
  143 +}
  144 +
  145 +@end
Example/CNLiveServices/Login/Model/CNLiveUserTypeDef.h 0 → 100644
  1 +//
  2 +// CNLiveUserTypeDef.h
  3 +// CNLiveServices_Example
  4 +//
  5 +// Created by CNLive-zxw on 2019/8/8.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#ifndef CNLiveUserTypeDef_h
  10 +#define CNLiveUserTypeDef_h
  11 +
  12 +// 获取验证码
  13 +typedef NS_ENUM(NSUInteger, CNLiveCodeType) {
  14 + CNLiveCodeTypeShortcutLogin = 0, //快捷登录
  15 + CNLiveCodeTypeRegister, //注册
  16 + CNLiveCodeTypeUpdateTel, //修改手机号
  17 + CNLiveCodeTypeRetrievePassword //找回或修改密码
  18 +};
  19 +
  20 +
  21 +// 修改单项用户信息类型
  22 +typedef NS_ENUM(NSUInteger, CNLiveUserInfoType) {
  23 + CNLiveUserInfoTypeTel = 0, //手机号
  24 + CNLiveUserInfoTypeName, //昵称
  25 + CNLiveUserInfoTypeHead, //头像
  26 + CNLiveUserInfoTypeSex, //性别
  27 + CNLiveUserInfoTypeIntroduction //简介
  28 +
  29 +};
  30 +
  31 +#endif /* CNLiveUserTypeDef_h */
Example/CNLiveServices/Login/Model/CNLiveUserUrl.h 0 → 100644
  1 +//
  2 +// CNLiveUserUrl.h
  3 +// CNLiveServices_Example
  4 +//
  5 +// Created by CNLive-zxw on 2019/9/2.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
  7 +//
  8 +
  9 +#ifndef CNLiveUserUrl_h
  10 +#define CNLiveUserUrl_h
  11 +
  12 +// 获取验证码
  13 +#define CNLive_User_Code @""
  14 +#define CNLive_User_Code_Test @""
  15 +
  16 +// 登录
  17 +#define CNLive_User_Register @""
  18 +#define CNLive_User_Register_Test @""
  19 +
  20 +// 快捷登录
  21 +#define CNLive_User_SLogin @""
  22 +#define CNLive_User_SLogin_Test @""
  23 +
  24 +// 登录
  25 +#define CNLive_User_Login @""
  26 +#define CNLive_User_Login_Test @""
  27 +
  28 +// 更新
  29 +#define CNLive_User_Update @""
  30 +#define CNLive_User_Update_Test @""
  31 +
  32 +
  33 +#endif /* CNLiveUserUrl_h */
Example/CNLiveServices/UserAgreement/CNUserAgreementManager.m
@@ -8,6 +8,8 @@ @@ -8,6 +8,8 @@
8 8
9 #import "CNUserAgreementManager.h" 9 #import "CNUserAgreementManager.h"
10 #import "CNUserAgreementWebController.h" 10 #import "CNUserAgreementWebController.h"
  11 +#import "CNLiveNetworking.h"
  12 +#import "CNLiveEnvironment.h"
11 13
12 @BeeHiveService(CNLiveUserAgreementServiceProtocol,CNUserAgreementManager) 14 @BeeHiveService(CNLiveUserAgreementServiceProtocol,CNUserAgreementManager)
13 @interface CNUserAgreementManager ()<CNLiveUserAgreementServiceProtocol> 15 @interface CNUserAgreementManager ()<CNLiveUserAgreementServiceProtocol>
@@ -86,172 +88,171 @@ static CNUserAgreementManager *_instance = nil; @@ -86,172 +88,171 @@ static CNUserAgreementManager *_instance = nil;
86 } 88 }
87 89
88 - (void)getAgreementH5WithType:(CNGetAgreementH5Type)type success:(SuccessBlock)success failure:(FailureBlock)failure { 90 - (void)getAgreementH5WithType:(CNGetAgreementH5Type)type success:(SuccessBlock)success failure:(FailureBlock)failure {
89 - // [CNLiveNetworking setAllowRequestDefaultArgument:NO];  
90 - // [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNGetAgreementH5Url Param:@{} CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {  
91 - // if (error) {  
92 - // if (failure) {  
93 - // failure(error);  
94 - // }  
95 - // }  
96 - // else{  
97 - // if ([responseObject isKindOfClass:[NSArray class]]) {  
98 - //  
99 - // for (NSDictionary *dic in responseObject) {  
100 - //  
101 - // switch (type) {  
102 - // case CNAgreementUser:  
103 - // {  
104 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yhxy"]) {  
105 - // if (success) {  
106 - // success(dic[@"detailUrl"],dic[@"title"]);  
107 - // return ;  
108 - // }  
109 - // }  
110 - // }  
111 - // break;  
112 - // case CNAgreementPrivacy:  
113 - // {  
114 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yszc"]) {  
115 - // if (success) {  
116 - // success(dic[@"detailUrl"],dic[@"title"]);  
117 - // return ;  
118 - // }  
119 - // }  
120 - // }  
121 - // break;  
122 - // case CNAgreementHelp:  
123 - // {  
124 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"bzfk"]) {  
125 - // if (success) {  
126 - // success(dic[@"detailUrl"],dic[@"title"]);  
127 - // return ;  
128 - // }  
129 - // }  
130 - // }  
131 - // break;  
132 - // case CNAgreementUnderstand:  
133 - // {  
134 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"ljwjj"]) {  
135 - // if (success) {  
136 - // success(dic[@"detailUrl"],dic[@"title"]);  
137 - // return ;  
138 - // }  
139 - // }  
140 - // }  
141 - // break;  
142 - // case CNAgreementIntroduction:  
143 - // {  
144 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yyjj"]) {  
145 - // if (success) {  
146 - // success(dic[@"detailUrl"],dic[@"title"]);  
147 - // return ;  
148 - // }  
149 - // }  
150 - // }  
151 - // break;  
152 - // case CNAgreementCopyright:  
153 - // {  
154 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"bqxx"]) {  
155 - // if (success) {  
156 - // success(dic[@"detailUrl"],dic[@"title"]);  
157 - // return ;  
158 - // }  
159 - // }  
160 - // }  
161 - // break;  
162 - // case CNAgreementPermission:  
163 - // {  
164 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"rjxkxy"]) {  
165 - // if (success) {  
166 - // success(dic[@"detailUrl"],dic[@"title"]);  
167 - // return ;  
168 - // }  
169 - // }  
170 - // }  
171 - // break;  
172 - // case CNAgreementIntegralRules:  
173 - // {  
174 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"jfgz"]) {  
175 - // if (success) {  
176 - // success(dic[@"detailUrl"],dic[@"title"]);  
177 - // return ;  
178 - // }  
179 - // }  
180 - // }  
181 - // break;  
182 - // case CNAgreementSigninRules:  
183 - // {  
184 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"jfjlgz"]) {  
185 - // if (success) {  
186 - // success(dic[@"detailUrl"],dic[@"title"]);  
187 - // return ;  
188 - // }  
189 - // }  
190 - // }  
191 - // break;  
192 - // case CNAgreementReviewApply:  
193 - // {  
194 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"shsqxy"]) {  
195 - // if (success) {  
196 - // success(dic[@"detailUrl"],dic[@"title"]);  
197 - // return ;  
198 - // }  
199 - // }  
200 - // }  
201 - // break;  
202 - // case CNAgreementCancellation:  
203 - // {  
204 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"zxxz"]) {  
205 - // if (success) {  
206 - // success(dic[@"detailUrl"],dic[@"title"]);  
207 - // return ;  
208 - // }  
209 - // }  
210 - // }  
211 - // break;  
212 - // case CNAgreementEmojiService:  
213 - // {  
214 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"fwsm"]) {  
215 - // if (success) {  
216 - // success(dic[@"detailUrl"],dic[@"title"]);  
217 - // return ;  
218 - // }  
219 - // }  
220 - // }  
221 - // break;  
222 - // case CNAgreementEmojiComplaints:  
223 - // {  
224 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"tssm"]) {  
225 - // if (success) {  
226 - // success(dic[@"detailUrl"],dic[@"title"]);  
227 - // return ;  
228 - // }  
229 - // }  
230 - // }  
231 - // break;  
232 - // case CNAgreementEnterpriseQualification:  
233 - // {  
234 - // if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"qyzz"]) {  
235 - // if (success) {  
236 - // success(dic[@"detailUrl"],dic[@"title"]);  
237 - // return ;  
238 - // }  
239 - // }  
240 - // }  
241 - // break;  
242 - // default:  
243 - // break;  
244 - // }  
245 - //  
246 - // }  
247 - //  
248 - // }  
249 - // if (failure) {  
250 - // failure(error);  
251 - // }  
252 - // }  
253 - // }];  
254 - success(@"https://www.baidu.com", @"用户注册协议"); 91 + [CNLiveNetworking setAllowRequestDefaultArgument:NO];
  92 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNGetAgreementH5Url Param:@{} CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  93 + if (error) {
  94 + if (failure) {
  95 + failure(error);
  96 + }
  97 + }
  98 + else{
  99 + if ([responseObject isKindOfClass:[NSArray class]]) {
  100 +
  101 + for (NSDictionary *dic in responseObject) {
  102 +
  103 + switch (type) {
  104 + case CNAgreementUser:
  105 + {
  106 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yhxy"]) {
  107 + if (success) {
  108 + success(dic[@"detailUrl"],dic[@"title"]);
  109 + return ;
  110 + }
  111 + }
  112 + }
  113 + break;
  114 + case CNAgreementPrivacy:
  115 + {
  116 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yszc"]) {
  117 + if (success) {
  118 + success(dic[@"detailUrl"],dic[@"title"]);
  119 + return ;
  120 + }
  121 + }
  122 + }
  123 + break;
  124 + case CNAgreementHelp:
  125 + {
  126 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"bzfk"]) {
  127 + if (success) {
  128 + success(dic[@"detailUrl"],dic[@"title"]);
  129 + return ;
  130 + }
  131 + }
  132 + }
  133 + break;
  134 + case CNAgreementUnderstand:
  135 + {
  136 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"ljwjj"]) {
  137 + if (success) {
  138 + success(dic[@"detailUrl"],dic[@"title"]);
  139 + return ;
  140 + }
  141 + }
  142 + }
  143 + break;
  144 + case CNAgreementIntroduction:
  145 + {
  146 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"yyjj"]) {
  147 + if (success) {
  148 + success(dic[@"detailUrl"],dic[@"title"]);
  149 + return ;
  150 + }
  151 + }
  152 + }
  153 + break;
  154 + case CNAgreementCopyright:
  155 + {
  156 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"bqxx"]) {
  157 + if (success) {
  158 + success(dic[@"detailUrl"],dic[@"title"]);
  159 + return ;
  160 + }
  161 + }
  162 + }
  163 + break;
  164 + case CNAgreementPermission:
  165 + {
  166 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"rjxkxy"]) {
  167 + if (success) {
  168 + success(dic[@"detailUrl"],dic[@"title"]);
  169 + return ;
  170 + }
  171 + }
  172 + }
  173 + break;
  174 + case CNAgreementIntegralRules:
  175 + {
  176 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"jfgz"]) {
  177 + if (success) {
  178 + success(dic[@"detailUrl"],dic[@"title"]);
  179 + return ;
  180 + }
  181 + }
  182 + }
  183 + break;
  184 + case CNAgreementSigninRules:
  185 + {
  186 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"jfjlgz"]) {
  187 + if (success) {
  188 + success(dic[@"detailUrl"],dic[@"title"]);
  189 + return ;
  190 + }
  191 + }
  192 + }
  193 + break;
  194 + case CNAgreementReviewApply:
  195 + {
  196 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"shsqxy"]) {
  197 + if (success) {
  198 + success(dic[@"detailUrl"],dic[@"title"]);
  199 + return ;
  200 + }
  201 + }
  202 + }
  203 + break;
  204 + case CNAgreementCancellation:
  205 + {
  206 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"zxxz"]) {
  207 + if (success) {
  208 + success(dic[@"detailUrl"],dic[@"title"]);
  209 + return ;
  210 + }
  211 + }
  212 + }
  213 + break;
  214 + case CNAgreementEmojiService:
  215 + {
  216 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"fwsm"]) {
  217 + if (success) {
  218 + success(dic[@"detailUrl"],dic[@"title"]);
  219 + return ;
  220 + }
  221 + }
  222 + }
  223 + break;
  224 + case CNAgreementEmojiComplaints:
  225 + {
  226 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"tssm"]) {
  227 + if (success) {
  228 + success(dic[@"detailUrl"],dic[@"title"]);
  229 + return ;
  230 + }
  231 + }
  232 + }
  233 + break;
  234 + case CNAgreementEnterpriseQualification:
  235 + {
  236 + if ([[NSString stringWithFormat:@"%@",dic[@"type"]] isEqualToString:@"qyzz"]) {
  237 + if (success) {
  238 + success(dic[@"detailUrl"],dic[@"title"]);
  239 + return ;
  240 + }
  241 + }
  242 + }
  243 + break;
  244 + default:
  245 + break;
  246 + }
  247 +
  248 + }
  249 +
  250 + }
  251 + if (failure) {
  252 + failure(error);
  253 + }
  254 + }
  255 + }];
255 256
256 } 257 }
257 258
Example/CNLiveServices/UserAgreement/CNUserAgreementWebController.m
@@ -169,7 +169,6 @@ @@ -169,7 +169,6 @@
169 169
170 // 页面加载失败时调用 170 // 页面加载失败时调用
171 - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(nonnull NSError *)error{ 171 - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(nonnull NSError *)error{
172 - NSLog(@"打印这个error%@",error);  
173 172
174 } 173 }
175 174
Example/Podfile
@@ -6,6 +6,8 @@ platform :ios, &#39;9.0&#39; @@ -6,6 +6,8 @@ platform :ios, &#39;9.0&#39;
6 6
7 target 'CNLiveServices_Example' do 7 target 'CNLiveServices_Example' do
8 pod 'CNLiveServices', :path => '../' 8 pod 'CNLiveServices', :path => '../'
  9 + pod 'CNLiveRequestBastKit'
  10 + pod 'MJExtension'
9 11
10 target 'CNLiveServices_Tests' do 12 target 'CNLiveServices_Tests' do
11 inherit! :search_paths 13 inherit! :search_paths