123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- //
- // LDChildCommissionController.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/18.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDChildCommissionController.h"
- #import "LDChildCommissionCell.h"
- #import "LDChildCommissionModel.h"
- #import "LDAdWebViewController.h"
- #import "LDChildCommissionModel.h"
- @interface LDChildCommissionController ()<UITableViewDelegate, UITableViewDataSource,LDChildCommissionCellDelegate>{
- NSString *dateStr;
- }
- @property (nonatomic, strong) NSMutableArray *dataArr;
- @property (nonatomic, assign) NSInteger page;
- @end
- @implementation LDChildCommissionController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self configTableView];
- [self requestAndRefresh:YES];
- }
- - (void)configTableView {
- self.page = 1;
- dateStr = @"";
- [self.view addSubview:self.tableView];
-
- }
- #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 {
- LDChildCommissionModel *model=self.dataArr[indexPath.row];
- if (model.order_status.integerValue == 1) {
- return 140;
- }
- return 110;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return 0.1;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- return 0.1;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- LDChildCommissionCell *cell = [LDChildCommissionCell cellWithTableView:tableView];
- LDChildCommissionModel *model=self.dataArr[indexPath.row];
- cell.model=model;
- cell.delegatre =self;
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- return cell;
- }
- #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:@"leaveTop" object:nil];//到顶通知父视图改变状态
- // }
- //}
- #pragma mark -网络请求
- #pragma mark - request
- - (void)requestAndRefresh:(BOOL)refresh {
-
- if (![self.tableView.mj_footer isRefreshing]) {
- [MBProgressHUD showLoadingAddedToView:self.view];
- }
-
- NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/orderListNew",BaseURL];
- NSDictionary *dic=@{
- @"type":@(self.type),
- @"page":@(self.page),
- @"yearMonthDay":dateStr,
- @"isDay":@1
- };
- [LDHttp post:url params:dic success:^(id json) {
- if (refresh) {
- [self.dataArr removeAllObjects];
- }
- NSArray *arr = [NSArray yy_modelArrayWithClass:[LDChildCommissionModel class] json:json[@"data"]];
- if (arr.count>0) {
- [self.dataArr addObjectsFromArray:arr];
- [self.tableView.mj_footer endRefreshing];
- }else {
- [self setUpNoDataView];
- [self noMoreDataWithArray:arr];
- }
- [self.tableView reloadData];
- [MBProgressHUD hideHUDForView:self.view];
- } failure:^(NSError *error) {
- [MBProgressHUD hideHUDForView:self.view];
- [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.noDataImageOffsetY = -70;
- self.tableView.defaultNoDataText = @"您还没有订单";
- self.tableView.defaultNoDataImage = [UIImage imageNamed:@"no_order"];
- }
- - (void)refreshWithDate:(NSString *)date {
- dateStr = date;
- [self requestAndRefresh:YES];
- }
- #pragma mark ------- layzer ------
- - (UITableView *)tableView {
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-70) style:UITableViewStyleGrouped];
- _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_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
- self.page ++;
- [self requestAndRefresh:NO];
- }];
-
- }
- return _tableView;
- }
- -(NSMutableArray *)dataArr{
- if (!_dataArr) {
- _dataArr=[NSMutableArray array];
- }
- return _dataArr;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void)ClickModel:(LDChildCommissionModel *)model
- {
-
- LDAdWebViewController *web = [[LDAdWebViewController alloc] init];
- web.url = model.red_url;
- [self.navigationController pushViewController:web animated:YES];
- }
- @end
|