VideoOrderController.m 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //
  2. // VideoOrderController.m
  3. // model
  4. //
  5. // Created by JuYi on 2018/7/17.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 视频订单界面
  8. #import "VideoOrderController.h"
  9. #import "MyOrderCell.h"
  10. @interface VideoOrderController ()<UITableViewDelegate, UITableViewDataSource>
  11. {
  12. NSInteger index;
  13. }
  14. @property (nonatomic, strong) UITableView *tableView;
  15. @property (nonatomic, strong) NSMutableArray *dataArr;
  16. @end
  17. @implementation VideoOrderController
  18. - (NSMutableArray *)dataArr {
  19. if (!_dataArr) {
  20. _dataArr = [NSMutableArray arrayWithCapacity:0];
  21. }
  22. return _dataArr;
  23. }
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. index = 1;
  27. //设置导航条
  28. [self creatNavBar];
  29. //设置子试图
  30. [self creatSubViews];
  31. [self getDataFromNetworking];
  32. }
  33. - (void)didReceiveMemoryWarning {
  34. [super didReceiveMemoryWarning];
  35. // Dispose of any resources that can be recreated.
  36. }
  37. #pragma mark -- 网络请求
  38. - (void)getDataFromNetworking {
  39. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  40. NSString *indexStr = [NSString stringWithFormat:@"%zd",index];
  41. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk,@"modelpk",indexStr,@"index",@"10",@"size", nil];
  42. [YanCNetWorkManager requestPostWithURLStr:Url_getVideoReordOrder(PublicUrl) parameters:dic finish:^(id dataDic) {
  43. [MBProgressHUD hideHUDForView:self.view animated:YES];
  44. NSString *issuccess = dataDic[@"msg"];
  45. if ([issuccess isEqualToString:@"success"]) {
  46. [self.dataArr addObjectsFromArray:dataDic[@"data"]];
  47. [self.tableView reloadData];
  48. NSString *number = dataDic[@"count"];
  49. NSInteger num = [number integerValue];
  50. [self.tableView.mj_header endRefreshing];
  51. if (num == self.dataArr.count || num == 0) {
  52. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  53. }else{
  54. [self.tableView.mj_footer endRefreshing];
  55. }
  56. } else {
  57. [MBProgressHUD showInfo:@"请求失败!"];
  58. }
  59. } enError:^(NSError *error) {
  60. [MBProgressHUD hideHUDForView:self.view animated:YES];
  61. }];
  62. }
  63. /*
  64. {
  65. begdate = "2018-06-13 00:00:00";
  66. coin = "";
  67. duration = "";
  68. hphoto = "upload/hphoto/2018-07-13/h1.png";
  69. memberpk = 8;
  70. modelpk = 2;
  71. pet = "\U5218\U5fb7\U534e";
  72. pk = 2;
  73. }
  74. */
  75. - (void)creatNavBar {
  76. self.title = @"视频订单";
  77. //
  78. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  79. btn.frame = CGRectMake(0, 0, 40, 40);
  80. [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
  81. btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0); // backBtn2
  82. [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  83. UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  84. UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  85. // nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
  86. self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
  87. }
  88. - (void)backClick {
  89. [self.navigationController popViewControllerAnimated:YES];
  90. }
  91. - (void)creatSubViews {
  92. float height = Height_NaviBar;
  93. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-height) style:UITableViewStyleGrouped];
  94. self.tableView.backgroundColor = [UIColor whiteColor];
  95. self.tableView.delegate = self;
  96. self.tableView.dataSource = self;
  97. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  98. self.tableView.tableFooterView = [[UIView alloc] init];
  99. self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshList)];
  100. self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
  101. [self.view addSubview:self.tableView];
  102. }
  103. -(void)refreshList{
  104. index = 1;
  105. [self.dataArr removeAllObjects];
  106. [self getDataFromNetworking];
  107. }
  108. - (void)loadMoreData{
  109. index++;
  110. [self getDataFromNetworking];
  111. }
  112. #pragma mark -- UITableViewDelegate, UITableViewDataSource
  113. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  114. return self.dataArr.count;
  115. }
  116. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  117. return 1;
  118. }
  119. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  120. static NSString *cellid = @"OrderCell";
  121. MyOrderCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid];
  122. if (!cell) {
  123. cell = [[MyOrderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];
  124. }
  125. [cell setMyOrderCellValueWithDic:self.dataArr[indexPath.section] titleStr:@"videoOrder"];
  126. return cell;
  127. }
  128. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  129. return 80;
  130. }
  131. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  132. }
  133. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  134. UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.01)];
  135. footerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  136. return footerView;
  137. }
  138. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  139. UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
  140. headerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  141. return headerView;
  142. }
  143. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  144. return 0.01;
  145. }
  146. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  147. if (section == 0) {
  148. return 0.01;
  149. } else {
  150. return 10;
  151. }
  152. }
  153. @end