Commit 7b159796e051c7450164f8721585024dcfc9ec55

Authored by 朱林
1 parent e2b7f56f

注册或登录成功后新增返回数据,新增第三方账号绑定接口,修改头像返回头像地址

CNLiveUserSystemDemo/CNLiveUserSystemDemo/Conreollers/LoginViewController.m
... ... @@ -53,22 +53,18 @@
53 53 {
54 54 [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
55 55 [SVProgressHUD show];
56   -
57   - [CNLiveUserSystemCenter loginWithUserName:_idAndPwdView.idTF.text password:_idAndPwdView.pwdTF.text frmId:nil success:^(id result) {
  56 +
  57 + [CNLiveUserSystemCenter loginWithUserName:@"941123686@qq.com" password:@"123456" frmId:nil success:^(id result) {
58 58  
59 59 NSLog(@"登录 success------------%@",result);
60   -
61   - [Tools setUserLogin:YES];
62 60 [SVProgressHUD showSuccessWithStatus:@"登录成功"];
63 61 [UserInfoSava saveUserinfoDic:result[@"data"]];
  62 + [Tools setUserLogin:YES];
64 63 [self.navigationController popViewControllerAnimated:YES];
65   -
66   -
67   - } failure:^(NSError *error) {
68 64  
69   - [Tools toast:error.localizedDescription];
  65 + } failure:^(NSDictionary *errorDic) {
  66 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
70 67 [SVProgressHUD dismiss];
71   -
72 68 }];
73 69 }
74 70  
... ...
CNLiveUserSystemDemo/CNLiveUserSystemDemo/Conreollers/ModifyUserInfoViewController.m
... ... @@ -50,8 +50,8 @@
50 50 [SVProgressHUD showSuccessWithStatus:@"手机号修改成功"];
51 51 [self.navigationController popViewControllerAnimated:YES];
52 52  
53   - } failure:^(NSError *error) {
54   - [Tools toast:error.localizedDescription];
  53 + } failure:^(NSDictionary *errorDic) {
  54 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
55 55 [SVProgressHUD dismiss];
56 56 }];
57 57  
... ... @@ -63,10 +63,9 @@
63 63 [SVProgressHUD showSuccessWithStatus:@"修改成功"];
64 64 [self.navigationController popViewControllerAnimated:YES];
65 65  
66   - } failure:^(NSError *error) {
67   - [Tools toast:error.localizedDescription];
  66 + } failure:^(NSDictionary *errorDic) {
  67 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
68 68 [SVProgressHUD dismiss];
69   -
70 69 }];
71 70 }
72 71 }
... ... @@ -79,8 +78,8 @@
79 78  
80 79 [Tools toast:result[@"errorMessage"]];
81 80  
82   - } failure:^(NSError *error) {
83   - [Tools toast:error.localizedDescription];
  81 + } failure:^(NSDictionary *errorDic) {
  82 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
84 83 }];
85 84 }
86 85  
... ...
CNLiveUserSystemDemo/CNLiveUserSystemDemo/Conreollers/RegisterViewController.m
... ... @@ -49,8 +49,8 @@
49 49  
50 50 [Tools toast:result[@"errorMessage"]];
51 51  
52   - } failure:^(NSError *error) {
53   - [Tools toast:error.localizedDescription];
  52 + } failure:^(NSDictionary *errorDic) {
  53 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
54 54 }];
55 55  
56 56 } else if ([_type isEqualToString:@"quicklyLogin"]) {
... ... @@ -59,9 +59,8 @@
59 59  
60 60 [Tools toast:result[@"errorMessage"]];
61 61  
62   - } failure:^(NSError *error) {
63   -
64   - [Tools toast:error.localizedDescription];
  62 + } failure:^(NSDictionary *errorDic) {
  63 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
65 64 }];
66 65  
67 66 } else {
... ... @@ -70,9 +69,8 @@
70 69  
71 70 [Tools toast:result[@"errorMessage"]];
72 71  
73   - } failure:^(NSError *error) {
74   -
75   - [Tools toast:error.localizedDescription];
  72 + } failure:^(NSDictionary *errorDic) {
  73 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
76 74 }];
77 75 }
78 76 }
... ... @@ -92,11 +90,9 @@
92 90 [UserInfoSava saveUserinfoDic:result[@"data"]];
93 91 [self.navigationController popToRootViewControllerAnimated:YES];
94 92  
95   - } failure:^(NSError *error) {
96   -
97   - [Tools toast:error.localizedDescription];
  93 + } failure:^(NSDictionary *errorDic) {
98 94 [SVProgressHUD dismiss];
99   -
  95 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
100 96 }];
101 97  
102 98 } else if ([_type isEqualToString:@"quicklyLogin"]) {
... ... @@ -108,11 +104,9 @@
108 104 [UserInfoSava saveUserinfoDic:result[@"data"]];
109 105 [self.navigationController popToRootViewControllerAnimated:YES];
110 106  
111   - } failure:^(NSError *error) {
112   -
113   - [Tools toast:error.localizedDescription];
  107 + } failure:^(NSDictionary *errorDic) {
  108 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
114 109 [SVProgressHUD dismiss];
115   -
116 110 }];
117 111  
118 112 } else {
... ... @@ -121,10 +115,9 @@
121 115 [SVProgressHUD showSuccessWithStatus:@"密码修改成功"];
122 116 [self.navigationController popToRootViewControllerAnimated:YES];
123 117  
124   - } failure:^(NSError *error) {
125   - [Tools toast:error.localizedDescription];
  118 + } failure:^(NSDictionary *errorDic) {
  119 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
126 120 [SVProgressHUD dismiss];
127   -
128 121 }];
129 122 }
130 123  
... ...
CNLiveUserSystemDemo/CNLiveUserSystemDemo/Conreollers/UserInfoViewController.m
... ... @@ -193,8 +193,8 @@
193 193 NSLog(@"%@",result);
194 194 [SVProgressHUD showSuccessWithStatus:@"修改成功"];
195 195  
196   - } failure:^(NSError *error) {
197   - [Tools toast:error.localizedDescription];
  196 + } failure:^(NSDictionary *errorDic) {
  197 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
198 198 [SVProgressHUD dismiss];
199 199 }];
200 200 }
... ... @@ -227,8 +227,8 @@
227 227  
228 228 NSLog(@"%@",result);
229 229  
230   - } failure:^(NSError *error) {
231   - [Tools toast:error.localizedDescription];
  230 + } failure:^(NSDictionary *errorDic) {
  231 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
232 232 }];
233 233  
234 234 } else {
... ...
CNLiveUserSystemDemo/CNLiveUserSystemDemo/Conreollers/ViewController.m
... ... @@ -132,8 +132,8 @@
132 132 [SVProgressHUD showSuccessWithStatus:@"更新附加信息成功"];
133 133 [self.navigationController popViewControllerAnimated:YES];
134 134  
135   - } failure:^(NSError *error) {
136   - [Tools toast:error.localizedDescription];
  135 + } failure:^(NSDictionary *errorDic) {
  136 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
137 137 [SVProgressHUD dismiss];
138 138 }];
139 139 }
... ... @@ -157,8 +157,8 @@
157 157 [_tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
158 158 [Tools toast:message];
159 159  
160   - } failure:^(NSError *error) {
161   - [Tools toast:error.localizedDescription];
  160 + } failure:^(NSDictionary *errorDic) {
  161 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
162 162 }];
163 163 }
164 164  
... ... @@ -167,8 +167,8 @@
167 167 [CNLiveUserSystemCenter feedbackWithContentId:@"11" message:@"fhsjhifkncznshfu" success:^(id result) {
168 168 [Tools toast:[NSString stringWithFormat:@"反馈--%@",result[@"errorMessage"]]];
169 169  
170   - } failure:^(NSError *error) {
171   - [Tools toast:error.localizedDescription];
  170 + } failure:^(NSDictionary *errorDic) {
  171 + [Tools toast:[NSString stringWithFormat:@"errorCode : %@ \n errorMessage : %@", errorDic[@"errorCode"],errorDic[@"errorMessage"]]];
172 172 }];
173 173 }
174 174 }
... ...
CNLiveUserSystemDemo/CNLiveUserSystemDemo/Tools/CNLiveThirdLoginManager.h
... ... @@ -14,10 +14,10 @@
14 14  
15 15 - (BOOL)handleOpenURL:(NSURL *)url;
16 16  
17   -- (void)qqLogin;
  17 +- (void)qqLoginIsBindingThirdParty:(BOOL)Binding;
