BindingSuccessViewController.m 4.08 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
//
//  BindingSuccessViewController.m
//  Lighting
//
//  Created by 曹云霄 on 2016/11/30.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "BindingSuccessViewController.h"
#import "UIButton+countDown.h"

@interface BindingSuccessViewController ()

@end

@implementation BindingSuccessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpUIAction];
    [self sendVerificationCodeAction];
}

#pragma mark - UI
- (void)setUpUIAction
{
曹云霄's avatar
曹云霄 committed
28
    self.mobileNumberLabel.text = [NSString stringWithFormat:@"请输入%@接收到的验证码",[self phoneNumberEncryption:self.bankEntity.phoneNumber]];
29 30 31 32 33 34 35 36 37
    self.bankNameAndCardTypeLabel.text = self.bankType;
}

#pragma mark - 发送验证码
- (void)sendVerificationCodeAction
{
    WS(weakSelf);
    [XBLoadingView showHUDViewWithDefault];
    //发送验证码
曹云霄's avatar
曹云霄 committed
38
    NSString *urlString = [NSString stringWithFormat:SERVERREQUESTURL(SENDSMSBANK),self.bankEntity.phoneNumber,[Shoppersmanager manager].Shoppers.employee.userName];
曹云霄's avatar
曹云霄 committed
39
    [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:[self returnUrlString:urlString]  WithRequestType:ONE WithParameter:nil WithReturnValueBlock:^(id returnValue) {
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
        [XBLoadingView hideHUDViewWithDefault];
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
            [XBLoadingView showHUDViewWithSuccessText:@"发送成功" completeBlock:^{
                [weakSelf.sendButton startWithTime:60 title:@"获取验证码" countDownTitle:@"秒后重发" mainColor:kMainBlueColor countColor:kMainBlueColor];
            }];
        }else
        {
            [XBLoadingView showHUDViewWithText:returnValue[@"message"]];
        }
    }WithFailureBlock:^(NSError *error) {
        [XBLoadingView hideHUDViewWithDefault];
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
    }];
}

曹云霄's avatar
曹云霄 committed
55 56 57 58 59 60
#pragma mark -汉字转码
- (NSString *)returnUrlString:(NSString *)ChineseString
{
    NSString* encodedString = [ChineseString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    return encodedString;
}
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118

#pragma mark - 绑定
- (IBAction)nextButtonClickAction:(UIButton *)sender {
    
    if (!self.isAgreeButton.selected) {
        [XBLoadingView showHUDViewWithText:@"需要同意用户协议"];return;
    }
    if ([[self class] isBlankString:self.verificationCodeTextField.text]) {
        [XBLoadingView showHUDViewWithText:@"验证码不能为空"];
    }
    TOBankBindEntity *entity = [[TOBankBindEntity alloc] init];
    entity.bankAccount = self.bankEntity.bankAccount;
    entity.accountName = self.bankEntity.accountName;
    entity.identityCode = self.bankEntity.identityCode;
    entity.phoneNumber = self.bankEntity.phoneNumber;
    entity.smsCode = self.verificationCodeTextField.text;
    entity.bankCardType = self.bankType;
    WS(weakSelf);
    [[NetworkRequestClassManager Manager] NetworkRequestWithURL:SERVERREQUESTURL(BINDING) WithRequestType:ZERO WithParameter:entity WithReturnValueBlock:^(id returnValue) {
        
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
            [XBLoadingView showHUDViewWithSuccessText:@"绑定成功" completeBlock:^{
                [weakSelf.navigationController popToRootViewControllerAnimated:YES];
            }];
        }else {
            [XBLoadingView showHUDViewWithText:returnValue[@"message"]];
        }
        
    } WithFailureBlock:^(NSError *error) {
        [XBLoadingView hideHUDViewWithDefault];
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
    }];
}

#pragma mark - 用户协议
- (IBAction)userAgreementButton:(UIButton *)sender {
    
}

#pragma mark - 是否同意用户协议
- (IBAction)isAgreeButtonClickAction:(UIButton *)sender {
    sender.selected = !sender.selected;
}

#pragma mark - 发送验证码
- (IBAction)sendVerificationCodeButtonClick:(UIButton *)sender {
    
    [self sendVerificationCodeAction];
}

#pragma mark - 手机号加密
- (NSString *)phoneNumberEncryption:(NSString *)phoneNumber
{
    return [phoneNumber stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
}


@end