UserAuthViewController.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // UserAuthViewController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/5/27.
  6. //
  7. #import "UserAuthViewController.h"
  8. #import "UserAuthBodyView.h"
  9. #import "KSBaseWKWebViewController.h"
  10. @interface UserAuthViewController ()
  11. @property (nonatomic, strong) UserAuthBodyView *bodyView;
  12. @property (nonatomic, copy) AuthSuccessCallback callback;
  13. @end
  14. @implementation UserAuthViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. // Do any additional setup after loading the view.
  18. [self allocTitle:@"实名认证"];
  19. [self configUI];
  20. }
  21. - (void)configUI {
  22. self.bodyView = [UserAuthBodyView shareInstance];
  23. [self.scrollView removeFromSuperview];
  24. [self.view addSubview:self.bodyView];
  25. [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.top.right.bottom.left.mas_equalTo(self.view);
  27. }];
  28. MJWeakSelf;
  29. [self.bodyView sureAuthCall:^(BOOL toProtocalDetail) {
  30. if (toProtocalDetail) {
  31. [weakSelf toProtocalDetail];
  32. }
  33. else {
  34. [weakSelf authAction];
  35. }
  36. }];
  37. }
  38. - (void)toProtocalDetail {
  39. KSBaseWKWebViewController *webCtrl = [[KSBaseWKWebViewController alloc] init];
  40. webCtrl.url = [NSString stringWithFormat:@"%@%@",WEBHOST, @"/#/previewProtocol"];
  41. [self.navigationController pushViewController:webCtrl animated:YES];
  42. }
  43. - (void)sureCallback:(AuthSuccessCallback)callback {
  44. if (callback) {
  45. self.callback = callback;
  46. }
  47. }
  48. - (void)authAction {
  49. if ([NSString isEmptyString:self.bodyView.nameField.text]) {
  50. [self MBPShow:@"请输入姓名"];
  51. return;
  52. }
  53. else if ([NSString isEmptyString:self.bodyView.cardField.text]) {
  54. [self MBPShow:@"请输入身份证号"];
  55. return;
  56. }
  57. else if (self.bodyView.isAgree == NO) {
  58. [self MBPShow:@"请阅读并同意用户注册协议"];
  59. return;
  60. }
  61. [self showhud];
  62. [KSNetworkingManager realNameAuthRequest:KS_POST idCardNo:self.bodyView.cardField.text realName:self.bodyView.nameField.text success:^(NSDictionary * _Nonnull dic) {
  63. [self removehub];
  64. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  65. MJWeakSelf;
  66. [self KSShowMsg:@"认证成功" promptCompletion:^{
  67. [weakSelf backAction];
  68. if (self.callback) {
  69. self.callback();
  70. }
  71. }];
  72. }
  73. else {
  74. [self MBPShow:MESSAGEKEY];
  75. }
  76. } faliure:^(NSError * _Nonnull error) {
  77. [self removehub];
  78. }];
  79. }
  80. /*
  81. #pragma mark - Navigation
  82. // In a storyboard-based application, you will often want to do a little preparation before navigation
  83. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  84. // Get the new view controller using [segue destinationViewController].
  85. // Pass the selected object to the new view controller.
  86. }
  87. */
  88. @end