123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- //
- // DRGetMoneyViewController.m
- // YouHuiProject
- //
- // Created by jcymac on 2018/6/5.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRGetMoneyViewController.h"
- #import "DRGetMoneyNextViewController.h"
- #import "DRToMoneyViewController.h"
- @interface DRGetMoneyViewController ()<UITextFieldDelegate>
- @property(nonatomic,strong)UIView *userView;
- @property(nonatomic,strong)UIView *moneyView;
- @property(nonatomic,strong)UIButton *getMoneyBtn;
- @property(nonatomic,strong)UILabel *bottomLabel;
- @end
- @implementation DRGetMoneyViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // self.view.backgroundColor=[UIColor YHColorWithHex:0xF2F2F2];
- self.view.backgroundColor=[UIColor whiteColor];
- [self configNavigationBar];
- [self addUI];
- [self adjustUI];
- }
- -(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]];
-
- UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
- [rightBtn setTitle:@"提现记录" forState:UIControlStateNormal];
- [rightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- rightBtn.titleLabel.font = [UIFont systemFontOfSize:14];
- [rightBtn addTarget:self action:@selector(gotoMoneyHistory) forControlEvents:UIControlEventTouchUpInside];
- [self.navigationBar setCustomRightButtons:@[rightBtn]];
-
- }
- - (void)gotoMoneyHistory {
- DRToMoneyViewController *money = [[DRToMoneyViewController alloc] init];
- [self.navigationController pushViewController:money animated:YES];
- }
- -(void)addUI{
- [self.view addSubview:self.userView];
- [self.view addSubview:self.moneyView];
- [self.view addSubview:self.getMoneyBtn];
- [self.view addSubview:self.bottomLabel];
- }
- -(void)adjustUI{
- [self.userView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(0);
- make.top.mas_equalTo(74);
- make.height.mas_equalTo(80);
- }];
- [self.moneyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(0);
- make.top.equalTo(self.userView.mas_bottom);
- make.height.mas_equalTo(144);
- }];
- [self.getMoneyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.moneyView.mas_bottom).offset(25);
- make.centerX.equalTo(self.view.mas_centerX);
- make.height.mas_equalTo(42);
- make.width.mas_equalTo(FITSIZE(250));
- }];
- [self.bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.getMoneyBtn.mas_bottom).offset(15);
- make.left.right.mas_equalTo(0);
- }];
-
- UIView *imgView=[self.userView viewWithTag:10001];
- [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(FITSIZE(15));
- make.centerY.equalTo(self.userView.mas_centerY);
- make.height.width.mas_equalTo(54);
- }];
- UIView *nameLabel=[self.userView viewWithTag:10002];
- [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(imgView.mas_right).offset(FITSIZE(14));
- make.top.equalTo(imgView.mas_top).offset(5);
- }];
- UIView *getFriendLabel=[self.userView viewWithTag:10003];
- [getFriendLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(nameLabel.mas_left);
- make.bottom.equalTo(imgView.mas_bottom).offset(-3);
- }];
-
-
-
-
-
- UIView *YView=[self.moneyView viewWithTag:20002];
- [YView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(FITSIZE(35));
- make.bottom.mas_equalTo(-41);
- make.width.mas_equalTo(25);
- }];
-
- UIView *lineView=[self.moneyView viewWithTag:20005];
- [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(YView.mas_left);
- make.right.mas_equalTo(FITSIZE(-35));
- make.top.equalTo(YView.mas_bottom);
- make.height.mas_equalTo(1);
-
- }];
- UIView *allMoneyView=[self.moneyView viewWithTag:20004];
- [allMoneyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(lineView.mas_bottom).offset(10.5f);
- make.right.mas_equalTo(lineView.mas_right);
- make.width.mas_equalTo(60);
- }];
- UIView *allowGetMoneyLabel=[self.moneyView viewWithTag:20006];
- [allowGetMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(YView.mas_left);
- make.centerY.equalTo(allMoneyView.mas_centerY);
- }];
- UIView *textView=[self.moneyView viewWithTag:20003];
- [textView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(YView.mas_right).offset(FITSIZE(5));
- make.right.equalTo(allMoneyView.mas_left).offset(FITSIZE(-5));
- make.height.mas_equalTo(YView.mas_height);
- make.top.equalTo(YView.mas_top);
- }];
-
-
- }
- #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;
- }
- if ([@"." isEqualToString:string]) {
- if (textField.text.length>0&&[textField.text rangeOfString:@"."].location==NSNotFound) {
- return YES;
- }
- }
-
- return NO;
- }
- #pragma mark -事件响应
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)setMoneyStr:(NSString *)moneyStr{
- _moneyStr=moneyStr;
- UILabel *moneyStrLabel=[self.moneyView viewWithTag:20006];
- moneyStrLabel.text=[NSString stringWithFormat:@"可提现余额 ¥%@",moneyStr];
- }
- #pragma mark -懒加载
- -(UIView *)userView{
- if (!_userView) {
- _userView=[[UIView alloc]init];
- _userView.hidden=YES;
- _userView.backgroundColor=[UIColor whiteColor];
- UIImageView *imgView=[[UIImageView alloc]init];
- imgView.layer.cornerRadius=27;
- imgView.layer.masksToBounds=YES;
- imgView.backgroundColor=[UIColor redColor];
- UILabel *nameLabel=[[UILabel alloc]init];
- nameLabel.text=@"用户名";
- [nameLabel sizeToFit];
- nameLabel.textColor=[UIColor YHColorWithHex:0x343434];
- nameLabel.font=[UIFont systemFontOfSize:16];
- UILabel *getFriendLabel=[[UILabel alloc]init];
- getFriendLabel.text=@"邀请码:------";
- [getFriendLabel sizeToFit];
- getFriendLabel.textColor=[UIColor YHColorWithHex:0x343434];
- getFriendLabel.font=[UIFont systemFontOfSize:14];
- imgView.tag=10001;
- nameLabel.tag=10002;
- getFriendLabel.tag=10003;
- [_userView addSubview:imgView];
- [_userView addSubview:nameLabel];
- [_userView addSubview:getFriendLabel];
-
- }
- return _userView;
- }
- -(UIView *)moneyView{
- if (!_moneyView) {
- _moneyView=[[UIView alloc]init];
- _moneyView.backgroundColor=[UIColor clearColor];
- UILabel *YLabel=[[UILabel alloc]init];
- YLabel.text=@"¥";
- YLabel.textColor=[UIColor YHColorWithHex:0x333333];
- YLabel.font=[UIFont systemFontOfSize:20];
- [YLabel sizeToFit];
- UITextField *textField=[[UITextField alloc]init];
- textField.placeholder=@"输入提现金额";
- textField.textColor=[UIColor blackColor];
- textField.font=[UIFont systemFontOfSize:14];
- textField.keyboardType=UIKeyboardTypeDecimalPad;
- textField.delegate=self;
- UIButton *allMoneyBtn=[UIButton buttonWithType:UIButtonTypeCustom];
- [allMoneyBtn setTitle:@"全部提现" forState:UIControlStateNormal];
- [allMoneyBtn setTitleColor:[UIColor YHColorWithHex:0xFF5200] forState:UIControlStateNormal] ;
- [[allMoneyBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
- if (self.moneyStr) {
- UITextField *textField=[self.view viewWithTag:20003];
- textField.text=self.moneyStr;
- }
- }];
- allMoneyBtn.titleLabel.font=[UIFont systemFontOfSize:12];
- [allMoneyBtn sizeToFit];
- UIView *lineView=[[UIView alloc]init];
- lineView.backgroundColor=[UIColor YHColorWithHex:0xD8D8D8];
- UILabel *allowGetMoneyLabel=[[UILabel alloc]init];
- allowGetMoneyLabel.textColor=[UIColor YHColorWithHex:0x717171];
- allowGetMoneyLabel.font=[UIFont systemFontOfSize:12];
- allowGetMoneyLabel.text=@"可提现余额 ¥-.--";
- [allowGetMoneyLabel sizeToFit];
- YLabel.tag=20002;
- textField.tag=20003;
- allMoneyBtn.tag=20004;
- lineView.tag=20005;
- allowGetMoneyLabel.tag=20006;
- [_moneyView addSubview:YLabel];
- [_moneyView addSubview:textField];
- [_moneyView addSubview:allMoneyBtn];
- [_moneyView addSubview:lineView];
- [_moneyView addSubview:allowGetMoneyLabel];
- }
- return _moneyView;
- }
- -(UIButton *)getMoneyBtn{
- if (!_getMoneyBtn) {
- _getMoneyBtn=[UIButton buttonWithType:UIButtonTypeCustom];
- _getMoneyBtn.layer.cornerRadius=21;
- [_getMoneyBtn setTitle:@"申请提现" forState:UIControlStateNormal];
- _getMoneyBtn.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF9000] toColor:[UIColor YHColorWithHex:0xFF5000] withWidth:FITSIZE(250)];
- [[_getMoneyBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
- DRGetMoneyNextViewController *vc=[[DRGetMoneyNextViewController alloc]init];
- UITextField *textFiled=[self.view viewWithTag:20003];
- vc.moneyStr=textFiled.text;
- if ([vc.moneyStr floatValue]>=10) {
- [self.navigationController pushViewController:vc animated:YES];
- }else{
- [MBProgressHUD showMessage:@"提现金额最低为10元哦"];
- }
-
- }];
- }
- return _getMoneyBtn;
- }
- -(UILabel *)bottomLabel{
- if (!_bottomLabel) {
- _bottomLabel=[[UILabel alloc]init];
- _bottomLabel.text=@"3个工作日内到账";
- _bottomLabel.textColor=[UIColor YHColorWithHex:0x666666];
- _bottomLabel.font=[UIFont systemFontOfSize:12];
- _bottomLabel.textAlignment=NSTextAlignmentCenter;
- [_bottomLabel sizeToFit];
- }
- return _bottomLabel;
- }
- @end
|