// // VideoOrderController.m // model // // Created by JuYi on 2018/7/17. // Copyright © 2018年 Mine. All rights reserved. // 视频订单界面 #import "VideoOrderController.h" #import "MyOrderCell.h" @interface VideoOrderController () { NSInteger index; } @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) NSMutableArray *dataArr; @end @implementation VideoOrderController - (NSMutableArray *)dataArr { if (!_dataArr) { _dataArr = [NSMutableArray arrayWithCapacity:0]; } return _dataArr; } - (void)viewDidLoad { [super viewDidLoad]; index = 1; //设置导航条 [self creatNavBar]; //设置子试图 [self creatSubViews]; [self getDataFromNetworking]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark -- 网络请求 - (void)getDataFromNetworking { [MBProgressHUD showHUDAddedTo:self.view animated:YES]; NSString *indexStr = [NSString stringWithFormat:@"%zd",index]; NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk,@"modelpk",indexStr,@"index",@"10",@"size", nil]; [YanCNetWorkManager requestPostWithURLStr:Url_getVideoReordOrder(PublicUrl) parameters:dic finish:^(id dataDic) { [MBProgressHUD hideHUDForView:self.view animated:YES]; NSString *issuccess = dataDic[@"msg"]; if ([issuccess isEqualToString:@"success"]) { [self.dataArr addObjectsFromArray:dataDic[@"data"]]; [self.tableView reloadData]; NSString *number = dataDic[@"count"]; NSInteger num = [number integerValue]; [self.tableView.mj_header endRefreshing]; if (num == self.dataArr.count || num == 0) { [self.tableView.mj_footer endRefreshingWithNoMoreData]; }else{ [self.tableView.mj_footer endRefreshing]; } } else { [MBProgressHUD showInfo:@"请求失败!"]; } } enError:^(NSError *error) { [MBProgressHUD hideHUDForView:self.view animated:YES]; }]; } /* { begdate = "2018-06-13 00:00:00"; coin = ""; duration = ""; hphoto = "upload/hphoto/2018-07-13/h1.png"; memberpk = 8; modelpk = 2; pet = "\U5218\U5fb7\U534e"; pk = 2; } */ - (void)creatNavBar { self.title = @"视频订单"; // UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(0, 0, 40, 40); [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal]; btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0); // backBtn2 [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn]; UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; // nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整 self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem]; } - (void)backClick { [self.navigationController popViewControllerAnimated:YES]; } - (void)creatSubViews { float height = Height_NaviBar; self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-height) style:UITableViewStyleGrouped]; self.tableView.backgroundColor = [UIColor whiteColor]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.tableFooterView = [[UIView alloc] init]; self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshList)]; self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; [self.view addSubview:self.tableView]; } -(void)refreshList{ index = 1; [self.dataArr removeAllObjects]; [self getDataFromNetworking]; } - (void)loadMoreData{ index++; [self getDataFromNetworking]; } #pragma mark -- UITableViewDelegate, UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.dataArr.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellid = @"OrderCell"; MyOrderCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid]; if (!cell) { cell = [[MyOrderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid]; } [cell setMyOrderCellValueWithDic:self.dataArr[indexPath.section] titleStr:@"videoOrder"]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 80; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.01)]; footerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0); return footerView; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)]; headerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0); return headerView; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 0.01; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { if (section == 0) { return 0.01; } else { return 10; } } @end