123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- //
- // ZBHotGoodVC.m
- // ZBProject
- //
- // Created by 学丽 on 2019/4/9.
- // Copyright © 2019 ZB. All rights reserved.
- //
- #import "ZBHotGoodVC.h"
- @interface ZBHotGoodVC ()<UITableViewDelegate,UITableViewDataSource>
- @property(nonatomic,strong)UITableView *tableViews;
- @property(nonatomic,strong)NSMutableArray *carArray;
- @property(nonatomic,strong)ZBTableHeadView *headView;
- @end
- @implementation ZBHotGoodVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self initWithNav];
- [self getCartgood];
- }
- -(void)updateHotGoodData
- {
-
- }
- -(void)getCartgood
- {
- if (![AccountTool isLogin]) {
- return;
- }
- [LoadingView showInView:self.view];
- [ZBHTTP post:getCarListURL params:nil success:^(id _Nonnull json) {
- self.headView.titlelabel.text=[NSString stringWithFormat:@"共%@件商品",json[@"count"]];
- NSArray *array =[NSArray yy_modelArrayWithClass:[ZBGoodModel class] json:json[@"data"]];
- [self.carArray addObjectsFromArray:array];
- if (self.carArray.count==0) {
- [self setUpNoDataView];
- }
- [self.tableViews reloadData];
- [LoadingView dismiss];
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- }];
- }
- -(void)initWithNav
- {
- //接收通知,侧滑的时候
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(updateHotGoodData) name:@"hotorder" object:nil];
-
- //添加tableview
- [self.view addSubview:self.tableViews];
- [self.tableViews mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.height.mas_equalTo(SCREEN_HEIGHT-45-NavBarHeight);
- make.left.right.mas_equalTo(0);
- }];
- self.headView=[[ZBTableHeadView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
- self.tableViews.tableHeaderView=self.headView;
- }
- #pragma mark---TableViewDelegate&&DataSource
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- ZBShopCarListCell *listC =[tableView dequeueReusableCellWithIdentifier:@"list"];
- if (!listC) {
- listC=[[ZBShopCarListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"list"];
- listC.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- listC.model=self.carArray[indexPath.section];
- return listC;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 1;
- }
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return self.carArray.count;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return 122;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 0.00;
- }
- -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
- UIView *back =[[UIView alloc]init];
- back.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
- return back;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- }
- -(UITableView *)tableViews
- {
- if (!_tableViews) {
- _tableViews =[[UITableView alloc]init];
- _tableViews.delegate=self;
- _tableViews.dataSource=self;
- _tableViews.backgroundColor=[UIColor whiteColor];
- _tableViews.separatorStyle=UITableViewCellSeparatorStyleNone;
-
- // _tableViews.layer.cornerRadius=10;
- // _tableViews.layer.masksToBounds=YES;
- _tableViews.showsHorizontalScrollIndicator=NO;
- _tableViews.showsVerticalScrollIndicator=NO;
-
- }
- return _tableViews;
- }
- -(NSMutableArray *)carArray
- {
- if (!_carArray) {
- _carArray =[NSMutableArray array];
- }
- return _carArray;
- }
- #pragma mark -- 移除通知
- -(void)dealloc{
-
- [[NSNotificationCenter defaultCenter]removeObserver:self];
- }
- - (void)setUpNoDataView {
- self.tableViews.showNoDataView = YES;
- self.tableViews.noDataImageOffsetY = -70;
- self.tableViews.defaultNoDataText = @"还没有记录";
- self.tableViews.defaultNoDataImage = [UIImage imageNamed:@"no_order"];
- }
- @end
|