18 18  
19   -- (void)weChatLogin;
  19 +- (void)weChatLoginIsBindingThirdParty:(BOOL)Binding;
20 20  
21   -- (void)sinaLogin;
  21 +- (void)sinaLoginIsBindingThirdParty:(BOOL)Binding;
22 22  
23 23 @end
... ...
CNLiveUserSystemDemo/CNLiveUserSystemDemo/Tools/CNLiveThirdLoginManager.m
... ... @@ -16,6 +16,7 @@
16 16 @interface CNLiveThirdLoginManager ()<WXApiDelegate,TencentSessionDelegate,TencentLoginDelegate,WBHttpRequestDelegate,WeiboSDKDelegate>
17 17 {
18 18 TencentOAuth *tencentOAuth;
  19 + BOOL _isBindingThird;
19 20 }
20 21  
21 22 @property (nonatomic, copy)NSString *appCode;
... ... @@ -39,7 +40,7 @@
39 40 });
40 41  
41 42 return share;
42   -
  43 +
43 44 }
44 45  
45 46 - (BOOL)handleOpenURL:(NSURL *)url
... ... @@ -56,22 +57,34 @@
56 57 return [QQApiInterface handleOpenURL:url delegate:self];
57 58  
58 59 }
59   -
  60 +
60 61 else {
61 62 return YES;
62 63 }
63 64 }
64 65  
65   --(void)qqLogin
  66 +-(void)qqLoginIsBindingThirdParty:(BOOL)Binding
