Skip to content

Commit 075b7b5

Browse files
committed
防机器人验证码【未完】
1 parent 7a93768 commit 075b7b5

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

Coding_iOS/Util/OC_Category/NSObject+Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
+ (void)showStatusBarSuccessStr:(NSString *)tipStr;
2121
+ (void)showStatusBarErrorStr:(NSString *)errorStr;
2222
+ (void)showStatusBarError:(NSError *)error;
23+
+ (void)showCaptchaView;
2324

2425
#pragma mark BaseURL
2526
+ (NSString *)baseURLStr;

Coding_iOS/Util/OC_Category/NSObject+Common.m

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#import "AppDelegate.h"
1717
#import "MBProgressHUD+Add.h"
1818
#import "CodingNetAPIClient.h"
19+
#import <SDCAlertView/SDCAlertController.h>
20+
#import "Coding_NetAPIManager.h"
1921

2022
@implementation NSObject (Common)
2123

@@ -343,4 +345,54 @@ -(id)handleResponse:(id)responseJSON autoShowError:(BOOL)autoShowError{
343345
}
344346
return error;
345347
}
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+
346398
@end

0 commit comments

Comments
 (0)