MyWalletController.m 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. //
  2. // MyWalletController.m
  3. // model
  4. //
  5. // Created by zuxiukuan on 2018/7/15.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 我的钱包
  8. #import "MyWalletController.h"
  9. #import "WithdrawalController.h"
  10. #import "IncreaseBalanceController.h"
  11. #import "WalletDetailsController.h"
  12. #import "MyWalletCell.h"
  13. #import "WithdrawController.h"
  14. @interface MyWalletController ()<UITableViewDelegate, UITableViewDataSource>
  15. @property (nonatomic, strong) UITableView *tableView;
  16. @property (nonatomic, strong) UILabel *moneyLabel;
  17. @property (nonatomic ,strong) NSArray *titlesArr;
  18. @property (nonatomic ,strong) NSArray *imagesArr;
  19. @end
  20. @implementation MyWalletController
  21. - (void)viewWillAppear:(BOOL)animated {
  22. [super viewWillAppear:animated];
  23. self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
  24. [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
  25. [self.navigationController.navigationBar setShadowImage:[UIImage new]];
  26. [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
  27. }
  28. - (void)viewWillDisappear:(BOOL)animated {
  29. [super viewWillDisappear:animated];
  30. self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
  31. [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
  32. [self.navigationController.navigationBar setShadowImage:nil];
  33. [self.navigationController.navigationBar setTitleTextAttributes:nil];
  34. }
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. self.view.backgroundColor = [UIColor whiteColor];
  38. self.titlesArr = @[@"提现",@"收入明细",@"提现明细"];
  39. self.imagesArr = @[@"tixian",@"shourumingxi",@"tixianmingxi"];
  40. //设置导航条
  41. [self creatNavBar];
  42. //设置TableView
  43. [self creatTableView];
  44. }
  45. - (void)didReceiveMemoryWarning {
  46. [super didReceiveMemoryWarning];
  47. // Dispose of any resources that can be recreated.
  48. }
  49. - (void)creatNavBar {
  50. self.title = @"我的钱包";
  51. //返回按钮
  52. UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
  53. btn.frame = CGRectMake(0, 0, 40, 40);
  54. [btn setImage:[UIImage imageNamed:@"fanhui1"] forState:UIControlStateNormal];
  55. btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
  56. [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  57. UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  58. UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  59. // nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
  60. self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
  61. }
  62. - (void)backClick {
  63. [self.navigationController popViewControllerAnimated:YES];
  64. }
  65. - (void)creatTableView {
  66. CGFloat headerHeight = (HeightStatusBar == 44) ? 219 : 175;
  67. UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, headerHeight)];
  68. UIImageView *bgView = [[UIImageView alloc] initWithFrame:headerView.bounds];
  69. [bgView setImage:[UIImage imageNamed:@"jianbianbeijing"]];
  70. [headerView addSubview:bgView];
  71. UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, Height_NaviBar + 30, ScreenWidth / 2, 15)];
  72. titleLabel.text = @"资产总额:";
  73. titleLabel.textAlignment = NSTextAlignmentLeft;
  74. titleLabel.font = [UIFont systemFontOfSize:15];
  75. titleLabel.textColor = RGBValueColor(0xffffff, 1.0);
  76. [headerView addSubview:titleLabel];
  77. self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(titleLabel.frame) + 7, ScreenWidth, 30)];
  78. self.moneyLabel.textAlignment = NSTextAlignmentCenter;
  79. self.moneyLabel.textColor = RGBValueColor(0xffffff, 1.0);
  80. NSString *str = [NSString stringWithFormat:@"%@元",self.amount];
  81. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:str];
  82. [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(0,str.length - 1)];
  83. [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(str.length - 1,1)];
  84. self.moneyLabel.attributedText = attrString;
  85. [headerView addSubview:self.moneyLabel];
  86. [self.view addSubview:headerView];
  87. //
  88. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(headerView.frame), ScreenWidth, ScreenHeight) style:UITableViewStyleGrouped];
  89. self.tableView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  90. self.tableView.delegate = self;
  91. self.tableView.dataSource = self;
  92. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  93. self.tableView.scrollEnabled = NO;
  94. [self.view addSubview:self.tableView];
  95. [self.tableView registerClass:[MyWalletCell class] forCellReuseIdentifier:@"WalletCell"];
  96. }
  97. #pragma mark -- UITableViewDelegate, UITableViewDataSource
  98. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  99. return 2;
  100. }
  101. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  102. if (section == 0) {
  103. return 1;
  104. } else {
  105. return 2;
  106. }
  107. }
  108. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  109. MyWalletCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WalletCell" forIndexPath:indexPath];
  110. if (indexPath.section == 0) {
  111. cell.iconImageView.image = [UIImage imageNamed:self.imagesArr[indexPath.row]];
  112. cell.titleLabel.text = self.titlesArr[indexPath.row];
  113. } else {
  114. cell.iconImageView.image = [UIImage imageNamed:self.imagesArr[indexPath.row + 1]];
  115. cell.titleLabel.text = self.titlesArr[indexPath.row + 1];
  116. }
  117. return cell;
  118. }
  119. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  120. return 50;
  121. }
  122. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  123. return 10;
  124. }
  125. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  126. return 0.01;
  127. }
  128. - (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  129. UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
  130. headerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  131. return headerView;
  132. }
  133. - (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  134. UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.01)];
  135. footerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  136. return footerView;
  137. }
  138. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  139. if (indexPath.section == 0) {
  140. // 提现
  141. WithdrawController *withdrawalVC = [[WithdrawController alloc] init];
  142. withdrawalVC.callback = ^(NSString *string) {
  143. self.amount = string;
  144. NSString *str = [NSString stringWithFormat:@"%@元",self.amount];
  145. NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:str];
  146. [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(0,str.length - 1)];
  147. [attrString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(str.length - 1,1)];
  148. self.moneyLabel.attributedText = attrString;
  149. };
  150. [self.navigationController pushViewController:withdrawalVC animated:YES];
  151. } else {
  152. if (indexPath.row == 0) { //收入明细
  153. WalletDetailsController *withdrawalVC = [[WalletDetailsController alloc] init];
  154. withdrawalVC.detailsIndex = @"1";
  155. [self.navigationController pushViewController:withdrawalVC animated:YES];
  156. } else { //提现明细
  157. WalletDetailsController *withdrawalVC = [[WalletDetailsController alloc] init];
  158. withdrawalVC.detailsIndex = @"2";
  159. [self.navigationController pushViewController:withdrawalVC animated:YES];
  160. }
  161. }
  162. }
  163. @end