dkahgld

ZBWithDrawalViewController.m 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. //
  2. // ZBWithDrawalViewController.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/3/28.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBWithDrawalViewController.h"
  9. #import "ZBWithDrawalListCell.h"
  10. @interface ZBWithDrawalViewController ()<UITableViewDelegate,UITableViewDataSource>
  11. {
  12. UILabel *totalL;
  13. UILabel *messagelabel;
  14. }
  15. @property(nonatomic,strong)UITableView *tableViews;
  16. @property(nonatomic,assign)NSInteger page;
  17. @property(nonatomic,strong)NSMutableArray *listArray;
  18. @end
  19. @implementation ZBWithDrawalViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. [self initNav];
  23. [self getBlance];
  24. [self getWithDrawList];
  25. }
  26. -(void)getBlance
  27. {
  28. if (![AccountTool isLogin]) {
  29. return;
  30. }
  31. [ZBHTTP post:getaccountPriceURL params:nil success:^(id _Nonnull json) {
  32. messagelabel.text=json[@"data"][@"alert"];
  33. NSString *title = [NSString stringWithFormat:@"¥%@",json[@"data"][@"notEnd"]];
  34. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
  35. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0,1)]; //设置字体字号和字体类别
  36. totalL.attributedText = str;
  37. } failure:^(NSError * _Nonnull error) {
  38. // [MBProgressHUD showMessage:@"网络错误"];
  39. }];
  40. }
  41. - (void)setUpNoDataView {
  42. self.tableViews.showNoDataView = YES;
  43. self.tableViews.noDataImageOffsetY = -70;
  44. self.tableViews.defaultNoDataText = @"还没有余额";
  45. self.tableViews.defaultNoDataImage = [UIImage imageNamed:@"no_order"];
  46. }
  47. #pragma mark---获取余额列表
  48. -(void)getWithDrawList
  49. {
  50. if (![AccountTool isLogin]) {
  51. return;
  52. }
  53. NSDictionary *dic =@{@"page":@(self.page)};
  54. [LoadingView showInView:self.view];
  55. [ZBHTTP post:getBalancelistURL params:dic success:^(id _Nonnull json) {
  56. [LoadingView dismiss];
  57. NSArray *array =[NSArray yy_modelArrayWithClass:[ZBWithDrawalModel class] json:json[@"balanceList"]];
  58. [self.tableViews.mj_header endRefreshing];
  59. [self.tableViews.mj_footer endRefreshing];
  60. if (array.count >0) {
  61. if (self.page == 1) {
  62. [self.listArray removeAllObjects];
  63. }
  64. [self.listArray addObjectsFromArray:array];
  65. }else{
  66. [self.tableViews.mj_footer endRefreshingWithNoMoreData];
  67. }
  68. if (self.listArray.count == 0) {
  69. [self setUpNoDataView];
  70. }
  71. [self.tableViews reloadData];
  72. NSLog(@"%@",json);
  73. } failure:^(NSError * _Nonnull error) {
  74. [LoadingView dismiss];
  75. }];
  76. }
  77. -(void)initNav
  78. {
  79. self.backView.hidden=YES;
  80. self.navBar.navTitleLabel.text=@"我的账户";
  81. self.page = 1;
  82. UIView *backV =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 203-NavBarHeight)];
  83. backV.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
  84. UIView *headV =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 168-NavBarHeight)];
  85. headV.backgroundColor=[UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFF9600] toColor:[UIColor YHColorWithHex:0xFF7200] withWidth:SCREEN_WIDTH];
  86. messagelabel =[[UILabel alloc]initWithFrame:CGRectMake(15, headV.bottom, SCREEN_WIDTH, 35)];
  87. messagelabel.text=@"每月25号结算上个月订单,收益会自动转入";
  88. messagelabel.textColor=[UIColor YHColorWithHex:0x333333];
  89. messagelabel.font=[UIFont systemFontOfSize:FITSIZE(12)];
  90. [backV addSubview:headV];
  91. [backV addSubview:messagelabel];
  92. self.tableViews.tableHeaderView=backV;
  93. totalL =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, headV.height)];
  94. totalL.textAlignment=NSTextAlignmentCenter;
  95. totalL.textColor=[UIColor whiteColor];
  96. totalL.font=[UIFont boldSystemFontOfSize:48];
  97. NSString *title = @"¥---.--";
  98. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
  99. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0,1)]; //设置字体字号和字体类别
  100. totalL.attributedText = str;
  101. [headV addSubview:totalL];
  102. UIButton *returnBtn =[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 20)];
  103. [returnBtn addTarget:self action:@selector(returnClickBtn) forControlEvents:UIControlEventTouchUpInside];
  104. [returnBtn setImage:[UIImage imageNamed:@"return_white"] forState:UIControlStateNormal];
  105. returnBtn.adjustsImageWhenHighlighted = NO;
  106. [self.navBar setCustomLeftButtons:@[returnBtn]];
  107. //添加tableview
  108. [self.view addSubview:self.tableViews];
  109. [self.tableViews mas_makeConstraints:^(MASConstraintMaker *make) {
  110. make.top.mas_equalTo(NavBarHeight);
  111. make.height.mas_equalTo(SCREEN_HEIGHT);
  112. make.left.right.mas_equalTo(0);
  113. }];
  114. self.tableViews.mj_header =[MJRefreshNormalHeader headerWithRefreshingBlock:^{
  115. self.page = 1;
  116. [self getWithDrawList];
  117. }];
  118. self.tableViews.mj_footer =[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  119. self.page++;
  120. [self getWithDrawList];
  121. }];
  122. }
  123. -(void)returnClickBtn
  124. {
  125. [self.navigationController popViewControllerAnimated:YES];
  126. }
  127. #pragma mark---TableViewDelegate&&DataSource
  128. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  129. {
  130. ZBWithDrawalListCell *listC =[tableView dequeueReusableCellWithIdentifier:@"draw"];
  131. if (!listC) {
  132. listC=[[ZBWithDrawalListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"draw"];
  133. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  134. }
  135. listC.model=self.listArray[indexPath.row];
  136. return listC;
  137. }
  138. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  139. {
  140. return self.listArray.count;
  141. }
  142. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  143. {
  144. return 1;
  145. }
  146. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  147. {
  148. return FITSIZE(80);
  149. }
  150. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  151. {
  152. return 10;
  153. }
  154. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  155. {
  156. UIView *back =[[UIView alloc]init];
  157. back.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
  158. return back;
  159. }
  160. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  161. {
  162. UIView *back =[[UIView alloc]init];
  163. back.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
  164. return back;
  165. }
  166. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  167. {
  168. }
  169. -(UITableView *)tableViews
  170. {
  171. if (!_tableViews) {
  172. _tableViews =[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
  173. _tableViews.delegate=self;
  174. _tableViews.dataSource=self;
  175. _tableViews.backgroundColor=[UIColor YHColorWithHex:0xF4F4F4];
  176. _tableViews.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
  177. _tableViews.sectionHeaderHeight=10;
  178. _tableViews.showsHorizontalScrollIndicator=NO;
  179. _tableViews.showsVerticalScrollIndicator=NO;
  180. }
  181. return _tableViews;
  182. }
  183. -(NSMutableArray *)listArray
  184. {
  185. if (!_listArray) {
  186. _listArray=[NSMutableArray array];
  187. }
  188. return _listArray;
  189. }
  190. @end