Withdraw提

2018-05-25  本文已影响9人  香蕉你个菠萝

YLWithdrawViewController.m

//
//  YLWithdrawViewController.m
//  DXYiGe
//
//  Created by JHT on 2018/5/23.
//  Copyright © 2018年 QC. All rights reserved.
//

#import "YLWithdrawViewController.h"
#import "YLWithdrawViewModel.h"
#import "YLWithdrawMainView.h"
@interface YLWithdrawViewController ()
@property (nonatomic,strong) YLWithdrawViewModel *viewModel;
@property (nonatomic,strong) YLWithdrawMainView *mainView;
@end

@implementation YLWithdrawViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"提现";
}
-(void)addChildView {
    [self.view addSubview:self.mainView];
}

-(void)updateViewConstraints {
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    [super updateViewConstraints];
}
-(YLWithdrawViewModel *)viewModel {
    if (!_viewModel) {
        _viewModel = [[YLWithdrawViewModel alloc] init];
    }
    return _viewModel;
}
-(YLWithdrawMainView *)mainView {
    if (!_mainView) {
        _mainView = [[YLWithdrawMainView alloc] initWithViewModel:self.viewModel];
    }
    return _mainView;
}
- (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.
}
*/

@end

YLWithdrawMainView.h

//
//  YLWithdrawMainView.m
//  DXYiGe
//
//  Created by JHT on 2018/5/23.
//  Copyright © 2018年 QC. All rights reserved.
//

#import "YLWithdrawMainView.h"
#import "YLWithdrawViewModel.h"
#import "YLRechargeWayCell.h"//共用
#import "YLWithdrawFootView.h"

@interface YLWithdrawMainView ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) YLWithdrawViewModel *viewModel;
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) YLWithdrawFootView *footView;
@property (nonatomic,strong) NSArray *iconArray;
@property (nonatomic,strong) NSArray *payArray;
@property (nonatomic,assign) int rechargeType;
@end


@implementation YLWithdrawMainView

-(instancetype)initWithViewModel:(id<BaseViewModelProtocol>)viewModel {
    self.viewModel = (YLWithdrawViewModel *)viewModel;
    return [super initWithViewModel:self.viewModel];
}
-(void)bindViewModel {
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.payArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 60;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    self.rechargeType = (int)indexPath.row;
    NSLog(@"rechargeType--->%d",self.rechargeType);
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section {
    return 10;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
    view.backgroundColor = RGB(240, 240, 240);
    return view;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
    view.backgroundColor = RGB(240, 240, 240);
    return view;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YLRechargeWayCell * cell  = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithUTF8String:object_getClassName([YLRechargeWayCell class])]];
    cell.nameLabel.text = self.payArray[indexPath.row];
    cell.imgView.image = [UIImage imageNamed:self.iconArray[indexPath.row]];
    
    return cell;
}

-(NSArray *)payArray {
    if (!_payArray) {
        _payArray = @[@"微信支付",@"支付宝支付"];
    }
    return _payArray;
}
-(NSArray *)iconArray {
    if (!_iconArray) {
        _iconArray = @[@"weixin",@"zhifubao"];
    }
    return _iconArray;
}

-(YLWithdrawFootView *)footView {
    if (!_footView) {
        _footView = [[YLWithdrawFootView alloc] initWithViewModel:self.viewModel];
    }
    return _footView;
}
-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:self.bounds style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerClass:[YLRechargeWayCell class] forCellReuseIdentifier:[NSString stringWithUTF8String:object_getClassName([YLRechargeWayCell class])]];
        
        self.footView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 160 + 60);
        [_tableView setTableFooterView:self.footView];
        
        _tableView.backgroundColor = RGB(240, 240, 240);
    }
    return _tableView;
}

-(void)setupViews {
    self.rechargeType = -1;
    [self addSubview:self.tableView];
    [self setNeedsUpdateConstraints];
    [self updateConstraintsIfNeeded];
}
-(void)updateConstraints {
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    [super updateConstraints];
}
- (YLWithdrawViewModel *)viewModel {
    if (!_viewModel) {
        _viewModel = [[YLWithdrawViewModel alloc] init];
    }
    return _viewModel;
}

@end

YLWithdrawFootView.h

//
//  YLWithdrawFootView.m
//  DXYiGe
//
//  Created by JHT on 2018/5/23.
//  Copyright © 2018年 QC. All rights reserved.
//

#import "YLWithdrawFootView.h"
#import "YLWithdrawViewModel.h"

@interface YLWithdrawFootView ()
@property (nonatomic,strong) YLWithdrawViewModel *viewModel;
@property (nonatomic,strong) UIView *whiteView;
@property (nonatomic,strong) UILabel *topLabel;
@property (nonatomic,strong) UILabel *yLabel;
@property (nonatomic,strong) UITextField *moneyTextfiled;
@property (nonatomic,strong) UIView *line;
@property (nonatomic,strong) UILabel *balanceLabel;//余
@property (nonatomic,strong) UIButton *rechargeBtn;
@property (nonatomic,strong) UILabel *todayWithDrawLabel;

@end

