HotVideoDetailVC.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. //
  2. // HotVideoDetailVC.m
  3. // YBVideo
  4. //
  5. // Created by ybRRR on 2021/3/1.
  6. // Copyright © 2021 cat. All rights reserved.
  7. //
  8. #import "HotVideoDetailVC.h"
  9. #import "UpHotCell.h"
  10. #import <YCMenuView.h>
  11. #import "addHotVideoVC.h"
  12. @interface HotVideoDetailVC ()<UITableViewDelegate, UITableViewDataSource,upHotCellDelegate>
  13. {
  14. UIButton *selectBtn;
  15. NSString *typeStr;
  16. int pageIndex;
  17. }
  18. @property (nonatomic, strong)UITableView *listTable;
  19. @property(nonatomic,strong)UIView *tabHeaderView;
  20. @property(nonatomic,strong)NSArray *selectArr;
  21. @property(nonatomic, strong)NSMutableArray *dataArr;
  22. @end
  23. @implementation HotVideoDetailVC
  24. - (void)viewWillAppear:(BOOL)animated{
  25. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
  26. }
  27. - (void)viewWillDisappear:(BOOL)animated{
  28. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
  29. }
  30. -(void)getOrderList{
  31. NSDictionary *dic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"type":typeStr,@"p":@(pageIndex)};
  32. [YBNetworking postWithUrl:@"Popular.getOrderList" Dic:dic Suc:^(int code, id info, NSString *msg) {
  33. [_listTable.mj_header endRefreshing];
  34. [_listTable.mj_footer endRefreshing];
  35. if (code == 0) {
  36. NSArray *listarr = info;
  37. if (pageIndex == 1) {
  38. [_dataArr removeAllObjects];
  39. }
  40. [_dataArr addObjectsFromArray:listarr];
  41. [_listTable reloadData];
  42. if (_dataArr.count > 0){
  43. [PublicView hiddenTextNoData:_listTable];
  44. } else{
  45. [PublicView showTextNoData:_listTable text1:@"" text2:YZMsg(@"暂无数据") centerY:0.8];
  46. }
  47. }
  48. } Fail:^(id fail) {
  49. [_listTable.mj_header endRefreshing];
  50. [_listTable.mj_footer endRefreshing];
  51. }];
  52. }
  53. -(void)creatNavi {
  54. // UIView *navi = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 64+statusbarHeight)];
  55. // navi.backgroundColor = [UIColor whiteColor];
  56. // [self.view addSubview:navi];
  57. //
  58. // UIButton *left_btn = [UIButton buttonWithType:UIButtonTypeCustom];
  59. // left_btn.frame = CGRectMake(10, 22+statusbarHeight, 40, 40);
  60. // left_btn.contentEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
  61. // [left_btn setImage:[UIImage imageNamed:@"pubBlack_back"] forState:0];
  62. // [left_btn addTarget:self action:@selector(clickLeftBtn) forControlEvents:UIControlEventTouchUpInside];
  63. // [navi addSubview:left_btn];
  64. //
  65. // UILabel *midLabel = [[UILabel alloc]initWithFrame:CGRectMake(_window_width/2-80, 22+statusbarHeight, 160, 40)];
  66. // midLabel.textAlignment = NSTextAlignmentCenter;
  67. // midLabel.textColor = RGB_COLOR(@"#323232", 1);
  68. // midLabel.font = [UIFont boldSystemFontOfSize:17];
  69. // midLabel.text = YZMsg(@"明细");
  70. // [navi addSubview:midLabel];
  71. }
  72. - (void)clickLeftBtn{
  73. [self.navigationController popViewControllerAnimated:YES];
  74. }
  75. - (void)viewDidLoad {
  76. [super viewDidLoad];
  77. self.naviView.hidden = YES;
  78. typeStr = @"0";
  79. pageIndex = 1;
  80. _dataArr = [NSMutableArray array];
  81. // [self creatNavi];
  82. self.view.backgroundColor =RGB_COLOR(@"#fafafa", 1);
  83. [self.view addSubview:self.listTable];
  84. [self getOrderList];
  85. }
  86. -(UITableView *)listTable {
  87. if (!_listTable) {
  88. //5个像素间隔
  89. _listTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height-64-statusbarHeight-ShowDiff) style:UITableViewStylePlain];
  90. _listTable.delegate = self;
  91. _listTable.dataSource = self;
  92. _listTable.separatorStyle = UITableViewCellStyleDefault;
  93. _listTable.backgroundColor = RGB_COLOR(@"#fafafa", 1);
  94. _listTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  95. pageIndex = 1;
  96. [self getOrderList];
  97. }];
  98. _listTable.mj_footer = [MJRefreshFooter footerWithRefreshingBlock:^{
  99. pageIndex +=1;
  100. [self getOrderList];
  101. }];
  102. }
  103. return _listTable;
  104. }
  105. -(UIView *)tabHeaderView {
  106. if (!_tabHeaderView) {
  107. _tabHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, _window_width, 50)];
  108. _tabHeaderView.backgroundColor = RGB_COLOR(@"#fafafa", 1);
  109. UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, 160, 50)];
  110. title.font = SYS_Font(15);
  111. title.text = YZMsg(@"我的视频订单");
  112. title.textColor = [UIColor blackColor];
  113. [_tabHeaderView addSubview:title];
  114. selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  115. selectBtn.frame = CGRectMake(_window_width-90, 0, 75, 50);
  116. [selectBtn setTitle:YZMsg(@"未完成") forState:0];
  117. [selectBtn setImage:[UIImage imageNamed:@"hot_down"] forState:0];
  118. [selectBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, - selectBtn.imageView.image.size.width, 0, selectBtn.imageView.image.size.width)];
  119. [selectBtn setImageEdgeInsets:UIEdgeInsetsMake(0, selectBtn.titleLabel.bounds.size.width, 0, -selectBtn.titleLabel.bounds.size.width)];
  120. selectBtn.titleLabel.font = SYS_Font(15);
  121. selectBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
  122. [selectBtn setTitleColor:GrayText forState:0];
  123. selectBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  124. [selectBtn addTarget:self action:@selector(selectBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  125. [_tabHeaderView addSubview:selectBtn];
  126. }
  127. return _tabHeaderView;
  128. }
  129. -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  130. return self.tabHeaderView;
  131. }
  132. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  133. return 50;
  134. }
  135. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  136. {
  137. return _dataArr.count;
  138. }
  139. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  140. {
  141. return 220;
  142. }
  143. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  144. {
  145. UpHotCell *cell = [UpHotCell cellWithTab:tableView andIndexPath:indexPath];
  146. cell.delegate = self;
  147. cell.dataDic = _dataArr[indexPath.row];
  148. cell.statuStr =typeStr;
  149. return cell;
  150. }
  151. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  152. {
  153. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  154. }
  155. -(void)selectBtnClick:(UIButton *)sender{
  156. // 创建YCMenuAction
  157. YCMenuAction *action = [YCMenuAction actionWithTitle:YZMsg(@"已完成") image:nil handler:^(YCMenuAction *action) {
  158. NSLog(@"点击了%@",action.title);
  159. [selectBtn setTitle:YZMsg(action.title) forState:0];
  160. typeStr = @"1";
  161. pageIndex = 1;
  162. [self getOrderList];
  163. }];
  164. YCMenuAction *action1 = [YCMenuAction actionWithTitle:YZMsg(@"未完成") image:nil handler:^(YCMenuAction *action) {
  165. NSLog(@"点击了%@",action.title);
  166. [selectBtn setTitle:YZMsg(action.title) forState:0];
  167. typeStr = @"0";
  168. pageIndex = 1;
  169. [self getOrderList];
  170. }];
  171. // 按钮(YCMenuAction)的集合
  172. self.selectArr = @[action,action1];
  173. // 创建YCMenuView(根据关联点或者关联视图)
  174. YCMenuView *view = [YCMenuView menuWithActions:self.selectArr width:120 relyonView:sender];
  175. // 自定义设置
  176. view.menuColor = [UIColor whiteColor];
  177. view.separatorColor = [UIColor clearColor];
  178. view.maxDisplayCount = 5; // 最大展示数量(其他的需要滚动才能看到)
  179. view.offset = 0; // 关联点和弹出视图的偏移距离
  180. view.textColor = [UIColor grayColor];
  181. view.textFont = [UIFont boldSystemFontOfSize:14];
  182. view.menuCellHeight = 44;
  183. view.dismissOnselected = YES;
  184. view.dismissOnTouchOutside = YES;
  185. // 显示
  186. [view show];
  187. }
  188. -(void)reUpOrderClick:(NSDictionary *)dic
  189. {
  190. [MBProgressHUD showMessage:@""];
  191. [YBNetworking postWithUrl:@"Video.getVideo" Dic:@{@"videoid":minstr([dic valueForKey:@"videoid"]),@"mobileid":[PublicObj getDeviceUUID]} Suc:^(int code, id info, NSString *msg) {
  192. [MBProgressHUD hideHUD];
  193. if (code == 0) {
  194. NSDictionary *infoDic = [info firstObject];
  195. addHotVideoVC *hot = [[addHotVideoVC alloc]init];
  196. hot.videoInfo = infoDic;
  197. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:hot animated:YES];
  198. }else {
  199. [MBProgressHUD showPop:msg];
  200. }
  201. } Fail:^(id fail) {
  202. [MBProgressHUD hideHUD];
  203. }];
  204. }
  205. @end