BogoTimeLineListViewController.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. //
  2. // BogoTimeLineListViewController.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/9/18.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoTimeLineListViewController.h"
  9. //#import "YHTimeLineListController.h"
  10. #import "CellForWorkGroup.h"
  11. #import "CellForWorkGroupRepost.h"
  12. #import "YHRefreshTableView.h"
  13. #import "YHWorkGroup.h"
  14. #import "YHUserInfoManager.h"
  15. //#import "YHUtils.h"
  16. #import "YHSharePresentView.h"
  17. #import "UITableViewCell+HYBMasonryAutoCellHeight.h"
  18. //#import "XWPublishController.h"
  19. #import "DetailsLineViewController.h"
  20. #import <CLPlayer/CLPlayerView.h>
  21. #import "YHPlayerViewController.h"
  22. #import "ReleaseDynamicVC.h"
  23. #import "BGTopicTimeLineListController.h"
  24. #import "MGNewDTNearByViewController.h"//附近的人
  25. //new
  26. #import "WBModel.h"
  27. #import "WBStatusLayout.h"
  28. #import "WBStatusCell.h"
  29. #import <ZFPlayer/ZFPlayer.h>
  30. #import <ZFPlayer/ZFAVPlayerManager.h>
  31. #import <ZFPlayer/ZFPlayerControlView.h>
  32. #import <AVFoundation/AVFoundation.h>
  33. #import <AFSoundManager/AFSoundManager.h>
  34. #import "YYPhotoGroupView.h"
  35. @interface BogoTimeLineListViewController ()<UITableViewDelegate,UITableViewDataSource,CellForWorkGroupDelegate,CellForWorkGroupRepostDelegate,BzoneLogicDelegate,WBStatusCellDelegate>{
  36. int _currentRequestPage; //当前请求页面
  37. BOOL _reCalculate;
  38. }
  39. //@property (nonatomic,strong) UITableView *tableView;
  40. @property (nonatomic, strong) UIButton *rightBtn;
  41. @property (nonatomic,strong) NSMutableArray *dataArray;
  42. @property (nonatomic,strong) NSMutableDictionary *heightDict;
  43. @property (nonatomic, strong) BzoneLogic *logic;
  44. @property (nonatomic, strong) WBStatusCell *c_cell;
  45. @property (nonatomic, strong) CLPlayerView *playerView;
  46. @property(nonatomic, assign) CGFloat scrollOffset;
  47. @property(nonatomic, strong) UIView *tableHeadView;
  48. //new
  49. @property (nonatomic, strong) NSMutableArray *layouts;
  50. @property (nonatomic, strong) ZFPlayerController *player;
  51. //@property (nonatomic, strong) WBStatusVideoControlView *controlView;
  52. @property (nonatomic, strong) NSMutableArray *urls;
  53. @property(nonatomic, strong) NSMutableArray *items;
  54. @property (nonatomic, strong) AFSoundPlayback *playback;
  55. @property (nonatomic, strong) AFSoundQueue *queue;
  56. @end
  57. @implementation BogoTimeLineListViewController
  58. -(instancetype)initWithIndexAct:(MGDTHOMETYPE)act withUID:(NSString *)toUid isHomePageFrame:(CGRect)homePageFrame{
  59. BogoTimeLineListViewController *vc = [BogoTimeLineListViewController new];
  60. vc.homeType = act;
  61. vc.toUid = toUid;
  62. vc.homePageFrame = homePageFrame;
  63. // _tableView = [YYTableView new];
  64. // _tableView.delegate = self;
  65. // _tableView.dataSource = self;
  66. return vc;
  67. }
  68. - (void)viewDidLoad{
  69. [super viewDidLoad];
  70. _layouts = [NSMutableArray new];
  71. _urls = [NSMutableArray array];
  72. _currentRequestPage = 1;
  73. [self initUI];
  74. // self.logic = [BzoneLogic new];
  75. //
  76. // self.logic.page = 1;
  77. // _logic.delegagte = self;
  78. // _logic.to_uid = self.toUid;
  79. // _logic.isGZ = YES;
  80. // [self requestDataLoadNew:YES];
  81. //设置UserId
  82. [YHUserInfoManager sharedInstance].userInfo.uid = @"1";
  83. // [self wbStatusInit];
  84. [self requestWBStauts:_currentRequestPage];
  85. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(refreshHeader) name:KBogoTimeReloadList object:nil];
  86. }
  87. - (void)initUI{
  88. self.tableView = [[UITableView alloc] initWithFrame:self.homePageFrame style:UITableViewStylePlain];
  89. self.tableView.tag = 1107;
  90. if (@available(iOS 15.0, *)) {
  91. self.tableView.sectionHeaderTopPadding = 0;
  92. }
  93. NSLog(@"%f",kTabBarHeight);
  94. NSLog(@"%f",kNavigationBarHeight);
  95. self.tableView.delegate = self;
  96. self.tableView.dataSource = self;
  97. self.tableView.backgroundColor = UIColor.clearColor;
  98. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  99. [self.view addSubview:self.tableView];
  100. // [self.tableView setEnableLoadNew:YES];
  101. // [self.tableView setEnableLoadMore:YES];
  102. self.view.backgroundColor = UIColor.clearColor;
  103. [self.tableView registerClass:[CellForWorkGroup class] forCellReuseIdentifier:NSStringFromClass([CellForWorkGroup class])];
  104. [self.tableView registerClass:[CellForWorkGroupRepost class] forCellReuseIdentifier:NSStringFromClass([CellForWorkGroupRepost class])];
  105. [_tableView registerClass:[WBStatusCell class] forCellReuseIdentifier:NSStringFromClass([WBStatusCell class])];
  106. self.rightBtn = [[UIButton alloc] init];
  107. self.rightBtn.frame = CGRectMake(kScreenW - 50 - 15, kScreenH - kNavigationBarHeight - kTabBarHeight - 50 - 25, 50, 50);
  108. // search.imageEdgeInsets = UIEdgeInsetsMake(6, 6, 6, 6);
  109. [self.rightBtn setImage:[UIImage imageNamed:@"mg_dy_publish"] forState:UIControlStateNormal];
  110. [self.rightBtn addTarget:self action:@selector(handleSearchEvent) forControlEvents:UIControlEventTouchUpInside];
  111. [BGMJRefreshManager refresh:self.tableView target:self headerRereshAction:@selector(refreshHeader) footerRereshAction:@selector(refreshFooter)];
  112. [self.view addSubview:self.rightBtn];
  113. }
  114. -(void)refreshHeader{
  115. [self resetHeadView];
  116. // [self requestDataLoadNew:YES];
  117. _currentRequestPage = 1;
  118. [self requestWBStauts:_currentRequestPage];
  119. }
  120. -(void)refreshFooter{
  121. // [self requestDataLoadNew:NO];
  122. _currentRequestPage ++;
  123. [self requestWBStauts:_currentRequestPage];
  124. }
  125. - (void)viewWillAppear:(BOOL)animated {
  126. [super viewWillAppear:animated];
  127. // [self requestDataLoadNew:YES];
  128. // [self.logic loadListDataWithAct:self.homeType];
  129. }
  130. - (void)viewWillDisappear:(BOOL)animated {
  131. [super viewWillDisappear:animated];
  132. [_playerView destroyPlayer];
  133. _c_cell =nil;
  134. }
  135. -(void)reloadDynamicData{
  136. // BzoneLogic *logic = [BzoneLogic new];
  137. // logic.delegagte = self;
  138. // [logic loadListDataWithAct:self.homeType];
  139. }
  140. //发布动态
  141. - (void)handleSearchEvent
  142. {
  143. // XWPublishController *pushVC = [XWPublishController new];
  144. ReleaseDynamicVC *pushVC = [ReleaseDynamicVC new];
  145. __weak __typeof(self)weakSelf = self;
  146. pushVC.postFinishBlock = ^(BOOL isFinish) {
  147. if (isFinish) {
  148. if (weakSelf.timeLineDelegate && [weakSelf.timeLineDelegate respondsToSelector:@selector(reloadDynamicData)]) {
  149. [weakSelf.timeLineDelegate reloadDynamicData];
  150. }
  151. // [weakSelf.logic loadListDataWithAct:self.homeType];
  152. }
  153. };
  154. [[AppDelegate sharedAppDelegate]presentViewController:pushVC animated:YES completion:nil];
  155. // [self presentViewController:pushVC animated:YES completion:nil];
  156. }
  157. #pragma mark - Lazy Load
  158. - (NSMutableArray *)dataArray{
  159. if (!_dataArray) {
  160. _dataArray = [NSMutableArray array];
  161. }
  162. return _dataArray;
  163. }
  164. - (NSMutableDictionary *)heightDict{
  165. if (!_heightDict) {
  166. _heightDict = [NSMutableDictionary new];
  167. }
  168. return _heightDict;
  169. }
  170. #pragma mark - UIScrollViewDelegate 列表播放必须实现
  171. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  172. [scrollView zf_scrollViewDidEndDecelerating];
  173. }
  174. - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
  175. [scrollView zf_scrollViewDidEndDraggingWillDecelerate:decelerate];
  176. }
  177. - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
  178. [scrollView zf_scrollViewDidScrollToTop];
  179. }
  180. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
  181. [scrollView zf_scrollViewWillBeginDragging];
  182. }
  183. #pragma mark - UITableViewDataSource
  184. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  185. return _layouts.count;
  186. }
  187. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  188. return self.tableHeadView;
  189. }
  190. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  191. return _homeType == MGDTHOMETYPE_NEARBY ? kRealValue(80) :0;
  192. }
  193. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  194. if (self.layouts.count < 1) {
  195. return [UITableViewCell new];
  196. }
  197. WBStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([WBStatusCell class])];
  198. cell.delegate = self;
  199. cell.isShowMore = [self.title isEqualToString:NSLocalizedString(@"我的动态",nil)];
  200. cell.indexRows = indexPath.row;
  201. if (_layouts.count > 0) {
  202. [cell setLayout:_layouts[indexPath.row]];
  203. }
  204. return cell;
  205. }
  206. #pragma mark - UITableViewDelegate
  207. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  208. return ((WBStatusLayout *)_layouts[indexPath.row]).height;
  209. }
  210. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  211. self.hidesBottomBarWhenPushed = YES;
  212. if (self.layouts.count > 0) {
  213. MGGroupUserInfo *model = self.layouts[indexPath.row];
  214. DetailsLineViewController *datails = [DetailsLineViewController new];
  215. datails.title = ASLocalizedString(@"动态详情");
  216. datails.model = model;
  217. datails.refreshData = ^{
  218. _currentRequestPage = 1;
  219. // self.logic.page = _currentRequestPage;
  220. // [self.logic loadListDataWithAct:self.homeType];
  221. };
  222. [[AppDelegate sharedAppDelegate] pushViewController:datails animated:YES];
  223. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  224. [AppDelegate sharedAppDelegate].topViewController.hidesBottomBarWhenPushed = YES;
  225. }
  226. }
  227. /// 点击了 Cell
  228. - (void)cellDidClick:(WBStatusCell *)cell {
  229. if (self.layouts.count > 0) {
  230. MGGroupUserInfo *model = (MGGroupUserInfo *)cell.layout.status;
  231. DetailsLineViewController *datails = [DetailsLineViewController new];
  232. datails.title = ASLocalizedString(@"动态详情");
  233. datails.model = model;
  234. datails.refreshData = ^{
  235. _currentRequestPage = 1;
  236. // self.logic.page = _currentRequestPage;
  237. // [self.logic loadListDataWithAct:self.homeType];
  238. };
  239. [[AppDelegate sharedAppDelegate] pushViewController:datails animated:YES];
  240. // [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  241. [AppDelegate sharedAppDelegate].topViewController.hidesBottomBarWhenPushed = YES;
  242. }
  243. }
  244. /// 点击了用户
  245. - (void)cell:(WBStatusCell *)cell didClickUser:(WBUserInfoModel *)user {
  246. if (cell.layout.status.no_name.intValue == 1 && ![cell.layout.status.uid isEqualToString:[BGIMLoginManager sharedInstance].loginParam.identifier]) {
  247. return;
  248. }
  249. SHomePageVC *tmpController= [[SHomePageVC alloc]init];
  250. tmpController.user_id = cell.statusView.layout.status.uid;
  251. tmpController.type = 0;
  252. [[AppDelegate sharedAppDelegate]pushViewController:tmpController animated:YES];
  253. }
  254. //点击了关注
  255. - (void)cell:(WBStatusCell *)cell didClickMore:(UIButton *)sender{
  256. WBModel *model = cell.layout.status;
  257. NSMutableDictionary *parmDict = [[NSMutableDictionary alloc]init];
  258. [parmDict setObject:@"user" forKey:@"ctl"];
  259. [parmDict setObject:@"follow" forKey:@"act"];
  260. [parmDict setObject:SafeStr(model.uid) forKey:@"to_user_id"];
  261. FWWeakify(self)
  262. [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  263. if ([[responseJson valueForKey:@"status"] integerValue] == 1) {
  264. model.is_focus = @"1";
  265. cell.statusView.layout.status = model;
  266. [self.layouts replaceObjectAtIndex:cell.indexRows withObject:cell.statusView.layout];
  267. sender.hidden = YES;
  268. }else{
  269. [BGHUDHelper alert:[responseJson valueForKey:@"error"]];
  270. }
  271. } FailureBlock:^(NSError *error) {
  272. }];
  273. }
  274. /// 点击了评论
  275. - (void)cellDidClickComment:(WBStatusCell *)cell {
  276. WBModel *model = cell.statusView.layout.status;
  277. DetailsLineViewController *datails = [DetailsLineViewController new];
  278. datails.hidesBottomBarWhenPushed = YES;
  279. datails.title = ASLocalizedString(@"动态详情");
  280. datails.model = (MGGroupUserInfo *)model;
  281. datails.refreshData = ^{
  282. _currentRequestPage = 1;
  283. };
  284. [[AppDelegate sharedAppDelegate] pushViewController:datails animated:YES];
  285. // [self.navigationController pushViewController:datails animated:YES];
  286. }
  287. -(void)cell:(WBStatusCell *)cell didClickDeleteBtn:(UIButton *)sender{
  288. __weak __typeof(self)weakSelf = self;
  289. [FanweMessage alert:ASLocalizedString(@"提示")message:ASLocalizedString(@"确定删除该动态?")destructiveAction:^{
  290. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  291. [parmDict setObject:@"dynamic" forKey:@"ctl"];
  292. [parmDict setObject:@"del_dynamic" forKey:@"act"];
  293. [parmDict setObject:cell.layout.status.id forKey:@"dynamic_id"];
  294. FWWeakify(self)
  295. [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  296. if ([[responseJson valueForKey:@"status"] integerValue] == 1) {
  297. [FanweMessage alertHUD:ASLocalizedString(@"删除动态成功")];
  298. }else{
  299. [FanweMessage alertHUD:[responseJson valueForKey:@"error"]];
  300. }
  301. [self requestWBStauts:_currentRequestPage];
  302. } FailureBlock:^(NSError *error) {
  303. }];
  304. } cancelAction:^{
  305. }];
  306. }
  307. /// 点击了赞
  308. - (void)cellDidClickLike:(WBStatusCell *)cell {
  309. __weak __typeof(self)weakSelf = self;
  310. WBModel *status = cell.statusView.layout.status;
  311. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  312. [parmDict setObject:@"dynamic" forKey:@"ctl"];
  313. [parmDict setObject:@"praise" forKey:@"act"];
  314. [parmDict setObject:SafeStr(status.id) forKey:@"dynamic_id"];
  315. NSString *like = !status.is_like.integerValue ? @"1" : @"2";
  316. [parmDict setObject:like forKey:@"is_praise"];
  317. FWWeakify(self)
  318. [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  319. NSInteger praise = [status.praise integerValue];
  320. if ([[responseJson valueForKey:@"status"]integerValue] == 1) {
  321. [cell.statusView.toolbarView setLiked:[[responseJson valueForKey:@"is_like"]intValue] withAnimation:YES];
  322. }
  323. } FailureBlock:^(NSError *error) {
  324. }];
  325. }
  326. #pragma 视频相关
  327. - (void)cell:(WBStatusCell *)cell didClickVideo:(NSString *)url{
  328. YHPlayerViewController *vc = [[YHPlayerViewController alloc]initWithPlayerURL:cell.layout.status.video];
  329. [[AppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
  330. }
  331. - (void)onShareInCell:(CellForWorkGroup *)cell{
  332. if (cell.indexPath.row < [self.dataArray count]){
  333. [self _shareWithCell:cell];
  334. }
  335. }
  336. - (void)onDeleteInCell:(CellForWorkGroup *)cell{
  337. if (cell.indexPath.row < [self.dataArray count]) {
  338. [self _deleteDynAtIndexPath:cell.indexPath dynamicId:cell.model.id cell:cell];
  339. }
  340. }
  341. - (void)onTopicInCell:(CellForWorkGroup *)cell{
  342. if (cell.indexPath.row < [self.dataArray count]) {
  343. BGTopicTimeLineListController *pushVC = [BGTopicTimeLineListController new];
  344. MGDynamicTopicModel *topic = [MGDynamicTopicModel new];
  345. topic.t_id = cell.model.theme_id;
  346. topic.name = cell.model.theme;
  347. pushVC.topic = topic;
  348. [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
  349. }
  350. }
  351. /// 点击了图片
  352. - (void)cell:(WBStatusCell *)cell didClickImageAtIndex:(NSUInteger)index {
  353. UIView *fromView = nil;
  354. NSMutableArray *items = [NSMutableArray new];
  355. WBModel *status = cell.statusView.layout.status;
  356. NSArray<NSString *> *pics = status.picUrls;
  357. NSArray<NSString *> *originPics = status.picUrls;
  358. for (NSUInteger i = 0, max = pics.count; i < max; i++) {
  359. UIView *imgView = cell.statusView.picViews[i];
  360. YYPhotoGroupItem *item = [YYPhotoGroupItem new];
  361. item.thumbView = imgView;
  362. item.largeImageURL = [NSURL URLWithString:originPics[i]];
  363. item.largeImageSize = CGSizeMake(kScreenW, kScreenH);
  364. [items addObject:item];
  365. if (i == index) {
  366. fromView = imgView;
  367. }
  368. }
  369. YYPhotoGroupView *v = [[YYPhotoGroupView alloc] initWithGroupItems:items];
  370. [v presentFromImageView:fromView toContainer:[UIApplication sharedApplication].keyWindow animated:YES completion:nil];
  371. }
  372. -(void)tableView:(UITableView *)tableView willDisplayCell:(WBStatusCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
  373. if (self.layouts.count < 1) {
  374. return;
  375. }
  376. WBStatusLayout *layout = self.layouts[indexPath.row];
  377. if (StrValid(layout.status.video) && indexPath.row == 0){
  378. //原创cell
  379. cell.statusView.cardView.button.hidden = YES;
  380. [cell.statusView.cardView.playerView.player play];
  381. }
  382. }
  383. - (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  384. {
  385. }
  386. -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
  387. if (self.layouts.count > 0) {
  388. NSArray *cellArr = self.tableView.visibleCells;
  389. WBStatusCell *cell;
  390. if (self.scrollOffset - scrollView.contentOffset.y > 0) {
  391. cell = cellArr.firstObject;
  392. }else{
  393. cell = cellArr.lastObject;
  394. }
  395. if (cellArr.count == 3) {//当可见视图有三个cell时,展示中间那个。
  396. cell = [cellArr objectAtIndex:1];
  397. }
  398. self.scrollOffset = scrollView.contentOffset.y;
  399. if (self.scrollOffset == 0) cell = cellArr.firstObject;//下拉刷新时展示第一个
  400. if (_c_cell != cell) {
  401. if (cell.statusView.cardView.hidden == NO) {
  402. _c_cell = cell;
  403. [_c_cell.statusView.cardView.playerView pausePlay];
  404. [cell.statusView.cardView.playerView playVideo];
  405. cell.statusView.cardView.button.hidden = NO;
  406. cell.statusView.cardView.button.hidden = YES;
  407. }
  408. }
  409. }
  410. if(self.timeLineDelegate && [self.timeLineDelegate respondsToSelector:@selector(protocolTimeLineDidScrollView:offset:)])
  411. {
  412. [self.timeLineDelegate protocolTimeLineDidScrollView:scrollView offset:scrollView.contentOffset.y];
  413. }
  414. }
  415. -(void)requestWBStauts:(NSInteger)pageIndex{
  416. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  417. [parmDict setObject:@"dynamic" forKey:@"ctl"];
  418. NSString *actStr = @"";
  419. if (self.homeType == MGDTHOMETYPE_CONCERT) {
  420. actStr = @"follow_index";
  421. }else if (self.homeType == MGDTHOMETYPE_NEARBY) {
  422. actStr = @"index";
  423. [parmDict setObject:@"fujin" forKey:@"list_type"];
  424. }else if (self.homeType == MGDTHOMETYPE_RECOMMAND) {
  425. actStr = @"index";
  426. [parmDict setObject:@"" forKey:@"list_type"];
  427. }else if (self.homeType == MGDTHOMETYPE_MY) {
  428. actStr = @"my_index";
  429. [parmDict setObject:self.toUid forKey:@"touid"];
  430. }else if (self.homeType == MGDTHOMETYPE_VIDEO){
  431. actStr = @"index";
  432. [parmDict setObject:@"video" forKey:@"list_type"];
  433. }
  434. [parmDict setObject:actStr forKey:@"act"];
  435. [parmDict setObject:[NSString stringWithFormat:@"%ld",pageIndex] forKey:@"p"];
  436. FWWeakify(self)
  437. [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  438. FWStrongify(self)
  439. if (_currentRequestPage == 1) {
  440. [_layouts removeAllObjects];
  441. [self.urls removeAllObjects];
  442. self.player.assetURLs = nil;
  443. [self.items removeAllObjects];
  444. _queue = nil;
  445. }
  446. for (NSDictionary *dict in responseJson[@"list"]) {
  447. WBModel *model = [WBModel mj_objectWithKeyValues:dict];
  448. if (StrValid(self.toUid)) {
  449. model.is_focus = @"1";
  450. }
  451. WBStatusLayout *layout = [[WBStatusLayout alloc] initWithStatus:model style:WBLayoutStyleTimeline];
  452. if (layout) {
  453. [_layouts addObject:layout];
  454. }
  455. NSURL *url = [NSURL URLWithString:model.audio.length ? model.audio : @""];
  456. [self.urls addObject:url];
  457. self.player.assetURLs = self.urls;
  458. }
  459. _queue = [[AFSoundQueue alloc] initWithItems:_items];
  460. self.navigationController.view.userInteractionEnabled = YES;
  461. if ([(NSArray *)responseJson[@"list"] count]) {
  462. [_tableView.mj_footer endRefreshing];
  463. [_tableView reloadData];
  464. }else{
  465. [_tableView.mj_footer endRefreshingWithNoMoreData];
  466. }
  467. [_tableView.mj_header endRefreshing];
  468. } FailureBlock:^(NSError *error) {
  469. }];
  470. }
  471. #pragma mark - 模拟产生数据源
  472. - (void)randomModel:(MGGroupUserInfo *)model totalCount:(int)totalCount{
  473. model.type = arc4random()%totalCount %2? DynType_Forward:DynType_Original;//动态类型
  474. if (model.type == DynType_Forward) {
  475. model.forwardModel = [MGGroupUserInfo new];
  476. [self creatOriModel:model.forwardModel totalCount:totalCount];
  477. }
  478. [self creatOriModel:model totalCount:totalCount];
  479. }
  480. - (void)creatOriModel:(MGGroupUserInfo *)model totalCount:(int)totalCount{
  481. }
  482. #pragma mark - YHRefreshTableViewDelegate
  483. - (void)refreshTableViewLoadNew:(YHRefreshTableView*)view{
  484. // [self requestDataLoadNew:YES];
  485. }
  486. - (void)refreshTableViewLoadmore:(YHRefreshTableView*)view{
  487. // [self requestDataLoadNew:NO];
  488. }
  489. #pragma mark - CellForWorkGroupDelegate
  490. - (void)onAvatarInCell:(CellForWorkGroup *)cell{
  491. SHomePageVC *tmpController= [[SHomePageVC alloc]init];
  492. tmpController.user_id = cell.model.uid;
  493. tmpController.type = 0;
  494. [[AppDelegate sharedAppDelegate]pushViewController:tmpController animated:YES];
  495. }
  496. - (void)onMoreInCell:(CellForWorkGroup *)cell{
  497. if (cell.indexPath.row < [self.dataArray count]) {
  498. YHWorkGroup *model = self.dataArray[cell.indexPath.row];
  499. model.isOpening = !model.isOpening;
  500. [self.tableView reloadRowsAtIndexPaths:@[cell.indexPath] withRowAnimation:UITableViewRowAnimationFade];
  501. }
  502. }
  503. - (void)onTouchActionVideo:(WBStatusCell *)cell withFullScreen:(BOOL)fullScreen
  504. {
  505. if (fullScreen) {
  506. YHPlayerViewController *vc = [[YHPlayerViewController alloc]initWithPlayerURL:cell.layout.status.video];
  507. [[AppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
  508. return;
  509. }
  510. _c_cell = cell;
  511. }
  512. #pragma mark - CellForWorkGroupRepostDelegate
  513. - (void)onAvatarInRepostCell:(CellForWorkGroupRepost *)cell{
  514. }
  515. - (void)onTapRepostViewInCell:(CellForWorkGroupRepost *)cell{
  516. }
  517. - (void)onCommentInRepostCell:(CellForWorkGroupRepost *)cell{
  518. }
  519. //附近--点击去看看
  520. -(void)cliclSeeBtn:(UIButton *)sender{
  521. if (kIsCheckingVersion())
  522. {
  523. return;
  524. }
  525. MGNewDTNearByViewController *pushVC = [[MGNewDTNearByViewController alloc]initWithType:MGNEWDTTYPE_NEAR_PEOPLE];
  526. [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
  527. }
  528. #pragma mark - private
  529. - (void)_deleteDynAtIndexPath:(NSIndexPath *)indexPath dynamicId:(NSString *)dynamicId cell:(CellForWorkGroup *)cell{
  530. __weak __typeof(self)weakSelf = self;
  531. // [FanweMessage alert:ASLocalizedString(@"提示")message:ASLocalizedString(@"确定删除该动态?")destructiveAction:^{
  532. [weakSelf.logic delZone:dynamicId Success:^{
  533. [weakSelf.logic loadListDataWithAct:self.homeType];
  534. [FanweMessage alertHUD:ASLocalizedString(@"删除成功")];
  535. }];
  536. // } cancelAction:^{
  537. //
  538. // }];
  539. }
  540. - (void)_shareWithCell:(CellForWorkGroup *)cell{
  541. __weak __typeof(self)weakSelf = self;
  542. [_logic dynamicForwardWithDynamic_id:cell.model.id Success:^{
  543. cell.model.bottomViewSelect = YES;
  544. cell.bottomView.hidden = YES;
  545. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"转发成功")];
  546. [weakSelf.logic loadListDataWithAct:self.homeType];
  547. }];
  548. }
  549. #pragma mark - UIScrollViewDelegate
  550. -(UIView *)tableHeadView{
  551. if (!_tableHeadView) {
  552. _tableHeadView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(80))];
  553. _tableHeadView.backgroundColor = UIColor.clearColor;
  554. UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(kRealValue(10), 0, kScreenW - kRealValue(10 * 2), kRealValue(80))];
  555. imgView.image = [UIImage imageNamed:@"dy_newby_people_bgimg"];
  556. imgView.userInteractionEnabled = YES;
  557. UILabel *titleL = [[UILabel alloc]initWithFrame:CGRectMake(kRealValue(28), kRealValue(12), kRealValue(100), kRealValue(20))];
  558. titleL.text = ASLocalizedString(@"附近的人");
  559. titleL.font = [UIFont systemFontOfSize:15];
  560. titleL.textColor = kBlackColor;
  561. UIButton *toSeeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  562. toSeeBtn.frame = CGRectMake(kRealValue(25), titleL.bottom + kRealValue(5), kRealValue(64), kRealValue(29));
  563. [toSeeBtn setBackgroundImage:[UIImage imageNamed:@"dy_newby_people_tosee"] forState:UIControlStateNormal];
  564. [toSeeBtn setTitle:ASLocalizedString(@"去看看")forState:UIControlStateNormal];
  565. [toSeeBtn addTarget:self action:@selector(cliclSeeBtn:) forControlEvents:UIControlEventTouchUpInside];
  566. toSeeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  567. [imgView addSubview:titleL];
  568. [imgView addSubview:toSeeBtn];
  569. [_tableHeadView addSubview:imgView];
  570. for (int i = 0; i < 3; i ++ ) {
  571. UIImageView *headImgView = [[UIImageView alloc]initWithFrame:CGRectMake(kRealValue(240) + kRealValue(30) * i, 0, kRealValue(40), kRealValue(40))];
  572. headImgView.tag = 100 + i;
  573. headImgView.centerY = imgView.height / 2;
  574. headImgView.layer.masksToBounds = YES;
  575. headImgView.layer.cornerRadius = kRealValue(40 / 2);
  576. headImgView.backgroundColor = kClearColor;
  577. [_tableHeadView addSubview:headImgView];
  578. }
  579. }
  580. return _tableHeadView;
  581. }
  582. -(void)resetHeadView{
  583. //附近的人
  584. if (self.homeType == MGDTHOMETYPE_NEARBY) {
  585. if (kIsCheckingVersion())
  586. {
  587. return;
  588. }
  589. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  590. [parmDict setObject:@"dynamic" forKey:@"ctl"];
  591. [parmDict setObject:@"fujin_user" forKey:@"act"];
  592. [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  593. if ([[responseJson valueForKey:@"status"] integerValue] == 1) {
  594. NSArray *arr = responseJson[@"data"];
  595. [self resetTableHeadViewWithArr:arr];
  596. }else{
  597. }
  598. } FailureBlock:^(NSError *error) {
  599. }];
  600. }
  601. }
  602. -(void)resetTableHeadViewWithArr:(NSArray *)arr{
  603. if (arr.count > 0)
  604. {
  605. for ( int i = 0; i < arr.count; i++) {
  606. NSDictionary *dic = arr[i];
  607. MGNewDTNearlistModel *model = [MGNewDTNearlistModel modelWithDictionary:dic];
  608. UIImageView *imgView = [_tableHeadView viewWithTag:100 + i];
  609. [imgView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:nil];
  610. }
  611. }
  612. }
  613. @end