SPSBPurchasersDetailsCheckIdCardViewController.m 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //
  2. // SPSBPurchasersDetailsCheckIdCardViewController.m
  3. // 我的社保
  4. //
  5. // Created by jiaxian_he on 2021/5/19.
  6. //
  7. #import "SPSBPurchasersDetailsCheckIdCardViewController.h"
  8. #import "SPSBUIGeneralHeader.h"
  9. #import "SPSBVerificationCodeManager.h"
  10. #import "SPSBKeyProfile.h"
  11. #import "SPSBTextField.h"
  12. #import "SPSBVerificationProfile.h"
  13. #import "UIViewController+SPSBNetworkManager.h"
  14. @interface SPSBPurchasersDetailsCheckIdCardViewController () {
  15. SPSBVerificationCodeManager *_verificationCodeManager;
  16. SPSBTextField *_verifyTextField;
  17. }
  18. @end
  19. @implementation SPSBPurchasersDetailsCheckIdCardViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. [self initData];
  23. [self setupUI];
  24. }
  25. - (void)initData {
  26. _verificationCodeManager = [[SPSBVerificationCodeManager alloc] initWithBaseController:self];
  27. }
  28. - (void)dealloc {
  29. [_verificationCodeManager invalidateTimer];
  30. }
  31. #pragma mark - Action
  32. - (void)confirmAction {
  33. jxh_endEdit();
  34. if (_verifyTextField.text.length != SPSBVerifyCodeLength) {
  35. [self.view showToastWithTitle:@"请输入四位验证码"];
  36. return;
  37. }
  38. [self checkVerificationCode];
  39. }
  40. - (void)dismissAction {
  41. [self hideAnimation:^(BOOL finished) {
  42. [self dismissViewControllerAnimated:false completion:nil];
  43. }];
  44. }
  45. #pragma mark - NetworkAction
  46. - (void)checkVerificationCode {
  47. @weakify(self)
  48. [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:@"正在加载" isLogin:true url:spsb_appUrl(SPSBUrlGetPurchasers) urlParameters:nil parameters:^NSDictionary * _Nonnull{
  49. return @{@"id": self->_spsb_purchasersId, @"verifyCode": self->_verifyTextField.text};
  50. } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
  51. @strongify(self)
  52. [self hideAnimation:^(BOOL finished) {
  53. [self dismissViewControllerAnimated:false completion:^{
  54. self->_spsb_checkSuccess([NSString stringWithFormat:@"%@", data[@"data"][@"id_card"]]);
  55. }];
  56. }];
  57. return @"";
  58. } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
  59. return @"加载失败";
  60. }];
  61. }
  62. #pragma mark - UI
  63. - (void)setupUI {
  64. self.view.backgroundColor = spsb_000000_color(SPSBPopupViewBackgroundAlpha);
  65. UIView *contentView = UIView.new;
  66. contentView.backgroundColor = spsb_FFFFFF_color(1.f);
  67. [contentView setLayerCornerRadius:10 clipToBounds:false];
  68. [self.view addSubview:contentView];
  69. [contentView makeConstraints:^(JXHConstraintMaker *make) {
  70. make.centerY.equalTo(0);
  71. make.left.equalTo(25);
  72. make.right.equalTo(-25);
  73. }];
  74. UILabel *tipsLabel = [UILabel convenienceWithFont:spsb_font(16) textColor:spsb_333333_color() limitWidth:jxh_screenWidth() - 106];
  75. [tipsLabel setAttributedStringWithText:@"为保护你的信息安全,需验证手机号才能查看完整信息" lineSpacing:4 lines:2];
  76. [contentView addSubview:tipsLabel];
  77. [tipsLabel makeConstraints:^(JXHConstraintMaker *make) {
  78. make.leading.equalTo(28);
  79. make.trailing.equalTo(-28);
  80. make.top.equalTo(34);
  81. }];
  82. UILabel *phoneTitle = [UILabel convenienceWithFont:spsb_font(16) text:@"验证手机" textColor:spsb_666666_color()];
  83. [contentView addSubview:phoneTitle];
  84. [phoneTitle makeConstraints:^(JXHConstraintMaker *make) {
  85. make.leading.equalTo(28);
  86. make.top.equalTo(tipsLabel.bottom).offset(22);
  87. }];
  88. NSMutableString *phone = [[jxh_userDefaults() objectForKey:SPSBUserName] mutableCopy];
  89. [phone replaceCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
  90. UILabel *phoneLebel = [UILabel convenienceWithFont:spsb_font(16) text:phone textColor:spsb_FF5E5E_color()];
  91. [contentView addSubview:phoneLebel];
  92. [phoneLebel makeConstraints:^(JXHConstraintMaker *make) {
  93. make.leading.equalTo(phoneTitle.trailing);
  94. make.centerY.equalTo(phoneTitle);
  95. }];
  96. UIView *textFieldView = UIView.new;
  97. textFieldView.backgroundColor = spsb_FFFFFF_color(1.F);
  98. [textFieldView setLayerBorderWidth:1 borderColor:spsb_EEEEEE_color()];
  99. [contentView addSubview:textFieldView];
  100. [textFieldView makeConstraints:^(JXHConstraintMaker *make) {
  101. make.top.equalTo(phoneTitle.bottom).offset(14);
  102. make.leading.equalTo(28);
  103. make.trailing.equalTo(-28);
  104. make.height.equalTo(45);
  105. }];
  106. UIButton *verifyCodeButton = [_verificationCodeManager createVerificationCodeButtonWithGetPhone:^NSString * _Nonnull{
  107. return [jxh_userDefaults() objectForKey:SPSBUserName];
  108. }];
  109. [textFieldView addSubview:verifyCodeButton];
  110. [verifyCodeButton makeConstraints:^(JXHConstraintMaker *make) {
  111. make.top.and.bottom.and.trailing.equalTo(0);
  112. make.width.equalTo(100);
  113. }];
  114. _verifyTextField = [SPSBTextField convenienceWithFont:spsb_font(15) placeholder:@"验证码" placeholderColor:spsb_CCCCCC_color() textColor:spsb_333333_color() clearButtonMode:UITextFieldViewModeWhileEditing returnType:UIReturnKeyDone keyboardType:UIKeyboardTypeNumberPad delegate:self];
  115. _verifyTextField.spsb_maxCount = SPSBVerifyCodeLength;
  116. [textFieldView addSubview:_verifyTextField];
  117. [_verifyTextField makeConstraints:^(JXHConstraintMaker *make) {
  118. make.leading.equalTo(13);
  119. make.top.and.bottom.equalTo(0);
  120. make.trailing.equalTo(verifyCodeButton.leading);
  121. }];
  122. UIButton *confirmButton = [UIButton convenienceWithFont:spsb_semiboldFont(16) target:self action:@selector(confirmAction)];
  123. [confirmButton setTitle:@"确定" titleColor:spsb_FFFFFF_color(1.f) image:nil backgroundImage:jxh_getImage(confirm_n) state:JXHButtonControlStateNormal];
  124. [confirmButton setBackgroundImage:jxh_getImage(confirm_h) state:JXHButtonControlStateHighlighted];
  125. [confirmButton setLayerCornerRadius:22.5 clipToBounds:true];
  126. [contentView addSubview:confirmButton];
  127. [confirmButton makeConstraints:^(JXHConstraintMaker *make) {
  128. make.top.equalTo(textFieldView.bottom).offset(28);
  129. make.leading.equalTo(28);
  130. make.trailing.equalTo(-28);
  131. make.height.equalTo(45);
  132. make.bottom.equalTo(-33);
  133. }];
  134. UIButton *cancelButton = [UIButton convenienceWithTarget:self action:@selector(dismissAction)];
  135. [cancelButton setImage:jxh_getImage(personal_display_idcard_cancel) state:JXHButtonControlStateNormal];
  136. [contentView addSubview:cancelButton];
  137. [cancelButton makeConstraints:^(JXHConstraintMaker *make) {
  138. make.top.and.trailing.equalTo(0);
  139. make.size.equalTo(CGSizeMake(35, 35));
  140. }];
  141. }
  142. @end