dkahgld

ZBIncomeViewController.m 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. //
  2. // ZBIncomeViewController.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/3/28.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBIncomeViewController.h"
  9. #import "ZBIncomeListCell.h"
  10. #import "ZBIncomeDetailModel.h"
  11. @interface ZBIncomeViewController ()<UITableViewDelegate,UITableViewDataSource>
  12. {
  13. UILabel *totalL;
  14. }
  15. @property(nonatomic,strong)UITableView *tableViews;
  16. @property(nonatomic,assign)NSInteger page;
  17. @property(nonatomic,strong)NSMutableArray *listArray;
  18. @property (nonatomic, strong) LDCalendarView *calendarView ;
  19. @property (nonatomic, strong) CCAlertShowView *alertShowView;
  20. @end
  21. @implementation ZBIncomeViewController
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. [self initNav];
  25. [self getIncomeList];
  26. if (self.isShow.integerValue==1) {
  27. [self showCalendar];
  28. }
  29. }
  30. - (void)showCalendar {
  31. if (self.alertShowView) {
  32. [self.alertShowView show];
  33. return;
  34. }
  35. CCAlertShowView *showView = [CCAlertShowView showAlertViewWithView:self.calendarView backgroundDismissEnable:YES];
  36. self.alertShowView = showView;
  37. [self.alertShowView show];
  38. }
  39. -(void)getIncomeList
  40. {
  41. if (![AccountTool isLogin]) {
  42. return;
  43. }
  44. [LoadingView show];
  45. NSDictionary *dic =@{@"yearMonthDay":_yearMonthDay,@"isDay":@(self.isDay),@"type":self.type,@"page":@(self.page)};
  46. [ZBHTTP post:getIncomeListURL params:dic success:^(id _Nonnull json) {
  47. NSLog(@"%@",json);
  48. [LoadingView dismiss];
  49. NSString *title=[NSString stringWithFormat:@"%@ 订单:%@笔 佣金:%@元",self.yearMonthDay,json[@"num"],json[@"allRebate"]];
  50. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
  51. [str addAttribute:NSForegroundColorAttributeName value:[UIColor baseColor] range:NSMakeRange(0,self.yearMonthDay.length)];
  52. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,self.yearMonthDay.length)]; //设置字体字号和字体类别
  53. totalL.attributedText = str;
  54. [self.tableViews.mj_header endRefreshing];
  55. [self.tableViews.mj_footer endRefreshing];
  56. NSArray *array =[NSArray yy_modelArrayWithClass:[ZBIncomeDetailModel class] json:json[@"data"]];
  57. if (array.count >0) {
  58. if (self.page == 1) {
  59. [self.listArray removeAllObjects];
  60. }
  61. [self.listArray addObjectsFromArray:array];
  62. }else{
  63. [self.tableViews.mj_footer endRefreshingWithNoMoreData];
  64. }
  65. if (self.listArray.count ==0) {
  66. [self setUpNoDataView];
  67. }
  68. [self.tableViews reloadData];
  69. } failure:^(NSError * _Nonnull error) {
  70. [LoadingView dismiss];
  71. // [MBProgressHUD showMessage:@"网络错误"];
  72. }];
  73. }
  74. -(void)initNav
  75. {
  76. self.backView.hidden=YES;
  77. self.page = 1;
  78. self.navBar.navTitleLabel.text=[NSString stringWithFormat:@"%@收入",self.yearMonthDay];
  79. UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 20)];
  80. [returnBtn addTarget:self action:@selector(returnClickBtn) forControlEvents:UIControlEventTouchUpInside];
  81. [returnBtn setImage:[UIImage imageNamed:@"return_white"] forState:UIControlStateNormal];
  82. returnBtn.adjustsImageWhenHighlighted = NO;
  83. [self.navBar setCustomLeftButtons:@[returnBtn]];
  84. UIView *headV =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 41)];
  85. headV.backgroundColor=[UIColor whiteColor];
  86. self.tableViews.tableHeaderView=headV;
  87. totalL =[[UILabel alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 41)];
  88. totalL.textColor=[UIColor YHColorWithHex:0x4A4A4A];
  89. totalL.font=[UIFont systemFontOfSize:14];
  90. NSString *title=@"0000-00 订单:-笔 佣金:--.--元";
  91. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
  92. [str addAttribute:NSForegroundColorAttributeName value:[UIColor baseColor] range:NSMakeRange(0,7)];
  93. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(0,7)]; //设置字体字号和字体类别
  94. totalL.attributedText = str;
  95. [headV addSubview:totalL];
  96. //添加tableview
  97. [self.view addSubview:self.tableViews];
  98. [self.tableViews mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.top.mas_equalTo(NavBarHeight);
  100. make.height.mas_equalTo(SCREEN_HEIGHT-NavBarHeight);
  101. make.left.right.mas_equalTo(0);
  102. }];
  103. // self.tableViews.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{
  104. // self.page = 1;
  105. // [self getIncomeList];
  106. // }];
  107. _tableViews.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  108. self.page++;
  109. [self getIncomeList];
  110. }];
  111. }
  112. -(void)returnClickBtn
  113. {
  114. [self.navigationController popViewControllerAnimated:YES];
  115. }
  116. #pragma mark---TableViewDelegate&&DataSource
  117. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  118. {
  119. ZBIncomeListCell *listC =[tableView dequeueReusableCellWithIdentifier:@"list"];
  120. if (!listC) {
  121. listC=[[ZBIncomeListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"list"];
  122. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  123. }
  124. listC.model=self.listArray[indexPath.row];
  125. return listC;
  126. }
  127. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  128. {
  129. return self.listArray.count;
  130. }
  131. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  132. {
  133. return 1;
  134. }
  135. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  136. {
  137. return 110;
  138. }
  139. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  140. {
  141. return 10;
  142. }
  143. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  144. {
  145. UIView *back =[[UIView alloc]init];
  146. back.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
  147. return back;
  148. }
  149. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  150. {
  151. }
  152. -(UITableView *)tableViews
  153. {
  154. if (!_tableViews) {
  155. _tableViews =[[UITableView alloc]init];
  156. _tableViews.delegate=self;
  157. _tableViews.dataSource=self;
  158. _tableViews.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
  159. _tableViews.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
  160. _tableViews.sectionHeaderHeight=10;
  161. _tableViews.showsHorizontalScrollIndicator=NO;
  162. _tableViews.showsVerticalScrollIndicator=NO;
  163. UIView *view =[ [UIView alloc]init];
  164. view.backgroundColor = [UIColor clearColor];
  165. [_tableViews setTableFooterView:view];
  166. }
  167. return _tableViews;
  168. }
  169. -(NSMutableArray *)listArray
  170. {
  171. if (!_listArray) {
  172. _listArray=[NSMutableArray array];
  173. }
  174. return _listArray;
  175. }
  176. - (void)setUpNoDataView {
  177. self.tableViews.showNoDataView = YES;
  178. self.tableViews.noDataImageOffsetY = -70;
  179. self.tableViews.defaultNoDataText = @"还没有收入";
  180. self.tableViews.defaultNoDataImage = [UIImage imageNamed:@"no_order"];
  181. }
  182. - (LDCalendarView *)calendarView {
  183. if (!_calendarView) {
  184. __weak typeof(self) weakSelf = self;
  185. _calendarView = [[LDCalendarView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-40, 0)];
  186. _calendarView.cancelBlock = ^{
  187. [weakSelf.alertShowView dismiss];
  188. };
  189. _calendarView.makeSureBlock = ^(NSString *dateStr) {
  190. if (dateStr) {
  191. weakSelf.yearMonthDay = dateStr;
  192. [weakSelf.navBar setNavTitle:dateStr];
  193. weakSelf.navBar.navTitleLabel.textColor = [UIColor whiteColor];
  194. weakSelf.page = 1;
  195. [weakSelf getIncomeList];
  196. [weakSelf.alertShowView dismiss];
  197. }else {
  198. [weakSelf.alertShowView dismiss];
  199. }
  200. };
  201. }
  202. return _calendarView;
  203. }
  204. @end