Açıklama Yok

KXThirdWebViewController.m 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. //
  2. // KXMainWebViewController.m
  3. // QBCS
  4. //
  5. // Created by kuxuan on 2017/7/10.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "KXThirdWebViewController.h"
  9. #import "KXSelectTableViewCell.h"
  10. #import "KXLogginViewController.h"
  11. #import "KXUserIdentificationContronller.h"
  12. @interface KXThirdWebViewController ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,UIGestureRecognizerDelegate>
  13. {
  14. UIView *_selectView;
  15. BOOL _selected;
  16. }
  17. @property (nonatomic,strong)UITableView *selectTableView;
  18. @property (nonatomic,strong)NSArray *careerArray;
  19. @property (nonatomic,strong)NSArray *incomellArray;
  20. @property (nonatomic,copy)NSString *Id;
  21. @end
  22. @implementation KXThirdWebViewController
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. // Do any additional setup after loading the view.
  26. [self initNavBar];
  27. [self initUpUIview];
  28. [self createviewSelectView];
  29. }
  30. -(void)viewWillAppear:(BOOL)animated
  31. {
  32. [super viewWillAppear:animated];
  33. // [self checkLog];
  34. }
  35. -(void)initNavBar
  36. {
  37. self.navigationController.navigationBar.hidden=NO;
  38. self.name=@"贷款申请";
  39. [self addLeftBarButtonItemWithImageName:@"main_back" title:nil target:self selector:@selector(beforeAction)];
  40. }
  41. -(void)beforeAction
  42. {
  43. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"离开" message:@"现在离开将不会保存所填写信息,确认离开吗?" preferredStyle:UIAlertControllerStyleAlert];
  44. [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  45. [self.navigationController popViewControllerAnimated:YES];
  46. }]];
  47. [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  48. }]];
  49. [self presentViewController:alertController animated:YES completion:nil];
  50. }
  51. -(void)initUpUIview
  52. {
  53. // -64-49
  54. UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64)];
  55. scrollView.showsVerticalScrollIndicator=NO;
  56. scrollView.showsHorizontalScrollIndicator=NO;
  57. if(536*SCREEN_MUTI>SCREEN_HEIGHT-64){
  58. scrollView.contentSize=CGSizeMake(SCREEN_WIDTH, 536*SCREEN_MUTI);
  59. }else{
  60. scrollView.contentSize=CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT-63);
  61. }
  62. scrollView.backgroundColor=[UIColor background];
  63. [self.view addSubview:scrollView];
  64. UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 130*SCREEN_MUTI)];
  65. imageView.image=[UIImage imageNamed:@"main_apply"];
  66. [scrollView addSubview:imageView];
  67. UILabel *lineLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 130*SCREEN_MUTI, SCREEN_WIDTH, SCREEN_MUTI)];
  68. lineLabel.backgroundColor=[UIColor lineColor1];
  69. [scrollView addSubview:lineLabel];
  70. UIView *whiteView=[[UIView alloc]initWithFrame:CGRectMake(14*SCREEN_MUTI, 140*SCREEN_MUTI, SCREEN_WIDTH-2*14*SCREEN_MUTI, 300*SCREEN_MUTI)];
  71. whiteView.backgroundColor=[UIColor whiteColor];
  72. whiteView.layer.cornerRadius=3;
  73. whiteView.layer.masksToBounds = YES;
  74. whiteView.layer.borderWidth = SCREEN_MUTI;
  75. whiteView.layer.borderColor =[[UIColor lineColor1]CGColor];
  76. [scrollView addSubview:whiteView];
  77. NSArray *infoArray=@[@"name",@"age",@"phone",@"work",@"income"];
  78. NSArray *titleArray=@[@"真实姓名",@"年 龄",@"联系方式",@"职 业",@"月 收 入"];
  79. NSArray *placeholderArray=@[@"请输入真实姓名",@"请输入年龄",@"请输入联系方式"];
  80. CGFloat width=0;
  81. NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:16],};
  82. for(NSString* title in titleArray){
  83. CGFloat width1=[title boundingRectWithSize:CGSizeMake(0, 0) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size.width;
  84. if(width1>width){
  85. width=width1;
  86. }
  87. }
  88. for (int i=0; i<5; i++) {
  89. UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(20*SCREEN_MUTI, (20+(60*i))*SCREEN_MUTI, 22*SCREEN_MUTI, 22*SCREEN_MUTI)];
  90. imageView.image=[UIImage imageNamed:[NSString stringWithFormat:@"userinfo_%@",infoArray[i]]];
  91. [whiteView addSubview:imageView];
  92. UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(52*SCREEN_MUTI, (60*i+1)*SCREEN_MUTI, width,60*SCREEN_MUTI)];
  93. label.text=titleArray[i];
  94. label.textColor=[UIColor titleColor];
  95. label.font=FONT_SYS(16);
  96. [whiteView addSubview:label];
  97. if(i<4){
  98. UILabel *lineLabel=[[UILabel alloc]initWithFrame:CGRectMake(14, (60*(i+1)+1)*SCREEN_MUTI, SCREEN_WIDTH-2*28*SCREEN_MUTI, SCREEN_MUTI)];
  99. lineLabel.backgroundColor=[UIColor lineColor1];
  100. [whiteView addSubview:lineLabel];
  101. }
  102. }
  103. for (int i=0; i<3; i++) {
  104. UITextField *tf=[[UITextField alloc]initWithFrame:CGRectMake( (52+width+34)*SCREEN_MUTI, (60*i+1)*SCREEN_MUTI, SCREEN_WIDTH-(52+width+34)*SCREEN_MUTI, 60*SCREEN_MUTI)];
  105. tf.tag=666+i;
  106. tf.textColor=[UIColor detailTitleColor];
  107. tf.placeholder=placeholderArray[i];
  108. tf.font=FONT_SYS(16);
  109. if(i!=0){
  110. tf.keyboardType = UIKeyboardTypeNamePhonePad;
  111. tf.delegate=self;
  112. }
  113. [whiteView addSubview:tf];
  114. }
  115. NSArray *buttonArray=@[@"请选择职业身份",@"请选择月收入"];
  116. for (int i=0; i<2; i++) {
  117. UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
  118. button.frame=CGRectMake((52+width+34)*SCREEN_MUTI, 60*(i+3)*SCREEN_MUTI, SCREEN_WIDTH-(86+width)*SCREEN_MUTI, 60*SCREEN_MUTI);
  119. [button setTitle:buttonArray[i] forState:UIControlStateNormal];
  120. button.titleLabel.font=FONT_SYS(16);
  121. button.tag=8989+i;
  122. [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
  123. button.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
  124. [button setTitleColor:[UIColor titleColor] forState:UIControlStateNormal];
  125. [whiteView addSubview:button];
  126. }
  127. UIButton *next=[UIButton buttonWithType:UIButtonTypeCustom];
  128. next.frame=CGRectMake(14*SCREEN_MUTI,466*SCREEN_MUTI, SCREEN_WIDTH-28*SCREEN_MUTI, 44*SCREEN_MUTI);
  129. next.layer.cornerRadius=3;
  130. next.tag=999;
  131. next.layer.masksToBounds=YES;
  132. next.backgroundColor=[UIColor baseColor];
  133. next.titleLabel.font=FONT_SYS(16);
  134. [next setTitle:@"下一步" forState:UIControlStateNormal];
  135. [next setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  136. [next addTarget:self action:@selector(nextllAction) forControlEvents:UIControlEventTouchUpInside];
  137. [scrollView addSubview:next];
  138. }
  139. -(void)buttonAction:(UIButton *)btn
  140. {
  141. switch (btn.tag) {
  142. case 8989:
  143. {
  144. _selected=YES;
  145. [self.selectTableView reloadData];
  146. }
  147. break;
  148. case 8990:
  149. {
  150. _selected=NO;
  151. [self.selectTableView reloadData];
  152. }
  153. break;
  154. default:
  155. break;
  156. }
  157. _selectView.hidden=NO;
  158. }
  159. //-(void)checkLog
  160. //{
  161. // UITextField *nameTF=[self.view viewWithTag:666];
  162. // UITextField *ageTF=[self.view viewWithTag:667];
  163. //// UITextField *identityTF=[self.view viewWithTag:668];
  164. // UITextField *cell_numTF=[self.view viewWithTag:668];
  165. // UIButton *careerBtn=[self.view viewWithTag:8989];
  166. // UIButton *incomeBtn=[self.view viewWithTag:8990];
  167. // UIButton *nextBtn=[self.view viewWithTag:999];
  168. //
  169. // NSString *urlString=[NSString stringWithFormat:@"%@/user/personalCenter",URL];
  170. // [KXHTTP post:urlString params:nil success:^(id json) {
  171. // if ([[json[@"user"] valueForKey:@"user_level_id"] isEqual:@(YES)]) {
  172. // [nextBtn setTitle:@"审核中..." forState:UIControlStateNormal];
  173. // nameTF.enabled=NO;
  174. // ageTF.enabled=NO;
  175. //// identityTF.enabled=NO;
  176. // cell_numTF.enabled=NO;
  177. // incomeBtn.enabled=NO;
  178. // careerBtn.enabled=NO;
  179. // NSString *urlSt=[NSString stringWithFormat:@"%@/user/getIosApplyById",URL];
  180. // [KXHTTP post:urlSt params:@{@"id":[json[@"user"] valueForKey:@"id"]} success:^(id json) {
  181. // nameTF.text=json[@"name"];
  182. // ageTF.text=json[@"age"];
  183. //// identityTF.text=json[@"identity"];
  184. // cell_numTF.text=json[@"cell_num"];
  185. // [incomeBtn setTitle:json[@"monthly_income"] forState:UIControlStateNormal];
  186. // [careerBtn setTitle:json[@"occupation"] forState:UIControlStateNormal];
  187. // } failure:^(NSError *error) {
  188. //
  189. // }];
  190. // }else{
  191. // [nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
  192. // nameTF.enabled=YES;
  193. // ageTF.enabled=YES;
  194. //// identityTF.enabled=YES;
  195. // cell_numTF.enabled=YES;
  196. // incomeBtn.enabled=YES;
  197. // careerBtn.enabled=YES;
  198. // nameTF.text=@"";
  199. // ageTF.text=@"";
  200. //// identityTF.text=@"";
  201. // cell_numTF.text=@"";
  202. // [incomeBtn setTitle:@"请选择月收入" forState:UIControlStateNormal];
  203. // [careerBtn setTitle:@"请选择职业身份" forState:UIControlStateNormal];
  204. // }
  205. // } failure:^(NSError *error) {
  206. //
  207. // }];
  208. //}
  209. -(void)nextllAction
  210. {
  211. UITextField *nameTF=[self.view viewWithTag:666];
  212. UITextField *ageTF=[self.view viewWithTag:667];
  213. // UITextField *identityTF=[self.view viewWithTag:668];
  214. UITextField *cell_numTF=[self.view viewWithTag:668];
  215. UIButton *careerBtn=[self.view viewWithTag:8989];
  216. UIButton *incomeBtn=[self.view viewWithTag:8990];
  217. UIButton *nextBtn=[self.view viewWithTag:999];
  218. nextBtn.enabled=NO;
  219. if ([nextBtn.titleLabel.text isEqualToString:@"审核中..."]) {
  220. [self createPromptWhit:@"不要着急,请耐心等待审核......"];
  221. return;
  222. }
  223. NSString *urlString=[NSString stringWithFormat:@"%@/user/personalCenter",URL];
  224. [KXHTTP post:urlString params:nil success:^(id json) {
  225. NSString *username= [[NSUserDefaults standardUserDefaults]valueForKey:USER_NAME];
  226. NSString *password=[[NSUserDefaults standardUserDefaults]valueForKey:USER_PASSWORD];
  227. if (!username||!password) {
  228. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请登录" preferredStyle:UIAlertControllerStyleAlert];
  229. [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  230. KXLogginViewController *loggin=[[KXLogginViewController alloc]init];
  231. [self.navigationController pushViewController:loggin animated:YES];
  232. [[NSUserDefaults standardUserDefaults]setObject:nil forKey:@"ISPOP"];
  233. [[NSUserDefaults standardUserDefaults]synchronize];
  234. }]];
  235. [self presentViewController:alertController animated:YES completion:nil];
  236. }else{
  237. nextBtn.enabled=YES;
  238. if(nameTF.text.length==0){
  239. [self createPromptWhit:@"填入真实姓名后在试"];
  240. return;
  241. }
  242. if(ageTF.text.length==0){
  243. [self createPromptWhit:@"请填入年龄后在试"];
  244. return;
  245. }
  246. if(cell_numTF.text.length==0){
  247. [self createPromptWhit:@"请填入联系方式后在试"];
  248. return;
  249. }
  250. if([careerBtn.titleLabel.text isEqualToString:@"请选择职业身份"]){
  251. [self createPromptWhit:@"请选择职业后在试"];
  252. nextBtn.enabled=YES;
  253. return;
  254. }
  255. if([incomeBtn.titleLabel.text isEqualToString:@"请选择月收入"]){
  256. [self createPromptWhit:@"请选择月收入后在试"];
  257. return;
  258. }
  259. NSDictionary *userDict=json[@"user"];
  260. // NSDictionary *para=@{@"information_id":self.ID,@"user_id":userDict[@"id"]};
  261. KXUserIdentificationContronller *identification=[[KXUserIdentificationContronller alloc]init];
  262. NSDictionary *paraDict=@{@"id":userDict[@"id"],@"amount":@(_amount),@"term":@(_term),@"name":nameTF.text,@"age":ageTF.text,@"cell_num":cell_numTF.text,@"occupation":careerBtn.titleLabel.text,@"monthly_income":incomeBtn.titleLabel.text};
  263. identification.paraDict=paraDict;
  264. [self.navigationController pushViewController:identification animated:YES];
  265. }
  266. }
  267. failure:^(NSError *error) {
  268. nextBtn.enabled=YES;
  269. }];
  270. }
  271. -(void)createPromptWhit:(NSString*) message{
  272. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:message preferredStyle:UIAlertControllerStyleAlert];
  273. [alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  274. }]];
  275. [self presentViewController:alertController animated:YES completion:nil];
  276. }
  277. -(void)createviewSelectView
  278. {
  279. _selectView=[[UIView alloc]initWithFrame:self.view.bounds];
  280. _selectView.hidden=YES;
  281. _selectView.backgroundColor=[UIColor colorWithWhite:0 alpha:0.5];
  282. UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenAction:)];
  283. tapGesturRecognizer.delegate = self;
  284. [_selectView addGestureRecognizer:tapGesturRecognizer];
  285. [self.view addSubview:_selectView];
  286. self.selectTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT-220-64, SCREEN_WIDTH, 220) style:UITableViewStylePlain];
  287. self.selectTableView.separatorStyle=UITableViewCellSeparatorStyleNone;
  288. [self.selectTableView registerClass:[KXSelectTableViewCell class] forCellReuseIdentifier:@"selected"];
  289. self.selectTableView.tableFooterView=[[UIView alloc]init];
  290. tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hiddenAction:)];
  291. tapGesturRecognizer.delegate = self;
  292. [_selectView addGestureRecognizer:tapGesturRecognizer];
  293. [self.selectTableView addGestureRecognizer:tapGesturRecognizer];
  294. self.selectTableView.delegate = self;
  295. self.selectTableView.dataSource = self;
  296. [_selectView addSubview:self.selectTableView];
  297. }
  298. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
  299. if ([touch.view isKindOfClass:[UITableView class]]) {
  300. return YES;
  301. }else if([touch.view isMemberOfClass:[UIView class]]){
  302. return YES;
  303. }
  304. return NO;
  305. }
  306. -(void)hiddenAction:(UIGestureRecognizer*) g{
  307. _selectView.hidden=YES;
  308. }
  309. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  310. {
  311. if (_selected==YES) {
  312. return self.careerArray.count;
  313. }else{
  314. return self.incomellArray.count;
  315. }
  316. }
  317. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  318. {
  319. KXSelectTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"selected"];
  320. if (!cell) {
  321. cell=[[KXSelectTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"selected"];
  322. }
  323. if (_selected==YES) {
  324. cell.detailStr=self.careerArray[indexPath.row];
  325. }else{
  326. cell.detailStr=self.incomellArray[indexPath.row];
  327. }
  328. return cell;
  329. }
  330. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath
  331. {
  332. return 45;
  333. }
  334. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  335. {
  336. if (_selected==YES) {
  337. UIButton *button=[self.view viewWithTag:8989];
  338. [button setTitle:self.careerArray[indexPath.row] forState:UIControlStateNormal];
  339. }else{
  340. UIButton *button=[self.view viewWithTag:8990];
  341. [button setTitle:self.incomellArray[indexPath.row] forState:UIControlStateNormal];
  342. }
  343. _selectView.hidden=YES;
  344. }
  345. -(NSArray *)careerArray
  346. {
  347. if (!_careerArray) {
  348. _careerArray=@[@"上班族",@"个体户",@"企业主",@"自由职业"];
  349. }
  350. return _careerArray;
  351. }
  352. -(NSArray *)incomellArray
  353. {
  354. if (!_incomellArray) {
  355. _incomellArray=@[@"1000以下",@"1000-3000",@"3000-5000",@"5000-7000",@"7000-10000",@"1万-3万",@"3万-5万",@"5万以上"];
  356. }
  357. return _incomellArray;
  358. }
  359. //- (BOOL)isPureInt:(NSString*)string{
  360. // NSScanner* scan = [NSScanner scannerWithString:string];
  361. // int val;
  362. // return[scan scanInt:&val] && [scan isAtEnd];
  363. //}
  364. //
  365. //- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  366. //{
  367. // if([self isPureInt:string]){
  368. // return YES;
  369. // }
  370. // return NO;
  371. //}
  372. - (void)didReceiveMemoryWarning {
  373. [super didReceiveMemoryWarning];
  374. // Dispose of any resources that can be recreated.
  375. }
  376. /*
  377. #pragma mark - Navigation
  378. // In a storyboard-based application, you will often want to do a little preparation before navigation
  379. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  380. // Get the new view controller using [segue destinationViewController].
  381. // Pass the selected object to the new view controller.
  382. }
  383. */
  384. @end