123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647 |
- //
- // 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"
- @interface HomeViewController () <UITableViewDataSource, UITableViewDelegate,SLBannerViewDelegate,AddChannelControllerDelegate>
- @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 = ^(){
- STRONGSELF
- HomeSearchController *homeSearch = [[HomeSearchController alloc] init];
- [strongSelf.navigationController pushViewController:homeSearch animated:YES];
-
- };
- [UserManager getUserInfoDetail];
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- [self.tableView registerNib:[UINib nibWithNibName:@"HomeListWorkCell" bundle:nil] forCellReuseIdentifier:@"HomeListWorkCell"];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableViewScrollTop) name:HOMESCROLLVIEWTOTOP 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.currentPage = 1;
- [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;
- }
- [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
- {
- [self.tableView scrollToTop];
- }
- - (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 reloadData];
- });
- });
- }
- - (void)ReGetHomeListData:(NSInteger)channelId
- {
- WS(weakSelf);
- 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) {
- 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) {
- [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) {
- 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) {
- [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.bottom.equalTo(self.view);
- }];
- [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.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];
- if (self.currentChannel == 1) {
- return 159.f + 15.f;
- }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;
- }
- switch (model.cellID) {
- case 1:
- {
- UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, SCREEN_WIDTH - 30, 18)];
- label.text = model.Title;
- label.font = [UIFont systemFontOfSize:18];
- label.numberOfLines = 2;
- CGSize maxSize = CGSizeMake(label.bounds.size.width, CGFLOAT_MAX);
- CGSize newSize = [label sizeThatFits:maxSize];
- int height = 50 + newSize.height;
- return height;
- }
- break;
- case 2:
- return 115;
- break;
- case 3:
- {
- UILabel * label = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, SCREEN_WIDTH - 30, 18)];
- label.text = model.Title;
- label.font = [UIFont systemFontOfSize:18];
- label.numberOfLines = 2;
- CGSize maxSize = CGSizeMake(label.bounds.size.width, CGFLOAT_MAX);
- CGSize newSize = [label sizeThatFits:maxSize];
- int height = 86 * (kGXScreenWidth / 375.0) + 67 + newSize.height;
- return height;
- }
- break;
- default:
- return 70;
- break;
- }
- }
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- WS(weakSelf);
- Item * model = self.dataSource[indexPath.row];
- // 待办工作
- 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
- {
- WS(weakSelf);
- Item * model = self.dataSource[indexPath.row];
- // 待办工作
- if (self.currentChannel == 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];
- }else{
- HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
- [homeDetail loadCurrentModel:model];
- homeDetail.indexFlag = 0;
- [self.navigationController pushViewController:homeDetail animated:YES];
- }
- }
- #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) {
- STRONGSELF
- REMOVESHOW;
- Item *itemModel = [[Item alloc]initWithDictionary:responseObject error:nil];
- HomeDetailController *homeDetail = [[HomeDetailController alloc] init];
- [homeDetail loadCurrentModel:itemModel];
- [strongSelf.navigationController pushViewController:homeDetail 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];
- }
- - (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;
- }
- @end
|