|
16 | 16 | #import "AppDelegate.h"
|
17 | 17 | #import "MBProgressHUD+Add.h"
|
18 | 18 | #import "CodingNetAPIClient.h"
|
| 19 | +#import <SDCAlertView/SDCAlertController.h> |
| 20 | +#import "Coding_NetAPIManager.h" |
19 | 21 |
|
20 | 22 | @implementation NSObject (Common)
|
21 | 23 |
|
@@ -343,4 +345,54 @@ -(id)handleResponse:(id)responseJSON autoShowError:(BOOL)autoShowError{
|
343 | 345 | }
|
344 | 346 | return error;
|
345 | 347 | }
|
| 348 | + |
| 349 | + |
| 350 | ++ (void)showCaptchaView{ |
| 351 | + SDCAlertController *alertV = [SDCAlertController alertControllerWithTitle:@"提示" message:@"亲,您操作这么快,不会是机器人吧?\n来,输个验证码先?" preferredStyle:SDCAlertControllerStyleAlert]; |
| 352 | + |
| 353 | + UITextField *textF = [UITextField new]; |
| 354 | + textF.layer.sublayerTransform = CATransform3DMakeTranslation(5, 0, 0); |
| 355 | + textF.backgroundColor = [UIColor whiteColor]; |
| 356 | + [textF doBorderWidth:0.5 color:nil cornerRadius:2.0]; |
| 357 | + |
| 358 | + UIImageView *imageV = [UIImageView new]; |
| 359 | + imageV.backgroundColor = [UIColor lightGrayColor]; |
| 360 | + imageV.contentMode = UIViewContentModeScaleAspectFit; |
| 361 | + imageV.clipsToBounds = YES; |
| 362 | + imageV.userInteractionEnabled = YES; |
| 363 | + [textF doBorderWidth:0.5 color:nil cornerRadius:2.0]; |
| 364 | + __weak typeof(imageV) weakImageV = imageV; |
| 365 | + NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@api/getCaptcha", [NSObject baseURLStr]]]; |
| 366 | + [imageV bk_whenTapped:^{ |
| 367 | + [weakImageV sd_setImageWithURL:imageURL placeholderImage:nil options:(SDWebImageRetryFailed | SDWebImageRefreshCached | SDWebImageHandleCookies)]; |
| 368 | + }]; |
| 369 | + [imageV sd_setImageWithURL:imageURL placeholderImage:nil options:(SDWebImageRetryFailed | SDWebImageRefreshCached | SDWebImageHandleCookies)]; |
| 370 | + |
| 371 | + [alertV.contentView addSubview:textF]; |
| 372 | + [alertV.contentView addSubview:imageV]; |
| 373 | + [textF mas_makeConstraints:^(MASConstraintMaker *make) { |
| 374 | + make.left.equalTo(alertV.contentView).offset(15); |
| 375 | + make.height.mas_equalTo(25); |
| 376 | + make.bottom.equalTo(alertV.contentView).offset(-10); |
| 377 | + }]; |
| 378 | + [imageV mas_makeConstraints:^(MASConstraintMaker *make) { |
| 379 | + make.right.equalTo(alertV.contentView).offset(-15); |
| 380 | + make.left.equalTo(textF.mas_right).offset(10); |
| 381 | + make.width.mas_equalTo(60); |
| 382 | + make.height.mas_equalTo(25); |
| 383 | + make.centerY.equalTo(textF); |
| 384 | + }]; |
| 385 | + [alertV addAction:[SDCAlertAction actionWithTitle:@"取消" style:SDCAlertActionStyleDefault handler:nil]]; |
| 386 | + [alertV addAction:[SDCAlertAction actionWithTitle:@"还真不是" style:SDCAlertActionStyleDefault handler:^(SDCAlertAction *action) { |
| 387 | + //校验验证码的接口。。。。 |
| 388 | + |
| 389 | + NSLog(@"textF.text ===== %@", textF.text); |
| 390 | + }]]; |
| 391 | + |
| 392 | + [alertV presentWithCompletion:^{ |
| 393 | + [textF becomeFirstResponder]; |
| 394 | + }]; |
| 395 | +} |
| 396 | + |
| 397 | + |
346 | 398 | @end
|
0 commit comments