123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- //
- // DRGetMoneyNextViewController.m
- // YouHuiProject
- //
- // Created by jcymac on 2018/6/11.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRGetMoneyNextViewController.h"
- @interface DRGetMoneyNextViewController ()<UITextFieldDelegate>
- @property (nonatomic,strong) UIView *codeView;
- @property (nonatomic,strong) UIButton *nextBtn;
- @end
- @implementation DRGetMoneyNextViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self addUI];
- [self adjustUI];
-
- [self timeAction:[self.view viewWithTag:10003]];
- }
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
- }
- - (void)configNavigationBar {
- [self.navigationBar setNavTitle:@"验证手机号"];
- self.navigationBar.backgroundColor = [UIColor changeColor];
- self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
- UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
- [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- [self.navigationBar setCustomLeftButtons:@[leftBtn]];
- }
- -(void)addUI{
- [self.view addSubview:self.codeView];
- [self.view addSubview:self.nextBtn];
- [self configNavigationBar];
- }
- -(void)adjustUI{
- [self.codeView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(FITSIZE(35));
- make.right.mas_equalTo(FITSIZE(-35));
- make.top.mas_equalTo(154);
- make.height.mas_equalTo(144);
- }];
- [self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.codeView.mas_bottom).offset(25);
- make.centerX.equalTo(self.view.mas_centerX);
- make.height.mas_equalTo(42);
- make.width.mas_equalTo(FITSIZE(250));
- }];
-
- UIView *imgView=[self.codeView viewWithTag:10001];
- UIView *textFieldView=[self.codeView viewWithTag:10002];
- UIView *timeView=[self.codeView viewWithTag:10003];
- UIView *lineView=[self.codeView viewWithTag:10004];
- [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.bottom.mas_equalTo((-41-10));
- make.width.height.mas_equalTo(18);
- }];
- [timeView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(0);
- make.centerY.equalTo(imgView.mas_centerY);
- make.width.mas_equalTo(76);
- make.height.mas_equalTo(22);
- }];
- [textFieldView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(imgView.mas_right).offset(FITSIZE(10));
- make.centerY.equalTo(imgView.mas_centerY);
- make.right.equalTo(timeView.mas_left);
- }];
- [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(imgView.mas_left);
- make.right.equalTo(timeView.mas_right);
- make.top.equalTo(imgView.mas_bottom).offset(10);
- make.height.mas_equalTo(1);
- }];
-
-
- }
- #pragma mark -事件
- -(void)timeAction:(UIButton *)sender{
- [self requestCode];
- [sender startWithTime:60 title:@"重新发送" countDownTitle:@"s" mainColor:[UIColor clearColor] countColor:[UIColor clearColor]];
- }
- #pragma mark -网络请求
- -(void)requestCode{
- //获取验证码
- NSString *url=[NSString stringWithFormat:@"%@/api/v2/users/sendCode",BaseURL];
- [DRHttp post:url params:nil success:^(id json) {
-
- } failure:^(NSError *error) {
- if (error) {
- [MBProgressHUD showMessage:@"获取失败"];
- }
- }];
-
-
- }
- -(void)requestGetMoney{
- UITextField *textField=[self.codeView viewWithTag:10002];
- if(textField.text &&![@"" isEqualToString:textField.text]) {
- NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/embodyApplication",BaseURL];
- NSDictionary *dic=@{
- @"money":self.moneyStr,
- @"code":textField.text
- };
- [DRHttp post:url params:dic success:^(id json) {
- [MBProgressHUD showMessage:@"提现成功"];
- [SVProgressHUD dismissWithDelay:1.0f];
- [self.navigationController popToRootViewControllerAnimated:YES];
- } failure:^(NSError *error) {
- if (error) {
- [MBProgressHUD showMessage:@"服务器开小差了,请稍后再试"];
- }
-
- }];
- }else{
- [MBProgressHUD showMessage:@"您的输入有误,请重新输入"];
- }
- }
- #pragma mark -代理
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
- if ([@"" isEqualToString:string]) {
- return YES;
- }
- if ([@"0123456789" rangeOfString:string].location!= NSNotFound) {
- return YES;
- }
- return NO;
- }
- #pragma mark -事件响应
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark -懒加载
- -(UIView *)codeView{
- if (!_codeView) {
- _codeView=[[UIView alloc]init];
- UIImageView *imgView=[[UIImageView alloc]init];
- UITextField *textField=[[UITextField alloc]init];
- UIButton *timeBtn=[UIButton buttonWithType:UIButtonTypeCustom];
- UIView *lineView=[[UIView alloc]init];
- imgView.tag=10001;
- textField.tag=10002;
- timeBtn.tag=10003;
- lineView.tag=10004;
- [_codeView addSubview:imgView];
- [_codeView addSubview:textField];
- [_codeView addSubview:timeBtn];
- [_codeView addSubview:lineView];
- imgView.image = [UIImage imageNamed:@"code_left"];
- textField.placeholder=@"输入验证码";
- textField.textColor=[UIColor blackColor];
- textField.font=[UIFont systemFontOfSize:14];
- textField.delegate=self;
- textField.keyboardType=UIKeyboardTypeNumberPad;
- [timeBtn setTitleColor:[UIColor YHColorWithHex:0xFF6D33] forState:UIControlStateNormal];
- timeBtn.layer.borderColor=[UIColor YHColorWithHex:0xFF6D33].CGColor;
- [timeBtn addTarget:self action:@selector(timeAction:) forControlEvents:UIControlEventTouchUpInside];
- [timeBtn setTitle:@"重新获取" forState:UIControlStateNormal];
- timeBtn.titleLabel.font=[UIFont systemFontOfSize:12];
- [timeBtn setTitleColor:[UIColor YHColorWithHex:0xFF6D33] forState:UIControlStateNormal];
- timeBtn.layer.borderWidth=1;
- timeBtn.layer.cornerRadius=11;
- timeBtn.layer.masksToBounds=YES;
- lineView.backgroundColor=[UIColor YHColorWithHex:0xD8D8D8];
- }
- return _codeView;
- }
- -(UIButton *)nextBtn{
- if (!_nextBtn) {
- _nextBtn=[UIButton buttonWithType:UIButtonTypeCustom];
- _nextBtn.layer.cornerRadius=21;
- [_nextBtn setTitle:@"完成" forState:UIControlStateNormal];
- _nextBtn.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF9000] toColor:[UIColor YHColorWithHex:0xFF5000] withWidth:FITSIZE(250)];
- [[_nextBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
- [self requestGetMoney];
- }];
- }
- return _nextBtn;
- }
- @end
|