123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- //
- // HmV0.m
- // jiaPei
- //
- // Created by apple on 15/11/13.
- // Copyright (c) 2015年 JCZ. All rights reserved.
- //
- #import "HmV0.h"
- #import "STButton.h"
- #import "STButton.h"
- #import "SchInfo.h"
- #import "ExerciseVC.h"
- #import "SchCell.h"
- #import "GuideVC.h"
- #import "SearchBase.h"
- #import "VowBar.h"
- #import "TopicesVC.h"
- #import "TrafficRulesViewController.h"
- #import "NeighbouringVC.h"
- @interface HmV0()<UITableViewDataSource,UITableViewDelegate>
- /**驾校VC
- */
- @property(nonatomic,strong)UITableView* tableView;
- /**
- */
- @property(assign)BOOL isFake;
- @property(nonatomic,strong)NSMutableArray* schools;
- @end
- @implementation HmV0
- {
- NSMutableArray *firArr,*secArr;
- /**所有地区名称,加code。pcode
- */
- NSArray* areaArr;
-
- /**培训类型 1 复训 2 陪练 3 计时
- */
- NSInteger trainType;
-
- /**排列类型 1 价格 2 口碑 3 人气
- */
- NSInteger sortType;
- /**排列方式 1 星级由低到高 2 由高到低
- */
- NSInteger sort;
-
- NSString* dqbh,*qxbh;
-
- UIButton *footerBtn;
-
- NSArray *schArray;
-
- UILabel *kHolder;
-
- CGFloat btnY;
- }
- -(id)initWithFake:(BOOL)isFake{
- self = [super init];
- if (self) {
- _isFake = isFake;
- }
- return self;
- }
- -(void)viewDidLoad
- {
- [super viewDidLoad];
- [self myInit];
- }
- -(void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
-
- } else {
- [self getSchInfoList];
- }
-
- }
- -(void)myInit
- {
- self.view.height = self.viewH;
- [self.view setBackgroundColor:[UIColor whiteColor]];
- [self configNavigationBar];
-
- //设置为请求的参数 而不是具体数
- dqbh = @"";
- qxbh = @"";
- sort = 2;
- trainType = 1;
- _schools = [NSMutableArray array];
- schArray = [NSMutableArray array];
- NSInteger tag = 0;
- CGFloat y,h;
- scroll = self.zzScrollV;
- [self.view addSubview:scroll];
-
- // UIView* hv = [[UIView alloc] initWithFrame:CGRectMake(0, -200, 320, 200)];
- // [hv setBackgroundColor:backGroundColor];
- // [scroll addSubview:hv];
-
-
- NSArray* imgs1 = @[@"subject1_traffic_identify_icon.png",@"subject2_exam_experance_icon.png",@"subject1_traffic_rules_icon.png"];//@"subject1_newbie_onroad_icon.png",
- NSArray* btnTitles = @[@"学车流程",@"体检须知",@"学车指南"];//@"报名须知",
- CGFloat btnW = kSize.width/btnTitles.count;
- CGFloat btnH = 90;
- for (int i = 0; i<btnTitles.count; i++)
- {
- STButton* btn = [[STButton alloc] initWithFrame:CGRectMake(btnW*i, 0, btnW, btnH)];
- //h=96
- [btn setImage:[UIImage imageNamed:imgs1[i]] withTitle:btnTitles[i] Font:NormalFont forState:UIControlStateNormal];
- [scroll addSubview:btn];
- [btn setStyle:1];
- btn.tag = 1+tag++;
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- }
-
- y = btnH + 10;
- UILabel* lbl10 = [[UILabel alloc] initWithFrame:CGRectMake(10, y, kSize.width, 40)];
- [lbl10 setText:@"驾校报名"];//推荐驾校
- // [scroll addSubview:lbl10];
- [lbl10 addViewWithRect:CGRectMake(0, y - 10, kSize.width, 10)];
- y += 40.5;
- [lbl10 addViewWithRect:CGRectMake(0, y - 0.5, kSize.width, .5)];
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, y, kSize.width, 0)];
- _tableView.rowHeight = 100;
- [_tableView setScrollEnabled:NO];
- _tableView.dataSource = self;
- _tableView.delegate = self;
- // [scroll addSubview:_tableView];
- [lbl10 addViewWithRect:CGRectMake(0, y , kSize.width,1)];
-
- kHolder = [[UILabel alloc] initWithFrame:CGRectMake(20, y, kSize.width - 20, 40)];
- kHolder.text = @"还未查找到推荐驾校哦~";
- kHolder.textColor = defGreen;
- [kHolder addSelfViewWithRect:CGRectMake(-20, 39 ,kSize.width, 1) Color:KlineColor];
- // [scroll addSubview:kHolder];
-
- // y += 40; 隐藏上一行
- UIButton* btn = [[UIButton alloc] initWithFrame:CGRectMake(0, y, kSize.width, 40)];
- [btn setTitle:@"查看报名点" textColor:defGreen font:NormalFont fotState:UIControlStateNormal];
- [btn addTarget:self action:@selector(seeMoreSchools) forControlEvents:UIControlEventTouchUpInside];
- btn.backgroundColor = [UIColor whiteColor];
- [btn setBoardWid:.5 Color:KlineColor];
- // [scroll addSubview:btn];
- footerBtn = btn;
- btnY = footerBtn.y;
-
- h = (_schools.count > 6 ? 6 : _schools.count)* [SchCell cellHeight];
- [scroll setContentSize:CGSizeMake(0,_tableView.y+ h)];
- }
- -(void)btnClick:(UIButton*)sender
- {
- // NSLog(@"btn%d click",(int)sender.tag);
- switch (sender.tag) {
- case 0:
- myDelegate.url = @"报名须知;registerNeed";
- [self gotoTrafficVC];
- break;
- case 1:
- myDelegate.url = @"学车流程;学车流程";
- [self gotoTrafficVC];
- break;
- case 2:
- myDelegate.url = @"体检须知;体检须知";
- [self gotoTrafficVC];
- break;
- case 3:
- {
- GuideVC* vc = [[GuideVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- break;
-
- default:
- break;
- }
- }
- -(void)seeMoreSchools
- {
- // self.tabBarController.selectedIndex = 2;
- NeighbouringVC *vc = [[NeighbouringVC alloc]init];
- vc.isPushed = YES;
- [self navPushHideTabbarToVC:vc];
- }
- -(void)gotoTrafficVC
- {
- TrafficRulesViewController* vc = [[TrafficRulesViewController alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- #pragma mark - tableView
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return _schools.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- SchCell* cell = [SchCell cellWithTableView:tableView];
- NSInteger row = indexPath.row;
- id obj = _schools[row];
- cell.school = obj;
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- SchDetailVC* vc = [[SchDetailVC alloc] init];
- NSDictionary *dic = schArray[indexPath.row];
- vc.schoolId = dic[@"id"];
- [self.parentViewController navPushHideTabbarToVC:vc];
- }
- #pragma mark - service
- /**耗时操作!请使用aSyncGetSchInfoList来调用它。
- */
- - (void)getSchInfoList {
- if (_isFake) {
- return;
- }
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- static NSString *lng = @"";
- static NSString *lat = @"";
- dqbh = @"3500";
- if (myDelegate.locationArray.count > 2) {
-
- if ([lng isEqualToString:[myDelegate.locationArray firstObject]]) {
- return;
- }
-
- lng = [myDelegate.locationArray firstObject];
- lat = [myDelegate.locationArray lastObject];
- dqbh = myDelegate.locationArray[1];
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:dqbh,@"dqbh", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:lng,@"lng", nil]];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:lat,@"lat", nil]];
- ;
- NSString *method= @"getSchInfoListByTujian";//这个接口 沈阳没用
-
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
- //@lee 这里错误也要继续走 2018/2/7
- if(dict){
- if([dict[@"code"] isEqualToString:@"0"]){
- NSArray* body = dict[@"body"];
- if (body.count>0)
- {
- //预防 返回结果数为0.导致意外。
- schArray = [NSArray arrayWithArray:body];
- [_schools removeAllObjects];
- if (!_schools) {
- _schools = [NSMutableArray array];
- }
- for (NSDictionary* bodyItem in body) {
- id obj= [SchInfo schoolInfoWithDict:bodyItem];
- [_schools addObject:obj];
- }
- }
- }
- }
-
- [self showSchool];//里面会判断没有返回值的情况
-
- }];
- }
- -(void)showSchool
- {
- for (UIView *view in scroll.subviews) {
- if ([view isKindOfClass:[VowBar class]]) {
- [view removeFromSuperview];
- }
- }
-
- CGFloat h = _schools.count* 100;
- CGFloat zz = _schools.count==0?0:kHolder.height;
- footerBtn.y = btnY + h - zz;
-
- //加一项许愿
- VowBar *vowItem = [[VowBar alloc] initWithFrame:CGRectMake(0, footerBtn.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)];
- scroll.backgroundColor = backGroundColor;
-
- if (!_schools || _schools.count < 1){
- return;
- }
- kHolder.hidden = YES;
- _tableView.height = h;
- [_tableView reloadData];
- }
- -(void)vowClick:(UIButton *)btn
- {
- TopicesVC* vc = [[TopicesVC alloc] init];
- vc.type = @"1";
- if (btn.tag == 11)
- {
- vc.groupId = @"3";
- }else {
- vc.groupId = @"9";
- }
- [self navPushHideTabbarToVC:vc];
- }
- @end
|