@@ -323,12 +323,11 @@ -(id)handleResponse:(id)responseJSON{
323
323
-(id )handleResponse : (id )responseJSON autoShowError : (BOOL )autoShowError {
324
324
NSError *error = nil ;
325
325
// code为非0值时,表示有错
326
- NSNumber *resultCode = [responseJSON valueForKeyPath: @" code" ];
326
+ NSInteger errorCode = [( NSNumber *)[ responseJSON valueForKeyPath: @" code" ] integerValue ];
327
327
328
- if (resultCode.intValue != 0 ) {
329
- error = [NSError errorWithDomain: [NSObject baseURLStr ] code: resultCode.intValue userInfo: responseJSON];
330
-
331
- if (resultCode.intValue == 1000 || resultCode.intValue == 3207 ) {// 用户未登录
328
+ if (errorCode != 0 ) {
329
+ error = [NSError errorWithDomain: [NSObject baseURLStr ] code: errorCode userInfo: responseJSON];
330
+ if (errorCode == 1000 || errorCode == 3207 ) {// 用户未登录
332
331
if ([Login isLogin ]) {
333
332
[Login doLogout ];// 已登录的状态要抹掉
334
333
// 更新 UI 要延迟 >1.0 秒,否则屏幕可能会不响应触摸事件。。暂不知为何
@@ -338,16 +337,17 @@ -(id)handleResponse:(id)responseJSON autoShowError:(BOOL)autoShowError{
338
337
});
339
338
}
340
339
}else {
341
- NSDictionary *msgDict = [responseJSON valueForKey: @" msg" ];
342
- __block BOOL need_captcha = NO ;
343
- [[msgDict allKeys ] enumerateObjectsUsingBlock: ^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
344
- if ([obj rangeOfString: @" need_captcha" ].location != NSNotFound ) {
345
- need_captcha = YES ;
346
- }
347
- }];
348
- if (need_captcha) {
349
- [NSObject showCaptchaViewParams: nil ];
340
+ // 验证码弹窗
341
+ NSMutableDictionary *params = nil ;
342
+ if (errorCode == 907 ) {// operation_need_captcha 比如:每日新增关注用户超过 20 个
343
+ params = @{@" type" : @3 }.mutableCopy ;
344
+ }else if (errorCode == 1018 ){// user_not_get_request_too_many
345
+ params = @{@" type" : @1 }.mutableCopy ;
350
346
}
347
+ if (params) {
348
+ [NSObject showCaptchaViewParams: params];
349
+ }
350
+ // 错误提示
351
351
if (autoShowError) {
352
352
[NSObject showError: error];
353
353
}
@@ -412,6 +412,8 @@ + (void)showCaptchaViewParams:(NSMutableDictionary *)params{
412
412
[weakAlertV dismissWithCompletion: ^{
413
413
[NSObject showHudTipStr: @" 验证码正确" ];
414
414
}];
415
+ }else {
416
+ [weakImageV sd_setImageWithURL: imageURL placeholderImage: nil options: (SDWebImageRetryFailed | SDWebImageRefreshCached | SDWebImageHandleCookies)];
415
417
}
416
418
}];
417
419
}
0 commit comments