// // AmoytechniqueViewController.m // jitao // // Created by 罗云飞 on 2018/2/5. // Copyright © 2018年 罗云飞. All rights reserved. // 淘技 #import "AmoytechniqueViewController.h" #import "YBPopupMenu.h" #import "MyattentionViewController.h" #import "AchievementsReleaseViewController.h" #import "MyOrderViewController.h" #import "AchievementsReleaseViewController.h" #import "ReleaserequirementsViewController.h" #import "ZZCarousel.h" #import "AssetsCollectionViewCell.h" #import "HeadlinesCollectionViewCell.h" #import "GBTopLineViewModel.h" #import "GBTopLineView.h" #import "ImmediatelyCollectionViewCell.h" #import "JiTaoRecommendCollectionViewCell.h" #import "RecommendedresultsCell.h" #import "ExpertCollectionViewCell.h" #import "HomeDataModel.h" #import "HomeRecommendedModel.h" #import "HomedemandModel.h" #import "TechnologyModel.h" #import "CarouselModel.h" #import "KnowledgeproductionModel.h" #import "HomeExpertModel.h" #import "AchievementsdetailViewController.h" #import "DemanddetailViewController.h" #import "ExpertdetailsViewController.h" #import "ScienceAchievementsViewController.h" #import "SciencedemandViewController.h" #import "ScienceexpertViewController.h" #import "DemanddetailViewController.h" #import "ExpertdetailsViewController.h" #import "HighidentificationViewController.h" #define TITLES @[@"我的关注", @"我的订单",@"发布成果",@"发布需求"] #define ICONS @[@"wdgz",@"wddd",@"fbcg",@"fbxq"] @interface AmoytechniqueViewController (){ UICollectionView *mainCollectionView; UICollectionViewFlowLayout *flowLayout; NSMutableArray *dataArray; UICollectionReusableView *headerView; ZZCarousel *_headwheel;//广告图 NSMutableArray *_headwheelArray; UILabel *label1; UIImageView *_topIndicatorView; NSMutableArray *_titleLabelArray; NSInteger status; NSMutableArray *JTheadlinesArray; NSMutableArray *JTKnowledgeArray; NSMutableArray *Achievements;//成果数组 NSMutableArray *demandArray;//需求数组 NSMutableArray *expertArray;//专家数组 } @property (strong ,nonatomic) UIButton * registerAccount; @property(nonatomic,strong)NSMutableArray*dataArr; @property (nonatomic,strong) GBTopLineView *TopLineView; @end @implementation AmoytechniqueViewController - (void)viewDidLoad { [super viewDidLoad]; [self setNavTitle:@"淘技"]; [self dataInitialization]; [self loadsView]; [self Networkrequest]; [self RecommendedNetworkrequest:@"1"]; [self addRefreshing]; // Do any additional setup after loading the view. } #pragma mark - 上拉下拉初始化 - (void)addRefreshing { __weak typeof(self) weakSelf = self; __weak UICollectionView *newvc = mainCollectionView; newvc.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ if ([NetworkRequestManager connectedToNetwork]) { // [weakSelf CarouselNetworkrequest:newvc.mj_header]; // [weakSelf VarietyNetworkrequest:newvc.mj_header]; // [weakSelf BusinessProjectNetworkrequest:newvc.mj_header]; [weakSelf Networkrequest]; [weakSelf RecommendedNetworkrequest:[NSString stringWithFormat:@"%i",status+1]]; [newvc.mj_header endRefreshing]; }else{ [newvc.mj_header endRefreshing]; } }]; } - (void)dismiss:(id)object { if ([object isKindOfClass:[MJRefreshNormalHeader class]]) { __weak UICollectionView *newvc = mainCollectionView; [newvc.mj_header endRefreshing]; }else { [MBProgressHUD hideHUDForView:self.view]; } } - (void)RecommendedNetworkrequest:(NSString *)type { NSMutableDictionary *dic = [NSMutableDictionary new]; [dic safeSetObject:type forKey:@"type"]; [NetworkRequestManager requestGetWithInterfacePrefix:JT_getHomeRecommended parameters:dic onSuccess:^(id requestData) { NSLog(@"服务器返回数据 :%@",requestData); if ([requestData[@"error"] count] !=0) { for (NSDictionary *dic in requestData[@"error"]) { [MBProgressHUD showError:dic[@"message"] toView:self.view]; } }else{ if ([type isEqualToString:@"1"]) { [Achievements removeAllObjects]; for (NSDictionary *dic in requestData[@"data"]) { HomeRecommendedModel*model = [[HomeRecommendedModel alloc] initWithDictionary:dic error:nil]; [Achievements addObject:model]; [mainCollectionView reloadSections:[NSIndexSet indexSetWithIndex:3]]; } }else if ([type isEqualToString:@"2"]){ [demandArray removeAllObjects]; for (NSDictionary *dic in requestData[@"data"]) { HomedemandModel*model = [[HomedemandModel alloc] initWithDictionary:dic error:nil]; [demandArray addObject:model]; [mainCollectionView reloadSections:[NSIndexSet indexSetWithIndex:3]]; } }else if ([type isEqualToString:@"3"]){ [expertArray removeAllObjects]; for (NSDictionary *dic in requestData[@"data"]) { HomeExpertModel*model = [[HomeExpertModel alloc] initWithDictionary:dic error:nil]; [expertArray addObject:model]; [mainCollectionView reloadSections:[NSIndexSet indexSetWithIndex:3]]; } } } } onFailure:^{ }]; } - (void)Networkrequest { NSMutableDictionary *dic = [NSMutableDictionary new]; [NetworkRequestManager requestGetWithInterfacePrefix:JT_getHomePageData parameters:dic onSuccess:^(id requestData) { NSLog(@"服务器返回数据 :%@",requestData); if ([requestData[@"error"] count] !=0) { for (NSDictionary *dic in requestData[@"error"]) { [MBProgressHUD showError:dic[@"message"] toView:self.view]; } }else{ [_headwheelArray removeAllObjects]; for (NSDictionary *dic in requestData[@"data"][@"homeImg"]) { CarouselModel *model = [[CarouselModel alloc] initWithDictionary:dic error:nil]; [_headwheelArray addObject:model]; } _headwheel?[_headwheel reloadData]:nil; for (NSDictionary *dic in requestData[@"data"][@"advertising"]) { HomeDataModel*model = [[HomeDataModel alloc] initWithDictionary:dic error:nil]; [JTheadlinesArray addObject:model]; } [JTKnowledgeArray removeAllObjects]; for (NSDictionary *dic in requestData[@"data"][@"achievemend"]) { KnowledgeproductionModel*model = [[KnowledgeproductionModel alloc] initWithDictionary:dic error:nil]; [JTKnowledgeArray addObject:model]; } [_dataArr removeAllObjects]; for (int i=0; i0) { [cell assignment:JTKnowledgeArray[indexPath.row]]; cell.backgroundColor = NewWhiteColor; } return cell; }else if (indexPath.section == 1){ HeadlinesCollectionViewCell*cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeRootVCCell1" forIndexPath:indexPath]; if (JTheadlinesArray.count>0) { cell.backgroundColor = NewWhiteColor; _TopLineView = [[GBTopLineView alloc]initWithFrame:CGRectMake(65, 0, SCREEN_WIDTH-65, 91)]; _TopLineView.backgroundColor = [UIColor whiteColor]; __weak __typeof(self)weakSelf = self; _TopLineView.clickBlock = ^(NSInteger index){ GBTopLineViewModel *model = weakSelf.dataArr[index]; // NSLog(@"%@,%@",model.type,model.title); }; [cell addSubview:_TopLineView]; [_TopLineView setVerticalShowDataArr:_dataArr]; UIImageView *zcjd = [UIImageView new]; [zcjd setImage:NewImageNamed(@"zcjx")]; zcjd.backgroundColor = NewClearColor; [cell addSubview:zcjd]; zcjd.sd_layout .leftSpaceToView(cell, 20) .topSpaceToView(cell, 20) .heightIs(92/2) .widthIs(100/2); UIImageView *lineimage = [UIImageView new]; [lineimage setImage:NewImageNamed(@"zcbx")]; [cell addSubview:lineimage]; lineimage.sd_layout .topSpaceToView(cell, 20) .heightIs(100/2) .leftSpaceToView(zcjd, 15) .widthIs(1); UILabel *line = [UILabel new]; line.backgroundColor = NewLineGrayColor; [cell addSubview:line]; line.sd_layout .leftEqualToView(cell) .rightEqualToView(cell) .heightIs(0.8) .topSpaceToView(_TopLineView, 0); UILabel *line1 = [UILabel new]; line1.backgroundColor = NewLineGrayColor; [cell addSubview:line1]; line1.sd_layout .leftSpaceToView(cell, SCREEN_WIDTH/2) .widthIs(0.8) .topSpaceToView(line, 0) .bottomEqualToView(cell); UIButton *assessmentBT = [UIButton new]; assessmentBT.backgroundColor = NewWhiteColor; NewTouchUpInside(assessmentBT, assessmentBTclick:); [cell addSubview:assessmentBT]; assessmentBT.sd_layout .leftEqualToView(cell) .topSpaceToView(line, 0) .bottomEqualToView(cell) .rightSpaceToView(line1, 0); UIImageView *assessmentimage = [UIImageView new]; [assessmentimage setImage:NewImageNamed(@"zxpg")]; assessmentimage.backgroundColor = NewClearColor; [assessmentBT addSubview:assessmentimage]; assessmentimage.sd_layout .centerYEqualToView(assessmentBT) .heightIs(23) .widthIs(33) .leftSpaceToView(assessmentBT, 15); UILabel *pinggu = [UILabel new]; [pinggu setText:@"在线评估"]; pinggu.font = NewFont(14); [pinggu setSingleLineAutoResizeWithMaxWidth:0]; [assessmentBT addSubview:pinggu]; pinggu.sd_layout .leftSpaceToView(assessmentimage, 10) .heightIs(14) .topEqualToView(assessmentimage); UILabel *liaojie = [UILabel new]; liaojie.text = @"立即了解您的技术价值"; liaojie.font = NewFont(12); [liaojie setSingleLineAutoResizeWithMaxWidth:0]; liaojie.textColor = [UIColor colorWithString:@"#9A9A9A"]; [assessmentBT addSubview:liaojie]; liaojie.sd_layout .leftEqualToView(pinggu) .heightIs(12) .topSpaceToView(pinggu, 5); UIButton *projectventureBT = [UIButton new]; projectventureBT.backgroundColor = NewWhiteColor; NewTouchUpInside(projectventureBT, projectventureBTclick:); [cell addSubview:projectventureBT]; projectventureBT.sd_layout .leftSpaceToView(line1, 0) .topSpaceToView(line, 0) .bottomEqualToView(cell) .rightEqualToView(cell); UIImageView *assessmentimage1 = [UIImageView new]; [assessmentimage1 setImage:NewImageNamed(@"xmct")]; assessmentimage1.backgroundColor = NewClearColor; [projectventureBT addSubview:assessmentimage1]; assessmentimage1.sd_layout .centerYEqualToView(projectventureBT) .heightIs(25) .widthIs(28) .leftSpaceToView(projectventureBT, 15); UILabel *xiangmu = [UILabel new]; [xiangmu setText:@"项目创投"]; xiangmu.font = NewFont(14); [xiangmu setSingleLineAutoResizeWithMaxWidth:0]; [projectventureBT addSubview:xiangmu]; xiangmu.sd_layout .leftSpaceToView(assessmentimage1, 10) .heightIs(14) .topEqualToView(assessmentimage1); UILabel *liebian = [UILabel new]; liebian.text = @"让资产迅速裂变"; liebian.font = NewFont(12); [liebian setSingleLineAutoResizeWithMaxWidth:0]; liebian.textColor = [UIColor colorWithString:@"#9A9A9A"]; [projectventureBT addSubview:liebian]; liebian.sd_layout .leftEqualToView(xiangmu) .heightIs(12) .topSpaceToView(xiangmu, 5); } return cell; }else if (indexPath.section == 2){ ImmediatelyCollectionViewCell*cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeRootVCCell2" forIndexPath:indexPath]; if (dataArray.count>0) { cell.backgroundColor = NewWhiteColor; NewTouchUpInside(cell.releaserequirementsBT, releaserequirementsBTclick:); NewTouchUpInside(cell.releaseresultsBT, releaseresultsBTBTclick:); } return cell; }else if (indexPath.section == 3){ if (status == 0) { JiTaoRecommendCollectionViewCell*cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeRootVCCell3" forIndexPath:indexPath]; if (Achievements.count>0) { cell.backgroundColor = NewWhiteColor; [cell assignment:Achievements[indexPath.row]]; if (indexPath.row == Achievements.count-1) { cell.line4.hidden = NO; cell.seemoreBT.hidden = NO; }else{ cell.line4.hidden = YES; cell.seemoreBT.hidden = YES; } cell.seemoreBT.tag = 100; NewTouchUpInside(cell.seemoreBT, seemoreBTclick:); } return cell; }else if (status == 1){ RecommendedresultsCell*cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeRootVCCell4" forIndexPath:indexPath]; if (demandArray.count>0) { cell.backgroundColor = NewWhiteColor; [cell assignment:demandArray[indexPath.row]]; if (indexPath.row == demandArray.count-1) { cell.line3.hidden = YES; cell.line4.hidden = NO; cell.seemoreBT.hidden = NO; }else{ cell.line4.hidden = YES; cell.line3.hidden = NO; cell.seemoreBT.hidden = YES; } cell.seemoreBT.tag = 101; NewTouchUpInside(cell.seemoreBT, seemoreBTclick:); } return cell; }else if (status == 2){ ExpertCollectionViewCell*cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeRootVCCell5" forIndexPath:indexPath]; if (expertArray.count>0) { cell.backgroundColor = NewWhiteColor; [cell assignment:expertArray[indexPath.row]]; if (indexPath.row == expertArray.count-1) { cell.line3.hidden = YES; cell.line4.hidden = NO; cell.seemoreBT.hidden = NO; }else{ cell.line4.hidden = YES; cell.line3.hidden = NO; cell.seemoreBT.hidden = YES; } cell.seemoreBT.tag = 102; NewTouchUpInside(cell.seemoreBT, seemoreBTclick:); } return cell; } } return [[UICollectionViewCell alloc] init]; } -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { KnowledgeproductionModel *model = JTKnowledgeArray[indexPath.row]; AchievementsdetailViewController *vc = [[AchievementsdetailViewController alloc] init]; vc.ID = model.ID; NewPushViewController(vc); } if (indexPath.section == 3) { if (status == 0) { KnowledgeproductionModel *model = Achievements[indexPath.row]; AchievementsdetailViewController *vc = [[AchievementsdetailViewController alloc] init]; vc.ID = model.ID; NewPushViewController(vc); }else if (status == 1){ HomedemandModel*model = demandArray[indexPath.row]; DemanddetailViewController *vc = [[DemanddetailViewController alloc] init]; vc.ID = model.ID; NewPushViewController(vc); }else if (status == 2){ HomeExpertModel*model = expertArray[indexPath.row]; ExpertdetailsViewController *vc = [[ExpertdetailsViewController alloc] init]; vc.uid = model.ID; NewPushViewController(vc); } NSLog(@"%lo",indexPath.row); } } - (UIButton *)registerAccount { if (!_registerAccount) { _registerAccount = [UIButton buttonWithType:UIButtonTypeCustom]; // [_registerAccount setTitle:@"" forState:UIControlStateNormal]; [_registerAccount setTitleColor:[UIColor colorWithString:@"#9A9A9A"] forState:UIControlStateNormal]; [_registerAccount setBackgroundColor:[UIColor clearColor]]; [_registerAccount setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight]; [_registerAccount.titleLabel setFont:[UIFont systemFontOfSize:fitScreenWidth(14)]]; [_registerAccount addTarget:self action:@selector(touchRegister:) forControlEvents:UIControlEventTouchUpInside]; // [_registerAccount setupAutoSizeWithHorizontalPadding:5 buttonHeight:44]; [_registerAccount setImage:NewImageNamed(@"gd") forState:UIControlStateNormal]; } return _registerAccount; } - (void)touchRegister:(UIButton *)sender{ [YBPopupMenu showRelyOnView:sender titles:TITLES icons:ICONS menuWidth:140 delegate:self]; } #pragma mark - YBPopupMenuDelegate - (void)ybPopupMenuDidSelectedAtIndex:(NSInteger)index ybPopupMenu:(YBPopupMenu *)ybPopupMenu { NSLog(@"点击了 %@ 选项",TITLES[index]); if (index == 0) { if ([UserHelper isLogin]) { NSLog(@"%@",@"已登录"); MyattentionViewController *vc = [[MyattentionViewController alloc] init]; NewPushViewController(vc); }else{ NSLog(@"%@",@"未登录"); NewLoginViewController *vc = [[NewLoginViewController alloc] init]; [vc setLoginSuccess:^(NSString *string) { NewPopViewController; }]; NewPushViewController(vc); } }else if (index == 1){ if ([UserHelper isLogin]) { NSLog(@"%@",@"已登录"); MyOrderViewController*vc = [[MyOrderViewController alloc] init]; NewPushViewController(vc); }else{ NSLog(@"%@",@"未登录"); NewLoginViewController *vc = [[NewLoginViewController alloc] init]; [vc setLoginSuccess:^(NSString *string) { NewPopViewController; }]; NewPushViewController(vc); } }else if (index == 2) { if ([UserHelper isLogin]) { NSLog(@"%@",@"已登录"); AchievementsReleaseViewController *vc = [[AchievementsReleaseViewController alloc] init]; NewPushViewController(vc); }else{ NSLog(@"%@",@"未登录"); NewLoginViewController *vc = [[NewLoginViewController alloc] init]; [vc setLoginSuccess:^(NSString *string) { NewPopViewController; }]; NewPushViewController(vc); } }else if (index == 3){ // if ([UserHelper isLogin]) { NSLog(@"%@",@"已登录"); ReleaserequirementsViewController *vc = [[ReleaserequirementsViewController alloc] init]; NewPushViewController(vc); // }else{ // NSLog(@"%@",@"未登录"); // NewLoginViewController *vc = [[NewLoginViewController alloc] init]; // [vc setLoginSuccess:^(NSString *string) { // NewDismissNavigationController; // }]; // NewPresentNavigationController(vc); // } } } #pragma mark-------------------------ZZCarousel轮播图片---------------------------------- -(ZZCarousel*)headViewwheel:(NSInteger)tag { //self.navigationController.navigationBar.frame.size.height (SCREEN_WIDTH * 500 ) / 1080 ZZCarousel* wheel = [[ZZCarousel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,169)]; wheel.tag = tag; /* * carouseScrollTimeInterval --- 此属性为设置轮播多长时间滚动到下一张 */ wheel.carouseScrollTimeInterval = CarouselTime; // 代理 wheel.delegate = self; /* * isAutoScroll --- 默认为NO,当为YES时 才能使轮播进行滚动 */ wheel.isAutoScroll = YES; /* * pageType --- 设置轮播样式 默认为系统样式。ZZCarousel 中封装了 两种样式,另外一种为数字样式 */ wheel.pageType = ZZCarouselPageTypeOfNone; /* * 设置UIPageControl 在轮播中的位置、系统默认的UIPageControl 的顶层颜色 和底层颜色已经背景颜色 */ if(wheel.tag == 500) { wheel.pageControlFrame = CGRectMake((SCREEN_WIDTH - 60 ) / 2, wheel.frame.size.height - 10, 60, 5); wheel.pageIndicatorTintColor = [UIColor whiteColor]; wheel.currentPageIndicatorTintColor = NewRGBColor(191, 191, 191, 1); wheel.pageControlBackGroundColor = [UIColor whiteColor]; /* * 设置数字样式的 UIPageControl 中的字体和字体颜色。 背景颜色仍然按照上面pageControlBackGroundColor属性来设置 */ wheel.pageControlOfNumberFont = [UIFont fontWithName:@"Helvetica-Bold" size:18]; wheel.pageContolOfNumberFontColor = [UIColor whiteColor]; } return wheel; } //ZZCarouselDelegate 轮播图片代理方法 -(NSInteger)numberOfZZCarousel:(ZZCarousel *)wheel { return _headwheelArray.count; } //图片赋值 -(ZZCarouselView *)zzcarousel:(UICollectionView *)zzcarousel viewForItemAtIndex:(NSIndexPath *)index itemsIndex:(NSInteger)itemsIndex identifire:(NSString *)identifire ZZCarousel:(ZZCarousel *)zZCarousel { /* * index参数 ※ 注意 */ ZZCarouselView *cell = [zzcarousel dequeueReusableCellWithReuseIdentifier:identifire forIndexPath:index]; if (!cell) { cell = [[ZZCarouselView alloc]init]; } // cell.title.text = [_imagesGroup objectAtIndex:indexPath.row]; // [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"图片地址"]]; /* * itemsIndex 参数 ※ 注意 */ if(zZCarousel.tag == 500){ if(_headwheelArray.count > itemsIndex){ CarouselModel *model = _headwheelArray[itemsIndex]; [cell.imageView sd_setImageWithURL:NewURL([model.imgUrl mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"banner")]; }else { [cell.imageView setImage:NewImageError_T]; } } return cell; } //图片点击方法 -(void)zzcarouselScrollView:(ZZCarousel *)zzcarouselScrollView didSelectItemAtIndex:(NSInteger)index { NSLog(@"%@",[NSString stringWithFormat:@"点击了 第%ld张 轮播图片",(long)index]); if (_headwheelArray.count>0) { CarouselModel *model = _headwheelArray[index]; if ([model.type isEqualToString:@"成果"]) { AchievementsdetailViewController *vc = [[AchievementsdetailViewController alloc] init]; vc.ID = model.ID; NewPushViewController(vc); }else if ([model.type isEqualToString:@"需求"]){ DemanddetailViewController *vc = [[DemanddetailViewController alloc] init]; vc.ID = model.ID; NewPushViewController(vc); }else if ([model.type isEqualToString:@"专家"]){ ExpertdetailsViewController *vc = [[ExpertdetailsViewController alloc] init]; vc.uid = model.ID; NewPushViewController(vc); } } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark------查看更多成果 需求 专家--------- - (void)seemoreBTclick:(UIButton *)sender { if (sender.tag == 100) { NSLog(@"查看更多成果"); ScienceAchievementsViewController *vc = [[ScienceAchievementsViewController alloc] init]; NewPushViewController(vc); }else if (sender.tag == 101){ NSLog(@"查看更多需求"); SciencedemandViewController *vc = [[SciencedemandViewController alloc] init]; NewPushViewController(vc); }else if (sender.tag == 102){ NSLog(@"查看更多专家"); ScienceexpertViewController *vc = [[ScienceexpertViewController alloc] init]; NewPushViewController(vc); } } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end