123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- #import "HmV3.h"
- #import "STButton.h"
- #import "AdvertisingColumn.h"
- #import "TRListVC.h"
- #import "TRDetailVC.h"
- #import "TopicesVC.h"
- #import "VowBar.h"
- #import "CLCell.h"
- #import "LightingAndSoundVC.h"
- @interface HmV3 ()<UITableViewDataSource,UITableViewDelegate>
- {
- NSArray *arr;
- NSArray *videoArray;
- NSMutableArray *array;
- NSMutableArray *dataArray;
- UITableView *_tableView;
- VowBar *vowItem;
- UIView *videoView;
- AdvertisingColumn *adView;
- }
- @end
- @implementation HmV3
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
-
- [self getVideos];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void)myInit
- {
- self.view.height = self.viewH;
- [self.view setBackgroundColor:backGroundColor];
- [self configNavigationBar];
-
- arr = @[@"科目三考试评判标准,提前了解不失分",
- @"科目三原来是这样丢分的",
- @"三招提高科目三考试成功率",
- @"科目三考试详细流程",
- @"科三再升级“人考”改“机考”车内多名安全员",
- @"科目三--加减档位操作",
- @"夜考,用这几招轻轻松松过",
- @"科目三大路考之靠边停车小技巧",
- @"科目三:模拟夜间行驶场景灯光使用技巧",
- @"超详细科目三考试口令速记口诀!",
- @"控制科目三方向的几个生死关键点",
- @"2015年科目三考试新规则和扣分标准",
- @"科目三:路考超车须知",
- @"科目三:电子路考需要注意什么",
- @"科目三:老手教你靠边停车技术",
- @"科目三:路考变更车道须知",
- @"科目三:路考通过人行横道线须知",
- @"科目三:路考中14项细节必需注意",
- @"考试指南 - 科目三路考评判标准",
- @"考试指南 - 科目三路考秘诀",
- @"考试指南 - 科目三必过的考场经验分享",
- @"考试指南 - 科目三抽到夜间考试怎么办?",
- @"考试指南 - 夜考灯光使用攻略,看完就过了!",
- @"考试指南 - 科目三路考会车攻略"];
- array = [NSMutableArray arrayWithArray:arr];
- dataArray = [NSMutableArray array];
- for (int i = 0; i < 5; i ++)
- {
- int index = arc4random()%(array.count - 1);
- [dataArray addObject:array[index]];
- [array removeObjectAtIndex:index];
- }
- scroll = self.zzScrollV;
- [scroll setScrollEnabled:YES];
- [self.view addSubview:scroll];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateAD:) name:@"updateAD" object:nil];
- adView = [[AdvertisingColumn alloc]initWithFrame:CGRectMake(0, 0, kSize.width, kSize.width*9/32.0)];
- //广告
- NSMutableArray *newAD = [NSMutableArray array];
- for (NSDictionary *dic in myDelegate.adArray) {
-
- if ([dic[@"LOCATION"] isEqualToString:@"5"]) {
-
- [newAD addObject:dic];
- }
- }
- [adView setImgArray:newAD];
- adView.supVC = self;
- [scroll addSubview:adView];
-
- CGFloat btnW = kSize.width/4;
- CGFloat btnH = 90;
- UIView* btnBg = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(adView.frame), kSize.width, btnH)];
- [btnBg setBackgroundColor:[UIColor whiteColor]];
- [scroll addSubview:btnBg];
-
- NSInteger tag =0;
- NSArray* titles = @[@"评判标准",@"路考秘诀",@"考场经验",@"秘籍指导"];
- NSArray* images = @[@"subject3_secret_guide_icon.png",@"subject2_standart_icon.png",
- @"subject1_apply_know_icon.png",@"subject1_newbie_onroad_icon.png"];
- for (int i =0; i<titles.count; i++) {
- STButton* btn = [[STButton alloc] initWithFrame:CGRectMake(btnW*i, 0, btnW, btnH)];
- btn.style = 1;
- //这里y为0是因为添加到btnBg里面了、
- [btnBg addSubview:btn];
- [btn setTag:tag++];
- [btn setImage:[UIImage imageNamed:images[i]] withTitle:titles[i] Font:NormalFont forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- }
-
- UIButton* btn;
- btn = [[UIButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(adView.frame)+btnH, kSize.width/2, 40)];
- [scroll addSubview:btn];
- [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
- [btn setImage:[UIImage imageNamed:@"subject3_light_ico.png"] forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- [btn setTitle:@"灯光操作" forState:UIControlStateNormal];
- [btn setBackgroundColor:[UIColor whiteColor]];
- [btn setTag:tag++];
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width/2, CGRectGetMaxY(adView.frame)+btnH, kSize.width/2, 40)];
- [scroll addSubview:btn];
- [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
- [btn setImage:[UIImage imageNamed:@"subject3_voice_icon.png"] forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- [btn setTitle:@"语音模拟" forState:UIControlStateNormal];
- [btn setBackgroundColor:[UIColor whiteColor]];
- [btn setTag:tag++];
-
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, btn.y + btn.height + 10, kFrame.size.width, 220)];
- [_tableView setScrollEnabled:NO];
- _tableView.dataSource = self;
- _tableView.delegate = self;
- [scroll addSubview:_tableView];
-
- //加一项许愿
- vowItem = [[VowBar alloc] initWithFrame:CGRectMake(0, [[scroll subviews] lastObject].bottom + 10, kFrame.size.width, VAWBAR_H) title:@"科目三"];
- vowItem.countLabel.text = @"点击参与讨论>>";
- [vowItem.topicBtn addTarget:self action:@selector(vowClick:) forControlEvents:UIControlEventTouchUpInside];
- vowItem.topicBtn.tag = 11;
- [vowItem.vomBtn addTarget:self action:@selector(vowClick:) forControlEvents:UIControlEventTouchUpInside];
- vowItem.vomBtn.tag = 12;
-
- // [scroll addSubview:vowItem];
- [scroll setContentSize:CGSizeMake(0, CGRectGetMaxY(vowItem.frame)+SCRV_BottomH)];
- }
- - (void)updateAD:(NSNotification *)notifica
- {
- NSMutableArray *newAD = [NSMutableArray array];
- for (NSDictionary *dic in myDelegate.adArray) {
-
- if ([dic[@"LOCATION"] isEqualToString:@"5"]) {
-
- [newAD addObject:dic];
- }
- }
- [adView setImgArray:newAD];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:@"updateAD" object:nil];
- }
- -(void)vowClick:(UIButton *)btn
- {
- TopicesVC* vc = [[TopicesVC alloc] init];
- vc.type = @"1";
- if (btn.tag == 11)
- {
- vc.groupId = @"6";
- }
- else
- {
- vc.groupId = @"9";
- }
- [self navPushHideTabbarToVC:vc];
- }
- #pragma mark tableView delegate
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return dataArray.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- CLCell *cell= [CLCell cellForTableView:tableView Style:UITableViewCellStyleDefault];
- [cell.textLabel setText:dataArray[indexPath.row]];
- [cell.imageView setImage:defaultImg];
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- TRDetailVC *vc=[[TRDetailVC alloc]init];
- [vc setFile:dataArray[indexPath.row]];
- [self navPushHideTabbarToVC:vc];
- }
- -(void)btnClick:(STButton*)sender
- {
- if (0 == sender.tag)
- {
- TRDetailVC* vc = [[TRDetailVC alloc] init];
- [vc setFile:@"科目三评判标准"];
- [self navPushHideTabbarToVC:vc];
- return;
- }
- if (1 == sender.tag)
- {
- TRDetailVC* vc = [[TRDetailVC alloc] init];
- [vc setFile:@"科目三路考秘诀"];
- [self navPushHideTabbarToVC:vc];
- return;
- }
- if (2 == sender.tag)
- {
- TRDetailVC* vc = [[TRDetailVC alloc] init];
- [vc setFile:@"科目三考场经验"];
- [self navPushHideTabbarToVC:vc];
- return;
- }
-
- if (3 == sender.tag)
- {
- TRListVC* vc = [[TRListVC alloc] init];
- arr = @[@"科目三考试评判标准,提前了解不失分",
- @"科目三原来是这样丢分的",
- @"三招提高科目三考试成功率",
- @"科目三考试详细流程",
- @"科三再升级“人考”改“机考”车内多名安全员",
- @"科目三--加减档位操作",
- @"夜考,用这几招轻轻松松过",
- @"科目三大路考之靠边停车小技巧",
- @"科目三:模拟夜间行驶场景灯光使用技巧",
- @"超详细科目三考试口令速记口诀!",
- @"控制科目三方向的几个生死关键点",
- @"2015年科目三考试新规则和扣分标准",
- @"科目三:路考超车须知",
- @"科目三:电子路考需要注意什么",
- @"科目三:老手教你靠边停车技术",
- @"科目三:路考变更车道须知",
- @"科目三:路考通过人行横道线须知",
- @"科目三:路考中14项细节必需注意",
- @"考试指南 - 科目三路考评判标准",
- @"考试指南 - 科目三路考秘诀",
- @"考试指南 - 科目三必过的考场经验分享",
- @"考试指南 - 科目三抽到夜间考试怎么办?",
- @"考试指南 - 夜考灯光使用攻略,看完就过了!",
- @"考试指南 - 科目三路考会车攻略"];
- [vc setModels:arr];
- [vc setTitle:@"秘籍指导"];
-
- [self navPushHideTabbarToVC:vc];
- return;
- }
- if (sender.tag == 4 || sender.tag == 5)
- {
- LightingAndSoundVC *VC = [[LightingAndSoundVC alloc] init];
- VC.styleTag = sender.tag;
- [self navPushHideTabbarToVC:VC];
- }
-
- if (6 == sender.tag) {
-
- // DownLoadVC *downLoadVC = [[DownLoadVC alloc] init];
- // downLoadVC.subject = 3;
- //
- // [self navPushHideTabbarToVC:downLoadVC];
- // VideoDownLoadListVC *downLoadVC = [[VideoDownLoadListVC alloc] init];
- // downLoadVC.videoListSegControlIndex = VideoListSegControlIndex_ObjectThree;
- // [self navPushHideTabbarToVC:downLoadVC];
- }
- if (sender.tag > 6 && sender.tag < 13) {
- // VideoPlayVC *vc = [[VideoPlayVC alloc] init];
- // if (videoArray.count > 5) {
- // vc.dataDic = videoArray[sender.tag - 7];
- // }
- // vc.subject = 3;
- // [self navPushHideTabbarToVC:vc];
-
- // LeeVideoVC *vc = [[LeeVideoVC alloc]init];
- // if (videoArray.count > 5) {
- // vc.dataDic = videoArray[sender.tag - 7];
- // }
- // vc.subject = 3;
- // vc.goDownLoadBlock = ^{
- // DownLoadVC *downLoadVC = [[DownLoadVC alloc] init];
- // downLoadVC.subject = 3;
- // [self navPushHideTabbarToVC:downLoadVC];
- // };
- // vc.modalPresentationStyle = UIModalPresentationFullScreen;
- // [self presentViewController:vc animated:YES completion:nil];
- // VideoPlayViewController *vc = [[VideoPlayViewController alloc] init];
- // if (videoArray.count > 5) {
- // NSDictionary *dic = videoArray[sender.tag - 7];
- // RQDownloadModel *downloadModel = [[RQDownloadModel alloc] init];
- // downloadModel.videoId = dic[@"id"];
- // downloadModel.subject = dic[@"subject"];
- // downloadModel.title = dic[@"title"];
- // downloadModel.urlString = dic[@"videoPath"];
- // downloadModel.imageUrl = dic[@"image"];
- // downloadModel.content = dic[@"content"];
- // vc.currentModel = downloadModel;
- // }
- // [self navPushHideTabbarToVC:vc];
- }
- }
- #pragma mark 获取视频资源
- -(void)getVideos
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *aArray=[NSMutableArray array];
- [aArray addPro:@"chapterId" Value:@"3"];
- [aArray addPro:@"subject" Value:@"3"];
- [aArray addPro:@"isPage" Value:@"0"];
- [aArray addPro:@"pageSize" Value:@"0"];
- [aArray addPro:@"currentPage" Value:@"0"];
-
- NSString* method = @"getVideos";
-
- [jiaPeiManager requestAnythingWithURL:method array:aArray data:nil completion:^(NSDictionary *root) {
-
- //NSLog(@"获取视频aArray-->%@------------------root-->%@",aArray,root);
-
- if (!root) {
- // ShowMsg(@"操作失败!请重试");
- return ;
- }
-
- if ([root[@"code"] isEqualToString:@"1"]) {
- return;
- }
-
- if ([root[@"body"] count] > 5) {
-
- videoArray = root[@"body"];
- [self initVideoView];
- //NSLog(@"-%d---%@",(int)videoArray.count,videoArray);
- }else{
- //其实这个是多余的 因为这个页面每次进来只会加载一次 就是说这个方法只会调用一次
- if ([videoView isKindOfClass:[UIView class]]) {
- [_tableView setHidden:NO];
- [videoView removeFromSuperview];
-
- vowItem.y = [[scroll subviews] lastObject].bottom + 10;
- [scroll setContentSize:CGSizeMake(0, CGRectGetMaxY(vowItem.frame)+SCRV_BottomH)];
- }
- }
- }];
- }
- -(void)initVideoView
- {
- [_tableView setHidden:YES];
-
- //290*260 290*180 290*70
- videoView = [[UIView alloc] initWithFrame:_tableView.frame];
- videoView.backgroundColor = [UIColor whiteColor];
-
- //重置页面展示形式
- CGFloat w = (kSize.width - 30)/2.0;
- videoView.height = w*78/29.0 + 40;
- [scroll addSubview:videoView];
- vowItem.y = videoView.bottom + 10;
- [scroll setContentSize:CGSizeMake(0, CGRectGetMaxY(vowItem.frame)+SCRV_BottomH)];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, kSize.width/2.0 - 10, 40)];
- [label setText:@"教学视频" Font:FontTitle TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
- [videoView addSubview:label];
- label = [[UILabel alloc] initWithFrame:CGRectMake(kSize.width/2.0, 0, kSize.width/2.0 - 10, 40)];
- [label setText:[NSString stringWithFormat:@"共%d个视频>",(int)videoArray.count] Font:Font17 TextColor:contentTextColor Alignment:NSTextAlignmentRight];
- [videoView addSubview:label];
-
- UIButton *moreVideoBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 40)];
- [moreVideoBtn target:self tag:6];//tag 6开始
- [videoView addSubview:moreVideoBtn];
-
- CGFloat bdH = w*26/29.0;
- CGFloat photoH = w*18/29.0;
- CGFloat labelH = w*7/29.0;
-
-
- NSInteger videoNum = videoArray.count;
- if (videoNum > 6) {
- videoNum = 6;
- }
- for (int i = 0; i < videoNum; i ++) {
-
- int row = i/2;
- int clumn = i%2;
-
- NSDictionary *dic = videoArray[i];
-
- //照片
- UIImageView *videoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10 + clumn*(w + 10), 40 + row*bdH, w, photoH)];
- NSString *str = dic[@"image"];
- if (str && ![str hasPrefix:@"http"]){
- str = [imgPreFix stringByAppendingString:str];
- }
- if (!str) {
- str = @"";
- }
- [videoImageView sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"NOIMG.png"]];
- [videoView addSubview:videoImageView];
-
- //时长
- label = [[UILabel alloc] initWithFrame:CGRectMake(10 + clumn*(w + 10), row*bdH + photoH + 15, w - 10, 25)];
- label.backgroundColor = windowBlockColor;
- int seconds = [dic[@"times"] intValue];
- NSString *min = [NSString stringWithFormat:@"%d",seconds/60];
- NSString *sec = [NSString stringWithFormat:@"%d",seconds%60];
- if (seconds/60 < 10) {
- min = [NSString stringWithFormat:@"0%@",min];
- }
- if (seconds%60 < 10) {
- sec = [NSString stringWithFormat:@"0%@",sec];
- }
- [label setText:[NSString stringWithFormat:@"%@:%@",min,sec] Font:NormalFont TextColor:[UIColor whiteColor] Alignment:NSTextAlignmentRight];
- [videoView addSubview:label];
-
- //title
- label = [[UILabel alloc] initWithFrame:CGRectMake(10 + clumn*(w + 10), 40 + row*bdH + photoH, w, labelH)];
- [label setText:dic[@"title"] Font:FontTitle TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
- [videoView addSubview:label];
-
- //btn
- UIButton *playBtn = [[UIButton alloc] initWithFrame:CGRectMake(10 + clumn*(w + 10), 40 + row*bdH, w, bdH)];
- playBtn.backgroundColor = [UIColor clearColor];
- [playBtn target:self tag:7 + i];//7开始
- [videoView addSubview:playBtn];
- }
- }
- -(void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self name:@"updateAD" object:nil];
- //下边这个其实不用写的 我们的项目应该不会被用在arc环境下
- #if ! __has_feature(objc_arc)
- [super dealloc];
- #endif
- }
- @end
|