BillManageVC.m 10 KB

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