66 67 {
  68 + if (Binding) {
  69 + _isBindingThird = YES;
  70 + } else {
  71 + _isBindingThird = NO;
  72 + }
  73 +
67 74 tencentOAuth = [[TencentOAuth alloc] initWithAppId:QQAppKey andDelegate:self];
68 75 NSArray *permissions = [NSArray arrayWithObjects:kOPEN_PERMISSION_GET_VIP_INFO, kOPEN_PERMISSION_GET_USER_INFO, kOPEN_PERMISSION_GET_SIMPLE_USER_INFO, nil];
69 76 [tencentOAuth authorize:permissions inSafari:NO];
70   -
  77 +
71 78 }
72 79  
73   -- (void)weChatLogin
  80 +- (void)weChatLoginIsBindingThirdParty:(BOOL)Binding
74 81 {
  82 + if (Binding) {
  83 + _isBindingThird = YES;
  84 + } else {
  85 + _isBindingThird = NO;
  86 + }
  87 +
75 88 if ([WXApi isWXAppInstalled]) {
76 89 SendAuthReq* req = [[SendAuthReq alloc] init];
77 90 req.scope = @"snsapi_userinfo";
... ... @@ -83,8 +96,14 @@
83 96 }
84 97 }
85 98  
86   -- (void)sinaLogin
  99 +- (void)sinaLoginIsBindingThirdParty:(BOOL)Binding
87 100 {
  101 +
  102 + if (Binding) {
  103 + _isBindingThird = YES;
  104 + } else {
  105 + _isBindingThird = NO;
  106 + }
88 107  
89 108 WBAuthorizeRequest *request = [WBAuthorizeRequest request];
90 109 request.redirectURI = kSinaRedirectURI;
... ... @@ -94,14 +113,14 @@
94 113 @"Other_Info_2": @[@"obj1", @"obj2"],
95 114 @"Other_Info_3": @{@"key1": @"obj1", @"key2": @"obj2"}};
96 115 [WeiboSDK sendRequest:request];
97   -
  116 +
98 117 }
99 118  
100 119 #pragma mark -- TencentSessionDelegate
101 120 //登陆完成调用
102 121 - (void)tencentDidLogin
103 122 {
104   -
  123 +
105 124 [tencentOAuth getUserInfo];
106 125 }
107 126  
... ... @@ -111,26 +130,38 @@
111 130  
112 131 NSDictionary *result = response.jsonResponse;
113 132  
114   - NSString *gender;
115   - if ([[result objectForKey:@"gender"] isEqualToString:@"女"]) {
116   - gender = @"f";
117   - } else if ([[result objectForKey:@"gender"] isEqualToString:@"女"]) {
118   - gender = @"m";
119   - } else {
120   - gender = @"n";
121   - }
122   -
123   - [CNLiveUserSystemCenter thirdPartyLoginWithThirdPartyPlatType:@"2" thirdPartyId:[tencentOAuth getUserOpenID] nickName:[result objectForKey:@"nickname"] gender:gender location:[result objectForKey:@"city"] faceUrl:[result objectForKey:@"figureurl"] frmId:nil success:^(id result) {
124   - NSLog(@"qq登录------%@",result);
  133 + if (_isBindingThird) {
125 134  
126   - [Tools setUserLogin:YES];
127   - [SVProgressHUD showSuccessWithStatus:@"登录成功"];
128   - [UserInfoSava saveUserinfoDic:result[@"data"]];
129   - [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginSuccess object:nil userInfo:nil];
  135 + UserInfoModel *model = [UserInfoModel modelWithKeyValues:[Tools getLocalUserInfo]];
  136 +
  137 + [CNLiveUserSystemCenter bindingThirdPartyWithUid:model.uid thirdPartyPlatType:@"2" thirdPartyId:[tencentOAuth getUserOpenID] success:^(id result) {
  138 + NSLog(@"绑定成功----%@",result);
  139 + } failure:^(NSDictionary *errorDic) {
  140 + NSLog(@"绑定失败----%@",errorDic);
  141 + }];
130 142  
131   - } failure:^(NSError *error) {
132   - [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginFailure object:nil userInfo:nil];
133   - }];
  143 + } else {
  144 + NSString *gender;
  145 + if ([[result objectForKey:@"gender"] isEqualToString:@"女"]) {
  146 + gender = @"f";
  147 + } else if ([[result objectForKey:@"gender"] isEqualToString:@"男"]) {
  148 + gender = @"m";
  149 + } else {
  150 + gender = @"n";
  151 + }
  152 +
  153 + [CNLiveUserSystemCenter thirdPartyLoginWithThirdPartyPlatType:@"2" thirdPartyId:[tencentOAuth getUserOpenID] nickName:[result objectForKey:@"nickname"] gender:gender location:[result objectForKey:@"city"] faceUrl:[result objectForKey:@"figureurl"] frmId:nil success:^(id result) {
  154 + NSLog(@"qq登录------%@",result);
  155 +
  156 + [Tools setUserLogin:YES];
  157 + [SVProgressHUD showSuccessWithStatus:@"登录成功"];
  158 + [UserInfoSava saveUserinfoDic:result[@"data"]];
  159 + [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginSuccess object:nil userInfo:nil];
  160 +
  161 + } failure:^(NSDictionary *errorDic) {
  162 + [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginFailure object:nil userInfo:nil];
  163 + }];
  164 + }
