123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- //
- // SPSBPurchasersDetailsCheckIdCardViewController.m
- // 我的社保
- //
- // Created by jiaxian_he on 2021/5/19.
- //
- #import "SPSBPurchasersDetailsCheckIdCardViewController.h"
- #import "SPSBUIGeneralHeader.h"
- #import "SPSBVerificationCodeManager.h"
- #import "SPSBKeyProfile.h"
- #import "SPSBTextField.h"
- #import "SPSBVerificationProfile.h"
- #import "UIViewController+SPSBNetworkManager.h"
- @interface SPSBPurchasersDetailsCheckIdCardViewController () {
- SPSBVerificationCodeManager *_verificationCodeManager;
- SPSBTextField *_verifyTextField;
- }
- @end
- @implementation SPSBPurchasersDetailsCheckIdCardViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initData];
- [self setupUI];
- }
- - (void)initData {
- _verificationCodeManager = [[SPSBVerificationCodeManager alloc] initWithBaseController:self];
- }
- - (void)dealloc {
- [_verificationCodeManager invalidateTimer];
- }
- #pragma mark - Action
- - (void)confirmAction {
- jxh_endEdit();
- if (_verifyTextField.text.length != SPSBVerifyCodeLength) {
- [self.view showToastWithTitle:@"请输入四位验证码"];
- return;
- }
- [self checkVerificationCode];
- }
- - (void)dismissAction {
- [self hideAnimation:^(BOOL finished) {
- [self dismissViewControllerAnimated:false completion:nil];
- }];
- }
- #pragma mark - NetworkAction
- - (void)checkVerificationCode {
- @weakify(self)
- [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:@"正在加载" isLogin:true url:spsb_appUrl(SPSBUrlGetPurchasers) urlParameters:nil parameters:^NSDictionary * _Nonnull{
- return @{@"id": self->_spsb_purchasersId, @"verifyCode": self->_verifyTextField.text};
- } success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- [self hideAnimation:^(BOOL finished) {
- [self dismissViewControllerAnimated:false completion:^{
- self->_spsb_checkSuccess([NSString stringWithFormat:@"%@", data[@"data"][@"id_card"]]);
- }];
- }];
- return @"";
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- return @"加载失败";
- }];
- }
- #pragma mark - UI
- - (void)setupUI {
- self.view.backgroundColor = spsb_000000_color(SPSBPopupViewBackgroundAlpha);
-
- UIView *contentView = UIView.new;
- contentView.backgroundColor = spsb_FFFFFF_color(1.f);
- [contentView setLayerCornerRadius:10 clipToBounds:false];
- [self.view addSubview:contentView];
- [contentView makeConstraints:^(JXHConstraintMaker *make) {
- make.centerY.equalTo(0);
- make.left.equalTo(25);
- make.right.equalTo(-25);
- }];
-
- UILabel *tipsLabel = [UILabel convenienceWithFont:spsb_font(16) textColor:spsb_333333_color() limitWidth:jxh_screenWidth() - 106];
- [tipsLabel setAttributedStringWithText:@"为保护你的信息安全,需验证手机号才能查看完整信息" lineSpacing:4 lines:2];
- [contentView addSubview:tipsLabel];
- [tipsLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(28);
- make.trailing.equalTo(-28);
- make.top.equalTo(34);
- }];
-
- UILabel *phoneTitle = [UILabel convenienceWithFont:spsb_font(16) text:@"验证手机" textColor:spsb_666666_color()];
- [contentView addSubview:phoneTitle];
- [phoneTitle makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(28);
- make.top.equalTo(tipsLabel.bottom).offset(22);
- }];
- NSMutableString *phone = [[jxh_userDefaults() objectForKey:SPSBUserName] mutableCopy];
- [phone replaceCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
- UILabel *phoneLebel = [UILabel convenienceWithFont:spsb_font(16) text:phone textColor:spsb_FF5E5E_color()];
- [contentView addSubview:phoneLebel];
- [phoneLebel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(phoneTitle.trailing);
- make.centerY.equalTo(phoneTitle);
- }];
-
- UIView *textFieldView = UIView.new;
- textFieldView.backgroundColor = spsb_FFFFFF_color(1.F);
- [textFieldView setLayerBorderWidth:1 borderColor:spsb_EEEEEE_color()];
- [contentView addSubview:textFieldView];
- [textFieldView makeConstraints:^(JXHConstraintMaker *make) {
- make.top.equalTo(phoneTitle.bottom).offset(14);
- make.leading.equalTo(28);
- make.trailing.equalTo(-28);
- make.height.equalTo(45);
- }];
- UIButton *verifyCodeButton = [_verificationCodeManager createVerificationCodeButtonWithGetPhone:^NSString * _Nonnull{
- return [jxh_userDefaults() objectForKey:SPSBUserName];
- }];
- [textFieldView addSubview:verifyCodeButton];
- [verifyCodeButton makeConstraints:^(JXHConstraintMaker *make) {
- make.top.and.bottom.and.trailing.equalTo(0);
- make.width.equalTo(100);
- }];
- _verifyTextField = [SPSBTextField convenienceWithFont:spsb_font(15) placeholder:@"验证码" placeholderColor:spsb_CCCCCC_color() textColor:spsb_333333_color() clearButtonMode:UITextFieldViewModeWhileEditing returnType:UIReturnKeyDone keyboardType:UIKeyboardTypeNumberPad delegate:self];
- _verifyTextField.spsb_maxCount = SPSBVerifyCodeLength;
- [textFieldView addSubview:_verifyTextField];
- [_verifyTextField makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(13);
- make.top.and.bottom.equalTo(0);
- make.trailing.equalTo(verifyCodeButton.leading);
- }];
- UIButton *confirmButton = [UIButton convenienceWithFont:spsb_semiboldFont(16) target:self action:@selector(confirmAction)];
- [confirmButton setTitle:@"确定" titleColor:spsb_FFFFFF_color(1.f) image:nil backgroundImage:jxh_getImage(confirm_n) state:JXHButtonControlStateNormal];
- [confirmButton setBackgroundImage:jxh_getImage(confirm_h) state:JXHButtonControlStateHighlighted];
- [confirmButton setLayerCornerRadius:22.5 clipToBounds:true];
- [contentView addSubview:confirmButton];
- [confirmButton makeConstraints:^(JXHConstraintMaker *make) {
- make.top.equalTo(textFieldView.bottom).offset(28);
- make.leading.equalTo(28);
- make.trailing.equalTo(-28);
- make.height.equalTo(45);
- make.bottom.equalTo(-33);
- }];
- UIButton *cancelButton = [UIButton convenienceWithTarget:self action:@selector(dismissAction)];
- [cancelButton setImage:jxh_getImage(personal_display_idcard_cancel) state:JXHButtonControlStateNormal];
- [contentView addSubview:cancelButton];
- [cancelButton makeConstraints:^(JXHConstraintMaker *make) {
- make.top.and.trailing.equalTo(0);
- make.size.equalTo(CGSizeMake(35, 35));
- }];
- }
- @end
|