AccountBalanceVC.m 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. //
  2. // AccountBalanceVC.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/2/6.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "AccountBalanceVC.h"
  9. #import "BillCell.h"
  10. #import "BuyerGetMoneyVC.h"
  11. @interface AccountBalanceVC ()<UITableViewDelegate, UITableViewDataSource>
  12. {
  13. UIView *bottomView;
  14. UILabel *bottomPrice; //底部账户余额
  15. UILabel *balanceLb; //账户余额
  16. int pageIndex;
  17. NSDictionary *user_balance;
  18. }
  19. @property(nonatomic, strong)UITableView *balanceTable;
  20. @property(nonatomic, strong)UIView *headerView;
  21. @property(nonatomic, strong)NSMutableArray *infoArr;
  22. @end
  23. @implementation AccountBalanceVC
  24. -(void)requestBalanceData{
  25. NSDictionary *signdic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken], @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  26. NSString *sign = [PublicObj sortString:signdic];
  27. NSDictionary *dic = @{
  28. @"uid":[Config getOwnID],
  29. @"token":[Config getOwnToken],
  30. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  31. @"sign":sign,
  32. @"p":@(pageIndex)
  33. };
  34. [YBNetworking postWithUrl:@"Buyer.getRefundList" Dic:dic Suc:^(int code, id info, NSString *msg) {
  35. if (code ==0) {
  36. NSDictionary *infos = [info firstObject];
  37. NSArray *listArr = [infos valueForKey:@"list"];
  38. user_balance =[infos valueForKey:@"user_balance"];
  39. [self reloadCurrentBalance:user_balance];
  40. if (pageIndex == 1) {
  41. [self.infoArr removeAllObjects];
  42. if (listArr.count < 1) {
  43. [PublicView showImgNoData:self.balanceTable name:@"shop_无数据" text:YZMsg(@"无相关退款记录")];
  44. [self.balanceTable reloadData];
  45. return ;
  46. }else{
  47. [PublicView hiddenImgNoData:self.balanceTable];
  48. }
  49. }
  50. [self.infoArr addObjectsFromArray:listArr];
  51. [self.balanceTable reloadData];
  52. }else{
  53. [MBProgressHUD showError:msg];
  54. }
  55. } Fail:^(id fail) {
  56. }];
  57. }
  58. -(void)reloadCurrentBalance:(NSDictionary *)dic{
  59. bottomPrice.text =[NSString stringWithFormat:@"¥%@",minstr([dic valueForKey:@"balance"])];
  60. balanceLb.text = [NSString stringWithFormat:@"¥%@",minstr([dic valueForKey:@"balance"])];
  61. }
  62. -(void)viewWillAppear:(BOOL)animated
  63. {
  64. [super viewWillAppear:YES];
  65. [self requestBalanceData];
  66. }
  67. - (UIStatusBarStyle)preferredStatusBarStyle {
  68. if (@available(iOS 13.0,*)) {
  69. return UIStatusBarStyleDarkContent;
  70. }
  71. return UIStatusBarStyleDefault;
  72. }
  73. - (void)viewDidLoad {
  74. [super viewDidLoad];
  75. self.titleL.text =YZMsg(@"账户余额");
  76. self.view.backgroundColor = RGB(245, 245, 245);
  77. self.subNavi.backgroundColor = UIColor.whiteColor;
  78. self.titleL.textColor = UIColor.blackColor;
  79. [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0];
  80. self.naviLine.hidden = NO;
  81. self.naviLine.backgroundColor = RGB(245, 245, 245);
  82. pageIndex = 1;
  83. self.infoArr = [NSMutableArray array];
  84. [self.view addSubview:self.balanceTable];
  85. [self creatBottomView];
  86. }
  87. #pragma mark-------底部view-------
  88. -(void)creatBottomView{
  89. bottomView = [[UIView alloc]init];
  90. bottomView.frame = CGRectMake(0, _window_height-60, _window_width, 60);
  91. bottomView.backgroundColor =UIColor.whiteColor;
  92. [self.view addSubview:bottomView];
  93. UILabel *titleLb = [[UILabel alloc]init];
  94. titleLb.frame = CGRectMake(12, 10, 150, 16);
  95. titleLb.font = [UIFont systemFontOfSize:13];
  96. titleLb.textColor = [UIColor blackColor];
  97. titleLb.text = YZMsg(@"账户余额");
  98. [bottomView addSubview:titleLb];
  99. bottomPrice =[[UILabel alloc]init];
  100. bottomPrice.frame = CGRectMake(12, titleLb.bottom+5, 150, 20);
  101. bottomPrice.font = [UIFont boldSystemFontOfSize:16];
  102. bottomPrice.textColor = [UIColor blackColor];
  103. [bottomView addSubview:bottomPrice];
  104. //收益
  105. UIButton *profitBtn = [UIButton buttonWithType:0];
  106. profitBtn.frame = CGRectMake(_window_width-85, bottomView.height/2-13, 75, 26);
  107. [profitBtn setBackgroundColor:Pink_Cor];
  108. [profitBtn setTitle:YZMsg(@"提取余额") forState:UIControlStateNormal];
  109. profitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  110. profitBtn.layer.cornerRadius = 13;
  111. profitBtn.layer.masksToBounds = YES;
  112. profitBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
  113. [profitBtn setTitleColor:[UIColor whiteColor] forState:0];
  114. [profitBtn addTarget:self action:@selector(profitBtnClick) forControlEvents:UIControlEventTouchUpInside];
  115. [bottomView addSubview:profitBtn];
  116. //提现
  117. UIButton *cashBtn = [UIButton buttonWithType:0];
  118. cashBtn.frame = CGRectMake(profitBtn.left-85, bottomView.height/2-13, 75, 26);
  119. cashBtn.layer.borderColor = Pink_Cor.CGColor;
  120. cashBtn.layer.borderWidth = 1;
  121. cashBtn.layer.cornerRadius = 13;
  122. cashBtn.layer.masksToBounds = YES;
  123. [cashBtn setTitle:YZMsg(@"提现记录") forState:UIControlStateNormal];
  124. cashBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
  125. cashBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  126. [cashBtn setTitleColor:Pink_Cor forState:0];
  127. [cashBtn addTarget:self action:@selector(cashBtnClick) forControlEvents:UIControlEventTouchUpInside];
  128. [bottomView addSubview:cashBtn];
  129. }
  130. #pragma mark------提取记录--------
  131. -(void)cashBtnClick{
  132. //用户体现记录
  133. NSString *url =[NSString stringWithFormat:@"%@/appapi/shopcash/index",h5url];
  134. PubH5 *h5VC = [[PubH5 alloc]init];
  135. h5VC.url = [self addurl:url];
  136. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:h5VC animated:YES];
  137. }
  138. //所有h5需要拼接uid和token
  139. -(NSString *)addurl:(NSString *)url{
  140. return [url stringByAppendingFormat:@"&uid=%@&token=%@",[Config getOwnID],[Config getOwnToken]];
  141. }
  142. #pragma mark-------提取余额----------
  143. -(void)profitBtnClick{
  144. BuyerGetMoneyVC *getVC = [[BuyerGetMoneyVC alloc]init];
  145. getVC.moneyDic = user_balance;
  146. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:getVC animated:YES];
  147. }
  148. -(UITableView *)balanceTable{
  149. if (!_balanceTable) {
  150. _balanceTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-60) style:UITableViewStylePlain];
  151. _balanceTable.delegate = self;
  152. _balanceTable.dataSource = self;
  153. _balanceTable.separatorStyle = UITableViewCellSeparatorStyleNone;
  154. _balanceTable.backgroundColor = [UIColor clearColor];
  155. _balanceTable.tableFooterView = [UIView new];
  156. }
  157. return _balanceTable;
  158. }
  159. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  160. {
  161. return 1;
  162. }
  163. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  164. {
  165. return self.infoArr.count;
  166. }
  167. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  168. {
  169. return 60;
  170. }
  171. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  172. {
  173. return 130;
  174. }
  175. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  176. {
  177. BillCell *cell = [BillCell cellWithTab:tableView andIndexPath:indexPath];
  178. cell.infoDic =self.infoArr[indexPath.row];
  179. return cell;
  180. }
  181. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  182. {
  183. return self.headerView;
  184. }
  185. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  186. {
  187. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  188. }
  189. -(UIView *)headerView
  190. {
  191. if (!_headerView) {
  192. _headerView = [[UIView alloc]init];
  193. _headerView.frame = CGRectMake(0, 0, _window_width, 130);
  194. _headerView.backgroundColor = UIColor.whiteColor;
  195. UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _headerView.height-40)];
  196. backView.backgroundColor = Pink_Cor;
  197. [_headerView addSubview:backView];
  198. UILabel *title1 = [[UILabel alloc]init];
  199. title1.frame = CGRectMake(12, 15, _window_width/2, 20);
  200. title1.font = [UIFont systemFontOfSize:14];
  201. title1.textColor = RGBA(255,255,255,0.5);
  202. title1.text = YZMsg(@"账户余额 (元)");
  203. [backView addSubview:title1];
  204. balanceLb = [[UILabel alloc]init];
  205. balanceLb.frame = CGRectMake(12, title1.bottom + 10, _window_width/2-10, 20);
  206. balanceLb.font = [UIFont systemFontOfSize:15];
  207. balanceLb.textColor = [UIColor whiteColor];
  208. [backView addSubview:balanceLb];
  209. UILabel *bottomLb = [[UILabel alloc]init];
  210. bottomLb.frame = CGRectMake(12, _headerView.height-30, _window_width-20, 20);
  211. bottomLb.text = YZMsg(@"退款记录");
  212. bottomLb.font = [UIFont boldSystemFontOfSize:14];
  213. bottomLb.textColor = [UIColor grayColor];
  214. [_headerView addSubview:bottomLb];
  215. }
  216. return _headerView;
  217. }
  218. @end