134 165 }
135 166  
136 167 //非网络错误导致登录失败:
... ... @@ -162,11 +193,11 @@
162 193  
163 194 SendAuthResp *authResp = (SendAuthResp *)resp;
164 195  
165   - self.appCode = temp.code;
166   -
  196 + self.appCode = temp.code;
  197 +
167 198 [self getWeChatUserInfo:authResp];
168 199  
169   - // }
  200 +// }
170 201  
171 202 }
172 203 else if (temp.errCode == -4) {
... ... @@ -217,44 +248,55 @@
217 248 if (data) {
218 249 NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
219 250  
220   - if ([[dic allKeys] containsObject:@"errcode"]) {
  251 + if (_isBindingThird) {
  252 + UserInfoModel *model = [UserInfoModel modelWithKeyValues:[Tools getLocalUserInfo]];
  253 +
  254 + [CNLiveUserSystemCenter bindingThirdPartyWithUid:model.uid thirdPartyPlatType:@"3" thirdPartyId:dic[@"openid"] success:^(id result) {
  255 + NSLog(@"绑定成功----%@",result);
  256 + } failure:^(NSDictionary *errorDic) {
  257 + NSLog(@"绑定失败----%@",errorDic);
  258 + }];
221 259  
222   - [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginFailure object:nil userInfo:nil];
223 260 } else {
224   -
225   - NSString *getGender = [dic objectForKey:@"sex"];
226   - NSString *gender;
227   - switch ([getGender intValue]) {
228   - case 0:
229   - {
230   - gender = @"n";
231   - }
232   - break;
233   - case 1:
234   - {
235   - gender = @"m";
236   - }
237   - break;
238   - case 2:
239   - {
240   - gender = @"f";
241   - }
242   - break;
243   - default:
244   - break;
245   - }
246   -
247   - [CNLiveUserSystemCenter thirdPartyLoginWithThirdPartyPlatType:@"3" thirdPartyId:[dic objectForKey:@"openid"] nickName:[dic objectForKey:@"nickname"] gender:gender location:[dic objectForKey:@"country"] faceUrl:[dic objectForKey:@"headimgurl"] frmId:nil success:^(id result) {
248   - NSLog(@"微信登录------%@",result);
  261 + if ([[dic allKeys] containsObject:@"errcode"]) {
249 262  
250   - [Tools setUserLogin:YES];
251   - [SVProgressHUD showSuccessWithStatus:@"登录成功"];
252   - [UserInfoSava saveUserinfoDic:result[@"data"]];
253   - [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginSuccess object:nil userInfo:nil];
254   -
255   - } failure:^(NSError *error) {
256 263 [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginFailure object:nil userInfo:nil];
257   - }];
  264 + } else {
  265 +
  266 + NSString *getGender = [dic objectForKey:@"sex"];
  267 + NSString *gender;
  268 + switch ([getGender intValue]) {
  269 + case 0:
  270 + {
  271 + gender = @"n";
  272 + }
  273 + break;
  274 + case 1:
  275 + {
  276 + gender = @"m";
  277 + }
  278 + break;
  279 + case 2:
  280 + {
  281 + gender = @"f";
  282 + }
  283 + break;
  284 + default:
  285 + break;
  286 + }
  287 +
  288 + [CNLiveUserSystemCenter thirdPartyLoginWithThirdPartyPlatType:@"3" thirdPartyId:[dic objectForKey:@"openid"] nickName:[dic objectForKey:@"nickname"] gender:gender location:[dic objectForKey:@"country"] faceUrl:[dic objectForKey:@"headimgurl"] frmId:nil success:^(id result) {
  289 + NSLog(@"微信登录------%@",result);
  290 +
  291 + [Tools setUserLogin:YES];
  292 + [SVProgressHUD showSuccessWithStatus:@"登录成功"];
  293 + [UserInfoSava saveUserinfoDic:result[@"data"]];
  294 + [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginSuccess object:nil userInfo:nil];
  295 +
  296 + } failure:^(NSDictionary *errorDic) {
  297 + [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginFailure object:nil userInfo:nil];
  298 + }];
  299 + }
258 300 }
259 301 }
260 302 });
... ... @@ -262,7 +304,7 @@
262 304 });
263 305 }
264 306  
265   -#pragma mark - <#mark#>
  307 +#pragma mark - sinaDelegate
