猎豆优选

LDChildAccountViewController.m 11KB

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