(void)failedOnCallingAPI:(CTURLResponse *)response withErrorType:(CTAPIManagerErrorType)errorType
{
self.isLoading = NO;
if (response) {
self.response = response;
}
self.errorType = errorType;
[self removeRequestIdWithRequestID:response.requestId];
// user token 无效,重新登录
if (errorType == CTAPIManagerErrorTypeNeedLogin) {
[[NSNotificationCenter defaultCenter] postNotificationName:kCTUserTokenIllegalNotification
object:nil
userInfo:@{
kCTUserTokenNotificationUserInfoKeyManagerToContinue:self
}];
return;
}
NSString *resCode = [NSString stringWithFormat:@"%@", response.content[@"resCode"]];
if ([resCode isEqualToString:@"00100009"]
|| [resCode isEqualToString:@"05111001"]
|| [resCode isEqualToString:@"05111002"]
|| [resCode isEqualToString:@"1080002"]
) {
[[NSNotificationCenter defaultCenter] postNotificationName:kCTUserTokenIllegalNotification
object:nil
userInfo:@{
kCTUserTokenNotificationUserInfoKeyManagerToContinue:self
}];
return;
}
NSString *errorCode = [NSString stringWithFormat:@"%@", response.content[@"errorCode"]];
if ([response.content[@"errorMsg"] isEqualToString:@"invalid token"]
|| [response.content[@"errorMsg"] isEqualToString:@"access_token is required"]
|| [errorCode isEqualToString:@"BL10015"]
) {
// token 失效
[[NSNotificationCenter defaultCenter] postNotificationName:kCTUserTokenInvalidNotification
object:nil
userInfo:@{
kCTUserTokenNotificationUserInfoKeyManagerToContinue:self
}];
return;
}