TechnologyVC.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. //
  2. // TechnologyVC.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2017/9/14.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "TechnologyVC.h"
  9. #import "ReviseinfoCell.h"
  10. #import "CCZTrotingLabel.h"
  11. #import "ScienceAchievementsViewController.h"//科技成果
  12. #import "SciencedemandViewController.h"//科技需求
  13. #import "ScienceexpertViewController.h"//科技专家
  14. #import "ZZCarousel.h"
  15. #import "TechnologyModel.h"
  16. #import "AchievementsdetailViewController.h"//成果详情
  17. #import "DemanddetailViewController.h"//需求详情
  18. #import "ExpertdetailsViewController.h"//专家详情
  19. #import "ReleaseresultsViewController.h"//发布成果
  20. #import "AchievementsReleaseViewController.h"//发布成果1
  21. #import "ReleaserequirementsViewController.h"//发布需求
  22. #import "MyOrderViewController.h"
  23. #import "YBPopupMenu.h"
  24. #import "MyattentionViewController.h"
  25. #define TITLES @[@"我的关注", @"我的订单",@"发布成果",@"发布需求"]
  26. #define ICONS @[@"wdgz",@"wddd",@"fbcg",@"fbxq"]
  27. @interface TechnologyVC ()<UITableViewDelegate,UITableViewDataSource,ZZCarouselDelegate,YBPopupMenuDelegate>{
  28. UITableView *newtableView;
  29. NSMutableArray *dataArray;
  30. NSString *url;
  31. ZZCarousel *_headwheel;//广告图
  32. NSMutableArray *_headwheelArray;
  33. UIView *view;
  34. }
  35. @property (strong ,nonatomic) UIButton * registerAccount;
  36. @property (strong ,nonatomic) CCZTrotingLabel *label;;
  37. @property (nonatomic, strong) YBPopupMenu *popupMenu;
  38. @end
  39. @implementation TechnologyVC
  40. - (void)viewWillAppear:(BOOL)animated
  41. {
  42. [super viewWillAppear:animated];
  43. [self Networkrequest];
  44. [newtableView reloadData];
  45. }
  46. - (void)viewDidLoad {
  47. [super viewDidLoad];
  48. [self setNavTitle:@"淘技"];
  49. [self dataInitialization];
  50. // [self Networkrequest];
  51. [self loadsView];
  52. // Do any additional setup after loading the view.
  53. }
  54. - (void)Networkrequest {
  55. NSMutableDictionary *dic = [NSMutableDictionary new];
  56. [NetworkRequestManager requestGetWithInterfacePrefix:JT_advertising parameters:dic onSuccess:^(id requestData) {
  57. NSLog(@"服务器返回数据 :%@",requestData);
  58. if ([requestData[@"error"] count] !=0) {
  59. for (NSDictionary *dic in requestData[@"error"]) {
  60. [MBProgressHUD showError:dic[@"message"] toView:self.view];
  61. }
  62. }else{
  63. [_headwheelArray removeAllObjects];
  64. for (NSDictionary *dic in requestData[@"data"]) {
  65. TechnologyModel *model = [[TechnologyModel alloc] initWithDictionary:dic error:nil];
  66. [_headwheelArray addObject:model];
  67. _headwheel?[_headwheel reloadData]:nil;
  68. }
  69. if (_headwheelArray.count>0) {
  70. TechnologyModel *model = _headwheelArray[0];
  71. [_label addText:model.slogan];
  72. }
  73. [newtableView reloadData];
  74. }
  75. } onFailure:^{
  76. }];
  77. }
  78. #pragma mark - 数据初始化
  79. - (void)dataInitialization{
  80. _headwheelArray = [NSMutableArray new];
  81. dataArray = NewMutableArrayInit;
  82. for (int i=0; i<4; i++) {
  83. NSDictionary *dataDic = [NSDictionary dictionary];
  84. switch (i) {
  85. case 0:
  86. dataDic = @{@"nameKey":@"科技成果",@"imageKey":@"发现-科技成果",@"classKey":@""};
  87. [dataArray addObject:dataDic];
  88. break;
  89. case 1:
  90. dataDic = @{@"nameKey":@"科技需求",@"imageKey":@"发现-科技需求",@"classKey":@""};
  91. [dataArray addObject:dataDic];
  92. break;
  93. case 2:
  94. dataDic = @{@"nameKey":@"科技专家",@"imageKey":@"发现-科技专家",@"classKey":@""};
  95. [dataArray addObject:dataDic];
  96. break;
  97. default:
  98. break;
  99. }
  100. }
  101. }
  102. #pragma mark ----加载界面
  103. - (void)loadsView{
  104. [self.navgationBar addSubview:self.registerAccount];
  105. _registerAccount.sd_layout
  106. .widthIs(30)
  107. .rightSpaceToView(self.navgationBar, 10)
  108. .heightIs(44)
  109. .topSpaceToView(self.navgationBar, 18);
  110. [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]];
  111. newtableView.separatorStyle = NO;
  112. }
  113. #pragma mark-------------------------UITableView------------------------------------
  114. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  115. {
  116. return 1;
  117. }
  118. //返回每段行数
  119. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  120. {
  121. return dataArray.count;
  122. }
  123. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  124. {
  125. static NSString *Cell = @"Cell";
  126. ReviseinfoCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell];
  127. if (cell == nil) {
  128. cell = [[ReviseinfoCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
  129. }
  130. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
  131. cell.accessoryType = UITableViewCellAccessoryNone;
  132. [cell assignment:dataArray[indexPath.row]];
  133. cell.seedetails.hidden = YES;
  134. return cell;
  135. }
  136. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  137. {
  138. return fitScreenHeight(44);
  139. }
  140. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  141. if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"科技成果"]) {
  142. ScienceAchievementsViewController *vc = [[ScienceAchievementsViewController alloc] init];
  143. NewPushViewController(vc);
  144. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"科技需求"]) {
  145. SciencedemandViewController *vc = [[SciencedemandViewController alloc] init];
  146. NewPushViewController(vc);
  147. }else if ([dataArray[indexPath.row][@"nameKey"] isEqualToString:@"科技专家"]) {
  148. ScienceexpertViewController *vc = [[ScienceexpertViewController alloc] init];
  149. NewPushViewController(vc);
  150. }
  151. }
  152. // tableView 如果是Gruop类型的话,section之间的间距变宽,执行返回高度的同时还需要执行return UIView的代理
  153. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  154. return fitScreenWidth(200);
  155. }
  156. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  157. return CGFLOAT_MIN;
  158. }
  159. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  160. if (!view) {
  161. view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, fitScreenWidth(200))];
  162. view.backgroundColor = NewNavigationColor;
  163. _headwheel = nil;
  164. //创建轮播图
  165. _headwheel = [self headViewwheel:500];
  166. _headwheel.backgroundColor = NewNavigationColor;
  167. [view addSubview:_headwheel];
  168. [_headwheel reloadData];
  169. }
  170. // UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, fitScreenWidth(170))];
  171. // [imageview sd_setImageWithURL:NewURL([url mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"")];
  172. // [view addSubview:imageview];
  173. [view addSubview:self.label];
  174. return view;
  175. }
  176. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  177. return [[UIView alloc] init];
  178. }
  179. - (CCZTrotingLabel *)label{
  180. if (!_label) {
  181. _label = [[CCZTrotingLabel alloc] init];
  182. _label.frame = CGRectMake(30, fitScreenWidth(140), SCREEN_WIDTH-60, fitScreenWidth(45));
  183. _label.rate = CCZTrotingRateNormal;
  184. ViewRadius(_label, 3);
  185. _label.autoTrotingRepeat = YES;
  186. _label.hideWhenStopTroting = NO;
  187. _label.pause = 2;
  188. _label.duration = 2.5;
  189. _label.direction = CCZTrotDirectionLeft;
  190. _label.backgroundImage = [UIImage imageNamed:@""];
  191. _label.backgroundColor = NewWhiteColor;
  192. UIImageView *head = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"小喇叭"]];
  193. _label.leftView = head;
  194. }
  195. return _label;
  196. }
  197. #pragma mark-------------------------ZZCarousel轮播图片----------------------------------
  198. -(ZZCarousel*)headViewwheel:(NSInteger)tag
  199. {
  200. //self.navigationController.navigationBar.frame.size.height (SCREEN_WIDTH * 500 ) / 1080
  201. ZZCarousel* wheel = [[ZZCarousel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,fitScreenWidth(170))];
  202. wheel.tag = tag;
  203. /*
  204. * carouseScrollTimeInterval --- 此属性为设置轮播多长时间滚动到下一张
  205. */
  206. wheel.carouseScrollTimeInterval = CarouselTime;
  207. // 代理
  208. wheel.delegate = self;
  209. /*
  210. * isAutoScroll --- 默认为NO,当为YES时 才能使轮播进行滚动
  211. */
  212. wheel.isAutoScroll = YES;
  213. /*
  214. * pageType --- 设置轮播样式 默认为系统样式。ZZCarousel 中封装了 两种样式,另外一种为数字样式
  215. */
  216. wheel.pageType = ZZCarouselPageTypeOfNone;
  217. /*
  218. * 设置UIPageControl 在轮播中的位置、系统默认的UIPageControl 的顶层颜色 和底层颜色已经背景颜色
  219. */
  220. if(wheel.tag == 500) {
  221. wheel.pageControlFrame = CGRectMake((SCREEN_WIDTH - 60 ) / 2, wheel.frame.size.height - 10, 60, 5);
  222. wheel.pageIndicatorTintColor = [UIColor whiteColor];
  223. wheel.currentPageIndicatorTintColor = NewRGBColor(191, 191, 191, 1);
  224. wheel.pageControlBackGroundColor = [UIColor whiteColor];
  225. /*
  226. * 设置数字样式的 UIPageControl 中的字体和字体颜色。 背景颜色仍然按照上面pageControlBackGroundColor属性来设置
  227. */
  228. wheel.pageControlOfNumberFont = [UIFont fontWithName:@"Helvetica-Bold" size:18];
  229. wheel.pageContolOfNumberFontColor = [UIColor whiteColor];
  230. }
  231. return wheel;
  232. }
  233. //ZZCarouselDelegate 轮播图片代理方法
  234. -(NSInteger)numberOfZZCarousel:(ZZCarousel *)wheel
  235. {
  236. return _headwheelArray.count;
  237. }
  238. //图片赋值
  239. -(ZZCarouselView *)zzcarousel:(UICollectionView *)zzcarousel viewForItemAtIndex:(NSIndexPath *)index itemsIndex:(NSInteger)itemsIndex identifire:(NSString *)identifire ZZCarousel:(ZZCarousel *)zZCarousel
  240. {
  241. /*
  242. * index参数 ※ 注意
  243. */
  244. ZZCarouselView *cell = [zzcarousel dequeueReusableCellWithReuseIdentifier:identifire forIndexPath:index];
  245. if (!cell) {
  246. cell = [[ZZCarouselView alloc]init];
  247. }
  248. // cell.title.text = [_imagesGroup objectAtIndex:indexPath.row];
  249. // [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"图片地址"]];
  250. /*
  251. * itemsIndex 参数 ※ 注意
  252. */
  253. if(zZCarousel.tag == 500){
  254. if(_headwheelArray.count > itemsIndex){
  255. TechnologyModel *model = _headwheelArray[itemsIndex];
  256. [cell.imageView sd_setImageWithURL:NewURL([model.picture mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"banner")];
  257. }else {
  258. [cell.imageView setImage:NewImageError_T];
  259. }
  260. }
  261. return cell;
  262. }
  263. //图片点击方法
  264. -(void)zzcarouselScrollView:(ZZCarousel *)zzcarouselScrollView didSelectItemAtIndex:(NSInteger)index
  265. {
  266. if (_headwheelArray.count>0) {
  267. TechnologyModel *model = _headwheelArray[index];
  268. if ([model.type isEqualToString:@"成果"]) {
  269. AchievementsdetailViewController *vc = [[AchievementsdetailViewController alloc] init];
  270. vc.ID = model.ID;
  271. NewPushViewController(vc);
  272. }else if ([model.type isEqualToString:@"需求"]){
  273. DemanddetailViewController *vc = [[DemanddetailViewController alloc] init];
  274. vc.ID = model.ID;
  275. NewPushViewController(vc);
  276. }else if ([model.type isEqualToString:@"专家"]){
  277. ExpertdetailsViewController *vc = [[ExpertdetailsViewController alloc] init];
  278. vc.uid = model.ID;
  279. NewPushViewController(vc);
  280. }
  281. }
  282. NSLog(@"%@",[NSString stringWithFormat:@"点击了 第%ld张 轮播图片",(long)index]);
  283. }
  284. - (UIButton *)registerAccount
  285. {
  286. if (!_registerAccount)
  287. {
  288. _registerAccount = [UIButton buttonWithType:UIButtonTypeCustom];
  289. // [_registerAccount setTitle:@"" forState:UIControlStateNormal];
  290. [_registerAccount setTitleColor:[UIColor colorWithString:@"#9A9A9A"] forState:UIControlStateNormal];
  291. [_registerAccount setBackgroundColor:[UIColor clearColor]];
  292. [_registerAccount setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
  293. [_registerAccount.titleLabel setFont:[UIFont systemFontOfSize:fitScreenWidth(14)]];
  294. [_registerAccount addTarget:self action:@selector(touchRegister:) forControlEvents:UIControlEventTouchUpInside];
  295. // [_registerAccount setupAutoSizeWithHorizontalPadding:5 buttonHeight:44];
  296. [_registerAccount setImage:NewImageNamed(@"gd") forState:UIControlStateNormal];
  297. }
  298. return _registerAccount;
  299. }
  300. - (void)touchRegister:(UIButton *)sender{
  301. [YBPopupMenu showRelyOnView:sender titles:TITLES icons:ICONS menuWidth:140 delegate:self];
  302. }
  303. #pragma mark - YBPopupMenuDelegate
  304. - (void)ybPopupMenuDidSelectedAtIndex:(NSInteger)index ybPopupMenu:(YBPopupMenu *)ybPopupMenu
  305. {
  306. NSLog(@"点击了 %@ 选项",TITLES[index]);
  307. if (index == 0) {
  308. if ([UserHelper isLogin]) {
  309. NSLog(@"%@",@"已登录");
  310. MyattentionViewController *vc = [[MyattentionViewController alloc] init];
  311. NewPushViewController(vc);
  312. }else{
  313. NSLog(@"%@",@"未登录");
  314. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  315. [vc setLoginSuccess:^(NSString *string) {
  316. NewPopViewController;
  317. }];
  318. NewPushViewController(vc);
  319. }
  320. }else if (index == 1){
  321. if ([UserHelper isLogin]) {
  322. NSLog(@"%@",@"已登录");
  323. MyOrderViewController*vc = [[MyOrderViewController alloc] init];
  324. NewPushViewController(vc);
  325. }else{
  326. NSLog(@"%@",@"未登录");
  327. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  328. [vc setLoginSuccess:^(NSString *string) {
  329. NewPopViewController;
  330. }];
  331. NewPushViewController(vc);
  332. }
  333. }else if (index == 2) {
  334. if ([UserHelper isLogin]) {
  335. NSLog(@"%@",@"已登录");
  336. AchievementsReleaseViewController *vc = [[AchievementsReleaseViewController alloc] init];
  337. NewPushViewController(vc);
  338. }else{
  339. NSLog(@"%@",@"未登录");
  340. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  341. [vc setLoginSuccess:^(NSString *string) {
  342. NewPopViewController;
  343. }];
  344. NewPushViewController(vc);
  345. }
  346. }else if (index == 3){
  347. if ([UserHelper isLogin]) {
  348. NSLog(@"%@",@"已登录");
  349. ReleaserequirementsViewController *vc = [[ReleaserequirementsViewController alloc] init];
  350. NewPushViewController(vc);
  351. }else{
  352. NSLog(@"%@",@"未登录");
  353. NewLoginViewController *vc = [[NewLoginViewController alloc] init];
  354. [vc setLoginSuccess:^(NSString *string) {
  355. NewPopViewController;
  356. }];
  357. NewPushViewController(vc);
  358. }
  359. }
  360. }
  361. - (void)didReceiveMemoryWarning {
  362. [super didReceiveMemoryWarning];
  363. // Dispose of any resources that can be recreated.
  364. }
  365. /*
  366. #pragma mark - Navigation
  367. // In a storyboard-based application, you will often want to do a little preparation before navigation
  368. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  369. // Get the new view controller using [segue destinationViewController].
  370. // Pass the selected object to the new view controller.
  371. }
  372. */
  373. @end