HomeViewController.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. //
  2. // HomeViewController.m
  3. // TheoryNetwork
  4. //
  5. // Created by tederen on 2019/9/20.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. //#import "DrawerView.h"
  9. #import "HomeViewController.h"
  10. #import "SurfaceSearchView.h"
  11. #import "HorizonScroll.h"
  12. #import "ChannelModel.h"
  13. #import "HomeSearchController.h"
  14. #import "AddChannelController.h"
  15. #import "HttpManager.h"
  16. #import "HomeDetailController.h"
  17. #import "APIPOPOPO.h"
  18. #import "MyApprovalPageDetail.h"
  19. #import "MailListDetailVC.h"
  20. #import "NavigationController.h"
  21. #import "UIAlertController+TapGesAlertController.h"
  22. #import "HomeArticleModel.h"
  23. #import "HomeListWorkCell.h"
  24. #import "HomeTableViewCell.h"
  25. #import "SLBannerView.h"
  26. #import "MyFavoriteVC.h"
  27. #import "OtherFavoriteVC.h"
  28. #import "NoteBookVC.h"
  29. #import "OtherNoteBookVC.h"
  30. @interface HomeViewController () <UITableViewDataSource, UITableViewDelegate,SLBannerViewDelegate,AddChannelControllerDelegate>
  31. @property (nonatomic, strong) UILabel *titleLabel;
  32. @property (nonatomic, strong) UIView *bannerBgV;
  33. @property (nonatomic, strong) SLBannerView *bannerView;
  34. @property (nonatomic, strong) SurfaceSearchView *searchView;
  35. @property (nonatomic, strong) HorizonScroll *channelScroll;
  36. @property (nonatomic, strong) NSMutableArray *bannerImgArr;
  37. @property (nonatomic, strong) NSMutableArray * tabConfigArray;
  38. @property (nonatomic, strong) NSMutableArray * bannerModelArray;
  39. @property (nonatomic, strong) HomeArticleModel *model;
  40. @property (nonatomic, strong) TDWaitWorkModel *waitModel;
  41. @property (nonatomic, assign) NSInteger currentPage;
  42. @property (nonatomic, assign) NSInteger totalPage;
  43. @property (nonatomic, assign) NSInteger currentChannel;
  44. @property (nonatomic, strong) NSMutableDictionary *articleDic;
  45. @property (nonatomic, copy) NSMutableArray *dataSource;
  46. @property (nonatomic, strong) UITableView *tableView;
  47. @property (strong, nonatomic) UIAlertController *alertVC;
  48. /// 我的频道
  49. @property (copy, nonatomic) NSMutableArray *myChannel;
  50. @property (strong, nonatomic) UIView *noDataView;
  51. @property (nonatomic, strong) UILabel *noDataLabel;
  52. @end
  53. @implementation HomeViewController
  54. - (void)viewWillAppear:(BOOL)animated
  55. {
  56. [super viewWillAppear:animated];
  57. [self getRedBadge];
  58. }
  59. #pragma mark - LifeCycle
  60. - (void)viewDidLoad {
  61. [super viewDidLoad];
  62. [self getdata];
  63. self.fd_prefersNavigationBarHidden = YES;
  64. [self loadStatusBarColor:[UIColor whiteColor]];
  65. self.view.backgroundColor = UIColorHex(F2F2F2);
  66. [self.view addSubview:self.titleLabel];
  67. [self.view addSubview:self.searchView];
  68. [self.view addSubview:self.tableView];
  69. self.bannerView = [[SLBannerView alloc] initWithFrame:CGRectMake(15, 0, kGXScreenWidth - 30, 125)];
  70. self.bannerView.delegate = self;
  71. self.bannerView.durTimeInterval = 0.2;
  72. self.bannerView.imgStayTimeInterval = 2.5;
  73. self.bannerBgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kGXScreenWidth, 132)];
  74. self.bannerBgV.backgroundColor = [UIColor clearColor];
  75. [self.searchView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 52)];
  76. [self.bannerBgV addSubview:self.bannerView];
  77. [self.tableView setTableHeaderView:self.bannerBgV];
  78. [self layoutSubviews];
  79. WEAKSELF
  80. self.searchView.buttonBlock = ^(){
  81. STRONGSELF
  82. HomeSearchController *homeSearch = [[HomeSearchController alloc] init];
  83. [strongSelf.navigationController pushViewController:homeSearch animated:YES];
  84. };
  85. [UserManager getUserInfoDetail];
  86. self.tableView.delegate = self;
  87. self.tableView.dataSource = self;
  88. [self.tableView registerNib:[UINib nibWithNibName:@"HomeListWorkCell" bundle:nil] forCellReuseIdentifier:@"HomeListWorkCell"];
  89. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableViewScrollTop) name:HOMESCROLLVIEWTOTOP object:nil];
  90. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shareReturnAction:) name:SHARERETURNSUCCESS object:nil];
  91. [self setTableViewRefresh];
  92. }
  93. - (void)setTableViewRefresh{
  94. WS(weakSelf);
  95. self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  96. [weakSelf headRefresh];
  97. }];
  98. self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
  99. [weakSelf footerRefresh];
  100. }];
  101. }
  102. - (void)headRefresh{
  103. self.currentPage = 1;
  104. [self.dataSource removeAllObjects];
  105. [self ReGetHomeListData:self.currentChannel];
  106. }
  107. - (void)footerRefresh{
  108. self.currentPage += 1;
  109. if (self.dataSource.count == self.totalPage) {
  110. self.tableView.mj_footer.hidden = YES;
  111. [self.tableView.mj_footer resetNoMoreData];
  112. return;
  113. }
  114. [self ReGetHomeListData:self.currentChannel];
  115. }
  116. - (void)getRedBadge
  117. {
  118. WS(weakSelf);
  119. //获取我审批和我发起以及抄送我的未读数
  120. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,@"/api/app/user/user-uread-count"] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  121. NSDictionary *dic = responseObject;
  122. WorkNumberModel *numberModel = [[WorkNumberModel alloc] initWithDictionary:dic error:nil];
  123. weakSelf.tabBarController.tabBar.items[1].badgeValue = numberModel.allNumber;
  124. weakSelf.tabBarController.tabBar.items[2].badgeValue = numberModel.allNotifacationNumber;
  125. } failure:^(NSError * _Nonnull error) {
  126. }];
  127. }
  128. - (void)tableViewScrollTop
  129. {
  130. [self.tableView scrollToTop];
  131. }
  132. - (void)dealloc
  133. {
  134. [[NSNotificationCenter defaultCenter] removeObserver:self];
  135. }
  136. #pragma mark - NetRequest
  137. - (void)getdata{
  138. #pragma mark - 轮播
  139. WS(weakSelf);
  140. dispatch_semaphore_t sem = dispatch_semaphore_create(0);
  141. __block NSInteger httpFinishCount = 0;
  142. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  143. [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,HomeSlideImages_GET] parameters: @{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  144. NSArray *arr = responseObject[@"Items"];
  145. NSLog(@"首页轮播数据%@",arr.firstObject);
  146. [weakSelf.bannerModelArray removeAllObjects];
  147. [weakSelf.bannerImgArr removeAllObjects];
  148. NSMutableArray *array = [NSMutableArray array];
  149. NSMutableArray *array2 = [NSMutableArray array];
  150. for (int i = 0; i < arr.count; i++) {
  151. NSDictionary *dic = arr[i];
  152. HomeTopImageModel *imageModel = [[HomeTopImageModel alloc] initWithDictionary:dic error:nil];
  153. [array2 addObject:imageModel];
  154. [array addObject:dic[@"ImageUrl"]];
  155. }
  156. weakSelf.bannerImgArr = array;
  157. weakSelf.bannerModelArray = array2;
  158. weakSelf.bannerView.slImages = array;
  159. if (++httpFinishCount == 3) {
  160. dispatch_semaphore_signal(sem);
  161. }
  162. } failure:^(NSError * _Nonnull error) {
  163. REMOVESHOW
  164. }];
  165. #pragma mark - 频道
  166. [weakSelf loadChannelModel];
  167. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  168. NSLog(@"%@",responseObject);
  169. NSArray *array = responseObject;
  170. for (NSInteger i = 0 ; i < array.count; i ++) {
  171. NSDictionary *dic = array[i];
  172. ChannelModel *model = [ChannelModel modelWithDictionary:dic];
  173. if (model.ArticleGroupId == 0) {
  174. model.IsSelect = YES;
  175. }
  176. [weakSelf.myChannel addObject:model];
  177. }
  178. [weakSelf.channelScroll setChannelArray:weakSelf.myChannel];
  179. //先注释观察
  180. if (++httpFinishCount == 3) {
  181. dispatch_semaphore_signal(sem);
  182. }
  183. } failure:^(NSError * _Nonnull error) {
  184. REMOVESHOW
  185. }];
  186. #pragma mark - 列表
  187. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Notice_list_Post] parameters: @{@"page":@(1),@"perPage":@10,@"GroupId":@(0)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  188. NSDictionary *dic = (NSDictionary *)responseObject;
  189. HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic];
  190. [weakSelf.dataSource addObjectsFromArray:model.Items];
  191. if (++httpFinishCount == 3) {
  192. dispatch_semaphore_signal(sem);
  193. }
  194. } failure:^(NSError * _Nonnull error) {
  195. }];
  196. dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
  197. dispatch_async(dispatch_get_main_queue(), ^{
  198. REMOVESHOW
  199. [weakSelf.tableView reloadData];
  200. });
  201. });
  202. }
  203. - (void)ReGetHomeListData:(NSInteger)channelId
  204. {
  205. WS(weakSelf);
  206. if (self.currentChannel == 1) {
  207. NSDictionary * paraDict = @{@"Type":@"MyChecking",@"page":@(self.currentPage),@"perPage":@10};
  208. [[HttpManager sharedHttpManager] GETUrl:Host(WorkFlowAddApproval_Post) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
  209. NSDictionary *dic = (NSDictionary *)responseObject;
  210. HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic];
  211. [weakSelf.tableView.mj_header endRefreshing];
  212. [weakSelf.tableView.mj_footer endRefreshing];
  213. weakSelf.totalPage = model.Count;
  214. [weakSelf.dataSource addObjectsFromArray:model.Items];
  215. [weakSelf.tableView reloadData];
  216. dispatch_async(dispatch_get_main_queue(), ^{
  217. if (weakSelf.dataSource.count > 0) {
  218. weakSelf.noDataView.hidden = YES;
  219. }else{
  220. weakSelf.noDataView.hidden = NO;
  221. if (weakSelf.currentChannel == 1) {
  222. weakSelf.noDataLabel.text = @"暂无待办工作";
  223. }else{
  224. weakSelf.noDataLabel.text = @"暂无数据";
  225. }
  226. }
  227. });
  228. } failure:^(NSError * _Nonnull error) {
  229. [weakSelf.tableView.mj_header endRefreshing];
  230. [weakSelf.tableView.mj_footer endRefreshing];
  231. SHOWERROR([ZYCTool handerResultData:error])
  232. }];
  233. }else{
  234. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Notice_list_Post] parameters: @{@"page":@(self.currentPage),@"perPage":@10,@"GroupId":@(channelId)} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  235. NSDictionary *dic = (NSDictionary *)responseObject;
  236. HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic];
  237. [weakSelf.tableView.mj_header endRefreshing];
  238. [weakSelf.tableView.mj_footer endRefreshing];
  239. weakSelf.totalPage = model.Count;
  240. [weakSelf.dataSource addObjectsFromArray:model.Items];
  241. [weakSelf.tableView reloadData];
  242. dispatch_async(dispatch_get_main_queue(), ^{
  243. if (weakSelf.dataSource.count > 0) {
  244. weakSelf.noDataView.hidden = YES;
  245. }else{
  246. weakSelf.noDataView.hidden = NO;
  247. if (weakSelf.currentChannel == 1) {
  248. weakSelf.noDataLabel.text = @"暂无待办工作";
  249. }else{
  250. weakSelf.noDataLabel.text = @"暂无数据";
  251. }
  252. }
  253. });
  254. } failure:^(NSError * _Nonnull error) {
  255. [weakSelf.tableView.mj_header endRefreshing];
  256. [weakSelf.tableView.mj_footer endRefreshing];
  257. }];
  258. }
  259. }
  260. -(void)layoutSubviews{
  261. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  262. make.top.equalTo(self.statusBar.mas_bottom);
  263. make.left.right.equalTo(self.view);
  264. make.height.equalTo(@44);
  265. }];
  266. [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
  267. make.top.mas_equalTo(self.titleLabel.mas_bottom);
  268. make.left.right.equalTo(self.view);
  269. make.height.mas_offset(52);
  270. }];
  271. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  272. make.top.mas_equalTo(self.searchView.mas_bottom);
  273. make.left.right.bottom.equalTo(self.view);
  274. }];
  275. [self.view addSubview:self.noDataView];
  276. [self.noDataView mas_makeConstraints:^(MASConstraintMaker *make) {
  277. make.top.mas_equalTo(self.searchView.mas_bottom).offset(170);
  278. make.left.right.mas_equalTo(self.tableView);
  279. make.bottom.mas_offset(-self.tabBarController.tabBar.height);
  280. }];
  281. [self.noDataView addSubview:self.noDataLabel];
  282. [self.noDataLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  283. make.center.mas_equalTo(self.noDataView);
  284. }];
  285. }
  286. - (BOOL)hidesBottomBarWhenPushed{
  287. return NO;
  288. }
  289. #pragma mark - UITableViewDataSource && UITableViewDelegate
  290. - (void)closeBtn_Click {
  291. [self.alertVC dismissViewControllerAnimated:YES completion:nil];
  292. }
  293. - (void)cellDidSelcet:(NSInteger )articleId{
  294. WEAKSELF
  295. UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  296. [closeBtn addTarget:self action:@selector(closeBtn_Click) forControlEvents:UIControlEventTouchUpInside];
  297. [closeBtn setImage:IMG(@"guanbi") forState:UIControlStateNormal];
  298. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"对此内容进行操作" message:@"" preferredStyle:UIAlertControllerStyleAlert];
  299. self.alertVC = alertVC;
  300. [alertVC.view addSubview:closeBtn];
  301. [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  302. make.right.equalTo(alertVC.view).offset(-10);
  303. make.top.equalTo(@10);
  304. make.size.mas_equalTo(CGSizeMake(22, 22));
  305. }];
  306. UIAlertAction *actionOK = [UIAlertAction actionWithTitle:@"屏蔽TA" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  307. STRONGSELF
  308. [strongSelf homeNewsHander:articleId withTypeId:1];
  309. }];
  310. [actionOK setValue:k9 forKey:@"_titleTextColor"];
  311. UIAlertAction *actionNO = [UIAlertAction actionWithTitle:@"不感兴趣" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  312. STRONGSELF
  313. [strongSelf homeNewsHander:articleId withTypeId:2];
  314. }];
  315. [alertVC addAction:actionOK];
  316. [alertVC addAction:actionNO];
  317. [self presentViewController:alertVC animated:YES completion:^{
  318. [alertVC tapGesAlert];
  319. }];
  320. }
  321. - (void)homeNewsHander:(NSInteger )articleId withTypeId:(NSInteger)blacklistType{
  322. WS(weakSelf);
  323. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@/%@",BaseUrl,Article_Hander_Post] parameters:@{@"ArticleId":@(articleId),@"BlacklistType":@(blacklistType)} responseStyle:DATA success:^(id _Nonnull responseObject) {
  324. [weakSelf headRefresh];
  325. } failure:^(NSError * _Nonnull error) {
  326. }];
  327. }
  328. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  329. return self.dataSource.count;
  330. }
  331. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  332. {
  333. WS(weakSelf);
  334. self.channelScroll.ClickAddChannelBlock = ^{
  335. [weakSelf didClickAddButtonChannel];
  336. };
  337. self.channelScroll.ClickSelectChannelBlock = ^(NSInteger channelId) {
  338. weakSelf.currentChannel = channelId;
  339. for (ChannelModel * model in weakSelf.myChannel) {
  340. model.IsSelect = NO;
  341. }
  342. for (ChannelModel * model in weakSelf.myChannel) {
  343. if (model.ArticleGroupId == channelId) {
  344. model.IsSelect = YES;
  345. }
  346. }
  347. [weakSelf.channelScroll.collectionView reloadData];
  348. [[HttpManager sharedHttpManager] cancelRequest];
  349. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  350. [weakSelf headRefresh];
  351. });
  352. };
  353. return self.channelScroll;
  354. }
  355. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  356. {
  357. return [UIView new];
  358. }
  359. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  360. {
  361. return 45.f;
  362. }
  363. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  364. {
  365. return 0.01f;
  366. }
  367. - (HorizonScroll *)channelScroll {
  368. if (!_channelScroll) {
  369. _channelScroll = [[HorizonScroll alloc] initWithFrame:CGRectMake(0, 0, kGXScreenWidth, 45)];
  370. _channelScroll.backgroundColor = [UIColor whiteColor];
  371. }
  372. return _channelScroll;
  373. }
  374. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  375. Item *model = self.dataSource[indexPath.row];
  376. if (self.currentChannel == 1) {
  377. return 159.f + 15.f;
  378. }else{
  379. if (model.ImageUrls.count == 0) {
  380. model.cellID = 1;
  381. }else if(model.ImageUrls.count == 1 || model.ImageUrls.count == 2){
  382. model.cellID = 2;
  383. }else{
  384. model.cellID = 3;
  385. }
  386. switch (model.cellID) {
  387. case 1:
  388. {
  389. UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, SCREEN_WIDTH - 30, 18)];
  390. label.text = model.Title;
  391. label.font = [UIFont systemFontOfSize:18];
  392. label.numberOfLines = 2;
  393. CGSize maxSize = CGSizeMake(label.bounds.size.width, CGFLOAT_MAX);
  394. CGSize newSize = [label sizeThatFits:maxSize];
  395. int height = 50 + newSize.height;
  396. return height;
  397. }
  398. break;
  399. case 2:
  400. return 115;
  401. break;
  402. case 3:
  403. {
  404. UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, SCREEN_WIDTH - 30, 18)];
  405. label.text = model.Title;
  406. label.font = [UIFont systemFontOfSize:18];
  407. label.numberOfLines = 2;
  408. CGSize maxSize = CGSizeMake(label.bounds.size.width, CGFLOAT_MAX);
  409. CGSize newSize = [label sizeThatFits:maxSize];
  410. int height = 86 * (kGXScreenWidth / 375.0) + 67 + newSize.height;
  411. return height;
  412. }
  413. break;
  414. default:
  415. return 70;
  416. break;
  417. }
  418. }
  419. }
  420. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  421. WS(weakSelf);
  422. Item * model = self.dataSource[indexPath.row];
  423. // 待办工作
  424. if (self.currentChannel == 1) {
  425. HomeListWorkCell *cell = (HomeListWorkCell *)[tableView dequeueReusableCellWithIdentifier:@"HomeListWorkCell"];
  426. if (cell != nil && self.dataSource.count > 0) {
  427. [cell loadSearchData:model];
  428. }
  429. return cell;
  430. }else{
  431. // 推荐
  432. if (model.ImageUrls.count == 0) {
  433. model.cellID = 1;
  434. }else if(model.ImageUrls.count == 1 || model.ImageUrls.count == 2){
  435. model.cellID = 2;
  436. }else{
  437. model.cellID = 3;
  438. }
  439. HomeTableViewCell *cell = [HomeTableViewCell cellWithTableView:tableView AndIndex:model.cellID];
  440. if (cell != nil && self.dataSource.count > 0) {
  441. [cell.deleteButton setCurrentButtonHotSize:CGSizeZero];
  442. [cell loadCurrentItemModel:model];
  443. cell.deleteButton.hidden = YES;
  444. cell.buttonBlock = ^{
  445. [weakSelf cellDidSelcet:model.Id];
  446. };
  447. }
  448. return cell;
  449. }
  450. }
  451. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  452. {
  453. WS(weakSelf);
  454. Item * model = self.dataSource[indexPath.row];
  455. // 待办工作
  456. if (self.currentChannel == 1) {
  457. MyApprovalPageDetail *myApprovalPageDetail = [[MyApprovalPageDetail alloc] init];
  458. [myApprovalPageDetail setActionSussBlock:^{
  459. [weakSelf headRefresh];
  460. }];
  461. if ([model.State isEqualToString:@"Meeting"]) {
  462. model.approvalText = @"上会";
  463. }else if ([model.State isEqualToString:@"Checked"]) {
  464. model.approvalText = @"审批通过";
  465. }else if ([model.State isEqualToString:@"Denied"]) {
  466. model.approvalText = @"已拒绝";
  467. }else if ([model.State isEqualToString:@"Wait"]) {
  468. model.approvalText = @"待定";
  469. }else{
  470. model.approvalText = @"待审核";
  471. }
  472. myApprovalPageDetail.pageType = Type_ONEA;
  473. myApprovalPageDetail.userId = model.UserId;
  474. myApprovalPageDetail.indexId = model.Id;
  475. myApprovalPageDetail.TodoId = model.TodoId;
  476. myApprovalPageDetail.title = model.Title;
  477. [self.navigationController pushViewController:myApprovalPageDetail animated:YES];
  478. }else{
  479. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  480. vc.type = CollectModel_Aritle;
  481. vc.Id = model.Id;
  482. [self.navigationController pushViewController:vc animated:YES];
  483. // HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
  484. // [homeDetail loadCurrentModel:model];
  485. // homeDetail.indexFlag = 0;
  486. // [self.navigationController pushViewController:homeDetail animated:YES];
  487. }
  488. }
  489. #pragma mark - channelScroll Block
  490. - (void)didClickAddButtonChannel{
  491. AddChannelController *addChannel = [[AddChannelController alloc] init];
  492. addChannel.modalPresentationStyle = UIModalPresentationFullScreen;
  493. addChannel.delegate = self;
  494. [self presentViewController:addChannel animated:YES completion:nil];
  495. }
  496. #pragma mark - AddChannelControllerDelegate
  497. - (void)upadateChannel{
  498. WS(weakSelf);
  499. [self loadChannelModel];
  500. [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
  501. NSLog(@"%@",responseObject);
  502. NSArray *array = responseObject;
  503. for (NSInteger i = 0 ; i < array.count; i ++) {
  504. NSDictionary *dic = array[i];
  505. ChannelModel *model = [ChannelModel modelWithDictionary:dic];
  506. [weakSelf.myChannel addObject:model];
  507. }
  508. dispatch_async(dispatch_get_main_queue(), ^{
  509. [weakSelf.channelScroll setChannelArray:weakSelf.myChannel];
  510. if (weakSelf.channelScroll.ClickSelectChannelBlock) {
  511. weakSelf.channelScroll.ClickSelectChannelBlock(weakSelf.currentChannel);
  512. }
  513. [weakSelf.tableView reloadData];
  514. });
  515. } failure:^(NSError * _Nonnull error) {
  516. REMOVESHOW
  517. }];
  518. }
  519. #pragma mark - SLBannerViewDelegate
  520. - (void)bannerView:(SLBannerView *)banner didClickImagesAtIndex:(NSInteger)index
  521. {
  522. [self getArticleDetail:index];
  523. }
  524. - (void)getArticleDetail:(NSInteger)index{
  525. HomeTopImageModel *model = self.bannerModelArray[index];
  526. NSLog(@"点击轮播图%ld",(long)model.ArticleId);
  527. SHOWLOADING
  528. WEAKSELF
  529. [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)model.ArticleId] parameters:@{} success:^(id _Nonnull responseObject) {
  530. REMOVESHOW;
  531. Item *model = [[Item alloc]initWithDictionary:responseObject error:nil];
  532. // HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
  533. // [homeDetail loadCurrentModel:itemModel];
  534. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  535. vc.type = CollectModel_Aritle;
  536. vc.Id = model.Id;
  537. [weakSelf.navigationController pushViewController:vc animated:YES];
  538. } failure:^(NSError * _Nonnull error) {
  539. SHOWERROR([ZYCTool handerResultData:error]);
  540. }];
  541. }
  542. #pragma mark - Setter
  543. - (UILabel *)titleLabel {
  544. if (!_titleLabel) {
  545. _titleLabel = [UILabel new];
  546. _titleLabel.backgroundColor = [UIColor whiteColor];
  547. _titleLabel.text = @"首页";
  548. _titleLabel.font = [UIFont systemFontOfSize:16.f];
  549. _titleLabel.textColor = UIColorHex(1A1A1A);
  550. _titleLabel.textAlignment = NSTextAlignmentCenter;
  551. }
  552. return _titleLabel;
  553. }
  554. - (SurfaceSearchView *)searchView {
  555. if (!_searchView) {
  556. _searchView = [[SurfaceSearchView alloc] init];
  557. [_searchView setBgViewColor:[UIColor clearColor]];
  558. [_searchView setPlaceHolderText:@"输入关键字搜索"];
  559. [_searchView setMainType];
  560. }
  561. return _searchView;
  562. }
  563. - (UITableView * )tableView
  564. {
  565. if (!_tableView) {
  566. _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  567. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  568. _tableView.backgroundColor = [UIColor clearColor];
  569. }
  570. return _tableView;
  571. }
  572. - (NSMutableArray *)dataSource
  573. {
  574. if (!_dataSource) {
  575. _dataSource = [NSMutableArray array];
  576. }
  577. return _dataSource;
  578. }
  579. - (NSMutableArray *)tabConfigArray{
  580. if (!_tabConfigArray) {
  581. _tabConfigArray = [NSMutableArray array];
  582. }
  583. return _tabConfigArray;
  584. }
  585. - (NSMutableDictionary *)articleDic{
  586. if (!_articleDic) {
  587. _articleDic = [NSMutableDictionary dictionary];
  588. }
  589. return _articleDic;
  590. }
  591. - (NSMutableArray *)myChannel {
  592. if (!_myChannel) {
  593. _myChannel = [NSMutableArray array];
  594. }
  595. return _myChannel;
  596. }
  597. - (void)loadChannelModel
  598. {
  599. [self.myChannel removeAllObjects];
  600. ChannelModel * model = [[ChannelModel alloc] init];
  601. model.ArticleGroupId = 0;
  602. model.ArticleGroupName = @"推荐";
  603. model.IsSelect = YES;
  604. [self.myChannel addObject:model];
  605. ChannelModel * workModel = [[ChannelModel alloc] init];
  606. workModel.ArticleGroupId = 1;
  607. workModel.ArticleGroupName = @"待办工作";
  608. workModel.IsSelect = NO;
  609. [self.myChannel addObject:workModel];
  610. }
  611. - (UIView *)noDataView
  612. {
  613. if (!_noDataView) {
  614. _noDataView = [UIView new];
  615. _noDataView.hidden = YES;
  616. _noDataView.backgroundColor = UIColorHex(0xEEEEEE);
  617. }
  618. return _noDataView;
  619. }
  620. - (UILabel *)noDataLabel
  621. {
  622. if (!_noDataLabel) {
  623. _noDataLabel = [UILabel new];
  624. _noDataLabel.textColor = UIColorHex(0xBBBBBB);
  625. _noDataLabel.font = [UIFont systemFontOfSize:14];
  626. }
  627. return _noDataLabel;
  628. }
  629. #pragma mark - 分享成功跳转
  630. - (void)shareReturnAction:(NSNotification *)noti
  631. {
  632. NSDictionary * dic = noti.userInfo;
  633. CollectModelType type = [[dic objectForKey:@"type"] intValue];
  634. NSInteger Id = [[dic objectForKey:@"Id"] integerValue];
  635. NSInteger userId = [[dic objectForKey:@"userId"] integerValue];
  636. NSString* name = [[dic objectForKey:@"name"] stringByRemovingPercentEncoding];
  637. NSString* describe = [[dic objectForKey:@"describe"] stringByRemovingPercentEncoding];
  638. switch (type) {
  639. case CollectModel_CollectFile:
  640. {
  641. if (userId == [AppUserModel sharedAppUserModel].Id) {
  642. MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC];
  643. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  644. vc.ParentId = 0;
  645. vc.FolderId = Id;
  646. vc.myTitle = Id == 0 ? @"我的收藏" :name;
  647. [self.navigationController pushViewController:vc animated:YES];
  648. }else{
  649. OtherFavoriteVC * vc = [OtherFavoriteVC initOtherFavoriteVC];
  650. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  651. vc.FolderId = Id;
  652. vc.Author = describe;
  653. vc.myTitle = name;
  654. vc.VisitUserId = userId;
  655. [self.navigationController pushViewController:vc animated:YES];
  656. }
  657. }
  658. break;
  659. case CollectModel_NoteFile:
  660. {
  661. if (userId == [AppUserModel sharedAppUserModel].Id) {
  662. NoteBookVC * vc = [NoteBookVC initNoteBookVC];
  663. if (Id == 0) {
  664. vc.listType = MyFavoriteListLevelTypeB;
  665. vc.myTitle = @"我的笔记";
  666. }else{
  667. vc.listType = MyFavoriteListLevelTypeC;
  668. vc.myTitle = name;
  669. }
  670. vc.ParentId = 0;
  671. vc.FolderId = Id;
  672. vc.isSubVC = YES;
  673. [self.navigationController pushViewController:vc animated:YES];
  674. }else{
  675. OtherNoteBookVC * vc = [OtherNoteBookVC initOtherNoteBookVC];
  676. vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB;
  677. vc.FolderId = Id;
  678. vc.Author = describe;
  679. vc.myTitle = name;
  680. vc.VisitUserId = userId;
  681. [self.navigationController pushViewController:vc animated:YES];
  682. }
  683. }
  684. break;
  685. default:
  686. {
  687. MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
  688. vc.type = type;
  689. vc.Id = Id;
  690. [self.navigationController pushViewController:vc animated:YES];
  691. }
  692. break;
  693. }
  694. }
  695. @end