123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- //
- // KDPProjectListVC.m
- // KuDianProject
- //
- // Created by 学丽 on 2019/7/10.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPProjectListVC.h"
- @interface KDPProjectListVC ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
- @property(nonatomic,strong)UICollectionView *listview;
- @property(nonatomic,assign)NSInteger pageNum;
- @property(nonatomic,strong)NSMutableArray *dataArray;
- @end
- @implementation KDPProjectListVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.pageNum=1;
- [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
- self.view.backgroundColor=[UIColor whiteColor];
- [self.view addSubview:self.listview];
- [self.listview mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.top.mas_equalTo(KDNavBarHeight);
- make.height.mas_equalTo(SCREEN_HEIGHT-KDNavBarHeight);
- make.width.mas_equalTo(SCREEN_WIDTH);
- }];
- [self goodListProject];
-
- }
- -(void)goodListProject
- {
- [LoadingView show];
- NSDictionary *dics =@{@"page":@(self.pageNum),@"id":self.projectID,@"type":self.type,@"start_price":@"",@"end_price":@"",@"start_tk_rate":@""};
- [KDPNetworkRequestHTTP postURL:projectGoodURL params:dics success:^(id _Nonnull json) {
- [LoadingView dismiss];
- if (self.pageNum == 1) {
- [self.dataArray removeAllObjects];
- }
-
- NSArray *array =[NSArray yy_modelArrayWithClass:[KDPGoodsModel class] json:json[@"data"]];
-
- [self.listview.mj_header endRefreshing];
- [self.listview.mj_footer endRefreshing];
- if (array.count == 0) {
- [self.listview.mj_footer endRefreshingWithNoMoreData];
- }
- [self.dataArray addObjectsFromArray:array];
- [self.listview reloadData];
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- }];
- }
- #pragma mark---CollectDelegate&&DataSource
- -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- KDPRecommendGoodCell *recommC=[collectionView dequeueReusableCellWithReuseIdentifier:@"recomm" forIndexPath:indexPath];
- recommC.model=self.dataArray[indexPath.row];
- return recommC;
- }
- -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
- return self.dataArray.count;
- }
- -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
- {
- return 1;
- }
- -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- return CGSizeMake(SCREEN_WIDTH, 121);
- }
- -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- {
- KDPGoodDetailVC *goodDetail=[[KDPGoodDetailVC alloc]init];
- goodDetail.model=self.dataArray[indexPath.row];
- [self.navigationController pushViewController:goodDetail animated:YES];
- }
- - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView{
- return [UIImage imageNamed:@"no_order"];
- }
- - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
- return YES;
- }
- - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView{
- return [[NSAttributedString alloc] initWithString:@"还没有记录" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x333333],NSFontAttributeName:FONT_SYS(12)}];
- }
- - (CGFloat )spaceHeightForEmptyDataSet:(UIScrollView *)scrollView{
- return 30;
- }
- -(void)returnClickBtn
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.navigationController.navigationBar.hidden=YES;
- self.tabBarController.tabBar.hidden=YES;
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- self.tabBarController.tabBar.hidden=NO;
- }
- -(UICollectionView *)listview
- {
- if (!_listview) {
- UICollectionViewFlowLayout *layout =[[UICollectionViewFlowLayout alloc]init];
- layout.minimumLineSpacing=0;
- layout.minimumInteritemSpacing=0;
-
- _listview=[[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) collectionViewLayout:layout];
- _listview.showsVerticalScrollIndicator=NO;
- _listview.backgroundColor=[UIColor whiteColor];
- _listview.delegate=self;
- _listview.dataSource=self;
- [_listview registerClass:[KDPRecommendGoodCell class] forCellWithReuseIdentifier:@"recomm"];
- _listview.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{
- self.pageNum = 1;
- [self goodListProject];
- }];
- _listview.emptyDataSetDelegate = self;
- _listview.emptyDataSetSource = self;
- _listview.mj_footer=[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
- self.pageNum++;
- [self goodListProject];
- }];
- }
- return _listview;
- }
- -(NSMutableArray *)dataArray
- {
- if (!_dataArray) {
- _dataArray=[NSMutableArray array];
-
- }
- return _dataArray;
- }
- @end
|