// // HomeViewController.m // TheoryNetwork // // Created by tederen on 2019/9/20. // Copyright © 2019 tederen. All rights reserved. // //#import "DrawerView.h" #import "HomeViewController.h" #import "SurfaceSearchView.h" #import "HorizonScroll.h" #import "ChannelModel.h" #import "HomeSearchController.h" #import "AddChannelController.h" #import "HttpManager.h" #import "HomeDetailController.h" #import "APIPOPOPO.h" #import "MyApprovalPageDetail.h" #import "MailListDetailVC.h" #import "NavigationController.h" #import "UIAlertController+TapGesAlertController.h" #import "HomeArticleModel.h" #import "HomeListWorkCell.h" #import "HomeTableViewCell.h" #import "SLBannerView.h" #import "MyFavoriteVC.h" #import "OtherFavoriteVC.h" #import "NoteBookVC.h" #import "OtherNoteBookVC.h" #import "BookStoreHome.h" #import "HomeMusicCell.h" #import "HomeSchoolCell.h" #import "HomeUserPrivilegeCell.h" #import "HomeWeiCousreCell.h" #import "BookWCDetailVC.h" #import "HomeProblemTopCell.h" #import "HomeGoodBookCell.h" #import "BookDetailVC.h" @interface HomeViewController () @property (nonatomic, strong) UILabel *titleLabel; @property (nonatomic, strong) UIView *bannerBgV; @property (nonatomic, strong) SLBannerView *bannerView; @property (nonatomic, strong) SurfaceSearchView *searchView; @property (nonatomic, strong) HorizonScroll *channelScroll; @property (nonatomic, strong) NSMutableArray *bannerImgArr; @property (nonatomic, strong) NSMutableArray * tabConfigArray; @property (nonatomic, strong) NSMutableArray * bannerModelArray; @property (nonatomic, strong) HomeArticleModel *model; @property (nonatomic, strong) TDWaitWorkModel *waitModel; @property (nonatomic, assign) NSInteger currentPage; @property (nonatomic, assign) NSInteger totalPage; @property (nonatomic, assign) NSInteger currentChannel; @property (nonatomic, strong) NSMutableDictionary *articleDic; @property (nonatomic, copy) NSMutableArray *dataSource; @property (nonatomic, strong) UITableView *tableView; @property (strong, nonatomic) UIAlertController *alertVC; /// 我的频道 @property (copy, nonatomic) NSMutableArray *myChannel; @property (strong, nonatomic) UIView *noDataView; @property (nonatomic, strong) UILabel *noDataLabel; @end @implementation HomeViewController - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self getRedBadge]; } #pragma mark - LifeCycle - (void)viewDidLoad { [super viewDidLoad]; [self getdata]; self.fd_prefersNavigationBarHidden = YES; [self loadStatusBarColor:[UIColor whiteColor]]; self.view.backgroundColor = UIColorHex(F2F2F2); [self.view addSubview:self.titleLabel]; [self.view addSubview:self.searchView]; [self.view addSubview:self.tableView]; self.bannerView = [[SLBannerView alloc] initWithFrame:CGRectMake(15, 0, kGXScreenWidth - 30, 125)]; self.bannerView.delegate = self; self.bannerView.durTimeInterval = 0.2; self.bannerView.imgStayTimeInterval = 2.5; self.bannerBgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kGXScreenWidth, 132)]; self.bannerBgV.backgroundColor = [UIColor clearColor]; [self.searchView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, 52)]; [self.bannerBgV addSubview:self.bannerView]; [self.tableView setTableHeaderView:self.bannerBgV]; [self layoutSubviews]; WEAKSELF self.searchView.buttonBlock = ^(){ HomeSearchController *homeSearch = [[HomeSearchController alloc] init]; [weakSelf.navigationController pushViewController:homeSearch animated:YES]; }; self.searchView.bookBlock = ^(){ BookStoreHome *vc = [BookStoreHome initBookStoreHome]; vc.hidesBottomBarWhenPushed = YES; [weakSelf.navigationController pushViewController:vc animated:YES]; }; [UserManager getUserInfoDetail]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.estimatedRowHeight = 100.f; self.tableView.rowHeight = UITableViewAutomaticDimension; [self.tableView registerNib:[UINib nibWithNibName:@"HomeListWorkCell" bundle:nil] forCellReuseIdentifier:@"HomeListWorkCell"]; [self.tableView registerNib:[UINib nibWithNibName:@"HomeMusicCell" bundle:nil] forCellReuseIdentifier:@"HomeMusicCell"]; [self.tableView registerNib:[UINib nibWithNibName:@"HomeSchoolCell" bundle:nil] forCellReuseIdentifier:@"HomeSchoolCell"]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableViewScrollTop) name:HOMESCROLLVIEWTOTOP object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shareReturnAction:) name:SHARERETURNSUCCESS object:nil]; [self setTableViewRefresh]; } - (void)setTableViewRefresh{ WS(weakSelf); self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ [weakSelf headRefresh]; }]; self.tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{ [weakSelf footerRefresh]; }]; } - (void)headRefresh{ [self.tableView.mj_header endRefreshing]; [self.tableView.mj_footer endRefreshing]; self.currentPage = 1; if (self.currentChannel == 2 || self.currentChannel == 3 || self.currentChannel == 4 || self.currentChannel == 5 || self.currentChannel == 6|| self.currentChannel == 7) { [self.tableView reloadData]; }else{ [self.dataSource removeAllObjects]; [self ReGetHomeListData:self.currentChannel]; } } - (void)footerRefresh{ self.currentPage += 1; if (self.dataSource.count == self.totalPage) { self.tableView.mj_footer.hidden = YES; [self.tableView.mj_footer resetNoMoreData]; return; } if (self.currentChannel == 2 || self.currentChannel == 3 || self.currentChannel == 4 || self.currentChannel == 5|| self.currentChannel == 6|| self.currentChannel == 7) { [self.tableView.mj_footer resetNoMoreData]; }else{ [self ReGetHomeListData:self.currentChannel]; }} - (void)getRedBadge { WS(weakSelf); //获取我审批和我发起以及抄送我的未读数 [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,@"/api/app/user/user-uread-count"] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) { NSDictionary *dic = responseObject; WorkNumberModel *numberModel = [[WorkNumberModel alloc] initWithDictionary:dic error:nil]; weakSelf.tabBarController.tabBar.items[1].badgeValue = numberModel.allNumber; weakSelf.tabBarController.tabBar.items[2].badgeValue = numberModel.allNotifacationNumber; } failure:^(NSError * _Nonnull error) { }]; } - (void)tableViewScrollTop { if (self.dataSource.count > 0) { [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO]; [self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES]; } } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } #pragma mark - NetRequest - (void)getdata{ #pragma mark - 轮播 WS(weakSelf); dispatch_semaphore_t sem = dispatch_semaphore_create(0); __block NSInteger httpFinishCount = 0; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [[HttpManager sharedHttpManager] GETUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,HomeSlideImages_GET] parameters: @{} responseStyle:JOSN success:^(id _Nonnull responseObject) { NSArray *arr = responseObject[@"Items"]; NSLog(@"首页轮播数据%@",arr.firstObject); [weakSelf.bannerModelArray removeAllObjects]; [weakSelf.bannerImgArr removeAllObjects]; NSMutableArray *array = [NSMutableArray array]; NSMutableArray *array2 = [NSMutableArray array]; for (int i = 0; i < arr.count; i++) { NSDictionary *dic = arr[i]; HomeTopImageModel *imageModel = [[HomeTopImageModel alloc] initWithDictionary:dic error:nil]; [array2 addObject:imageModel]; [array addObject:dic[@"ImageUrl"]]; } weakSelf.bannerImgArr = array; weakSelf.bannerModelArray = array2; weakSelf.bannerView.slImages = array; if (++httpFinishCount == 3) { dispatch_semaphore_signal(sem); } } failure:^(NSError * _Nonnull error) { REMOVESHOW }]; #pragma mark - 频道 [weakSelf loadChannelModel]; [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) { NSLog(@"%@",responseObject); NSArray *array = responseObject; for (NSInteger i = 0 ; i < array.count; i ++) { NSDictionary *dic = array[i]; ChannelModel *model = [ChannelModel modelWithDictionary:dic]; if (model.ArticleGroupId == 0) { model.IsSelect = YES; } [weakSelf.myChannel addObject:model]; } [weakSelf.channelScroll setChannelArray:weakSelf.myChannel]; //先注释观察 if (++httpFinishCount == 3) { dispatch_semaphore_signal(sem); } } failure:^(NSError * _Nonnull error) { REMOVESHOW }]; #pragma mark - 列表 [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Notice_list_Post] parameters: @{@"page":@(1),@"perPage":@10,@"GroupId":@(0)} responseStyle:JOSN success:^(id _Nonnull responseObject) { NSDictionary *dic = (NSDictionary *)responseObject; HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic]; [weakSelf.dataSource addObjectsFromArray:model.Items]; if (++httpFinishCount == 3) { dispatch_semaphore_signal(sem); } } failure:^(NSError * _Nonnull error) { }]; dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER); dispatch_async(dispatch_get_main_queue(), ^{ REMOVESHOW [weakSelf.tableView.mj_header endRefreshing]; [weakSelf.tableView.mj_footer endRefreshing]; [weakSelf.tableView reloadData]; }); }); } - (void)ReGetHomeListData:(NSInteger)channelId { WS(weakSelf); SHOWLOADING if (self.currentChannel == 1) { NSDictionary * paraDict = @{@"Type":@"MyChecking",@"page":@(self.currentPage),@"perPage":@10}; [[HttpManager sharedHttpManager] GETUrl:Host(WorkFlowAddApproval_Post) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) { REMOVESHOW NSDictionary *dic = (NSDictionary *)responseObject; HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic]; [weakSelf.tableView.mj_header endRefreshing]; [weakSelf.tableView.mj_footer endRefreshing]; weakSelf.totalPage = model.Count; [weakSelf.dataSource addObjectsFromArray:model.Items]; [weakSelf.tableView reloadData]; dispatch_async(dispatch_get_main_queue(), ^{ if (weakSelf.dataSource.count > 0) { weakSelf.noDataView.hidden = YES; }else{ weakSelf.noDataView.hidden = NO; if (weakSelf.currentChannel == 1) { weakSelf.noDataLabel.text = @"暂无待办工作"; }else{ weakSelf.noDataLabel.text = @"暂无数据"; } } }); } failure:^(NSError * _Nonnull error) { REMOVESHOW [weakSelf.tableView.mj_header endRefreshing]; [weakSelf.tableView.mj_footer endRefreshing]; SHOWERROR([ZYCTool handerResultData:error]) }]; }else{ [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Notice_list_Post] parameters: @{@"page":@(self.currentPage),@"perPage":@10,@"GroupId":@(channelId)} responseStyle:JOSN success:^(id _Nonnull responseObject) { REMOVESHOW NSDictionary *dic = (NSDictionary *)responseObject; HomeArticleModel *model = [HomeArticleModel modelWithDictionary:dic]; [weakSelf.tableView.mj_header endRefreshing]; [weakSelf.tableView.mj_footer endRefreshing]; weakSelf.totalPage = model.Count; [weakSelf.dataSource addObjectsFromArray:model.Items]; [weakSelf.tableView reloadData]; dispatch_async(dispatch_get_main_queue(), ^{ if (weakSelf.dataSource.count > 0) { weakSelf.noDataView.hidden = YES; }else{ weakSelf.noDataView.hidden = NO; if (weakSelf.currentChannel == 1) { weakSelf.noDataLabel.text = @"暂无待办工作"; }else{ weakSelf.noDataLabel.text = @"暂无数据"; } } }); } failure:^(NSError * _Nonnull error) { REMOVESHOW [weakSelf.tableView.mj_header endRefreshing]; [weakSelf.tableView.mj_footer endRefreshing]; }]; } } -(void)layoutSubviews{ [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.statusBar.mas_bottom); make.left.right.equalTo(self.view); make.height.equalTo(@44); }]; [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.titleLabel.mas_bottom); make.left.right.equalTo(self.view); make.height.mas_offset(52); }]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.searchView.mas_bottom); make.left.right.equalTo(self.view); if (@available(iOS 11.0, *)) { make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom); } else { make.bottom.equalTo(self.view.mas_bottom); } }]; [self.view addSubview:self.noDataView]; [self.noDataView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.searchView.mas_bottom).offset(170); make.left.right.mas_equalTo(self.tableView); make.bottom.mas_offset(-self.tabBarController.tabBar.height); }]; [self.noDataView addSubview:self.noDataLabel]; [self.noDataLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.center.mas_equalTo(self.noDataView); }]; } - (BOOL)hidesBottomBarWhenPushed{ return NO; } #pragma mark - UITableViewDataSource && UITableViewDelegate - (void)closeBtn_Click { [self.alertVC dismissViewControllerAnimated:YES completion:nil]; } - (void)cellDidSelcet:(NSInteger )articleId{ WEAKSELF UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [closeBtn addTarget:self action:@selector(closeBtn_Click) forControlEvents:UIControlEventTouchUpInside]; [closeBtn setImage:IMG(@"guanbi") forState:UIControlStateNormal]; UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"对此内容进行操作" message:@"" preferredStyle:UIAlertControllerStyleAlert]; self.alertVC = alertVC; [alertVC.view addSubview:closeBtn]; [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(alertVC.view).offset(-10); make.top.equalTo(@10); make.size.mas_equalTo(CGSizeMake(22, 22)); }]; UIAlertAction *actionOK = [UIAlertAction actionWithTitle:@"屏蔽TA" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { STRONGSELF [strongSelf homeNewsHander:articleId withTypeId:1]; }]; [actionOK setValue:k9 forKey:@"_titleTextColor"]; UIAlertAction *actionNO = [UIAlertAction actionWithTitle:@"不感兴趣" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { STRONGSELF [strongSelf homeNewsHander:articleId withTypeId:2]; }]; [alertVC addAction:actionOK]; [alertVC addAction:actionNO]; [self presentViewController:alertVC animated:YES completion:^{ [alertVC tapGesAlert]; }]; } - (void)homeNewsHander:(NSInteger )articleId withTypeId:(NSInteger)blacklistType{ WS(weakSelf); [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@/%@",BaseUrl,Article_Hander_Post] parameters:@{@"ArticleId":@(articleId),@"BlacklistType":@(blacklistType)} responseStyle:DATA success:^(id _Nonnull responseObject) { [weakSelf headRefresh]; } failure:^(NSError * _Nonnull error) { }]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.dataSource.count; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { WS(weakSelf); self.channelScroll.ClickAddChannelBlock = ^{ [weakSelf didClickAddButtonChannel]; }; self.channelScroll.ClickMusicBlock = ^{ NSLog(@"MUSIC"); }; self.channelScroll.ClickSelectChannelBlock = ^(NSInteger channelId) { weakSelf.currentChannel = channelId; for (ChannelModel * model in weakSelf.myChannel) { model.IsSelect = NO; } for (ChannelModel * model in weakSelf.myChannel) { if (model.ArticleGroupId == channelId) { model.IsSelect = YES; } } [weakSelf.channelScroll.collectionView reloadData]; [[HttpManager sharedHttpManager] cancelRequest]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [weakSelf headRefresh]; }); }; return self.channelScroll; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { return [UIView new]; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 45.f; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 0.01f; } - (HorizonScroll *)channelScroll { if (!_channelScroll) { _channelScroll = [[HorizonScroll alloc] initWithFrame:CGRectMake(0, 0, kGXScreenWidth, 45)]; _channelScroll.backgroundColor = [UIColor whiteColor]; } return _channelScroll; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ Item *model = self.dataSource[indexPath.row]; switch (self.currentChannel) { case 1: { return 159.f + 15.f; } break; case 2: { return UITableViewAutomaticDimension; } break; case 3: { return UITableViewAutomaticDimension; } break; case 4: { return UITableViewAutomaticDimension; } break; case 5: { return UITableViewAutomaticDimension; } break; case 6: { return UITableViewAutomaticDimension; } break; case 7: { return UITableViewAutomaticDimension; } break; default: { if (model.ImageUrls.count == 0) { model.cellID = 1; }else if(model.ImageUrls.count == 1 || model.ImageUrls.count == 2){ model.cellID = 2; }else{ model.cellID = 3; } switch (model.cellID) { case 1: { // UILabel * label = [UILabel new]; // label.text = model.Title; // label.font = [UIFont systemFontOfSize:18]; // label.numberOfLines = 2; // CGSize maxSize = CGSizeMake(SCREEN_WIDTH - 30, CGFLOAT_MAX); // CGSize newSize = [label sizeThatFits:maxSize]; // int height = 49 + newSize.height; // return height; return UITableViewAutomaticDimension; } break; case 2: return 112; break; case 3: { UILabel * label = [UILabel new]; label.text = model.Title; label.font = [UIFont fontWithName:@"PingFang SC" size:18]; label.numberOfLines = 2; CGSize maxSize = CGSizeMake(SCREEN_WIDTH - 30.f, CGFLOAT_MAX); CGSize newSize = [label sizeThatFits:maxSize]; NSInteger height = 86.f / 336.f * (SCREEN_WIDTH - 30.f) + 52.5f + newSize.height; return height; } break; default: return 70; break; } } break; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ WS(weakSelf); Item * model = self.dataSource[indexPath.row]; // 待办工作 switch (self.currentChannel) { case 1: { HomeListWorkCell *cell = (HomeListWorkCell *)[tableView dequeueReusableCellWithIdentifier:@"HomeListWorkCell"]; if (cell != nil && self.dataSource.count > 0) { if (indexPath.row == 0) { cell.top.constant = 11.f; } [cell loadSearchData:model]; } return cell; } break; case 2: { HomeMusicCell * cell = [HomeMusicCell configCell:tableView indexPath:indexPath]; if (indexPath.row == 0) { cell.height.constant = -2.f; } return cell; } break; case 3: { HomeSchoolCell * cell = [HomeSchoolCell configCell:tableView indexPath:indexPath]; if (indexPath.row == 0) { cell.height.constant = -4.f; cell.topView.backgroundColor = [UIColor whiteColor]; } [cell setData]; return cell; } break; case 4: { HomeUserPrivilegeCell * cell = [HomeUserPrivilegeCell configCell:tableView indexPath:indexPath]; if (indexPath.row == 0) { cell.height.constant = 11.f; } BOOL isEnd = self.dataSource.count - 1 == indexPath.row; [cell setDataWithItem:indexPath.row isUnUser:isEnd]; return cell; } break; case 5: { HomeWeiCousreCell * cell = [HomeWeiCousreCell configCell0:tableView indexPath:indexPath]; if (indexPath.row == 0) { cell.height.constant = 11.f; } return cell; } break; case 6: { if (indexPath.row == 0) { HomeProblemTopCell * cell = [HomeProblemTopCell configCell0:tableView indexPath:indexPath]; cell.height.constant = -2.f; [cell setData]; return cell; }else{ HomeProblemTopCell * cell = [HomeProblemTopCell configCell1:tableView indexPath:indexPath]; return cell; } } break; case 7: { HomeGoodBookCell * cell = [HomeGoodBookCell configCell:tableView indexPath:indexPath]; if (indexPath.row == 0) { cell.height.constant = 11.f; } BOOL isEnd = self.dataSource.count - 1 == indexPath.row; [cell setDataWithItem:indexPath.row isUnUser:isEnd]; cell.ClickIndexBlock = ^{ BookDetailVC * vc = [BookDetailVC initBookDetailVC]; vc.hidesBottomBarWhenPushed = YES; [weakSelf.navigationController pushViewController:vc animated:YES]; }; return cell; } break; default: { if (model.ImageUrls.count == 0) { model.cellID = 1; }else if(model.ImageUrls.count == 1 || model.ImageUrls.count == 2){ model.cellID = 2; }else{ model.cellID = 3; } HomeTableViewCell *cell = [HomeTableViewCell cellWithTableView:tableView AndIndex:model.cellID]; if (cell != nil && self.dataSource.count > 0) { [cell.deleteButton setCurrentButtonHotSize:CGSizeZero]; [cell loadCurrentItemModel:model]; cell.deleteButton.hidden = YES; cell.buttonBlock = ^{ [weakSelf cellDidSelcet:model.Id]; }; } return cell; } break; } // if (self.currentChannel == 1) { // HomeListWorkCell *cell = (HomeListWorkCell *)[tableView dequeueReusableCellWithIdentifier:@"HomeListWorkCell"]; // if (cell != nil && self.dataSource.count > 0) { // [cell loadSearchData:model]; // } // return cell; // }else{ // // 推荐 // if (model.ImageUrls.count == 0) { // model.cellID = 1; // }else if(model.ImageUrls.count == 1 || model.ImageUrls.count == 2){ // model.cellID = 2; // }else{ // model.cellID = 3; // } // HomeTableViewCell *cell = [HomeTableViewCell cellWithTableView:tableView AndIndex:model.cellID]; // if (cell != nil && self.dataSource.count > 0) { // [cell.deleteButton setCurrentButtonHotSize:CGSizeZero]; // [cell loadCurrentItemModel:model]; // cell.deleteButton.hidden = YES; // cell.buttonBlock = ^{ // [weakSelf cellDidSelcet:model.Id]; // }; // } // return cell; // } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; WS(weakSelf); Item * model = self.dataSource[indexPath.row]; // 待办工作 switch (self.currentChannel) { case 1: { MyApprovalPageDetail *myApprovalPageDetail = [[MyApprovalPageDetail alloc] init]; [myApprovalPageDetail setActionSussBlock:^{ [weakSelf headRefresh]; }]; if ([model.State isEqualToString:@"Meeting"]) { model.approvalText = @"上会"; }else if ([model.State isEqualToString:@"Checked"]) { model.approvalText = @"审批通过"; }else if ([model.State isEqualToString:@"Denied"]) { model.approvalText = @"已拒绝"; }else if ([model.State isEqualToString:@"Wait"]) { model.approvalText = @"待定"; }else{ model.approvalText = @"待审核"; } myApprovalPageDetail.pageType = Type_ONEA; myApprovalPageDetail.userId = model.UserId; myApprovalPageDetail.indexId = model.Id; myApprovalPageDetail.TodoId = model.TodoId; myApprovalPageDetail.title = model.Title; [self.navigationController pushViewController:myApprovalPageDetail animated:YES]; } break; case 2: { } break; case 3: { } break; case 4: { } break; case 5: { BookWCDetailVC * vc = [BookWCDetailVC initBookWCDetailVC]; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; } break; case 6: { if (indexPath.row > 0) { BookWCDetailVC * vc = [BookWCDetailVC initBookWCDetailVC]; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; } } break; case 7: { } break; default: { MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC]; vc.type = CollectModel_Aritle; vc.Id = model.Id; [self.navigationController pushViewController:vc animated:YES]; } break; } } #pragma mark - channelScroll Block - (void)didClickAddButtonChannel{ AddChannelController *addChannel = [[AddChannelController alloc] init]; addChannel.modalPresentationStyle = UIModalPresentationFullScreen; addChannel.delegate = self; [self presentViewController:addChannel animated:YES completion:nil]; } #pragma mark - AddChannelControllerDelegate - (void)upadateChannel{ WS(weakSelf); [self loadChannelModel]; [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,Article_Pindao_User_Post] parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) { NSLog(@"%@",responseObject); NSArray *array = responseObject; for (NSInteger i = 0 ; i < array.count; i ++) { NSDictionary *dic = array[i]; ChannelModel *model = [ChannelModel modelWithDictionary:dic]; [weakSelf.myChannel addObject:model]; } dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.channelScroll setChannelArray:weakSelf.myChannel]; if (weakSelf.channelScroll.ClickSelectChannelBlock) { weakSelf.channelScroll.ClickSelectChannelBlock(weakSelf.currentChannel); } [weakSelf.tableView reloadData]; }); } failure:^(NSError * _Nonnull error) { REMOVESHOW }]; } #pragma mark - SLBannerViewDelegate - (void)bannerView:(SLBannerView *)banner didClickImagesAtIndex:(NSInteger)index { [self getArticleDetail:index]; } - (void)getArticleDetail:(NSInteger)index{ HomeTopImageModel *model = self.bannerModelArray[index]; NSLog(@"点击轮播图%ld",(long)model.ArticleId); SHOWLOADING WEAKSELF [[HttpManager sharedHttpManager] GETWithUrl:[NSString stringWithFormat:@"%@%ld",Article_Detail_Get,(long)model.ArticleId] parameters:@{} success:^(id _Nonnull responseObject) { REMOVESHOW; Item *model = [[Item alloc]initWithDictionary:responseObject error:nil]; // HomeDetailController *homeDetail = [[HomeDetailController alloc] init]; // [homeDetail loadCurrentModel:itemModel]; MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC]; vc.type = CollectModel_Aritle; vc.Id = model.Id; [weakSelf.navigationController pushViewController:vc animated:YES]; } failure:^(NSError * _Nonnull error) { SHOWERROR([ZYCTool handerResultData:error]); }]; } #pragma mark - Setter - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [UILabel new]; _titleLabel.backgroundColor = [UIColor whiteColor]; _titleLabel.text = @"首页"; _titleLabel.font = [UIFont systemFontOfSize:16.f]; _titleLabel.textColor = UIColorHex(1A1A1A); _titleLabel.textAlignment = NSTextAlignmentCenter; } return _titleLabel; } - (SurfaceSearchView *)searchView { if (!_searchView) { _searchView = [[SurfaceSearchView alloc] init]; [_searchView setBgViewColor:[UIColor clearColor]]; // [_searchView setPlaceHolderText:@"输入关键字搜索"]; [_searchView setMainType]; } return _searchView; } - (UITableView * )tableView { if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; _tableView.backgroundColor = [UIColor clearColor]; } return _tableView; } - (NSMutableArray *)dataSource { if (!_dataSource) { _dataSource = [NSMutableArray array]; } return _dataSource; } - (NSMutableArray *)tabConfigArray{ if (!_tabConfigArray) { _tabConfigArray = [NSMutableArray array]; } return _tabConfigArray; } - (NSMutableDictionary *)articleDic{ if (!_articleDic) { _articleDic = [NSMutableDictionary dictionary]; } return _articleDic; } - (NSMutableArray *)myChannel { if (!_myChannel) { _myChannel = [NSMutableArray array]; } return _myChannel; } - (void)loadChannelModel { [self.myChannel removeAllObjects]; ChannelModel * model = [[ChannelModel alloc] init]; model.ArticleGroupId = 0; model.ArticleGroupName = @"推荐"; model.IsSelect = YES; [self.myChannel addObject:model]; // ChannelModel * workModel = [[ChannelModel alloc] init]; // workModel.ArticleGroupId = 1; // workModel.ArticleGroupName = @"待办工作"; // workModel.IsSelect = NO; // [self.myChannel addObject:workModel]; ChannelModel * sModel = [[ChannelModel alloc] init]; sModel.ArticleGroupId = 2; sModel.ArticleGroupName = @"信源听说"; sModel.IsSelect = NO; [self.myChannel addObject:sModel]; ChannelModel * mModel = [[ChannelModel alloc] init]; mModel.ArticleGroupId = 3; mModel.ArticleGroupName = @"名校"; mModel.IsSelect = NO; [self.myChannel addObject:mModel]; ChannelModel * aModel = [[ChannelModel alloc] init]; aModel.ArticleGroupId = 4; aModel.ArticleGroupName = @"会员特供"; aModel.IsSelect = NO; [self.myChannel addObject:aModel]; ChannelModel * bModel = [[ChannelModel alloc] init]; bModel.ArticleGroupId = 5; bModel.ArticleGroupName = @"每日微课"; bModel.IsSelect = NO; [self.myChannel addObject:bModel]; ChannelModel * cModel = [[ChannelModel alloc] init]; cModel.ArticleGroupId = 6; cModel.ArticleGroupName = @"每日一题"; cModel.IsSelect = NO; [self.myChannel addObject:cModel]; ChannelModel * dModel = [[ChannelModel alloc] init]; dModel.ArticleGroupId = 7; dModel.ArticleGroupName = @"每日好书"; dModel.IsSelect = NO; [self.myChannel addObject:dModel]; // ChannelModel * eModel = [[ChannelModel alloc] init]; // eModel.ArticleGroupId = 8; // eModel.ArticleGroupName = @"每日好文"; // eModel.IsSelect = NO; // [self.myChannel addObject:eModel]; } - (UIView *)noDataView { if (!_noDataView) { _noDataView = [UIView new]; _noDataView.hidden = YES; _noDataView.backgroundColor = UIColorHex(0xEEEEEE); } return _noDataView; } - (UILabel *)noDataLabel { if (!_noDataLabel) { _noDataLabel = [UILabel new]; _noDataLabel.textColor = UIColorHex(0xBBBBBB); _noDataLabel.font = [UIFont systemFontOfSize:14]; } return _noDataLabel; } #pragma mark - 分享成功跳转 - (void)shareReturnAction:(NSNotification *)noti { NSDictionary * dic = noti.userInfo; CollectModelType type = [[dic objectForKey:@"type"] intValue]; NSInteger Id = [[dic objectForKey:@"Id"] integerValue]; NSInteger userId = [[dic objectForKey:@"userId"] integerValue]; NSString* name = [[dic objectForKey:@"name"] stringByRemovingPercentEncoding]; NSString* describe = [[dic objectForKey:@"describe"] stringByRemovingPercentEncoding]; switch (type) { case CollectModel_CollectFile: { if (userId == [AppUserModel sharedAppUserModel].Id) { MyFavoriteVC *vc = [MyFavoriteVC initMyFavoriteVC]; vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB; vc.ParentId = 0; vc.FolderId = Id; vc.myTitle = Id == 0 ? @"我的收藏" :name; [self.navigationController pushViewController:vc animated:YES]; }else{ OtherFavoriteVC * vc = [OtherFavoriteVC initOtherFavoriteVC]; vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB; vc.FolderId = Id; vc.Author = describe; vc.myTitle = name; vc.VisitUserId = userId; [self.navigationController pushViewController:vc animated:YES]; } } break; case CollectModel_NoteFile: { if (userId == [AppUserModel sharedAppUserModel].Id) { NoteBookVC * vc = [NoteBookVC initNoteBookVC]; if (Id == 0) { vc.listType = MyFavoriteListLevelTypeB; vc.myTitle = @"我的笔记"; }else{ vc.listType = MyFavoriteListLevelTypeC; vc.myTitle = name; } vc.ParentId = 0; vc.FolderId = Id; vc.isSubVC = YES; [self.navigationController pushViewController:vc animated:YES]; }else{ OtherNoteBookVC * vc = [OtherNoteBookVC initOtherNoteBookVC]; vc.listType = Id == 0 ? MyFavoriteListLevelTypeA : MyFavoriteListLevelTypeB; vc.FolderId = Id; vc.Author = describe; vc.myTitle = name; vc.VisitUserId = userId; [self.navigationController pushViewController:vc animated:YES]; } } break; default: { MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC]; vc.type = type; vc.Id = Id; [self.navigationController pushViewController:vc animated:YES]; } break; } } @end