123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #import "UserAuthViewController.h"
- #import "UserAuthBodyView.h"
- #import "KSBaseWKWebViewController.h"
- @interface UserAuthViewController ()
- @property (nonatomic, strong) UserAuthBodyView *bodyView;
- @property (nonatomic, copy) AuthSuccessCallback callback;
- @end
- @implementation UserAuthViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self allocTitle:@"实名认证"];
- [self configUI];
- }
- - (void)configUI {
- self.bodyView = [UserAuthBodyView shareInstance];
- [self.scrollView removeFromSuperview];
- [self.view addSubview:self.bodyView];
- [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.right.bottom.left.mas_equalTo(self.view);
- }];
- MJWeakSelf;
- [self.bodyView sureAuthCall:^(BOOL toProtocalDetail) {
- if (toProtocalDetail) {
- [weakSelf toProtocalDetail];
- }
- else {
- [weakSelf authAction];
- }
- }];
- }
- - (void)toProtocalDetail {
- KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
- webCtrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST, @"/#/previewProtocol"];
- [self.navigationController pushViewController:webCtrl animated:YES];
- }
- - (void)sureCallback:(AuthSuccessCallback)callback {
- if (callback) {
- self.callback = callback;
- }
- }
- - (void)authAction {
- if ([NSString isEmptyString:self.bodyView.nameField.text]) {
- [self MBPShow:@"请输入姓名"];
- return;
- }
- else if ([NSString isEmptyString:self.bodyView.cardField.text]) {
- [self MBPShow:@"请输入身份证号"];
- return;
- }
- else if (self.bodyView.isAgree == NO) {
- [self MBPShow:@"请阅读并同意用户注册协议"];
- return;
- }
- [self showhud];
- [KSNetworkingManager realNameAuthRequest:KS_POST idCardNo:self.bodyView.cardField.text realName:self.bodyView.nameField.text success:^(NSDictionary * _Nonnull dic) {
- [self removehub];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- MJWeakSelf;
- [self KSShowMsg:@"认证成功" promptCompletion:^{
- [weakSelf backAction];
- if (self.callback) {
- self.callback();
- }
- }];
- }
- else {
- [self MBPShow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [self removehub];
- }];
- }
- @end
|