| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- //
- // TechnologyVC.m
- // jitao
- //
- // Created by 罗云飞 on 2017/9/14.
- // Copyright © 2017年 罗云飞. All rights reserved.
- //
- #import "TechnologyVC.h"
- #import "ReviseinfoCell.h"
- #import "CCZTrotingLabel.h"
- #import "ScienceAchievementsViewController.h"//科技成果
- #import "SciencedemandViewController.h"//科技需求
- #import "ScienceexpertViewController.h"//科技专家
- #import "ZZCarousel.h"
- #import "TechnologyModel.h"
- #import "AchievementsdetailViewController.h"//成果详情
- #import "DemanddetailViewController.h"//需求详情
- #import "ExpertdetailsViewController.h"//专家详情
- #import "ReleaseresultsViewController.h"//发布成果
- #import "AchievementsReleaseViewController.h"//发布成果1
- #import "ReleaserequirementsViewController.h"//发布需求
- #import "MyOrderViewController.h"
- #import "YBPopupMenu.h"
- #import "MyattentionViewController.h"
- #define TITLES @[@"我的关注", @"我的订单",@"发布成果",@"发布需求"]
- #define ICONS @[@"wdgz",@"wddd",@"fbcg",@"fbxq"]
- @interface TechnologyVC ()<UITableViewDelegate,UITableViewDataSource,ZZCarouselDelegate,YBPopupMenuDelegate>{
- UITableView *newtableView;
- NSMutableArray *dataArray;
- NSString *url;
- ZZCarousel *_headwheel;//广告图
- NSMutableArray *_headwheelArray;
- UIView *view;
-
- }
- @property (strong ,nonatomic) UIButton * registerAccount;
- @property (strong ,nonatomic) CCZTrotingLabel *label;;
- @property (nonatomic, strong) YBPopupMenu *popupMenu;
- @end
- @implementation TechnologyVC
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self Networkrequest];
- [newtableView reloadData];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setNavTitle:@"淘技"];
- [self dataInitialization];
- // [self Networkrequest];
- [self loadsView];
- // Do any additional setup after loading the view.
- }
- - (void)Networkrequest {
- NSMutableDictionary *dic = [NSMutableDictionary new];
- [NetworkRequestManager requestGetWithInterfacePrefix:JT_advertising 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"]) {
- TechnologyModel *model = [[TechnologyModel alloc] initWithDictionary:dic error:nil];
- [_headwheelArray addObject:model];
- _headwheel?[_headwheel reloadData]:nil;
- }
- if (_headwheelArray.count>0) {
- TechnologyModel *model = _headwheelArray[0];
- [_label addText:model.slogan];
- }
- [newtableView reloadData];
- }
- } onFailure:^{
-
- }];
- }
- #pragma mark - 数据初始化
- - (void)dataInitialization{
- _headwheelArray = [NSMutableArray new];
- dataArray = NewMutableArrayInit;
- for (int i=0; i<4; i++) {
- NSDictionary *dataDic = [NSDictionary dictionary];
- switch (i) {
- case 0:
- dataDic = @{@"nameKey":@"科技成果",@"imageKey":@"发现-科技成果",@"classKey":@""};
- [dataArray addObject:dataDic];
- break;
- case 1:
- dataDic = @{@"nameKey":@"科技需求",@"imageKey":@"发现-科技需求",@"classKey":@""};
- [dataArray addObject:dataDic];
- break;
- case 2:
- dataDic = @{@"nameKey":@"科技专家",@"imageKey":@"发现-科技专家",@"classKey":@""};
- [dataArray addObject:dataDic];
- break;
- default:
- break;
- }
- }
- }
- #pragma mark ----加载界面
- - (void)loadsView{
- [self.navgationBar addSubview:self.registerAccount];
- _registerAccount.sd_layout
- .widthIs(30)
- .rightSpaceToView(self.navgationBar, 10)
- .heightIs(44)
- .topSpaceToView(self.navgationBar, 18);
- [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, NavHeader, SCREEN_WIDTH, SCREEN_HEIGHT-NavHeader) backgroundColor:NewNavigationColor style:UITableViewStyleGrouped delegate:self dataSource:self showsHorizontalScrollIndicator:NO showsVerticalScrollIndicator:NO hidden:NO tag:100 userInteractionEnabled:YES]];
- newtableView.separatorStyle = NO;
- }
- #pragma mark-------------------------UITableView------------------------------------
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- //返回每段行数
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return dataArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *Cell = @"Cell";
- ReviseinfoCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell];
- if (cell == nil) {
- cell = [[ReviseinfoCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
- }
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
- cell.accessoryType = UITableViewCellAccessoryNone;
- [cell assignment:dataArray[indexPath.row]];
- cell.seedetails.hidden = YES;
- return cell;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return fitScreenHeight(44);
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"科技成果"]) {
- ScienceAchievementsViewController *vc = [[ScienceAchievementsViewController alloc] init];
- NewPushViewController(vc);
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"科技需求"]) {
- SciencedemandViewController *vc = [[SciencedemandViewController alloc] init];
- NewPushViewController(vc);
- }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"科技专家"]) {
- ScienceexpertViewController *vc = [[ScienceexpertViewController alloc] init];
- NewPushViewController(vc);
- }
- }
- // tableView 如果是Gruop类型的话,section之间的间距变宽,执行返回高度的同时还需要执行return UIView的代理
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return fitScreenWidth(200);
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
-
- if (!view) {
- view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, fitScreenWidth(200))];
- view.backgroundColor = NewNavigationColor;
- _headwheel = nil;
- //创建轮播图
- _headwheel = [self headViewwheel:500];
- _headwheel.backgroundColor = NewNavigationColor;
- [view addSubview:_headwheel];
- [_headwheel reloadData];
- }
- // UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, fitScreenWidth(170))];
- // [imageview sd_setImageWithURL:NewURL([url mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"")];
- // [view addSubview:imageview];
- [view addSubview:self.label];
- return view;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
- return [[UIView alloc] init];
- }
- - (CCZTrotingLabel *)label{
- if (!_label) {
- _label = [[CCZTrotingLabel alloc] init];
- _label.frame = CGRectMake(30, fitScreenWidth(140), SCREEN_WIDTH-60, fitScreenWidth(45));
- _label.rate = CCZTrotingRateNormal;
- ViewRadius(_label, 3);
- _label.autoTrotingRepeat = YES;
- _label.hideWhenStopTroting = NO;
- _label.pause = 2;
- _label.duration = 2.5;
- _label.direction = CCZTrotDirectionLeft;
- _label.backgroundImage = [UIImage imageNamed:@""];
- _label.backgroundColor = NewWhiteColor;
- UIImageView *head = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"小喇叭"]];
- _label.leftView = head;
- }
- return _label;
- }
-
- #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,fitScreenWidth(170))];
- 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){
- TechnologyModel *model = _headwheelArray[itemsIndex];
- [cell.imageView sd_setImageWithURL:NewURL([model.picture mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"banner")];
- }else {
- [cell.imageView setImage:NewImageError_T];
- }
- }
- return cell;
- }
-
- //图片点击方法
- -(void)zzcarouselScrollView:(ZZCarousel *)zzcarouselScrollView didSelectItemAtIndex:(NSInteger)index
- {
- if (_headwheelArray.count>0) {
- TechnologyModel *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);
- }
- }
- NSLog(@"%@",[NSString stringWithFormat:@"点击了 第%ld张 轮播图片",(long)index]);
- }
- - (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) {
- NewPopViewController;
- }];
- NewPushViewController(vc);
- }
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #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
|