您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页recharge

recharge

来源:二三四教育网

vc

#import "YLRechargeViewController.h"
#import "YLRechargeMainView.h"
#import "YLRechargeViewModel.h"

@interface YLRechargeViewController ()
@property (nonatomic,strong) YLRechargeMainView *mainView;
@property (nonatomic,strong) YLRechargeViewModel *viewModel;
@end

@implementation YLRechargeViewController

- (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];
}
-(YLRechargeMainView *)mainView {
    if (!_mainView) {
        _mainView = [[YLRechargeMainView alloc] initWithViewModel:self.viewModel];
    }
    return _mainView;
}
-(YLRechargeViewModel *)viewModel {
    if (!_viewModel) {
        _viewModel = [[YLRechargeViewModel alloc] init];
    }
    return _viewModel;
}

mainView

#import "YLRechargeMainView.h"
#import "YLRechargeViewModel.h"
#import "YLRechargeFootView.h"
#import "YLRechargeWayCell.h"

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

@implementation YLRechargeMainView
-(instancetype)initWithViewModel:(id<BaseViewModelProtocol>)viewModel {
    self.viewModel = (YLRechargeViewModel *)viewModel;
    return [super initWithViewModel:self.viewModel];
}
-(void)bindViewModel {
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}
-(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;
}

-(YLRechargeFootView *)footView {
    if (!_footView) {
        _footView = [[YLRechargeFootView 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];
}

- (YLRechargeViewModel *)viewModel {
    if (!_viewModel) {
        _viewModel = [[YLRechargeViewModel alloc] init];
    }
    return _viewModel;
}

waycell

@interface YLRechargeWayCell ()

//@property (nonatomic,strong) UILabel *nameLabel;
//@property (nonatomic,strong) UIImageView *imgView;
//@property (nonatomic,strong) UILabel *rightLabel;

@property (nonatomic,strong) UIButton *selectBtn;
@property (nonatomic,strong) UIView *line;
@end

@implementation YLRechargeWayCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(void)setupViews {
    [self addSubview:self.nameLabel];
    [self addSubview:self.imgView];
    [self addSubview:self.selectBtn];
    [self addSubview:self.line];
    [self addSubview:self.rightLabel];
    [self setNeedsUpdateConstraints];
    [self updateConstraintsIfNeeded];
}
-(void)updateConstraints {
    

    [self.selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(15);
        make.size.mas_offset(CGSizeMake(17, 17));
    }];
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self.selectBtn.mas_right).offset(15);
        make.size.mas_offset(CGSizeMake(20, 20));
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self.imgView.mas_right).offset(15);
        make.size.mas_offset(CGSizeMake(160, 20));
    }];
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(self);
        make.height.mas_equalTo(0.5f);
    }];
    
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-15);
        make.centerY.equalTo(self);
        make.left.equalTo(self.nameLabel.mas_right);
    }];

    [super updateConstraints];
    
}

-(void)selectClick:(id)sender {
    
}
-(UILabel *)rightLabel {
    if (!_rightLabel) {
        _rightLabel = [[UILabel alloc] init];
        _rightLabel.text = @"**";
        _rightLabel.font = [UIFont systemFontOfSize:14.0f];
        _rightLabel.textColor = RGB(51, 51, 51);
        _rightLabel.textAlignment = NSTextAlignmentRight;
    }
    return _rightLabel;
}
-(UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = RGB(240, 240, 240);
    }
    return _line;
}
-(UIButton *)selectBtn {
    if (!_selectBtn) {
        _selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_selectBtn setImage:[UIImage imageNamed:@"pay_weixuanzhogn"] forState:UIControlStateNormal];
        [_selectBtn setImage:[UIImage imageNamed:@"pay_xuanzhogn"] forState:UIControlStateSelected];
    }
    return _selectBtn;
}
-(UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.text = @"**支付";
        _nameLabel.font = [UIFont systemFontOfSize:14.0f];
        _nameLabel.textColor = RGB(51, 51, 51);
    }
    return _nameLabel;
}
-(UIImageView *)imgView {
    if (!_imgView) {
        _imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"weixin"]];
        _imgView.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _imgView;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectBtn.selected = selected;
}

footView

#import "YLRechargeFootView.h"
#import "YLRechargeViewModel.h"
@interface YLRechargeFootView ()
@property (nonatomic,strong) YLRechargeViewModel *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;
@end

@implementation YLRechargeFootView
-(instancetype)initWithViewModel:(id<BaseViewModelProtocol>)viewModel {
    self.viewModel = (YLRechargeViewModel *)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 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(-16);
    }];
    [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);
    }];
    [super updateConstraints];
}

-(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;
}
- (YLRechargeViewModel *)viewModel {
    if (!_viewModel) {
        _viewModel = [[YLRechargeViewModel alloc] init];
    }
    return _viewModel;
}


@end

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务