123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614 |
- //
- // KXMainNewWebViewController.m
- // CAISHEN
- //
- // Created by jikaipeng on 2017/10/16.
- // Copyright © 2017年 kuxuan. All rights reserved.
- //
- #import "KXMainNewWebViewController.h"
- #import "KXSelectTableViewCell.h"
- #import "KXLogginViewController.h"
- #import <math.h>
- #import "KXMainWebView2ViewController.h"
- @interface KXMainNewWebViewController ()<UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,UIGestureRecognizerDelegate,UIWebViewDelegate>
- {
- UIView *_selectView;
- // BOOL _selected;
- }
- @property (nonatomic,strong)UITableView *selectTableView;
- @property (nonatomic,strong)NSArray *monthArray;
- @property (nonatomic,assign)NSInteger month;
- @property (nonatomic,strong)UIView *proView;
- @property (nonatomic,assign)BOOL agreeBool;
- @property (nonatomic,strong)UIView *topView;
- @property (nonatomic,strong)UIView *backView;
- @property (nonatomic,strong)NSArray *protocolArray;
- @end
- @implementation KXMainNewWebViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.agreeBool=YES;
- // Do any additional setup after loading the view.
- self.name = @"贷款申请";
- [self setUpUI];
- [self createllSelectView];
- // CGPoint point=self.view.center;
- // point.y=self.view.bounds.size.height-220;
- // self.proView.center=point;
- [self setPro];
- [self addViews];
-
- }
- /**********************************************/
- -(void)addViews{
- [self.view addSubview:self.backView];
- [self.view addSubview:self.topView];
- self.topView.hidden=YES;
- self.backView.hidden=YES;
- }
- -(void)agreeAction:(UIButton *)sender{
- self.agreeBool=!self.agreeBool;
- sender.selected=self.agreeBool;
- }
- -(void)protocolAction:(UIButton *)sender{
- self.backView.hidden=NO;
- self.topView.hidden=NO;
- long indexSender=sender.tag-1000;
- UILabel *titleLabel=[self.topView viewWithTag:764];
- titleLabel.text=sender.titleLabel.text;
- UIWebView *content=[self.topView viewWithTag:766];
- content.delegate=self;
- NSString *path = [[NSBundle mainBundle] bundlePath];
- NSURL *baseURL = [NSURL fileURLWithPath:path];
- NSString * htmlPath = [[NSBundle mainBundle] pathForResource:self.protocolArray[indexSender][@"html"]
- ofType:@"html"];
- // NSLog(@"--%@--%@--",self.protocolArray[indexSender][@"html"],htmlPath);
- NSString * htmlCont = [NSString stringWithContentsOfFile:htmlPath
- encoding:NSUTF8StringEncoding
- error:nil];
- [content loadHTMLString:htmlCont baseURL:baseURL];
- }
- -(void)setPro{
- UIButton *agreeButton=[UIButton buttonWithType:UIButtonTypeCustom];
- agreeButton.frame=CGRectMake(0, 0, 16, 16);
- agreeButton.tag=2000;
- [agreeButton addTarget:self action:@selector(agreeAction:) forControlEvents:UIControlEventTouchUpInside];
- agreeButton.selected=YES;
- [agreeButton setImage:[UIImage imageNamed:@"disagree_protocol"] forState:UIControlStateNormal];
- [agreeButton setImage:[UIImage imageNamed:@"agree_protocol"] forState:UIControlStateSelected];
- UIView *protocolView=[[UIView alloc]init];
- protocolView.frame=CGRectMake(0, 0, 240, 20);
- for (int i=0; i<3; i++) {
- UIButton *button=[[UIButton alloc]init];
- button.titleLabel.font=[UIFont systemFontOfSize:12.0f];
- [button addTarget:self action:@selector(protocolAction:) forControlEvents:UIControlEventTouchUpInside];
- [button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
- button.tag=1000+i;
- switch (i) {
- case 0:
- {
- [button setTitle:@"《委托授权协议》" forState:UIControlStateNormal];
- button.frame=CGRectMake(0-10, -3, 100, 20);
- }
- break;
- case 1:
- {
- [button setTitle:@"《借款协议》" forState:UIControlStateNormal];
- button.frame=CGRectMake(90-10, -3, 65, 20);
- }
- break;
- case 2:
- {
- [button setTitle:@"《平台服务协议》" forState:UIControlStateNormal];
- button.frame=CGRectMake(90+65-10, -3, 70, 20);
- }
- break;
- default:
- break;
- }
- [button sizeToFit];
- [protocolView addSubview:button];
- }
- UITextField *protocolText=[[UITextField alloc]initWithFrame:self.proView.bounds];
- protocolText.text=@"同意";
- protocolText.font = [UIFont systemFontOfSize:12.0];
- protocolText.textAlignment=NSTextAlignmentCenter;
- protocolText.leftView=agreeButton;
- protocolText.leftViewMode=UITextFieldViewModeAlways;
- protocolText.rightView=protocolView;
- protocolText.rightViewMode=UITextFieldViewModeAlways;
- [self.proView addSubview:protocolText];
- UIView * views=[[UIView alloc]initWithFrame:CGRectMake(13, 0, 35, 16)];
- views.backgroundColor=[UIColor clearColor];
- [protocolText addSubview:views];
- }
- -(UIView *)proView{
- if (!_proView) {
- _proView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 290, 25)];
- }
- return _proView;
- }
- -(UIView *)topView{
- if (!_topView) {
- _topView=[[UIView alloc]initWithFrame:CGRectMake((self.backView.bounds.size.width-300)/2,10, 300, 350)];
- // CGPoint point=self.view.center;
- // point.x=_topView.center.x;
- // point.
- // _topView.center=self.view.center;
- _topView.backgroundColor=[UIColor whiteColor];
- UILabel *titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 300, 49.5)];
- titleLabel.textColor=[UIColor baseColor];
- titleLabel.textAlignment=NSTextAlignmentCenter;
- UIView *line1=[[UIView alloc]initWithFrame:CGRectMake(0, 49.5, 300, 0.5)];
- line1.backgroundColor=[UIColor baseColor];
- UIView *line2=[[UIView alloc]initWithFrame:CGRectMake(0, 300, 300, 0.5)];
- line2.backgroundColor=[UIColor baseColor];
- titleLabel.tag=764;
- // UIScrollView *contentScrollView=[[UIScrollView alloc]initWithFrame:];
- // contentScrollView.tag=765;
- UIWebView*content=[[UIWebView alloc]initWithFrame:CGRectMake(0, 50, 300, 250)];
- content.tag=766;
- UIButton *closeButton=[[UIButton alloc]initWithFrame:CGRectMake(0, 300.5, 300, 50)];
- content.backgroundColor=[UIColor whiteColor];
- [closeButton setTitle:@"关闭" forState:UIControlStateNormal];
- [closeButton setTitleColor:[UIColor baseColor] forState:UIControlStateNormal];
- [closeButton addTarget:self action:@selector(closeTop) forControlEvents:UIControlEventTouchUpInside];
- closeButton.tag=767;
- [_topView addSubview:titleLabel];
- // [contentScrollView addSubview:content];
- // [_topView addSubview:contentScrollView];
- [_topView addSubview:content];
- [_topView addSubview:closeButton];
- [_topView addSubview:line1];
- [_topView addSubview:line2];
- }
- return _topView;
- }
- -(void)closeTop{
- self.topView.hidden=YES;
- self.backView.hidden=YES;
- UIWebView *content=[self.topView viewWithTag:766];
- [content loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]];
- }
- -(UIView *)backView{
- if (!_backView) {
- _backView=[[UIView alloc]initWithFrame:self.view.bounds];
- _backView.backgroundColor=[UIColor KXColorWithHex:0x000000 alpha:0.3];
- }
- return _backView;
- }
- -(NSArray *)protocolArray{
- if (!_protocolArray) {
- NSMutableArray *arr=[NSMutableArray array];
- NSString*path=[[NSBundle mainBundle] pathForResource:@"protocolList" ofType:@"plist"];
- NSMutableArray *dataList=[NSMutableArray arrayWithContentsOfFile:path];
- for (NSDictionary *dic in dataList) {
- [arr addObject:dic];
- }
- _protocolArray=[NSArray arrayWithArray:arr];
- }
- return _protocolArray;
- }
- /**********************/
- -(void)createllSelectView
- {
- _month=0;
- _selectView=[[UIView alloc]initWithFrame:self.view.bounds];
- _selectView.hidden=YES;
- _selectView.backgroundColor=[UIColor colorWithWhite:0 alpha:0.5];
-
- [self.view addSubview:_selectView];
- UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenAction:)];
- tapGesturRecognizer.delegate = self;
- [_selectView addGestureRecognizer:tapGesturRecognizer];
-
- self.selectTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT-220-110, SCREEN_WIDTH, 220) style:UITableViewStylePlain];
- self.selectTableView.separatorStyle=UITableViewCellSeparatorStyleNone;
-
- [self.selectTableView registerClass:[KXSelectTableViewCell class] forCellReuseIdentifier:@"selected"];
- self.selectTableView.tableFooterView=[[UIView alloc]init];
- self.selectTableView.delegate = self;
- self.selectTableView.dataSource = self;
- [_selectView addSubview:self.selectTableView];
- }
- -(void)hiddenAction:(UITapGestureRecognizer*) g{
- _selectView.hidden=YES;
- }
- - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
- CGPoint point = [gestureRecognizer locationInView:_selectView];
- if(point.y<SCREEN_HEIGHT-220-49){
- return YES;
- }
- return NO;
- }
- #pragma mark UITextFieldDelegate
- -(void)calculate:(NSInteger) c {
- UILabel* label=(UILabel*)[self.view viewWithTag:8800];
- UILabel* label1=(UILabel*)[self.view viewWithTag:8801];
- // loan/limit+(loan-i*loan/limit)*0.005;
- // 应该等额本息计算:每月还款金额 = 〔贷款本金×月利率×(1+月利率)^还款月数〕÷〔(1+月利率)^还款月数-1〕
- label.text =[NSString stringWithFormat:@"%.2f",(float)c];
- if (!c) {
- label1.text=@"0";
- }else{
- label1.text=[NSString stringWithFormat:@"%.2f",c*0.005*pow(1.005,(int)_month)/(pow(1.005,(int)_month)-1)];
- }
- }
- - (BOOL)isPureInt:(NSString*)string{
- NSScanner* scan = [NSScanner scannerWithString:string];
- int val;
- return[scan scanInt:&val] && [scan isAtEnd];
- }
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
- {
- if (textField.text.length+string.length>8) {
- return NO;
- }
- if([self isPureInt:string]){
- if(range.location==0&&[string hasPrefix:@"0"]){
- return NO;
- }
- }else{
- if(string.length!=0){
- return NO;
- }
- }
- return YES;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 6;
- }
- -(NSArray *)monthArray
- {
- if (!_monthArray) {
- _monthArray=@[@"1",@"3",@"6",@"12",@"24",@"36"];
- }
- return _monthArray;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- KXSelectTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"selected"];
- if (!cell) {
- cell=[[KXSelectTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"selected"];
- }
-
- cell.detailStr=self.monthArray[indexPath.row];
-
- return cell;
-
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
- {
- return 45;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- _month=[self.monthArray[indexPath.row] integerValue];
- UIButton *button=[self.view viewWithTag:8866];
- [button setTitle:self.monthArray[indexPath.row] forState:UIControlStateNormal];
- UITextField* text=(UITextField*)[self.view viewWithTag:8800];
- if(text.text.length==0){
- [self calculate: 5000];
- }else{
- [self calculate: text.text.integerValue];
- }
- _selectView.hidden=YES;
-
- }
- -(void)buttonllAction:(UIButton *)btn{
- _selectView.hidden=NO;
- }
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self checkLog];
- }
- - (void)checkLog{
- UIButton *nextBtn=[self.view viewWithTag:1000];
- UITextField *allFiled = [self.view viewWithTag:8800];
- UIButton *button = [self.view viewWithTag:8866];
- UILabel *label = [self.view viewWithTag:8801];
- NSString *urlString=[NSString stringWithFormat:@"%@/user/personalCenter",URL];
- [KXHTTP post:urlString params:nil success:^(id json) {
- NSString *username= [[NSUserDefaults standardUserDefaults]valueForKey:USER_NAME];
- if (!username) {
- allFiled.enabled = YES;
- button.enabled = YES;
- nextBtn.enabled = YES;
- allFiled.text = @"5000";
- [button setTitle:@"24" forState:UIControlStateNormal];
- [nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
- [nextBtn setBackgroundColor:[UIColor baseColor]];
- label.text=@"210.95";
- return;
- }
- if ([[json[@"user"] valueForKey:@"user_level_id"] isEqual:@(YES)]) {
- NSString *urlSt=[NSString stringWithFormat:@"%@/user/getIosApplyById",URL];
- [KXHTTP post:urlSt params:@{@"id":[json[@"user"] valueForKey:@"id"]} success:^(id json) {
- _month=[json[@"term"] integerValue];
- if (json[@"amount"]) {
- allFiled.enabled = NO;
- allFiled.text = json[@"amount"];
- }
- if (json[@"term"]) {
- button.enabled = NO;
- [button setTitle:json[@"term"] forState:UIControlStateNormal];
- }
- label.text=[NSString stringWithFormat:@"%.2f",[json[@"amount"] integerValue]*0.005*pow(1.005,(int)_month)/(pow(1.005,(int)_month)-1)];
- [nextBtn setBackgroundColor:[UIColor redColor]];
- [nextBtn setTitle:@"审核中......" forState:UIControlStateNormal];
- nextBtn.enabled = NO;
- } failure:^(NSError *error) {
- }];
- }
- } failure:^(NSError *error) {
- }];
- }
- - (void) setUpUI{
- UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 150*SCREEN_MUTI)];
- imageview.image = [UIImage imageNamed:@"main_banner2"];
- [self.view addSubview:imageview];
-
- UIView *backview = [[UIView alloc] init];
- backview.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:backview];
- // UIView *view1 = [[UIView alloc] init];
- // view1.backgroundColor = [UIColor baseColor];
- // [backview addSubview:view1];
-
- UILabel* labelAll=[[UILabel alloc] init];
- labelAll.textColor=[UIColor titleColor];
- labelAll.font=FONT_SYS(22);
- labelAll.text=@"贷款金额:";
-
- UITextField* textAll=[[UITextField alloc] init];
- textAll.textColor=[UIColor baseColor];
- textAll.font=FONT_SYS(22);
- textAll.placeholder=@"请输入金额";
- textAll.text = @"5000";
- textAll.tag=8800;
- textAll.keyboardType = UIKeyboardTypeNumberPad;
- textAll.delegate=self;
-
- UILabel* labelAll1=[[UILabel alloc] init];
- labelAll1.textColor=[UIColor titleColor];
- labelAll1.font=FONT_SYS(22);
- labelAll1.text=@"元";
-
- UILabel *deadlineLabel = [[UILabel alloc] init];
- deadlineLabel.text = @"贷款期数:";
- deadlineLabel.textColor = [UIColor titleColor];
- deadlineLabel.font = FONT_SYS(22);
-
- UIButton *button2=[UIButton buttonWithType:UIButtonTypeCustom];
- [button2 setTitle:@"24" forState:UIControlStateNormal];
- [button2 setTitleColor:[UIColor baseColor] forState:UIControlStateNormal];
- button2.titleLabel.font=FONT_SYS(22);
- button2.tag=8866;
- [button2 addTarget:self action:@selector(buttonllAction:) forControlEvents:UIControlEventTouchUpInside];
- button2.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
-
- UILabel* labeldeadline=[[UILabel alloc] init];
- labeldeadline.textColor=[UIColor titleColor];
- labeldeadline.font=FONT_SYS(22);
- labeldeadline.text=@"月";
-
- UILabel *repayLabel = [[UILabel alloc] init];
- repayLabel.font = FONT_SYS(18);
- repayLabel.text =@"每月还款金额:";
- UILabel *label2 = [[UILabel alloc] init];
- label2.font = FONT_SYS(18);
- label2.textColor = [UIColor baseColor];
- label2.text=@"210.95";
- label2.tag = 8801;
- UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
- button.backgroundColor = [UIColor baseColor];
- button.layer.cornerRadius = 3;
- button.layer.masksToBounds = YES;
- [button setTitle:@"立即申请" forState:UIControlStateNormal];
- [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- button.layer.masksToBounds = YES;
- button.tag = 1000;
- [button addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
- UIView *line1 = [[UIView alloc] init];
- line1.backgroundColor = [UIColor lineColor];
- UIView *line2 = [[UIView alloc] init];
- line2.backgroundColor = [UIColor lineColor];
- [backview addSubview:labelAll];
- [backview addSubview:labelAll1];
- [backview addSubview:textAll];
- [backview addSubview:deadlineLabel];
- [backview addSubview:button2];
- [backview addSubview:labeldeadline];
- [backview addSubview:repayLabel];
- [backview addSubview:label2];
- [backview addSubview:button];
- [backview addSubview:line1];
- [backview addSubview:line2];
- [backview addSubview:self.proView];
- WS(weakSelf);
- [backview mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(weakSelf.view.mas_left).offset(14);
- make.top.equalTo(imageview.mas_bottom).offset(14);
- make.right.equalTo(weakSelf.view.mas_right).offset(-14);
- make.height.equalTo(240*SCREEN_MUTI);
- }];
-
-
- // [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(backview.mas_left);
- // make.right.equalTo(backview.mas_right);
- // make.top.equalTo(backview.mas_top);
- // make.height.equalTo(@16);
- // }];
- [labelAll mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(backview.mas_left).offset(22);
- make.top.equalTo(backview.mas_top).offset(10);
- }];
- [labelAll1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(backview.mas_right).offset(-22);
- make.top.equalTo(labelAll.mas_top);
- }];
- [textAll mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(labelAll.mas_right);
- make.top.equalTo(labelAll.mas_top);
- make.right.equalTo(labelAll1.mas_left);
- make.width.equalTo(SCREEN_WIDTH-28-44-22-99);
- }];
- [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(textAll.mas_left);
- make.top.equalTo(textAll.mas_bottom);
- make.width.equalTo(SCREEN_WIDTH-28-44-22-99);
- make.height.equalTo(1);
- }];
- [deadlineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(labelAll.mas_left);
- make.top.equalTo(labelAll.mas_bottom).offset(18);
- }];
- [labeldeadline mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(labelAll1.mas_right);
- make.top.equalTo(deadlineLabel.mas_top);
- }];
- [button2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(deadlineLabel.mas_right);
- make.top.equalTo(deadlineLabel.mas_top);
- make.right.equalTo(labeldeadline.mas_left);
- make.size.equalTo(CGSizeMake(SCREEN_WIDTH-28-44-22-99, 20));
- }];
- [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(button2.mas_left);
- make.top.equalTo(button2.mas_bottom);
- make.height.equalTo(1);
- make.width.equalTo(SCREEN_WIDTH-28-44-22-99);
- }];
- [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(labeldeadline.mas_right);
- make.top.equalTo(labeldeadline.mas_bottom).offset(38);
- }];
- [repayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(label2.mas_top);
- make.right.equalTo(label2.mas_left);
- }];
- [button mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(labelAll.mas_left);
- make.right.equalTo(label2.mas_right);
- make.bottom.equalTo(backview.mas_bottom).offset(-17);
- make.height.equalTo(44);
- }];
- [self.proView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(backview.mas_centerX);
- make.top.equalTo(deadlineLabel).offset(30);
- make.width.mas_equalTo(290);
- make.height.equalTo(30);
- }];
- UILabel *littleLabel=[[UILabel alloc]init];
- littleLabel.text=[NSString stringWithFormat:@"%@为您提供高品质金融服务",KXCOMPANY];
- littleLabel.textColor=[UIColor detailTitleColor];
- littleLabel.textAlignment=NSTextAlignmentCenter;
- littleLabel.font=FONT_SYS(12);
- [self.view addSubview:littleLabel];
- [littleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(backview.mas_bottom).offset(2*SCREEN_MUTI);
- make.centerX.equalTo(backview.mas_centerX);
- }];
- }
- - (void)nextAction{
-
- UIButton *nextBtn = [self.view viewWithTag:1000];
-
- NSString *urlString=[NSString stringWithFormat:@"%@/user/personalCenter",URL];
- [KXHTTP post:urlString params:nil success:^(id json) {
- NSString *username= [[NSUserDefaults standardUserDefaults]valueForKey:USER_NAME];
-
- if (!username) {
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请登录" preferredStyle:UIAlertControllerStyleAlert];
- [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- KXLogginViewController *loggin=[[KXLogginViewController alloc]init];
- [self.navigationController pushViewController:loggin animated:YES];
- [[NSUserDefaults standardUserDefaults]setObject:nil forKey:@"ISPOP"];
- [[NSUserDefaults standardUserDefaults]synchronize];
- }]];
- [self presentViewController:alertController animated:YES completion:nil];
- nextBtn.enabled=YES;
- }else if (!self.agreeBool){//请勾选同意协议
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请勾选同意协议" preferredStyle:UIAlertControllerStyleAlert];
- [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- [[NSUserDefaults standardUserDefaults]setObject:nil forKey:@"ISPOP"];
- [[NSUserDefaults standardUserDefaults]synchronize];
- }]];
- [self presentViewController:alertController animated:YES completion:nil];
- nextBtn.enabled=YES;
- }else{
-
- UITextField* textfield=[self.view viewWithTag:8800];
- UIButton *button = [self.view viewWithTag:8866];
- if(textfield.text.length==0){
- [self createPromptWhit:@"请输入金额后再试"];
- nextBtn.enabled=YES;
- return;
- }
-
- if(!button.titleLabel.text){
- [self createPromptWhit:@"请选择期限后再试"];
- nextBtn.enabled=YES;
- return;
- }
-
- KXMainWebView2ViewController *mainWeb=[[KXMainWebView2ViewController alloc]init];
- mainWeb.amount=textfield.text.integerValue ;
- mainWeb.term=_month;
- [self.navigationController pushViewController:mainWeb animated:YES];
- nextBtn.enabled=YES;
- }
- } failure:^(NSError *error) {
- nextBtn.enabled=YES;
- }];
- }
- -(void)createPromptWhit:(NSString*) message{
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
- [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-
- }]];
- [self presentViewController:alertController animated:YES completion:nil];
- }
- - (void)webViewDidFinishLoad:(UIWebView *)webView{
- NSString *company=[NSString stringWithFormat:@"document.getElementById('company').innerHTML='%@'",KXCOMPANY];
- [webView stringByEvaluatingJavaScriptFromString:company];
- NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
- NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
- NSString *appName=[NSString stringWithFormat:@"document.getElementById('appName').innerHTML='%@'",app_Name];
- [webView stringByEvaluatingJavaScriptFromString:appName];
- }
- @end
|