123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- //
- // KXLoanAllDetailViewController.m
- // QBCS
- //
- // Created by kuxuan on 2017/6/8.
- // Copyright © 2017年 kuxuan. All rights reserved.
- //
- #import "KXLoanAllDetailViewController.h"
- #import "KXMainListTableViewCell.h"
- #import "KXHotList.h"
- #import "KXMainDetailViewController.h"
- #import "KXMainDetailModel.h"
- #import "KXWebDetailViewController.h"
- @interface KXLoanAllDetailViewController ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic,strong)UITableView *tableView;
- @property (nonatomic,strong)NSMutableArray *dataSource;
- @property (nonatomic,assign)NSInteger page;
- @end
- @implementation KXLoanAllDetailViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.page=1;
- [self createNavigationBar];
- [self createTabletableView];
-
- }
- -(void)createNavigationBar
- {
- self.name=self.titleString;
- [self addLeftBarButtonItemWithImageName:@"main_back" title:nil target:self selector:@selector(backAction)];
- }
- -(void)backAction
- {
- self.changeLabel();
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)createTabletableView
- {
- self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavHeight-safeBottomHeight) style:UITableViewStylePlain];
- self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
- [self.tableView registerClass:[KXMainListTableViewCell class] forCellReuseIdentifier:@"main"];
- self.tableView.tableFooterView=[[UIView alloc]init];
- //下拉刷新
- MJRefreshNormalHeader *header =
- [[MJRefreshNormalHeader alloc]init];
- [header setRefreshingTarget:self refreshingAction:@selector(refreshHeader:)];
- self.tableView.mj_header = header;
- [header beginRefreshing];
- //上拉加载
- MJRefreshAutoNormalFooter *footer=[[MJRefreshAutoNormalFooter alloc]init];
- [footer setRefreshingTarget:self refreshingAction:@selector(refreshFooter:)];
- self.tableView.mj_footer=footer;
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- [self.view addSubview:self.tableView];
-
- header.stateLabel.font = FONT_SYS(14);
- header.stateLabel.textColor=[UIColor detailTitleColor];
- header.lastUpdatedTimeLabel.font=FONT_SYS(14);
- header.lastUpdatedTimeLabel.textColor=[UIColor detailTitleColor];
- footer.stateLabel.textColor=[UIColor detailTitleColor];
- }
- #pragma mark 下拉刷新和上拉加载
- -(void)refreshHeader:(MJRefreshHeader *)header
- {
- self.page=1;
- [self requestDataWithPage:self.page];
- }
- -(void)refreshFooter:(MJRefreshAutoFooter *)footer
- {
- self.page++;
- [self requestDataWithPage:self.page];
- }
- -(void)requestDataWithPage:(NSInteger)page
- {
- NSString *urlString=[NSString stringWithFormat:@"%@/product/getInfoByCat",URL];
- [KXHTTP post:urlString params:@{@"id":self.ID,@"page":@(page)} success:^(id json) {
- NSArray *array=[NSArray yy_modelArrayWithClass:[KXHotList class] json:json[@"data"]];
- if (self.page==1) {
- [self.dataSource removeAllObjects];
- }
- for (KXHotList *model in array) {
- [self.dataSource addObject:model];
- }
- if (array.count < 10) {
- [_tableView.mj_header endRefreshing];
- [_tableView.mj_footer endRefreshing];
- [_tableView.mj_footer endRefreshingWithNoMoreData];
- }else{
- [_tableView.mj_header endRefreshing];
- [_tableView.mj_footer endRefreshing];
- }
- [_tableView reloadData];
- } failure:^(NSError *error) {
-
- }];
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.dataSource.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- KXHotList *model=self.dataSource[indexPath.row];
- KXMainListTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"main"];
- if (!cell) {
- cell=[[KXMainListTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"main"];
- }
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- // cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
- cell.hotmodel=model;
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 80*SCREEN_MUTI;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- KXHotList *model=self.dataSource[indexPath.row];
- //0跳详情,1跳链接
- if ([model.skip_type isEqualToString:@"1"]) {
-
- KXWebDetailViewController *web=[[KXWebDetailViewController alloc]init];
- web.webStr=model.link;
- web.titleStr = model.name;
- web.product_id = model.Id;
- web.product_apply_id = @"0";
- [self.navigationController pushViewController:web animated:YES];
- }else{
- KXMainDetailViewController *detail=[[KXMainDetailViewController alloc]init];
- detail.detailID=model.Id;
- detail.titleString=model.name;
- if ([self.titleString isEqualToString:@"极速贷"]) {
-
- detail.enterSource = @"speedKind";
- } else if ([self.titleString isEqualToString:@"热门贷"])
- {
- detail.enterSource = @"hotKind";
- } else if ([self.titleString isEqualToString:@"信用贷"])
- {
- detail.enterSource = @"creditKind";
- } else if ([self.titleString isEqualToString:@"大额贷"])
- {
- detail.enterSource = @"LargeAmount_kind";
- }
- [self.navigationController pushViewController:detail animated:YES];
- }
- }
- #pragma mark lazyload
- -(NSMutableArray *)dataSource
- {
- if (!_dataSource) {
- _dataSource=[[NSMutableArray alloc]init];
- }
- return _dataSource;
- }
- @end
|