酷店

KDPAccountVC.m 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. //
  2. // KDPAccountVC.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/8.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPAccountVC.h"
  9. #import "KDPAccountListCell.h"
  10. @interface KDPAccountVC ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
  11. {
  12. UILabel *_accountMoneyLabel;
  13. UILabel *_tipeLabel;
  14. NSInteger page_num;
  15. }
  16. @property(nonatomic,strong)UITableView *accountView;
  17. @property(nonatomic,strong)NSMutableArray *dataArray;
  18. @end
  19. @implementation KDPAccountVC
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. [self setNavUI];
  23. page_num = 1;
  24. [self getAccountBalance];
  25. [self getBalanceList];
  26. }
  27. -(void)getBalanceList
  28. {
  29. [LoadingView show];
  30. [KDPNetworkRequestHTTP postURL:BalancelistURL params:@{@"page":@(page_num)} success:^(id _Nonnull json) {
  31. [LoadingView dismiss];
  32. NSArray *array =[NSArray yy_modelArrayWithClass:[KDPBalanceModel class] json:json[@"balanceList"]];
  33. if (page_num ==1) {
  34. [self.dataArray removeAllObjects];
  35. }
  36. [self.accountView.mj_header endRefreshing];
  37. [self.accountView.mj_footer endRefreshing];
  38. if (array.count == 0) {
  39. [self.accountView.mj_footer endRefreshingWithNoMoreData];
  40. }
  41. [self.dataArray addObjectsFromArray:array];
  42. [self.accountView reloadData];
  43. } failure:^(NSError * _Nonnull error) {
  44. [LoadingView dismiss];
  45. }];
  46. }
  47. -(void)getAccountBalance
  48. {
  49. [LoadingView show];
  50. [KDPNetworkRequestHTTP postURL:balanceURL params:nil success:^(id _Nonnull json) {
  51. [LoadingView dismiss];
  52. _tipeLabel.text=json[@"data"][@"alert"];
  53. NSString *contents = [NSString stringWithFormat:@"¥%@",json[@"data"][@"notEnd"]];
  54. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:contents];
  55. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0,1)]; //设置字体字号和字体类别
  56. _accountMoneyLabel.attributedText = str;
  57. } failure:^(NSError * _Nonnull error) {
  58. [LoadingView dismiss];
  59. }];
  60. }
  61. -(void)setNavUI
  62. {
  63. self.view.backgroundColor=[UIColor whiteColor];
  64. [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
  65. self.navBar.navTitleLabel.text=@"我的账户";
  66. [self.view addSubview:self.accountView];
  67. }
  68. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  69. {
  70. KDPAccountListCell *listC=[tableView dequeueReusableCellWithIdentifier:@"account"];
  71. if (!listC) {
  72. listC=[[KDPAccountListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"account"];
  73. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  74. }
  75. listC.model=self.dataArray[indexPath.row];
  76. return listC;
  77. }
  78. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  79. {
  80. return self.dataArray.count;
  81. }
  82. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  83. {
  84. }
  85. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  86. {
  87. return 80;
  88. }
  89. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  90. {
  91. return 1;
  92. }
  93. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView{
  94. return [UIImage imageNamed:@"no_order"];
  95. }
  96. - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView{
  97. return YES;
  98. }
  99. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView{
  100. return [[NSAttributedString alloc] initWithString:@"还没有记录" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHex:0x333333],NSFontAttributeName:FONT_SYS(12)}];
  101. }
  102. - (CGFloat )spaceHeightForEmptyDataSet:(UIScrollView *)scrollView{
  103. return 50;
  104. }
  105. -(void)returnClickBtn
  106. {
  107. [self.navigationController popViewControllerAnimated:YES];
  108. }
  109. -(void)viewWillAppear:(BOOL)animated
  110. {
  111. [super viewWillAppear:animated];
  112. self.navigationController.navigationBar.hidden=YES;
  113. self.tabBarController.tabBar.hidden=YES;
  114. }
  115. -(void)viewWillDisappear:(BOOL)animated
  116. {
  117. [super viewWillDisappear:animated];
  118. self.tabBarController.tabBar.hidden=NO;
  119. }
  120. -(UITableView *)accountView
  121. {
  122. if (!_accountView) {
  123. _accountView=[[UITableView alloc]initWithFrame:CGRectMake(0, KDNavBarHeight, SCREEN_WIDTH, self.view.height)];
  124. _accountView.backgroundColor=[UIColor clearColor];
  125. _accountView.separatorStyle=UITableViewCellSeparatorStyleNone;
  126. _accountView.emptyDataSetDelegate = self;
  127. _accountView.emptyDataSetSource = self;
  128. _accountView.delegate=self;
  129. _accountView.dataSource=self;
  130. _accountView.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{
  131. page_num = 1;
  132. [self getBalanceList];
  133. }];
  134. _accountView.mj_footer=[MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  135. page_num++;
  136. [self getBalanceList];
  137. }];
  138. [self addAccountviews];
  139. }
  140. return _accountView;
  141. }
  142. -(void)addAccountviews
  143. {
  144. UIView *headV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 134)];
  145. UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 104)];
  146. backV.backgroundColor=[UIColor gradientOneColor:[UIColor colorWithHexString:@"#FF235F"] toColor:[UIColor colorWithHexString:@"#FF7676"] Width:SCREEN_WIDTH];
  147. self.accountView.tableHeaderView=headV;
  148. [headV addSubview:backV];
  149. _accountMoneyLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, backV.height)];
  150. _accountMoneyLabel.center=backV.center;
  151. _accountMoneyLabel.font=[UIFont systemFontOfSize:48];
  152. _accountMoneyLabel.textAlignment=NSTextAlignmentCenter;
  153. _accountMoneyLabel.textColor=[UIColor whiteColor];
  154. NSString *title = @"¥---.--";
  155. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:title];
  156. [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0,1)]; //设置字体字号和字体类别
  157. _accountMoneyLabel.attributedText = str;
  158. [backV addSubview:_accountMoneyLabel];
  159. _tipeLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, backV.bottom, SCREEN_WIDTH-20, 30)];
  160. _tipeLabel.font=[UIFont systemFontOfSize:12];
  161. _tipeLabel.textColor=[UIColor colorWithHexString:@"#999999"];
  162. [headV addSubview:_tipeLabel];
  163. }
  164. -(NSMutableArray *)dataArray
  165. {
  166. if (!_dataArray) {
  167. _dataArray=[NSMutableArray array];
  168. }
  169. return _dataArray;
  170. }
  171. @end