add files

This commit is contained in:
lianxiang
2018-08-31 18:23:25 +08:00
parent 3efde8e0ea
commit e64e011d8f
26 changed files with 496 additions and 256 deletions
+130 -22
View File
@@ -7,6 +7,8 @@
//
#import "PassWordResetVC.h"
#import "NSTimer+Convenience.h"
#import "GiGaBaseAPiRequest.h"
@interface PassWordResetVC ()
@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextField;
@@ -15,64 +17,170 @@
@property (weak, nonatomic) IBOutlet UITextField *passNewTextField;
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
@property(nonatomic,strong) NSTimer*timer;
@property(nonatomic) NSInteger time;
@end
@implementation PassWordResetVC
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"重置密码";
// Do any additional setup after loading the view from its nib.
//self.title = @"重置密码";
[self addNavTitile:@"重置密码"];
[self confirmUI];
_time = 60;
[self.codeSendBtn addTarget:self action:@selector(codeSendBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[self.confirmBtn addTarget:self action:@selector(confirmBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)confirmUI{
UIView *phoneView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
phoneView.backgroundColor = [UIColor redColor];
UIImageView *phoneIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 5, 16, 18)];
phoneIcon.image = [UIImage imageNamed:@""];
UIImageView *phoneIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 9, 12, 22)];
phoneIcon.image = [UIImage imageNamed:@"ic_number"];
[phoneView addSubview:phoneIcon];
self.phoneNumberTextField.leftView = phoneView;
self.phoneNumberTextField.leftViewMode = UITextFieldViewModeAlways;
UIView *codeView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
codeView.backgroundColor = [UIColor redColor];
UIImageView *codeIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 5, 16, 18)];
codeIcon.image = [UIImage imageNamed:@""];
UIImageView *codeIcon = [[UIImageView alloc] initWithFrame:CGRectMake(11,13.5, 18, 13)];
codeIcon.image = [UIImage imageNamed:@"ic_note"];
[codeView addSubview:codeIcon];
self.codeTextField.leftView = codeView;
self.codeTextField.leftViewMode = UITextFieldViewModeAlways;
[self.passNewTextField setValue:[UIColor colorWithRed:153/255.0f green:153/255.0f blue:153/255.0f alpha:1] forKey:@"_placeholderLabel.textColor"];
UIView *passView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
passView.backgroundColor = [UIColor redColor];
UIImageView *passIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 5, 16, 18)];
passIcon.image = [UIImage imageNamed:@""];
UIImageView *passIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15,10, 12, 22)];
passIcon.image = [UIImage imageNamed:@"icon_key"];
[passView addSubview:passIcon];
self.passNewTextField.leftView = passView;
self.passNewTextField.leftViewMode = UITextFieldViewModeAlways;
self.confirmBtn.layer.masksToBounds = YES;
self.confirmBtn.layer.cornerRadius = self.confirmBtn.frame.size.height / 2;
}
#pragma mark - 发送短信
//短信发送
-(void)codeSendBtnAction:(UIButton *)btn{
if (self.phoneNumberTextField.text.length == 0) {
GIGA_ShowToast(@"请输入手机号");
return;
}
if (![GiGaHelper isPhoneNumber:self.phoneNumberTextField.text]) {
GIGA_ShowToast(@"请输入正确手机号");
return;
}
btn.userInteractionEnabled = NO;
[self startTimer:btn];
[self requstCode:btn];
}
//计时
-(void)startTimer:(UIButton *)btn{
if (_time>0) {
_timer = [NSTimer scheduledTimerWithTimeInterval:1 count:60 callback:^{
NSString *timeStr=[NSString stringWithFormat:@"%lds",(long)self->_time];
[btn setTitle:timeStr forState:UIControlStateNormal];
self->_time--;
if (self->_time==0) {
[self.codeSendBtn setTitle:@"发送验证码" forState:UIControlStateNormal];
self->_time =60;
btn.userInteractionEnabled = YES;
}
}];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
}
}
//获取验证码请求
-(void)requstCode:(UIButton *)btn{
if (self.phoneNumberTextField.text.length == 0) {
GIGA_ShowToast(@"请输入手机号");
return;
}
if (![GiGaHelper isPhoneNumber:self.phoneNumberTextField.text]) {
GIGA_ShowToast(@"请输入正确手机号");
return;
}
[self.view makeToastActivity:CSToastPositionCenter];
NSDictionary *params = @{@"mobile":self.phoneNumberTextField.text};
GiGaBaseAPiRequest *requst = [GiGaBaseAPiRequest initWithRequestPath:@"msg/sms/v1/retrievesendcode" method:RequestPostMethod parms:params];
[requst requstDataWithResult:^(GiGaAPIResult *result) {
btn.userInteractionEnabled = YES;
[self.view hideToastActivity];
GIGA_ShowToast(result.message);
}];
}
#pragma mark - 确认
-(void)confirmBtnAction:(UIButton *)btn{
if (self.phoneNumberTextField.text.length == 0) {
GIGA_ShowToast(@"请输入手机号");
return;
}
if (![GiGaHelper isPhoneNumber:self.phoneNumberTextField.text]) {
GIGA_ShowToast(@"请输入正确手机号");
return;
}
if (self.codeTextField.text.length == 0) {
GIGA_ShowToast(@"请输入验证码");
return;
}
if (self.passNewTextField.text.length == 0) {
GIGA_ShowToast(@"请输入新密码");
return;
}
if (!(self.passNewTextField.text.length >= 6 && self.passNewTextField.text.length <= 20)) {
GIGA_ShowToast(@"请输入6~20位新密码");
return;
}
btn.userInteractionEnabled = NO;
[self.view makeToastActivity:CSToastPositionCenter];
NSDictionary *params = @{
@"username":self.phoneNumberTextField.text,
@"password":self.passNewTextField.text,
@"verifiedCode":self.codeTextField.text
};
GiGaBaseAPiRequest *requst = [GiGaBaseAPiRequest initWithRequestPath:@"sys/v1/retrievepwd" method:RequestPostMethod parms:params];
[requst requstDataWithResult:^(GiGaAPIResult *result) {
[self.view hideToastActivity];
btn.userInteractionEnabled = YES;
if (result.success) {
GIGA_WIndowTost(result.message);
[self.navigationController popViewControllerAnimated:YES];
}
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
-(void)dealloc{
if (_timer) {
[_timer unfireTimer];
[_timer invalidate];
_timer = nil;
}
}
*/
@end