dkahgld

ZBHotGoodVC.m 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //
  2. // ZBHotGoodVC.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/9.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBHotGoodVC.h"
  9. @interface ZBHotGoodVC ()<UITableViewDelegate,UITableViewDataSource>
  10. @property(nonatomic,strong)UITableView *tableViews;
  11. @property(nonatomic,strong)NSMutableArray *carArray;
  12. @property(nonatomic,strong)ZBTableHeadView *headView;
  13. @end
  14. @implementation ZBHotGoodVC
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. [self initWithNav];
  18. [self getCartgood];
  19. }
  20. -(void)updateHotGoodData
  21. {
  22. }
  23. -(void)getCartgood
  24. {
  25. if (![AccountTool isLogin]) {
  26. return;
  27. }
  28. [LoadingView showInView:self.view];
  29. [ZBHTTP post:getCarListURL params:nil success:^(id _Nonnull json) {
  30. self.headView.titlelabel.text=[NSString stringWithFormat:@"共%@件商品",json[@"count"]];
  31. NSArray *array =[NSArray yy_modelArrayWithClass:[ZBGoodModel class] json:json[@"data"]];
  32. [self.carArray addObjectsFromArray:array];
  33. if (self.carArray.count==0) {
  34. [self setUpNoDataView];
  35. }
  36. [self.tableViews reloadData];
  37. [LoadingView dismiss];
  38. } failure:^(NSError * _Nonnull error) {
  39. [LoadingView dismiss];
  40. }];
  41. }
  42. -(void)initWithNav
  43. {
  44. //接收通知,侧滑的时候
  45. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(updateHotGoodData) name:@"hotorder" object:nil];
  46. //添加tableview
  47. [self.view addSubview:self.tableViews];
  48. [self.tableViews mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.top.mas_equalTo(0);
  50. make.height.mas_equalTo(SCREEN_HEIGHT-45-NavBarHeight);
  51. make.left.right.mas_equalTo(0);
  52. }];
  53. self.headView=[[ZBTableHeadView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
  54. self.tableViews.tableHeaderView=self.headView;
  55. }
  56. #pragma mark---TableViewDelegate&&DataSource
  57. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  58. {
  59. ZBShopCarListCell *listC =[tableView dequeueReusableCellWithIdentifier:@"list"];
  60. if (!listC) {
  61. listC=[[ZBShopCarListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"list"];
  62. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  63. }
  64. listC.model=self.carArray[indexPath.section];
  65. return listC;
  66. }
  67. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  68. {
  69. return 1;
  70. }
  71. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  72. {
  73. return self.carArray.count;
  74. }
  75. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  76. {
  77. return 122;
  78. }
  79. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  80. {
  81. return 0.00;
  82. }
  83. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  84. {
  85. UIView *back =[[UIView alloc]init];
  86. back.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
  87. return back;
  88. }
  89. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  90. {
  91. }
  92. -(UITableView *)tableViews
  93. {
  94. if (!_tableViews) {
  95. _tableViews =[[UITableView alloc]init];
  96. _tableViews.delegate=self;
  97. _tableViews.dataSource=self;
  98. _tableViews.backgroundColor=[UIColor whiteColor];
  99. _tableViews.separatorStyle=UITableViewCellSeparatorStyleNone;
  100. // _tableViews.layer.cornerRadius=10;
  101. // _tableViews.layer.masksToBounds=YES;
  102. _tableViews.showsHorizontalScrollIndicator=NO;
  103. _tableViews.showsVerticalScrollIndicator=NO;
  104. }
  105. return _tableViews;
  106. }
  107. -(NSMutableArray *)carArray
  108. {
  109. if (!_carArray) {
  110. _carArray =[NSMutableArray array];
  111. }
  112. return _carArray;
  113. }
  114. #pragma mark -- 移除通知
  115. -(void)dealloc{
  116. [[NSNotificationCenter defaultCenter]removeObserver:self];
  117. }
  118. - (void)setUpNoDataView {
  119. self.tableViews.showNoDataView = YES;
  120. self.tableViews.noDataImageOffsetY = -70;
  121. self.tableViews.defaultNoDataText = @"还没有记录";
  122. self.tableViews.defaultNoDataImage = [UIImage imageNamed:@"no_order"];
  123. }
  124. @end