123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- //
- // LDChildAccountViewController.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/7/31.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDChildAccountViewController.h"
- #import "LDChildOrderCell.h"
- #import "LDWithdrawDetailController.h"
- #import "LDAdWebViewController.h"
- #import "LDAccountHeader.h"
- #import "LDLinkAliPayViewController.h"
- #import "LDWithdrawController.h"
- @interface LDChildAccountViewController ()<
- UITableViewDelegate,
- UITableViewDataSource
- >
- {
- UIView *_sectionHeader;
- CGFloat rebate_account;//收入总计
- CGFloat rebate_account_tx;//提现
- NSInteger allTimes;
- LDAccountHeader *header;
- }
- @property (nonatomic, assign) NSInteger page;
- @property (nonatomic, strong) NSMutableArray *dataArr;
- @end
- @implementation LDChildAccountViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self configNavigationBar];
- [self configTableView];
-
-
- }
- - (void)configNavigationBar {
- [self.navigationBar setNavTitle:@"我的余额"];
- self.navigationBar.backgroundColor = [UIColor changeColor];
- self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
- UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
- [leftBtn setImage:[UIImage imageNamed:@"back_white"] forState:UIControlStateNormal];
- [leftBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
- [self.navigationBar setCustomLeftButtons:@[leftBtn]];
-
-
- UIButton * nextBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-Fitsize(50), 0, Fitsize(100), Fitsize(30))];
- nextBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- [nextBtn setImage:[UIImage imageNamed:@"Doubt"] forState:UIControlStateNormal];;
- nextBtn.titleLabel.font = [UIFont systemFontOfSize:Fitsize(13)];
- nextBtn.titleLabel.textAlignment = NSTextAlignmentRight;
- [nextBtn setButtonImageTitleStyle:ButtonImageTitleStyleRight padding:-5];
-
- [nextBtn addTarget:self action:@selector(RightBtnAction) forControlEvents:UIControlEventTouchUpInside];
-
- [self.navigationBar setCustomRightButtons:@[nextBtn]];
- }
- -(void)RightBtnAction
- {
- LDAdWebViewController *adWeb = [[LDAdWebViewController alloc] init];
- adWeb.url =Orderwithdrawal;
- [self.navigationController pushViewController:adWeb animated:YES];
-
- }
- - (void)backAction {
- [self.navigationController popViewControllerAnimated:YES];
- }
- - (void)configTableView {
- self.page = 1;
- [self.view addSubview:self.tableView];
-
- header = [[LDAccountHeader alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, FITSIZE(100))];
-
- header.moneyBackBlcok = ^(NSString *blance,BOOL isLinkAliPay){
- if (blance.length > 0) {
- if (isLinkAliPay) {
- //提现
- LDWithdrawController *toMoney = [[LDWithdrawController alloc] init];
- toMoney.moneyStr = blance;
- [self.navigationController pushViewController:toMoney animated:YES];
- }else {
- LDLinkAliPayViewController *link = [[LDLinkAliPayViewController alloc] init];
- [self.navigationController pushViewController:link animated:YES];
- }
-
- }else {
- [MBProgressHUD showMessage:@"正在校验您的余额,请稍后重试"];
- }
-
-
- };
- self.tableView.tableHeaderView = header;
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.page = 1;
- [header reloadData];
- [self requestWith:YES];
-
- }
- #pragma mark ------
- - (void)requestWith:(BOOL)refresh {
- NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/commissionListNew",BaseURL];
-
-
- NSDictionary *dic=@{
- @"type":@(0),
- @"page":@(self.page)
- };
- [LDHttp post:url params:dic success:^(id json) {
- if (refresh) {
- self.page = 1;
- [self.dataArr removeAllObjects];
- }
- NSNumber *rebate = json[@"data"][@"rebate_account_yj"];
- rebate_account_tx = [json[@"data"][@"rebate_account_tx"] floatValue];
- rebate_account = [rebate floatValue];
- NSArray *arr = [NSArray yy_modelArrayWithClass:[LDChildOrderModel class] json:json[@"data"][@"commsionList"]];
- if (arr.count>0) {
- [self.dataArr addObjectsFromArray:arr];
- [self.tableView.mj_footer endRefreshing];
- }else {
- [self setUpNoDataView];
- [self noMoreDataWithArray:arr];
- }
- [self.tableView.mj_header endRefreshing];
- [self.tableView reloadData];
- } failure:^(NSError *error) {
- [self.tableView.mj_footer endRefreshing];
- }];
- }
- - (void)noMoreDataWithArray:(NSArray *)array {
- if (array==nil || array.count <= 0) {
- [self.tableView.mj_footer endRefreshingWithNoMoreData];
- }
- }
- - (void)setUpNoDataView {
- self.tableView.showNoDataView = YES;
- self.tableView.defaultNoDataText = @"您还没有任何记录";
- self.tableView.defaultNoDataImage = [UIImage imageNamed:@"noData"];
- }
- //#pragma mark ------ scrollView delegate -----
- //- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- //
- // if (!self.childCanScroll) {
- // scrollView.contentOffset = CGPointZero;
- // }
- // if (scrollView.contentOffset.y <= 0) {
- //
- // self.childCanScroll = NO;
- // scrollView.contentOffset = CGPointZero;
- // [[NSNotificationCenter defaultCenter] postNotificationName:@"childDetailleaveTop" object:nil];//到顶通知父视图改变状态
- // }
- //}
- #pragma mark -------- UITableView Delegate -----
- - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
- if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
- [cell setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 15)];
- }
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.dataArr.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return FITSIZE(80);
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return FITSIZE(35);
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- return 0.1;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- LDChildOrderCell *cell = [LDChildOrderCell cellWithTableView:tableView];
- LDChildOrderModel *model = self.dataArr[indexPath.row];
- cell.model=model;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
-
- _sectionHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, FITSIZE(35))];
- _sectionHeader.backgroundColor = [UIColor YHColorWithHex:0xF4F4F4];
- UILabel *priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(FITSIZE(14), 0, SCREEN_WIDTH-FITSIZE(50), FITSIZE(35))];
- priceLabel.textColor = [UIColor YHColorWithHex:0x999999];
- priceLabel.font = [UIFont systemFontOfSize:12];
- priceLabel.text = [NSString stringWithFormat:@"累计收入¥%.2f 成功提现¥%.2f",rebate_account,rebate_account_tx];
- [_sectionHeader addSubview:priceLabel];
-
- return _sectionHeader;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- LDChildOrderModel *model= self.dataArr[indexPath.row];
- if (model.type.integerValue == 1) {//已通过
- LDWithdrawDetailController *detail = [[LDWithdrawDetailController alloc] init];
- detail.detailId = model.Id;
- [[self currentViewController].navigationController pushViewController:detail animated:YES];
- }else if (model.type.integerValue == 2) {//未通过
- LDAdWebViewController *webV = [[LDAdWebViewController alloc] init];
- webV.url = model.problem_url;
- [[self currentViewController].navigationController pushViewController:webV animated:YES];
- }
-
- }
- - (UIViewController *)currentViewController{
-
- UIViewController * currVC = nil;
- UIWindow *window = [UIApplication sharedApplication].delegate.window;
- UIViewController * Rootvc = window.rootViewController;
-
- do {
- if ([Rootvc isKindOfClass:[UINavigationController class]]) {
- UINavigationController * nav = (UINavigationController *)Rootvc;
- UIViewController * v = [nav.viewControllers lastObject];
- currVC = v;
- Rootvc = v.presentedViewController;
- continue;
- }else if([Rootvc isKindOfClass:[UITabBarController class]]){
- UITabBarController * tabVC = (UITabBarController *)Rootvc;
- currVC = tabVC;
- Rootvc = [tabVC.viewControllers objectAtIndex:tabVC.selectedIndex];
- continue;
- }
- } while (Rootvc!=nil);
-
- return currVC;
- }
- #pragma mark ------- layzer ------
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) style:UITableViewStylePlain];
- _tableView.estimatedSectionHeaderHeight = 0;
- _tableView.estimatedSectionFooterHeight = 0;
- _tableView.sectionFooterHeight = 0;
- _tableView.sectionHeaderHeight = 0;
- _tableView.estimatedRowHeight = 0;
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
- _tableView.backgroundColor = [UIColor yhGrayColor];
- _tableView.bounces = YES;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
- _tableView.separatorColor = [UIColor YHColorWithHex:0xEEEEEE];
- _tableView.mj_header=[MJRefreshNormalHeader headerWithRefreshingBlock:^{
- self.page =1;
- [self requestWith:YES];
- }];
- _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
- self.page ++;
- [self requestWith:NO];
- }];
-
-
-
- }
- return _tableView;
- }
- - (NSMutableArray *)dataArr {
- if (!_dataArr) {
- _dataArr = [NSMutableArray array];
- }
- return _dataArr;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|