266 308 - (void)didReceiveWeiboRequest:(WBBaseRequest *)request
267 309 {
268 310  
... ... @@ -293,25 +335,37 @@
293 335 if ([request.tag isEqualToString:@"userinfo"]) {
294 336 NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
295 337  
296   - NSString *gender;
297   - if ([dic objectForKey:@"gender"]) {
298   - gender = [dic objectForKey:@"gender"];
  338 + if (_isBindingThird) {
  339 +
  340 + UserInfoModel *model = [UserInfoModel modelWithKeyValues:[Tools getLocalUserInfo]];
  341 +
  342 + [CNLiveUserSystemCenter bindingThirdPartyWithUid:model.uid thirdPartyPlatType:@"1" thirdPartyId:[dic objectForKey:@"id"] success:^(id result) {
  343 + NSLog(@"绑定成功----%@",result);
  344 + } failure:^(NSDictionary *errorDic) {
  345 + NSLog(@"绑定失败----%@",errorDic);
  346 + }];
  347 +
299 348 } else {
300   - gender = @"n";
301   - }
302   -
303   - [CNLiveUserSystemCenter thirdPartyLoginWithThirdPartyPlatType:@"1" thirdPartyId:[dic objectForKey:@"id"] nickName:[dic objectForKey:@"name"] gender:gender location:[dic objectForKey:@"location"] faceUrl:[dic objectForKey:@"avatar_hd"] frmId:nil success:^(id result) {
304   - NSLog(@"微博登录------%@",result);
305 349  
306   - [Tools setUserLogin:YES];
307   - [SVProgressHUD showSuccessWithStatus:@"登录成功"];
308   - [UserInfoSava saveUserinfoDic:result[@"data"]];
309   - [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginSuccess object:nil userInfo:nil];
  350 + NSString *gender;
  351 + if ([dic objectForKey:@"gender"]) {
  352 + gender = [dic objectForKey:@"gender"];
  353 + } else {
  354 + gender = @"n";
  355 + }
310 356  
311   - } failure:^(NSError *error) {
312   - [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginFailure object:nil userInfo:nil];
313   - }];
314   -
  357 + [CNLiveUserSystemCenter thirdPartyLoginWithThirdPartyPlatType:@"1" thirdPartyId:[dic objectForKey:@"id"] nickName:[dic objectForKey:@"name"] gender:gender location:[dic objectForKey:@"location"] faceUrl:[dic objectForKey:@"avatar_hd"] frmId:nil success:^(id result) {
  358 + NSLog(@"微博登录------%@",result);
  359 +
  360 + [Tools setUserLogin:YES];
  361 + [SVProgressHUD showSuccessWithStatus:@"登录成功"];
  362 + [UserInfoSava saveUserinfoDic:result[@"data"]];
  363 + [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginSuccess object:nil userInfo:nil];
  364 +
  365 + } failure:^(NSDictionary *errorDic) {
  366 + [[NSNotificationCenter defaultCenter] postNotificationName:ThirdLoginFailure object:nil userInfo:nil];
  367 + }];
  368 + }
315 369 }
316 370 }
317 371  
... ...
CNLiveUserSystemDemo/CNLiveUserSystemDemo/Views/ThirdPartyView.h 0 → 100644
  1 +//
  2 +// ThirdPartyView.h
  3 +// CNLiveUserSystemDemo
  4 +//
  5 +// Created by iOS on 16/11/18.
  6 +// Copyright © 2016年 zhulin. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@protocol ThirdPartyViewDelegate <NSObject>
  12 +
  13 +- (void)thirdPartyBtnAction:(NSString *)title;
  14 +
  15 +@optional
  16 +- (void)cancelThirdView;
  17 +
  18 +@end
  19 +
  20 +@interface ThirdPartyView : UIView
  21 +
  22 +@property (nonatomic, assign) id<ThirdPartyViewDelegate> delegate;
  23 +
  24 +- (instancetype)initWithFrame:(CGRect)frame binding:(BOOL)binding;
  25 +
  26 +@end
