HomeViewController.m 25 KB

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