《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRChildAccountViewController.m 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. //
  2. // DRChildAccountViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/7/31.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRChildAccountViewController.h"
  9. #import "DRChildOrderCell.h"
  10. #import "DRWithdrawDetailController.h"
  11. #import "DRAdWebViewController.h"
  12. #import "DRAccountHeader.h"
  13. #import "DRLinkAliPayViewController.h"
  14. #import "DRWithdrawController.h"
  15. @interface DRChildAccountViewController ()<
  16. UITableViewDelegate,
  17. UITableViewDataSource
  18. >
  19. {
  20. UIView *_sectionHeader;
  21. CGFloat rebate_account;//收入总计
  22. CGFloat rebate_account_tx;//提现
  23. NSInteger allTimes;
  24. DRAccountHeader *header;
  25. }
  26. @property (nonatomic, assign) NSInteger page;
  27. @property (nonatomic, strong) NSMutableArray *dataArr;
  28. @end
  29. @implementation DRChildAccountViewController
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. [self configNavigationBar];
  33. [self configTableView];
  34. }
  35. - (void)configNavigationBar {
  36. [self.navigationBar setNavTitle:@"我的余额"];
  37. self.navigationBar.backgroundColor = [UIColor changeColor];
  38. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  39. UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  40. [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
  41. [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  42. [self.navigationBar setCustomLeftButtons:@[leftBtn]];
  43. }
  44. - (void)backAction {
  45. [self.navigationController popViewControllerAnimated:YES];
  46. }
  47. - (void)configTableView {
  48. self.page = 1;
  49. [self.view addSubview:self.tableView];
  50. header = [[DRAccountHeader alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, FITSIZE(100))];
  51. header.moneyBackBlcok = ^(NSString *blance,BOOL isLinkAliPay){
  52. if (blance.length > 0) {
  53. if (isLinkAliPay) {
  54. //提现
  55. DRWithdrawController *toMoney = [[DRWithdrawController alloc] init];
  56. toMoney.moneyStr = blance;
  57. [self.navigationController pushViewController:toMoney animated:YES];
  58. }else {
  59. DRLinkAliPayViewController *link = [[DRLinkAliPayViewController alloc] init];
  60. [self.navigationController pushViewController:link animated:YES];
  61. }
  62. }else {
  63. [MBProgressHUD showMessage:@"正在校验您的余额,请稍后重试"];
  64. }
  65. };
  66. self.tableView.tableHeaderView = header;
  67. }
  68. -(void)viewWillAppear:(BOOL)animated
  69. {
  70. [super viewWillAppear:animated];
  71. self.page = 1;
  72. [header reloadData];
  73. [self requestWith:YES];
  74. }
  75. #pragma mark ------
  76. - (void)requestWith:(BOOL)refresh {
  77. NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/commissionListNew",BaseURL];
  78. NSDictionary *dic=@{
  79. @"type":@(0),
  80. @"page":@(self.page)
  81. };
  82. [DRHttp post:url params:dic success:^(id json) {
  83. if (refresh) {
  84. self.page = 1;
  85. [self.dataArr removeAllObjects];
  86. }
  87. NSNumber *rebate = json[@"data"][@"rebate_account_yj"];
  88. rebate_account_tx = [json[@"data"][@"rebate_account_tx"] floatValue];
  89. rebate_account = [rebate floatValue];
  90. NSArray *arr = [NSArray yy_modelArrayWithClass:[DRChildOrderModel class] json:json[@"data"][@"commsionList"]];
  91. if (arr.count>0) {
  92. [self.dataArr addObjectsFromArray:arr];
  93. [self.tableView.mj_footer endRefreshing];
  94. }else {
  95. [self setUpNoDataView];
  96. [self noMoreDataWithArray:arr];
  97. }
  98. [self.tableView.mj_header endRefreshing];
  99. [self.tableView reloadData];
  100. } failure:^(NSError *error) {
  101. [self.tableView.mj_footer endRefreshing];
  102. }];
  103. }
  104. - (void)noMoreDataWithArray:(NSArray *)array {
  105. if (array==nil || array.count <= 0) {
  106. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  107. }
  108. }
  109. - (void)setUpNoDataView {
  110. self.tableView.showNoDataView = YES;
  111. self.tableView.defaultNoDataText = @"您还没有任何记录";
  112. self.tableView.defaultNoDataImage = [UIImage imageNamed:@"noData"];
  113. }
  114. //#pragma mark ------ scrollView delegate -----
  115. //- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  116. //
  117. // if (!self.childCanScroll) {
  118. // scrollView.contentOffset = CGPointZero;
  119. // }
  120. // if (scrollView.contentOffset.y <= 0) {
  121. //
  122. // self.childCanScroll = NO;
  123. // scrollView.contentOffset = CGPointZero;
  124. // [[NSNotificationCenter defaultCenter] postNotificationName:@"childDetailleaveTop" object:nil];//到顶通知父视图改变状态
  125. // }
  126. //}
  127. #pragma mark -------- UITableView Delegate -----
  128. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  129. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  130. [cell setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 15)];
  131. }
  132. }
  133. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  134. return self.dataArr.count;
  135. }
  136. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  137. return FITSIZE(80);
  138. }
  139. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  140. return FITSIZE(35);
  141. }
  142. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  143. return 0.1;
  144. }
  145. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  146. DRChildOrderCell *cell = [DRChildOrderCell cellWithTableView:tableView];
  147. DRChildOrderModel *model = self.dataArr[indexPath.row];
  148. cell.model=model;
  149. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  150. return cell;
  151. }
  152. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  153. _sectionHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, FITSIZE(35))];
  154. _sectionHeader.backgroundColor = [UIColor YHColorWithHex:0xF4F4F4];
  155. UILabel *priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(FITSIZE(14), 0, SCREEN_WIDTH-FITSIZE(50), FITSIZE(35))];
  156. priceLabel.textColor = [UIColor YHColorWithHex:0x999999];
  157. priceLabel.font = [UIFont systemFontOfSize:12];
  158. priceLabel.text = [NSString stringWithFormat:@"累计收入¥%.2f 成功提现¥%.2f",rebate_account,rebate_account_tx];
  159. [_sectionHeader addSubview:priceLabel];
  160. return _sectionHeader;
  161. }
  162. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  163. {
  164. DRChildOrderModel *model= self.dataArr[indexPath.row];
  165. if (model.type.integerValue == 1) {//已通过
  166. DRWithdrawDetailController *detail = [[DRWithdrawDetailController alloc] init];
  167. detail.detailId = model.Id;
  168. [[self currentViewController].navigationController pushViewController:detail animated:YES];
  169. }else if (model.type.integerValue == 2) {//未通过
  170. DRAdWebViewController *webV = [[DRAdWebViewController alloc] init];
  171. webV.url = model.problem_url;
  172. [[self currentViewController].navigationController pushViewController:webV animated:YES];
  173. }
  174. }
  175. - (UIViewController *)currentViewController{
  176. UIViewController * currVC = nil;
  177. UIWindow *window = [UIApplication sharedApplication].delegate.window;
  178. UIViewController * Rootvc = window.rootViewController;
  179. do {
  180. if ([Rootvc isKindOfClass:[UINavigationController class]]) {
  181. UINavigationController * nav = (UINavigationController *)Rootvc;
  182. UIViewController * v = [nav.viewControllers lastObject];
  183. currVC = v;
  184. Rootvc = v.presentedViewController;
  185. continue;
  186. }else if([Rootvc isKindOfClass:[UITabBarController class]]){
  187. UITabBarController * tabVC = (UITabBarController *)Rootvc;
  188. currVC = tabVC;
  189. Rootvc = [tabVC.viewControllers objectAtIndex:tabVC.selectedIndex];
  190. continue;
  191. }
  192. } while (Rootvc!=nil);
  193. return currVC;
  194. }
  195. #pragma mark ------- layzer ------
  196. - (UITableView *)tableView {
  197. if (!_tableView) {
  198. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) style:UITableViewStylePlain];
  199. _tableView.estimatedSectionHeaderHeight = 0;
  200. _tableView.estimatedSectionFooterHeight = 0;
  201. _tableView.sectionFooterHeight = 0;
  202. _tableView.sectionHeaderHeight = 0;
  203. _tableView.estimatedRowHeight = 0;
  204. _tableView.delegate = self;
  205. _tableView.dataSource = self;
  206. _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  207. _tableView.backgroundColor = [UIColor yhGrayColor];
  208. _tableView.bounces = YES;
  209. _tableView.showsVerticalScrollIndicator = NO;
  210. _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  211. _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
  212. _tableView.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{
  213. self.page =1;
  214. [self requestWith:YES];
  215. }];
  216. _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  217. self.page ++;
  218. [self requestWith:NO];
  219. }];
  220. }
  221. return _tableView;
  222. }
  223. - (NSMutableArray *)dataArr {
  224. if (!_dataArr) {
  225. _dataArr = [NSMutableArray array];
  226. }
  227. return _dataArr;
  228. }
  229. - (void)didReceiveMemoryWarning {
  230. [super didReceiveMemoryWarning];
  231. // Dispose of any resources that can be recreated.
  232. }
  233. /*
  234. #pragma mark - Navigation
  235. // In a storyboard-based application, you will often want to do a little preparation before navigation
  236. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  237. // Get the new view controller using [segue destinationViewController].
  238. // Pass the selected object to the new view controller.
  239. }
  240. */
  241. @end