... ...
CNLiveUserSystemDemo/CNLiveUserSystemDemo/Views/ThirdPartyView.m 0 → 100644
  1 +//
  2 +// ThirdPartyView.m
  3 +// CNLiveUserSystemDemo
  4 +//
  5 +// Created by iOS on 16/11/18.
  6 +// Copyright © 2016年 zhulin. All rights reserved.
  7 +//
  8 +
  9 +#import "ThirdPartyView.h"
  10 +
  11 +#define SpaceWidth (KScreenWidth-80*3)/4
  12 +@interface ThirdPartyView ()
  13 +
  14 +@property (nonatomic, strong) UIButton *weChatBtn;
  15 +@property (nonatomic, strong) UIButton *sinaBtn;
  16 +@property (nonatomic, strong) UIButton *qqBtn;
  17 +@property (nonatomic, strong) UILabel *thirdpartyLoginLbl;
  18 +@property (nonatomic, strong) UIButton *cancelBtn;
  19 +
  20 +@end
  21 +
  22 +@implementation ThirdPartyView
  23 +
  24 +- (instancetype)initWithFrame:(CGRect)frame binding:(BOOL)binding
  25 +{
  26 + self = [super initWithFrame:frame];
  27 + if (self) {
  28 + self.backgroundColor = [UIColor blackColor];
  29 + [self addSubview:self.sinaBtn];
  30 + [self addSubview:self.qqBtn];
  31 + [self addSubview:self.weChatBtn];
  32 + [self addSubview:self.thirdpartyLoginLbl];
  33 +
  34 + if (binding) {
  35 + [self addSubview:self.cancelBtn];
  36 + }
  37 + }
  38 + return self;
  39 +}
  40 +
  41 +#pragma mark - ****************action******
  42 +- (void)thirdPartyBtnAction:(UIButton *)button
  43 +{
  44 + if (self.delegate && [self.delegate respondsToSelector:@selector(thirdPartyBtnAction:)]) {
  45 + [self.delegate thirdPartyBtnAction:button.titleLabel.text];
  46 + }
  47 +}
  48 +
  49 +- (void)cancelBtnAction
  50 +{
  51 + if (self.delegate && [self.delegate respondsToSelector:@selector(cancelThirdView)]) {
  52 + [self.delegate cancelThirdView];
  53 + }
  54 +}
  55 +
  56 +#pragma mark - ****************getter******
  57 +
  58 +- (UILabel *)thirdpartyLoginLbl
  59 +{
  60 + if (!_thirdpartyLoginLbl) {
  61 + _thirdpartyLoginLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, KScreenWidth, 15)];
  62 + _thirdpartyLoginLbl.textAlignment = NSTextAlignmentCenter;
  63 + _thirdpartyLoginLbl.textColor = [UIColor orangeColor];
  64 + _thirdpartyLoginLbl.text = @"第三方平台";
  65 + _thirdpartyLoginLbl.font = [UIFont systemFontOfSize:15];
  66 + }
  67 + return _thirdpartyLoginLbl;
  68 +}
  69 +
  70 +- (UIButton *)weChatBtn
  71 +{
  72 + if (!_weChatBtn) {
  73 + _weChatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  74 + _weChatBtn.backgroundColor = [UIColor orangeColor];
  75 + [_weChatBtn setFrame:CGRectMake(SpaceWidth, 70, 80, 40)];
  76 + _weChatBtn.layer.cornerRadius = 20;
  77 + _weChatBtn.layer.masksToBounds = YES;
  78 + [_weChatBtn setTitle:@"微信" forState:UIControlStateNormal];
  79 + [_weChatBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  80 + }
  81 + return _weChatBtn;
  82 +}
  83 +
  84 +- (UIButton *)sinaBtn
  85 +{
  86 + if (!_sinaBtn) {
  87 + _sinaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  88 + _sinaBtn.backgroundColor = [UIColor orangeColor];
  89 + [_sinaBtn setFrame:CGRectMake(SpaceWidth*2+80, 70, 80, 40)];
  90 + _sinaBtn.layer.cornerRadius = 20;
  91 + _sinaBtn.layer.masksToBounds = YES;
  92 + [_sinaBtn setTitle:@"微博" forState:UIControlStateNormal];
  93 + [_sinaBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  94 + }
  95 + return _sinaBtn;
  96 +}
  97 +
  98 +- (UIButton *)qqBtn
  99 +{
  100 + if (!_qqBtn) {
  101 + _qqBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  102 + _qqBtn.backgroundColor = [UIColor orangeColor];
  103 + [_qqBtn setFrame:CGRectMake(SpaceWidth*3+80*2, 70, 80, 40)];
  104 + _qqBtn.layer.cornerRadius = 20;
  105 + _qqBtn.layer.masksToBounds = YES;
  106 + [_qqBtn setTitle:@"QQ" forState:UIControlStateNormal];
  107 + [_qqBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  108 + }
  109 + return _qqBtn;
  110 +}
  111 +
  112 +- (UIButton *)cancelBtn
  113 +{
  114 + if (!_cancelBtn) {
  115 + _cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  116 + _cancelBtn.frame = CGRectMake(self.bounds.size.width-30, 10, 20, 20);
  117 + [_cancelBtn setBackgroundImage:[UIImage imageNamed:@"cancel"] forState:UIControlStateNormal];
  118 + [_cancelBtn addTarget:self action:@selector(cancelBtnAction) forControlEvents:UIControlEventTouchUpInside];
  119 + }
  120 + return _cancelBtn;
  121 +}
  122 +
  123 +@end
... ...
CNLiveUserSystemDemo/CNLiveUserSystemSDK.framework/CNLiveUserSystemSDK 100755 → 100644
No preview for this file type
CNLiveUserSystemDemo/CNLiveUserSystemSDK.framework/Headers/CNLiveUserSystemCenter.h
... ... @@ -22,6 +22,7 @@
22 22 */
23 23 + (void)setAppId:(NSString *)appId appKey:(NSString *)appKey appSecret:(NSString *)appSecret;
24 24  
  25 +
25 26 /**
26 27 @abstract 注册
27 28 @param userName 邮箱或手机
... ... @@ -32,11 +33,12 @@
32 33 @param success 成功回调
33 34 @param failure 失败回调
34 35 */
35   -+ (void)registerWithUserName:(NSString *)userName password:(NSString *)password verificationCode:(NSString *)verificationCode invitationCode:(NSString *)invitationCode frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  36 ++ (void)registerWithUserName:(NSString *)userName password:(NSString *)password verificationCode:(NSString *)verificationCode invitationCode:(NSString *)invitationCode frmId:(NSString *)frmId success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  37 +
36 38  
37 39 /**
38 40 @abstract 第三方登录
39   - @param plat 第三方平台编号(如plat: 1:sina weibo 2:qq weibo 3:weixin 4:renren 注:如qq登录,plat=@"2")
  41 + @param plat 第三方平台编号(如plat: 1:sina weibo 2:qq 3:weixin 4:renren 注:如qq登录,plat=@"2")
40 42 @param thirdPartyId 第三方用户ID
41 43 @param nickName 用户昵称
42 44 @param gender 性别,m:男、f:女、n:未知(非必填)
... ... @@ -46,7 +48,8 @@
46 48 @param success 成功回调
47 49 @param failure 失败回调
48 50 */
49   -+ (void)thirdPartyLoginWithThirdPartyPlatType:(NSString *)plat thirdPartyId:(NSString *)thirdPartyId nickName:(NSString *)nickName gender:(NSString *)gender location:(NSString *)location faceUrl:(NSString *)faceUrl frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  51 ++ (void)thirdPartyLoginWithThirdPartyPlatType:(NSString *)plat thirdPartyId:(NSString *)thirdPartyId nickName:(NSString *)nickName gender:(NSString *)gender location:(NSString *)location faceUrl:(NSString *)faceUrl frmId:(NSString *)frmId success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  52 +
50 53  
51 54 /**
52 55 @abstract 快捷登录
... ... @@ -56,7 +59,8 @@
56 59 @param success 成功回调
57 60 @param failure 失败回调
58 61 */
59   -+ (void)shortcutLoginWithUserName:(NSString *)userName verificationCode:(NSString *)verificationCode frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  62 ++ (void)shortcutLoginWithUserName:(NSString *)userName verificationCode:(NSString *)verificationCode frmId:(NSString *)frmId success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  63 +
60 64  
61 65 /**
62 66 @abstract 登录
... ... @@ -66,7 +70,8 @@
66 70 @param success 成功回调
67 71 @param failure 失败回调
68 72 */
69   -+ (void)loginWithUserName:(NSString *)userName password:(NSString *)password frmId:(NSString *)frmId success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  73 ++ (void)loginWithUserName:(NSString *)userName password:(NSString *)password frmId:(NSString *)frmId success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  74 +
70 75  
71 76 /**
72 77 @abstract 发送验证码
... ... @@ -75,7 +80,8 @@
75 80 @param success 成功回调
76 81 @param failure 失败回调
77 82 */
78   -+ (void)verificationCodeType:(VerificationCodeType)type mobile:(NSString *)mobile success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  83 ++ (void)verificationCodeType:(VerificationCodeType)type mobile:(NSString *)mobile success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  84 +
79 85  
80 86 /**
81 87 @abstract 更新用户附加信息
... ... @@ -84,7 +90,8 @@
84 90 @param success 成功回调
85 91 @param failure 失败回调
86 92 */
87   -+ (void)updateOtherInfoWithUid:(NSString *)uid extInfo:(NSString *)extInfo success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  93 ++ (void)updateOtherInfoWithUid:(NSString *)uid extInfo:(NSString *)extInfo success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  94 +
88 95  
89 96 /**
90 97 @abstract 修改用户单项信息
... ... @@ -94,7 +101,8 @@
94 101 @param success 成功回调
95 102 @param failure 失败回调
96 103 */
97   -+ (void)modifyUserInfoType:(UserInfoType)type uid:(NSString *)uid modifyInfo:(NSString *)info success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  104 ++ (void)modifyUserInfoType:(UserInfoType)type uid:(NSString *)uid modifyInfo:(NSString *)info success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  105 +
98 106  
99 107 /**
100 108 @abstract 更新手机号
... ... @@ -104,7 +112,19 @@
104 112 @param success 成功回调
105 113 @param failure 失败回调
106 114 */
107   -+ (void)updateMobileWithUid:(NSString *)uid mobile:(NSString *)mobile verificationCode:(NSString *)verificationCode success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  115 ++ (void)updateMobileWithUid:(NSString *)uid mobile:(NSString *)mobile verificationCode:(NSString *)verificationCode success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  116 +
  117 +
  118 +/**
  119 + @abstract 绑定第三方账号
  120 + @param uid 用户ID
  121 + @param plat 第三方平台编号(如platform: 1:sina weibo 2:qq 3:weixin 4:renren 注:如绑定qq,thirdPartyPlat = @"2")
  122 + @param thirdPartyId 第三方用户ID
  123 + @param success 成功回调
  124 + @param failure 失败回调
  125 + */
  126 ++ (void)bindingThirdPartyWithUid:(NSString *)uid thirdPartyPlatType:(NSString *)plat thirdPartyId:(NSString *)thirdPartyId success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  127 +
108 128  
109 129 /**
110 130 @abstract 修改密码(通过手机号修改)
... ... @@ -114,7 +134,8 @@
114 134 @param success 成功回调
115 135 @param failure 失败回调
116 136 */
117   -+ (void)changePasswordWithMobile:(NSString *)mobile verificationCode:(NSString *)verificationCode newPassword:(NSString *)newPassword success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  137 ++ (void)changePasswordWithMobile:(NSString *)mobile verificationCode:(NSString *)verificationCode newPassword:(NSString *)newPassword success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  138 +
118 139  
119 140 /**
120 141 @abstract 上传头像
... ... @@ -123,7 +144,8 @@
123 144 @param success 成功回调
124 145 @param failure 失败回调
125 146 */
126   -+ (void)uploadIconWithUid:(NSString *)uid icon:(UIImage *)icon success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  147 ++ (void)uploadIconWithUid:(NSString *)uid icon:(UIImage *)icon success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  148 +
127 149  
128 150 /**
129 151 @abstract 查询用户信息
... ... @@ -132,7 +154,8 @@
132 154 @param success 成功回调
133 155 @param failure 失败回调
134 156 */
135   -+ (void)queryUserInfoWithUid:(NSString *)uid srcUid:(NSString *)srcUid success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  157 ++ (void)queryUserInfoWithUid:(NSString *)uid srcUid:(NSString *)srcUid success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  158 +
136 159  
137 160 /**
138 161 @abstract 用户反馈
... ... @@ -141,7 +164,8 @@
141 164 @param success 成功回调
142 165 @param failure 失败回调
143 166 */
144   -+ (void)feedbackWithContentId:(NSString *)contentId message:(NSString *)message success:(void (^)(id result))success failure :(void (^)(NSError *error))failure;
  167 ++ (void)feedbackWithContentId:(NSString *)contentId message:(NSString *)message success:(void (^)(id result))success failure:(void (^)(NSDictionary *errorDic))failure;
  168 +
145 169  
146 170 /**
147 171 * 获取SDK版本号
... ...
CNLiveUserSystemDemo/CNLiveUserSystemSDK.framework/Info.plist
No preview for this file type