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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
//
// 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
{
self.mobileNumberLabel.text = [NSString stringWithFormat:@"请输入%@接收到的验证码",[self phoneNumberEncryption:self.bankEntity.phoneNumber]];
self.bankNameAndCardTypeLabel.text = self.bankType;
}
#pragma mark - 发送验证码
- (void)sendVerificationCodeAction
{
WS(weakSelf);
[XBLoadingView showHUDViewWithDefault];
NSString *urlString = [NSString stringWithFormat:SERVERREQUESTURL(SENDSMSBANK),self.bankEntity.phoneNumber,[Shoppersmanager manager].shoppers.employee.userName];
[HTTP networkWithDictionaryRequestWithURL:[self returnUrlString:urlString] withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
[XBLoadingView hideHUDViewWithDefault];
if (RESULT(returnValue)) {
[XBLoadingView showHUDViewWithSuccessText:@"发送成功" completeBlock:^{
[weakSelf.sendButton startWithTime:60 title:@"获取验证码" countDownTitle:@"秒后重发" mainColor:kMainBlueColor countColor:kMainBlueColor];
}];
}else
{
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
}withFailureBlock:^(NSError *error) {
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
}
#pragma mark -汉字转码
- (NSString *)returnUrlString:(NSString *)ChineseString
{
NSString* encodedString = [ChineseString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
return encodedString;
}
#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);
[HTTP networkRequestWithURL:SERVERREQUESTURL(BINDING) withRequestType:ZERO withParameter:entity withReturnValueBlock:^(id returnValue) {
if (RESULT(returnValue)) {
[XBLoadingView showHUDViewWithSuccessText:@"绑定成功" completeBlock:^{
[weakSelf.navigationController popToRootViewControllerAnimated:YES];
}];
}else {
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
} withFailureBlock:^(NSError *error) {
[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