123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //
- // KXLoanAllViewController.m
- // QBCS
- //
- // Created by kuxuan on 2017/6/8.
- // Copyright © 2017年 kuxuan. All rights reserved.
- //
- #import "KXLoanAllViewController.h"
- #import "KXLoanAllModel.h"
- #import "KXLoanAllTableViewCell.h"
- #import "KXLoanAllDetailViewController.h"
- @interface KXLoanAllViewController ()<UITableViewDelegate,UITableViewDataSource>
- {
- UITableView *_tableView;
- }
- @property (nonatomic,strong)NSMutableArray *dataSource;
- @property (nonatomic,strong)NSArray *otherSource;
- @end
- @implementation KXLoanAllViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.view.backgroundColor= [UIColor KXColorWithRed:239 green:239 blue:244];
- [self createNavigation];
- [self createTableView];
- [self requestSource];
- }
- -(void)createNavigation
- {
- self.name=@"极速贷款";
- [self addLeftBarButtonItemWithImageName:@"main_back" title:nil target:self selector:@selector(backAction)];
- }
- -(void)backAction
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)createTableView
- {
- _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,SCREEN_HEIGHT) style:UITableViewStylePlain];
- _tableView.backgroundColor= [UIColor KXColorWithRed:239 green:239 blue:244];
- _tableView.dataSource=self;
- _tableView.delegate=self;
- [_tableView registerClass:[KXLoanAllTableViewCell class] forCellReuseIdentifier:@"loanall"];
- _tableView.tableFooterView=[[UIView alloc]init];
- _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
- [self.view addSubview:_tableView];
- }
- -(void)requestSource
- {
- NSString *urlString=[NSString stringWithFormat:@"%@/category/list",URL];
- [KXHTTP post:urlString params:nil success:^(id json) {
- NSArray *array=[NSArray yy_modelArrayWithClass:[KXLoanAllModel class] json:json];
- for (KXLoanAllModel *model in array) {
- [self.dataSource addObject:model];
- }
- [_tableView reloadData];
- } failure:^(NSError *error) {
-
- }];
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.dataSource.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- KXLoanAllModel *model=self.dataSource[indexPath.row];
- NSDictionary *dict=self.otherSource[indexPath.row];
- KXLoanAllTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (!cell) {
- cell=[[KXLoanAllTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
- }
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- cell.model=model;
- cell.image=[UIImage imageNamed:dict[@"image"]];
- cell.backColor=dict[@"color"];
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 80*SCREEN_MUTI;
- }
-
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- KXLoanAllModel *model=self.dataSource[indexPath.row];
- KXLoanAllDetailViewController *detail=[[KXLoanAllDetailViewController alloc]init];
- detail.ID=@(model.Id.integerValue);
- detail.titleString=model.Description[0];
- [self.navigationController pushViewController:detail animated:YES];
- }
- -(NSMutableArray *)dataSource
- {
- if (!_dataSource) {
- _dataSource=[[NSMutableArray alloc]init];
- }
- return _dataSource;
- }
- -(NSArray *)otherSource
- {
- if (!_otherSource) {
- _otherSource=@[@{@"image":@"main_all_quick",@"color":[UIColor baseColor]},@{@"image":@"main_all_hot",@"color":[UIColor KXColorWithHex:0xff5a6a]},@{@"image":@"main_all_credit",@"color":[UIColor KXColorWithHex:0x57c62b]},@{@"image":@"main_all_stu",@"color":[UIColor KXColorWithHex:0xffba49]},@{@"image":@"main_all_house",@"color":[UIColor KXColorWithHex:0xc66bd6]}];
- }
- return _otherSource;
- }
- @end
|