Geen omschrijving

KXMainNewWebViewController.m 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. //
  2. // KXMainNewWebViewController.m
  3. // CAISHEN
  4. //
  5. // Created by jikaipeng on 2017/10/16.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "KXMainNewWebViewController.h"
  9. #import "KXSelectTableViewCell.h"
  10. #import "KXLogginViewController.h"
  11. #import <math.h>
  12. #import "KXMainWebView2ViewController.h"
  13. @interface KXMainNewWebViewController ()<UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,UIGestureRecognizerDelegate,UIWebViewDelegate>
  14. {
  15. UIView *_selectView;
  16. // BOOL _selected;
  17. }
  18. @property (nonatomic,strong)UITableView *selectTableView;
  19. @property (nonatomic,strong)NSArray *monthArray;
  20. @property (nonatomic,assign)NSInteger month;
  21. @property (nonatomic,strong)UIView *proView;
  22. @property (nonatomic,assign)BOOL agreeBool;
  23. @property (nonatomic,strong)UIView *topView;
  24. @property (nonatomic,strong)UIView *backView;
  25. @property (nonatomic,strong)NSArray *protocolArray;
  26. @end
  27. @implementation KXMainNewWebViewController
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. self.agreeBool=YES;
  31. // Do any additional setup after loading the view.
  32. self.name = @"贷款申请";
  33. [self setUpUI];
  34. [self createllSelectView];
  35. // CGPoint point=self.view.center;
  36. // point.y=self.view.bounds.size.height-220;
  37. // self.proView.center=point;
  38. [self setPro];
  39. [self addViews];
  40. }
  41. /**********************************************/
  42. -(void)addViews{
  43. [self.view addSubview:self.backView];
  44. [self.view addSubview:self.topView];
  45. self.topView.hidden=YES;
  46. self.backView.hidden=YES;
  47. }
  48. -(void)agreeAction:(UIButton *)sender{
  49. self.agreeBool=!self.agreeBool;
  50. sender.selected=self.agreeBool;
  51. }
  52. -(void)protocolAction:(UIButton *)sender{
  53. self.backView.hidden=NO;
  54. self.topView.hidden=NO;
  55. long indexSender=sender.tag-1000;
  56. UILabel *titleLabel=[self.topView viewWithTag:764];
  57. titleLabel.text=sender.titleLabel.text;
  58. UIWebView *content=[self.topView viewWithTag:766];
  59. content.delegate=self;
  60. NSString *path = [[NSBundle mainBundle] bundlePath];
  61. NSURL *baseURL = [NSURL fileURLWithPath:path];
  62. NSString * htmlPath = [[NSBundle mainBundle] pathForResource:self.protocolArray[indexSender][@"html"]
  63. ofType:@"html"];
  64. // NSLog(@"--%@--%@--",self.protocolArray[indexSender][@"html"],htmlPath);
  65. NSString * htmlCont = [NSString stringWithContentsOfFile:htmlPath
  66. encoding:NSUTF8StringEncoding
  67. error:nil];
  68. [content loadHTMLString:htmlCont baseURL:baseURL];
  69. }
  70. -(void)setPro{
  71. UIButton *agreeButton=[UIButton buttonWithType:UIButtonTypeCustom];
  72. agreeButton.frame=CGRectMake(0, 0, 16, 16);
  73. agreeButton.tag=2000;
  74. [agreeButton addTarget:self action:@selector(agreeAction:) forControlEvents:UIControlEventTouchUpInside];
  75. agreeButton.selected=YES;
  76. [agreeButton setImage:[UIImage imageNamed:@"disagree_protocol"] forState:UIControlStateNormal];
  77. [agreeButton setImage:[UIImage imageNamed:@"agree_protocol"] forState:UIControlStateSelected];
  78. UIView *protocolView=[[UIView alloc]init];
  79. protocolView.frame=CGRectMake(0, 0, 240, 20);
  80. for (int i=0; i<3; i++) {
  81. UIButton *button=[[UIButton alloc]init];
  82. button.titleLabel.font=[UIFont systemFontOfSize:12.0f];
  83. [button addTarget:self action:@selector(protocolAction:) forControlEvents:UIControlEventTouchUpInside];
  84. [button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
  85. button.tag=1000+i;
  86. switch (i) {
  87. case 0:
  88. {
  89. [button setTitle:@"《委托授权协议》" forState:UIControlStateNormal];
  90. button.frame=CGRectMake(0-10, -3, 100, 20);
  91. }
  92. break;
  93. case 1:
  94. {
  95. [button setTitle:@"《借款协议》" forState:UIControlStateNormal];
  96. button.frame=CGRectMake(90-10, -3, 65, 20);
  97. }
  98. break;
  99. case 2:
  100. {
  101. [button setTitle:@"《平台服务协议》" forState:UIControlStateNormal];
  102. button.frame=CGRectMake(90+65-10, -3, 70, 20);
  103. }
  104. break;
  105. default:
  106. break;
  107. }
  108. [button sizeToFit];
  109. [protocolView addSubview:button];
  110. }
  111. UITextField *protocolText=[[UITextField alloc]initWithFrame:self.proView.bounds];
  112. protocolText.text=@"同意";
  113. protocolText.font = [UIFont systemFontOfSize:12.0];
  114. protocolText.textAlignment=NSTextAlignmentCenter;
  115. protocolText.leftView=agreeButton;
  116. protocolText.leftViewMode=UITextFieldViewModeAlways;
  117. protocolText.rightView=protocolView;
  118. protocolText.rightViewMode=UITextFieldViewModeAlways;
  119. [self.proView addSubview:protocolText];
  120. UIView * views=[[UIView alloc]initWithFrame:CGRectMake(13, 0, 35, 16)];
  121. views.backgroundColor=[UIColor clearColor];
  122. [protocolText addSubview:views];
  123. }
  124. -(UIView *)proView{
  125. if (!_proView) {
  126. _proView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 290, 25)];
  127. }
  128. return _proView;
  129. }
  130. -(UIView *)topView{
  131. if (!_topView) {
  132. _topView=[[UIView alloc]initWithFrame:CGRectMake((self.backView.bounds.size.width-300)/2,10, 300, 350)];
  133. // CGPoint point=self.view.center;
  134. // point.x=_topView.center.x;
  135. // point.
  136. // _topView.center=self.view.center;
  137. _topView.backgroundColor=[UIColor whiteColor];
  138. UILabel *titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 300, 49.5)];
  139. titleLabel.textColor=[UIColor baseColor];
  140. titleLabel.textAlignment=NSTextAlignmentCenter;
  141. UIView *line1=[[UIView alloc]initWithFrame:CGRectMake(0, 49.5, 300, 0.5)];
  142. line1.backgroundColor=[UIColor baseColor];
  143. UIView *line2=[[UIView alloc]initWithFrame:CGRectMake(0, 300, 300, 0.5)];
  144. line2.backgroundColor=[UIColor baseColor];
  145. titleLabel.tag=764;
  146. // UIScrollView *contentScrollView=[[UIScrollView alloc]initWithFrame:];
  147. // contentScrollView.tag=765;
  148. UIWebView*content=[[UIWebView alloc]initWithFrame:CGRectMake(0, 50, 300, 250)];
  149. content.tag=766;
  150. UIButton *closeButton=[[UIButton alloc]initWithFrame:CGRectMake(0, 300.5, 300, 50)];
  151. content.backgroundColor=[UIColor whiteColor];
  152. [closeButton setTitle:@"关闭" forState:UIControlStateNormal];
  153. [closeButton setTitleColor:[UIColor baseColor] forState:UIControlStateNormal];
  154. [closeButton addTarget:self action:@selector(closeTop) forControlEvents:UIControlEventTouchUpInside];
  155. closeButton.tag=767;
  156. [_topView addSubview:titleLabel];
  157. // [contentScrollView addSubview:content];
  158. // [_topView addSubview:contentScrollView];
  159. [_topView addSubview:content];
  160. [_topView addSubview:closeButton];
  161. [_topView addSubview:line1];
  162. [_topView addSubview:line2];
  163. }
  164. return _topView;
  165. }
  166. -(void)closeTop{
  167. self.topView.hidden=YES;
  168. self.backView.hidden=YES;
  169. UIWebView *content=[self.topView viewWithTag:766];
  170. [content loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]];
  171. }
  172. -(UIView *)backView{
  173. if (!_backView) {
  174. _backView=[[UIView alloc]initWithFrame:self.view.bounds];
  175. _backView.backgroundColor=[UIColor KXColorWithHex:0x000000 alpha:0.3];
  176. }
  177. return _backView;
  178. }
  179. -(NSArray *)protocolArray{
  180. if (!_protocolArray) {
  181. NSMutableArray *arr=[NSMutableArray array];
  182. NSString*path=[[NSBundle mainBundle] pathForResource:@"protocolList" ofType:@"plist"];
  183. NSMutableArray *dataList=[NSMutableArray arrayWithContentsOfFile:path];
  184. for (NSDictionary *dic in dataList) {
  185. [arr addObject:dic];
  186. }
  187. _protocolArray=[NSArray arrayWithArray:arr];
  188. }
  189. return _protocolArray;
  190. }
  191. /**********************/
  192. -(void)createllSelectView
  193. {
  194. _month=0;
  195. _selectView=[[UIView alloc]initWithFrame:self.view.bounds];
  196. _selectView.hidden=YES;
  197. _selectView.backgroundColor=[UIColor colorWithWhite:0 alpha:0.5];
  198. [self.view addSubview:_selectView];
  199. UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenAction:)];
  200. tapGesturRecognizer.delegate = self;
  201. [_selectView addGestureRecognizer:tapGesturRecognizer];
  202. self.selectTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT-220-110, SCREEN_WIDTH, 220) style:UITableViewStylePlain];
  203. self.selectTableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  204. [self.selectTableView registerClass:[KXSelectTableViewCell class] forCellReuseIdentifier:@"selected"];
  205. self.selectTableView.tableFooterView=[[UIView alloc]init];
  206. self.selectTableView.delegate = self;
  207. self.selectTableView.dataSource = self;
  208. [_selectView addSubview:self.selectTableView];
  209. }
  210. -(void)hiddenAction:(UITapGestureRecognizer*) g{
  211. _selectView.hidden=YES;
  212. }
  213. - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
  214. CGPoint point = [gestureRecognizer locationInView:_selectView];
  215. if(point.y<SCREEN_HEIGHT-220-49){
  216. return YES;
  217. }
  218. return NO;
  219. }
  220. #pragma mark UITextFieldDelegate
  221. -(void)calculate:(NSInteger) c {
  222. UILabel* label=(UILabel*)[self.view viewWithTag:8800];
  223. UILabel* label1=(UILabel*)[self.view viewWithTag:8801];
  224. // loan/limit+(loan-i*loan/limit)*0.005;
  225. // 应该等额本息计算:每月还款金额 = 〔贷款本金×月利率×(1+月利率)^还款月数〕÷〔(1+月利率)^还款月数-1〕
  226. label.text =[NSString stringWithFormat:@"%.2f",(float)c];
  227. if (!c) {
  228. label1.text=@"0";
  229. }else{
  230. label1.text=[NSString stringWithFormat:@"%.2f",c*0.005*pow(1.005,(int)_month)/(pow(1.005,(int)_month)-1)];
  231. }
  232. }
  233. - (BOOL)isPureInt:(NSString*)string{
  234. NSScanner* scan = [NSScanner scannerWithString:string];
  235. int val;
  236. return[scan scanInt:&val] && [scan isAtEnd];
  237. }
  238. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  239. {
  240. if (textField.text.length+string.length>8) {
  241. return NO;
  242. }
  243. if([self isPureInt:string]){
  244. if(range.location==0&&[string hasPrefix:@"0"]){
  245. return NO;
  246. }
  247. }else{
  248. if(string.length!=0){
  249. return NO;
  250. }
  251. }
  252. return YES;
  253. }
  254. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  255. {
  256. return 6;
  257. }
  258. -(NSArray *)monthArray
  259. {
  260. if (!_monthArray) {
  261. _monthArray=@[@"1",@"3",@"6",@"12",@"24",@"36"];
  262. }
  263. return _monthArray;
  264. }
  265. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  266. {
  267. KXSelectTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"selected"];
  268. if (!cell) {
  269. cell=[[KXSelectTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"selected"];
  270. }
  271. cell.detailStr=self.monthArray[indexPath.row];
  272. return cell;
  273. }
  274. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
  275. {
  276. return 45;
  277. }
  278. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  279. {
  280. _month=[self.monthArray[indexPath.row] integerValue];
  281. UIButton *button=[self.view viewWithTag:8866];
  282. [button setTitle:self.monthArray[indexPath.row] forState:UIControlStateNormal];
  283. UITextField* text=(UITextField*)[self.view viewWithTag:8800];
  284. if(text.text.length==0){
  285. [self calculate: 5000];
  286. }else{
  287. [self calculate: text.text.integerValue];
  288. }
  289. _selectView.hidden=YES;
  290. }
  291. -(void)buttonllAction:(UIButton *)btn{
  292. _selectView.hidden=NO;
  293. }
  294. - (void)viewWillAppear:(BOOL)animated
  295. {
  296. [super viewWillAppear:animated];
  297. [self checkLog];
  298. }
  299. - (void)checkLog{
  300. UIButton *nextBtn=[self.view viewWithTag:1000];
  301. UITextField *allFiled = [self.view viewWithTag:8800];
  302. UIButton *button = [self.view viewWithTag:8866];
  303. UILabel *label = [self.view viewWithTag:8801];
  304. NSString *urlString=[NSString stringWithFormat:@"%@/user/personalCenter",URL];
  305. [KXHTTP post:urlString params:nil success:^(id json) {
  306. NSString *username= [[NSUserDefaults standardUserDefaults]valueForKey:USER_NAME];
  307. if (!username) {
  308. allFiled.enabled = YES;
  309. button.enabled = YES;
  310. nextBtn.enabled = YES;
  311. allFiled.text = @"5000";
  312. [button setTitle:@"24" forState:UIControlStateNormal];
  313. [nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
  314. [nextBtn setBackgroundColor:[UIColor baseColor]];
  315. label.text=@"210.95";
  316. return;
  317. }
  318. if ([[json[@"user"] valueForKey:@"user_level_id"] isEqual:@(YES)]) {
  319. NSString *urlSt=[NSString stringWithFormat:@"%@/user/getIosApplyById",URL];
  320. [KXHTTP post:urlSt params:@{@"id":[json[@"user"] valueForKey:@"id"]} success:^(id json) {
  321. _month=[json[@"term"] integerValue];
  322. if (json[@"amount"]) {
  323. allFiled.enabled = NO;
  324. allFiled.text = json[@"amount"];
  325. }
  326. if (json[@"term"]) {
  327. button.enabled = NO;
  328. [button setTitle:json[@"term"] forState:UIControlStateNormal];
  329. }
  330. label.text=[NSString stringWithFormat:@"%.2f",[json[@"amount"] integerValue]*0.005*pow(1.005,(int)_month)/(pow(1.005,(int)_month)-1)];
  331. [nextBtn setBackgroundColor:[UIColor redColor]];
  332. [nextBtn setTitle:@"审核中......" forState:UIControlStateNormal];
  333. nextBtn.enabled = NO;
  334. } failure:^(NSError *error) {
  335. }];
  336. }
  337. } failure:^(NSError *error) {
  338. }];
  339. }
  340. - (void) setUpUI{
  341. UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 150*SCREEN_MUTI)];
  342. imageview.image = [UIImage imageNamed:@"main_banner2"];
  343. [self.view addSubview:imageview];
  344. UIView *backview = [[UIView alloc] init];
  345. backview.backgroundColor = [UIColor whiteColor];
  346. [self.view addSubview:backview];
  347. // UIView *view1 = [[UIView alloc] init];
  348. // view1.backgroundColor = [UIColor baseColor];
  349. // [backview addSubview:view1];
  350. UILabel* labelAll=[[UILabel alloc] init];
  351. labelAll.textColor=[UIColor titleColor];
  352. labelAll.font=FONT_SYS(22);
  353. labelAll.text=@"贷款金额:";
  354. UITextField* textAll=[[UITextField alloc] init];
  355. textAll.textColor=[UIColor baseColor];
  356. textAll.font=FONT_SYS(22);
  357. textAll.placeholder=@"请输入金额";
  358. textAll.text = @"5000";
  359. textAll.tag=8800;
  360. textAll.keyboardType = UIKeyboardTypeNumberPad;
  361. textAll.delegate=self;
  362. UILabel* labelAll1=[[UILabel alloc] init];
  363. labelAll1.textColor=[UIColor titleColor];
  364. labelAll1.font=FONT_SYS(22);
  365. labelAll1.text=@"元";
  366. UILabel *deadlineLabel = [[UILabel alloc] init];
  367. deadlineLabel.text = @"贷款期数:";
  368. deadlineLabel.textColor = [UIColor titleColor];
  369. deadlineLabel.font = FONT_SYS(22);
  370. UIButton *button2=[UIButton buttonWithType:UIButtonTypeCustom];
  371. [button2 setTitle:@"24" forState:UIControlStateNormal];
  372. [button2 setTitleColor:[UIColor baseColor] forState:UIControlStateNormal];
  373. button2.titleLabel.font=FONT_SYS(22);
  374. button2.tag=8866;
  375. [button2 addTarget:self action:@selector(buttonllAction:) forControlEvents:UIControlEventTouchUpInside];
  376. button2.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
  377. UILabel* labeldeadline=[[UILabel alloc] init];
  378. labeldeadline.textColor=[UIColor titleColor];
  379. labeldeadline.font=FONT_SYS(22);
  380. labeldeadline.text=@"月";
  381. UILabel *repayLabel = [[UILabel alloc] init];
  382. repayLabel.font = FONT_SYS(18);
  383. repayLabel.text =@"每月还款金额:";
  384. UILabel *label2 = [[UILabel alloc] init];
  385. label2.font = FONT_SYS(18);
  386. label2.textColor = [UIColor baseColor];
  387. label2.text=@"210.95";
  388. label2.tag = 8801;
  389. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  390. button.backgroundColor = [UIColor baseColor];
  391. button.layer.cornerRadius = 3;
  392. button.layer.masksToBounds = YES;
  393. [button setTitle:@"立即申请" forState:UIControlStateNormal];
  394. [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  395. button.layer.masksToBounds = YES;
  396. button.tag = 1000;
  397. [button addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
  398. UIView *line1 = [[UIView alloc] init];
  399. line1.backgroundColor = [UIColor lineColor];
  400. UIView *line2 = [[UIView alloc] init];
  401. line2.backgroundColor = [UIColor lineColor];
  402. [backview addSubview:labelAll];
  403. [backview addSubview:labelAll1];
  404. [backview addSubview:textAll];
  405. [backview addSubview:deadlineLabel];
  406. [backview addSubview:button2];
  407. [backview addSubview:labeldeadline];
  408. [backview addSubview:repayLabel];
  409. [backview addSubview:label2];
  410. [backview addSubview:button];
  411. [backview addSubview:line1];
  412. [backview addSubview:line2];
  413. [backview addSubview:self.proView];
  414. WS(weakSelf);
  415. [backview mas_makeConstraints:^(MASConstraintMaker *make) {
  416. make.left.equalTo(weakSelf.view.mas_left).offset(14);
  417. make.top.equalTo(imageview.mas_bottom).offset(14);
  418. make.right.equalTo(weakSelf.view.mas_right).offset(-14);
  419. make.height.equalTo(240*SCREEN_MUTI);
  420. }];
  421. // [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
  422. // make.left.equalTo(backview.mas_left);
  423. // make.right.equalTo(backview.mas_right);
  424. // make.top.equalTo(backview.mas_top);
  425. // make.height.equalTo(@16);
  426. // }];
  427. [labelAll mas_makeConstraints:^(MASConstraintMaker *make) {
  428. make.left.equalTo(backview.mas_left).offset(22);
  429. make.top.equalTo(backview.mas_top).offset(10);
  430. }];
  431. [labelAll1 mas_makeConstraints:^(MASConstraintMaker *make) {
  432. make.right.equalTo(backview.mas_right).offset(-22);
  433. make.top.equalTo(labelAll.mas_top);
  434. }];
  435. [textAll mas_makeConstraints:^(MASConstraintMaker *make) {
  436. make.left.equalTo(labelAll.mas_right);
  437. make.top.equalTo(labelAll.mas_top);
  438. make.right.equalTo(labelAll1.mas_left);
  439. make.width.equalTo(SCREEN_WIDTH-28-44-22-99);
  440. }];
  441. [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
  442. make.left.equalTo(textAll.mas_left);
  443. make.top.equalTo(textAll.mas_bottom);
  444. make.width.equalTo(SCREEN_WIDTH-28-44-22-99);
  445. make.height.equalTo(1);
  446. }];
  447. [deadlineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  448. make.left.equalTo(labelAll.mas_left);
  449. make.top.equalTo(labelAll.mas_bottom).offset(18);
  450. }];
  451. [labeldeadline mas_makeConstraints:^(MASConstraintMaker *make) {
  452. make.right.equalTo(labelAll1.mas_right);
  453. make.top.equalTo(deadlineLabel.mas_top);
  454. }];
  455. [button2 mas_makeConstraints:^(MASConstraintMaker *make) {
  456. make.left.equalTo(deadlineLabel.mas_right);
  457. make.top.equalTo(deadlineLabel.mas_top);
  458. make.right.equalTo(labeldeadline.mas_left);
  459. make.size.equalTo(CGSizeMake(SCREEN_WIDTH-28-44-22-99, 20));
  460. }];
  461. [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
  462. make.left.equalTo(button2.mas_left);
  463. make.top.equalTo(button2.mas_bottom);
  464. make.height.equalTo(1);
  465. make.width.equalTo(SCREEN_WIDTH-28-44-22-99);
  466. }];
  467. [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
  468. make.right.equalTo(labeldeadline.mas_right);
  469. make.top.equalTo(labeldeadline.mas_bottom).offset(38);
  470. }];
  471. [repayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  472. make.top.equalTo(label2.mas_top);
  473. make.right.equalTo(label2.mas_left);
  474. }];
  475. [button mas_makeConstraints:^(MASConstraintMaker *make) {
  476. make.left.equalTo(labelAll.mas_left);
  477. make.right.equalTo(label2.mas_right);
  478. make.bottom.equalTo(backview.mas_bottom).offset(-17);
  479. make.height.equalTo(44);
  480. }];
  481. [self.proView mas_makeConstraints:^(MASConstraintMaker *make) {
  482. make.centerX.equalTo(backview.mas_centerX);
  483. make.top.equalTo(deadlineLabel).offset(30);
  484. make.width.mas_equalTo(290);
  485. make.height.equalTo(30);
  486. }];
  487. UILabel *littleLabel=[[UILabel alloc]init];
  488. littleLabel.text=[NSString stringWithFormat:@"%@为您提供高品质金融服务",KXCOMPANY];
  489. littleLabel.textColor=[UIColor detailTitleColor];
  490. littleLabel.textAlignment=NSTextAlignmentCenter;
  491. littleLabel.font=FONT_SYS(12);
  492. [self.view addSubview:littleLabel];
  493. [littleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  494. make.top.equalTo(backview.mas_bottom).offset(2*SCREEN_MUTI);
  495. make.centerX.equalTo(backview.mas_centerX);
  496. }];
  497. }
  498. - (void)nextAction{
  499. UIButton *nextBtn = [self.view viewWithTag:1000];
  500. NSString *urlString=[NSString stringWithFormat:@"%@/user/personalCenter",URL];
  501. [KXHTTP post:urlString params:nil success:^(id json) {
  502. NSString *username= [[NSUserDefaults standardUserDefaults]valueForKey:USER_NAME];
  503. if (!username) {
  504. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请登录" preferredStyle:UIAlertControllerStyleAlert];
  505. [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  506. KXLogginViewController *loggin=[[KXLogginViewController alloc]init];
  507. [self.navigationController pushViewController:loggin animated:YES];
  508. [[NSUserDefaults standardUserDefaults]setObject:nil forKey:@"ISPOP"];
  509. [[NSUserDefaults standardUserDefaults]synchronize];
  510. }]];
  511. [self presentViewController:alertController animated:YES completion:nil];
  512. nextBtn.enabled=YES;
  513. }else if (!self.agreeBool){//请勾选同意协议
  514. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请勾选同意协议" preferredStyle:UIAlertControllerStyleAlert];
  515. [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  516. [[NSUserDefaults standardUserDefaults]setObject:nil forKey:@"ISPOP"];
  517. [[NSUserDefaults standardUserDefaults]synchronize];
  518. }]];
  519. [self presentViewController:alertController animated:YES completion:nil];
  520. nextBtn.enabled=YES;
  521. }else{
  522. UITextField* textfield=[self.view viewWithTag:8800];
  523. UIButton *button = [self.view viewWithTag:8866];
  524. if(textfield.text.length==0){
  525. [self createPromptWhit:@"请输入金额后再试"];
  526. nextBtn.enabled=YES;
  527. return;
  528. }
  529. if(!button.titleLabel.text){
  530. [self createPromptWhit:@"请选择期限后再试"];
  531. nextBtn.enabled=YES;
  532. return;
  533. }
  534. KXMainWebView2ViewController *mainWeb=[[KXMainWebView2ViewController alloc]init];
  535. mainWeb.amount=textfield.text.integerValue ;
  536. mainWeb.term=_month;
  537. [self.navigationController pushViewController:mainWeb animated:YES];
  538. nextBtn.enabled=YES;
  539. }
  540. } failure:^(NSError *error) {
  541. nextBtn.enabled=YES;
  542. }];
  543. }
  544. -(void)createPromptWhit:(NSString*) message{
  545. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
  546. [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  547. }]];
  548. [self presentViewController:alertController animated:YES completion:nil];
  549. }
  550. - (void)webViewDidFinishLoad:(UIWebView *)webView{
  551. NSString *company=[NSString stringWithFormat:@"document.getElementById('company').innerHTML='%@'",KXCOMPANY];
  552. [webView stringByEvaluatingJavaScriptFromString:company];
  553. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  554. NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
  555. NSString *appName=[NSString stringWithFormat:@"document.getElementById('appName').innerHTML='%@'",app_Name];
  556. [webView stringByEvaluatingJavaScriptFromString:appName];
  557. }
  558. @end