@implementation YLWithdrawFootView
-(instancetype)initWithViewModel:(id<BaseViewModelProtocol>)viewModel {
    self.viewModel = (YLWithdrawViewModel *)viewModel;
    return [super initWithViewModel:self.viewModel];
}
-(void)bindViewModel {
    
}
-(void)btnClick {
    
}
-(void)setupViews {
    self.backgroundColor = RGB(240, 240, 240);
    
    [self addSubview:self.whiteView];
    [self.whiteView addSubview:self.topLabel];
    [self.whiteView addSubview:self.yLabel];
    [self.whiteView addSubview:self.moneyTextfiled];
    [self.whiteView addSubview:self.line];
    [self.whiteView addSubview:self.balanceLabel];
    [self addSubview:self.rechargeBtn];
    [self.whiteView addSubview:self.todayWithDrawLabel];
    
    [self setNeedsUpdateConstraints];
    [self updateConstraintsIfNeeded];
}
-(void)updateConstraints {
    [self.whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.bottom.equalTo(self).offset(-60);
    }];
    [self.topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.whiteView).offset(15);
        //        make.size.mas_offset(CGSizeMake(100, 16))
        make.width.mas_offset(100);
    }];
    [self.yLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.whiteView).offset(15);
        make.top.equalTo(self.topLabel.mas_bottom).offset(25);
        //        make.width.mas_offset(15);
    }];
    [self.moneyTextfiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.yLabel);
        make.left.equalTo(self.yLabel.mas_right).offset(10);
        make.right.equalTo(self.whiteView);
    }];
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.whiteView);
        make.top.equalTo(self.moneyTextfiled.mas_bottom).offset(15);
        make.height.mas_offset(1);
    }];
    [self.balanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.whiteView).offset(16);
        make.top.equalTo(self.line.mas_bottom).offset(7);
        make.right.equalTo(self.whiteView).offset(-100);
    }];
    [self.rechargeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.whiteView.mas_bottom).offset(10);
        make.left.equalTo(self).offset(15);
        make.right.equalTo(self).offset(-15);
        make.height.mas_offset(45);
    }];
    [self.todayWithDrawLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.whiteView).offset(-15);
        make.left.equalTo(self.whiteView).offset(100);
        make.top.equalTo(self.line.mas_bottom).offset(7);
    }];
    
    [super updateConstraints];
}
-(UILabel *)todayWithDrawLabel {
    if (!_todayWithDrawLabel) {
        _todayWithDrawLabel = [[UILabel alloc] init];
        _todayWithDrawLabel.font = [UIFont systemFontOfSize:17];
        _todayWithDrawLabel.textColor = RGB(51, 51, 51);
        _todayWithDrawLabel.text = @"today..";
        _todayWithDrawLabel.textAlignment = NSTextAlignmentRight;
    }
    return _todayWithDrawLabel;
}
-(UILabel *)balanceLabel {
    if (!_balanceLabel) {
        _balanceLabel = [[UILabel alloc] init];
        _balanceLabel.font = [UIFont systemFontOfSize:17];
        _balanceLabel.textColor = RGB(153, 153, 153);
        _balanceLabel.text = @"yuee:..";
    }
    return _balanceLabel;
}
-(UIButton *)rechargeBtn {
    if (!_rechargeBtn) {
        _rechargeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_rechargeBtn setTitle:@"提现" forState:UIControlStateNormal];
        [_rechargeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _rechargeBtn.titleLabel.font = [UIFont systemFontOfSize:18.0f];
        [_rechargeBtn setBackgroundColor:RGB(255, 218, 68) forState:UIControlStateNormal];
        _rechargeBtn.layer.cornerRadius = 5.0f;
        _rechargeBtn.layer.masksToBounds = YES;
        [_rechargeBtn addTarget:self  action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _rechargeBtn;
}

-(UITextField *)moneyTextfiled {
    if (!_moneyTextfiled) {
        _moneyTextfiled = [[UITextField alloc] init];
        _moneyTextfiled.textColor = [UIColor blackColor];//46
        _moneyTextfiled.font = [UIFont systemFontOfSize:46];
        NSString *holderText = @"请输入金额";
        NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:holderText];
        [placeholder addAttribute:NSForegroundColorAttributeName
                            value:RGB(153, 153, 153)
                            range:NSMakeRange(0, holderText.length)];
        [placeholder addAttribute:NSFontAttributeName
                            value:[UIFont systemFontOfSize:15.0f]
                            range:NSMakeRange(0, holderText.length)];
        _moneyTextfiled.attributedPlaceholder = placeholder;
        _moneyTextfiled.borderStyle = UITextBorderStyleNone;
        _moneyTextfiled.backgroundColor =[UIColor whiteColor];
        _moneyTextfiled.keyboardType = UIKeyboardTypeNumberPad;
    }
    return _moneyTextfiled;
}
-(UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = RGB(240, 240, 240);
    }
    return _line;
}
-(UIView *)whiteView {
    if (!_whiteView) {
        _whiteView = [[UIView alloc] init];
        _whiteView.backgroundColor = [UIColor whiteColor];
    }
    return _whiteView;
}
-(UILabel *)yLabel {
    if (!_yLabel) {
        _yLabel = [[UILabel alloc] init];
        _yLabel.font = [UIFont systemFontOfSize:30];
        _yLabel.textColor = RGB(51, 51, 51);
        _yLabel.text = @"¥";
    }
    return _yLabel;
}
-(UILabel *)topLabel {
    if (!_topLabel) {
        _topLabel = [[UILabel alloc] init];
        _topLabel.font = [UIFont systemFontOfSize:17];
        _topLabel.textColor = RGB(51, 51, 51);
        _topLabel.text = @"提现金额";
    }
    return _topLabel;
}
- (YLWithdrawViewModel *)viewModel {
    if (!_viewModel) {
        _viewModel = [[YLWithdrawViewModel alloc] init];
    }
    return _viewModel;
}



@end

上一篇下一篇

猜你喜欢

热点阅读