MsgTopPubVC.m 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. //
  2. // MsgTopPubVC.m
  3. // YBVideo
  4. //
  5. // Created by YunBao on 2018/7/24.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "MsgTopPubVC.h"
  9. #import "MsgTopPubModel.h"
  10. #import "MsgTopPubCell.h"
  11. #import "YBCenterVC.h"
  12. #import "commentview.h"
  13. //#import "SingleVideoVC.h"
  14. #import "YBGetVideoObj.h"
  15. @interface MsgTopPubVC ()<UITableViewDelegate,UITableViewDataSource,MsgClickDelegate>
  16. {
  17. int _paging;
  18. NSString *_noData2;
  19. MJRefreshAutoNormalFooter *_footer;
  20. NSString *pullurl;
  21. }
  22. @property(nonatomic,strong)UITableView *tableView;
  23. @property(nonatomic,strong)NSMutableArray *dateArray;
  24. @property(nonatomic,strong)NSArray *models;
  25. @property(nonatomic,strong)commentview *comment; //评论
  26. @end
  27. @implementation MsgTopPubVC
  28. - (UIStatusBarStyle)preferredStatusBarStyle {
  29. if (@available(iOS 13.0,*)) {
  30. return UIStatusBarStyleDarkContent;
  31. }
  32. return UIStatusBarStyleDefault;
  33. }
  34. -(void)viewWillDisappear:(BOOL)animated {
  35. [super viewWillDisappear:animated];
  36. [IQKeyboardManager sharedManager].enable = YES;
  37. }
  38. -(void)viewWillAppear:(BOOL)animated {
  39. [super viewWillAppear:animated];
  40. [IQKeyboardManager sharedManager].enable = NO;
  41. [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
  42. [self pullData];
  43. }
  44. - (void)viewDidLoad {
  45. [super viewDidLoad];
  46. if ([_type isEqual:@"赞"]){
  47. self.titleL.text = YZMsg(@"赞");
  48. _noData2 = YZMsg(@"你还没有被赞哦");
  49. }else if ([_type isEqual:@"@我的"]){
  50. self.titleL.text = YZMsg(@"@我的");
  51. _noData2 = YZMsg(@"你还没有被@哦");
  52. }else{
  53. //评论
  54. self.titleL.text = YZMsg(@"评论");
  55. _noData2 = YZMsg(@"你还没有收到任何评论");
  56. }
  57. self.subNavi.backgroundColor = UIColor.whiteColor;
  58. self.titleL.textColor = UIColor.blackColor;
  59. [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0];
  60. self.naviLine.hidden = NO;
  61. self.naviLine.backgroundColor = RGB(245, 245, 245);
  62. self.dateArray = [NSMutableArray array];
  63. self.models = [NSArray array];
  64. _paging = 1;
  65. [self.view addSubview:self.tableView];
  66. }
  67. - (NSArray *)models {
  68. NSMutableArray *m_array = [NSMutableArray array];
  69. for (NSDictionary *dic in _dateArray) {
  70. //区分 赞、@我的、评论(有部分字段key值不一样)
  71. MsgTopPubModel *model = [MsgTopPubModel modelWithDic:dic vcType:_type];
  72. [m_array addObject:model];
  73. }
  74. _models = m_array;
  75. return _models;
  76. }
  77. #pragma mark - 数据
  78. -(void)refreshFooter {
  79. _paging +=1;
  80. [self pullData];
  81. }
  82. -(void)pullData {
  83. NSString *domain;
  84. if ([_type isEqual:@"赞"]){
  85. domain = @"Message.praiseLists";
  86. }else if ([_type isEqual:@"@我的"]){
  87. domain = @"Message.atLists";
  88. }else{//评论
  89. domain = @"Message.commentLists";
  90. }
  91. NSString *url = [NSString stringWithFormat:@"%@&uid=%@&token=%@&p=%d",domain,[Config getOwnID],[Config getOwnToken],_paging];
  92. pullurl = url;
  93. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  94. [_tableView.mj_header endRefreshing];
  95. [_tableView.mj_footer endRefreshing];
  96. if (code == 0) {
  97. NSArray *infoA = [NSArray arrayWithArray:info];
  98. if (_paging==1) {
  99. [_dateArray removeAllObjects];
  100. }
  101. if (infoA.count==0) {
  102. [_tableView.mj_footer endRefreshingWithNoMoreData];
  103. }else{
  104. [_dateArray addObjectsFromArray:infoA];
  105. }
  106. if (_dateArray.count<=0) {
  107. _footer.hidden = YES;
  108. [PublicView showTextNoData:_tableView text1:@"" text2:_noData2 centerY:0.8];
  109. }else {
  110. _footer.hidden = NO;
  111. [PublicView hiddenTextNoData:_tableView];
  112. }
  113. [_tableView reloadData];
  114. }else {
  115. [MBProgressHUD showPop:msg];
  116. }
  117. } Fail:^(id fail) {
  118. }];
  119. }
  120. #pragma mark - MsgClickDelegate
  121. -(void)iconClickUid:(NSString *)uid {
  122. YBCenterVC *center = [[YBCenterVC alloc]init];
  123. center.otherUid = uid;
  124. center.isPush = YES;
  125. //[self.navigationController pushViewController:center animated:YES];
  126. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:center animated:YES];
  127. }
  128. - (void)coverClickVideoid:(NSString *)videoid {
  129. NSLog(@"播放视频");
  130. [YBGetVideoObj lookManeger].fromWhere = @"MsgTopPubVC";
  131. [YBGetVideoObj lookManeger].videoID = videoid;
  132. [YBGetVideoObj lookManeger].playIndex = 0;
  133. [YBGetVideoObj lookManeger].videoList =@[].mutableCopy;// [_dateArray mutableCopy];//
  134. [YBGetVideoObj lookManeger].paging = 1;
  135. [YBGetVideoObj lookManeger].baseUrl =@"";//pullurl;//
  136. [[YBGetVideoObj lookManeger]goLookVC];
  137. }
  138. #pragma mark - cell 点击事件
  139. -(void)goVideo:(NSString *)videoid {
  140. [self coverClickVideoid:videoid];
  141. }
  142. -(void)goComment:(NSString *)videoid videoUid:(NSString *)videouid{
  143. YBWeakSelf;
  144. if (!_comment) {
  145. _comment = [[commentview alloc]initWithFrame:CGRectMake(0,_window_height, _window_width, _window_height) hide:^(NSString *type) {
  146. [UIView animateWithDuration:0.3 animations:^{
  147. weakSelf.comment.frame = CGRectMake(0, _window_height, _window_width, _window_height);
  148. } ];
  149. } andvideoid:videoid andhostid:videouid count:0 talkCount:^(id type) {
  150. } detail:^(id type) {
  151. [weakSelf pushdetails:type];
  152. } youke:^(id type) {
  153. [PublicObj warnLogin];
  154. } andFrom:@"消息事件"];
  155. [self.view addSubview:_comment];
  156. }
  157. [UIView animateWithDuration:0.3 animations:^{
  158. weakSelf.comment.frame = CGRectMake(0,0,_window_width, _window_height);
  159. }];
  160. }
  161. -(void)pushdetails:(NSDictionary *)type{
  162. YBWeakSelf;
  163. [_comment endEditing:YES];
  164. _comment.hidden = YES;
  165. /*
  166. //rk_2_25
  167. commectDetails *detail = [[commectDetails alloc]init];
  168. detail.hostDic = type;
  169. detail.event = ^{
  170. weakSelf.comment.hidden = NO;
  171. };
  172. [self.navigationController pushViewController:detail animated:YES];
  173. */
  174. }
  175. #pragma mark - UITableViewDelegate、UITableViewDataSource
  176. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  177. return 80;
  178. }
  179. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  180. return self.models.count;
  181. }
  182. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  183. MsgTopPubCell *cell = [MsgTopPubCell cellWithTab:tableView andIndexPath:indexPath];
  184. cell.delegatge = self;
  185. cell.model = _models[indexPath.row];
  186. cell.backgroundColor = UIColor.whiteColor;
  187. cell.selectedBackgroundView = [[UIImageView alloc]initWithImage:[PublicObj getImgWithColor:RGB(245, 245, 245)]];
  188. return cell;
  189. }
  190. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  191. [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  192. MsgTopPubModel *model = _models[indexPath.row];
  193. /*
  194. * 赞 列表区分视频赞,还是评论赞
  195. * @我的、评论列表消息事件 cell点击都跳评论
  196. */
  197. if ([model.pageVC isEqual:@"赞"]&&[model.typeStr isEqual:@"1"]) {
  198. //跳视频
  199. [self goVideo:model.videoidStr];
  200. }else if([model.pageVC isEqual:@"@我的"] && [model.typeStr isEqual:@"1"]){
  201. //上热门-不跳转
  202. }else{
  203. //跳评论
  204. [self goComment:model.videoidStr videoUid:model.videouidStr];
  205. }
  206. }
  207. - (void)didReceiveMemoryWarning {
  208. [super didReceiveMemoryWarning];
  209. // Dispose of any resources that can be recreated.
  210. }
  211. #pragma mark - set/get
  212. -(UITableView *)tableView {
  213. if (!_tableView) {
  214. _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,64+statusbarHeight, _window_width, _window_height - 64-statusbarHeight)style:UITableViewStylePlain];
  215. _tableView.delegate = self;
  216. _tableView.dataSource = self;
  217. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  218. _tableView.backgroundColor = UIColor.whiteColor;
  219. YBWeakSelf;
  220. _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  221. _paging = 1;
  222. [weakSelf pullData];
  223. }];
  224. _footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(refreshFooter)];
  225. _tableView.mj_footer = _footer;
  226. [_footer setTitle:YZMsg(@"数据加载中...") forState:MJRefreshStateRefreshing];
  227. [_footer setTitle:@"" forState:MJRefreshStateIdle];//YZMsg(@"没有更多了哦~")
  228. _footer.stateLabel.font = [UIFont systemFontOfSize:15.0f];
  229. }
  230. return _tableView;
  231. }
  232. #pragma mark - 导航
  233. @end