123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- //
- // ListVC.m
- // jiaPei
- //
- // Created by apple on 15/11/4.
- // Copyright (c) 2015年 JCZ. All rights reserved.
- //
- #import "ListVC.h"
- @interface ListVC ()
- @property (nonatomic, readwrite, copy) NSArray *chapterListArr;
- @end
- @implementation ListVC
- #pragma mark -
- - (void)viewDidLoad {
- @weakify(self)
- [super viewDidLoad];
- [self configNavBar];
- [[RQ_HTTP_Service getChapterList] subscribeNext:^(NSArray *chapterListArr) {
- @strongify(self)
- if ([chapterListArr isKindOfClass:[NSArray class]]) {
- if (chapterListArr.count > 0) {
- self.chapterListArr = chapterListArr;
- }
- }
- } error:^(NSError * _Nullable error) {
-
- } completed:^{
- @strongify(self)
- [self configTable];
- }];
-
-
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- #pragma mark -
- -(void)configNavBar
- {
- self.view.backgroundColor = [UIColor whiteColor];
- [self configNavigationBar];
- [self setTitle:@"章节练习"];
- }
- - (void)btnClick:(UIView*)sender {
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- [self gotoExerciseVCWithChapterName:self.titleList[sender.tag]];
- } else {
- if ([defUser.car_type isEqualToString:@"2"]) {
- NSString *chapter = [self.titleList[sender.tag] objectForKey:@"chapter"];
- myDelegate.where = [NSString stringWithFormat:@"chapter = %@",chapter];
- [self gotoExerciseVC];
- } else {
- [self gotoExerciseVCWithChapterName:self.titleList[sender.tag]];
- }
- }
- }
- -(void)gotoExerciseVCWithChapterName:(NSString *)chapterName{
- ExerciseVC* vc = [[ExerciseVC alloc] init];
- vc.chapterName = chapterName;
- [self navPushHideTabbarToVC:vc];
- }
- -(void)configTable
- {
- NSString *string = myDelegate.subject;
- if ([defUser.car_type isEqualToString:@"1"] || [defUser.car_type isEqualToString:@"2"] || [defUser.car_type isEqualToString:@"3"] || [defUser.car_type isEqualToString:@"4"] || [defUser.car_type isEqualToString:@"5"] || [defUser.car_type isEqualToString:@"6"])
- {
- string = @"1";
- }
- NSString *cartype = defUser.car_type;
-
- if ([defUser.car_type isEqualToString:@"C1"]) {
- cartype = @"C1,C2,C3";
- }
- if ([defUser.car_type isEqualToString:@"A2"]) {
- cartype = @"A2,B2";
- }
- if ([defUser.car_type isEqualToString:@"A1"]) {
- cartype = @"A1,A3,B1";
- }
-
- //如果是科四 除了摩托车 都是C1
- if ([string isEqualToString:@"4"] && ![defUser.car_type isEqualToString:@"D"]) {
- cartype = @"C1,C2,C3";
- }
- NSString *sql;
- NSArray *array;
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- array = [self.chapterListArr.rac_sequence.signal map:^id _Nullable(RQDictInfoModel * dictInfoModel) {
- return dictInfoModel.dictValue;
- }].toArray;
- } else {
- if ([defUser.car_type isEqualToString:@"2"]) {
- sql = [NSString stringWithFormat:@"select * from GZPT_EXAM_CYRY_CHAPTER"];
- array = [DB_Que_Helper queryGZPZ_EXAM_CYRYList:sql];
- } else {
- // sql=[NSString stringWithFormat:@"select * from chapter where cartype = '%@' and subject = '%@'",cartype,string];
- // array = [DB_Que_Helper queryList:sql];
- // array = [RQ_YDTQuestion_Module getChapterArr];
-
- array = [self.chapterListArr.rac_sequence.signal map:^id _Nullable(RQDictInfoModel * dictInfoModel) {
- return dictInfoModel.dictValue;
- }].toArray;
- }
- }
-
-
- self.titleList = [NSMutableArray arrayWithArray:array];
-
- UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:kFrame];
- scroll.height -= kNavOffSet;
- scroll.scrollEnabled = YES;
- [self.view addSubview:scroll];
-
- CGFloat btnX = 20;
- CGFloat btnY = 30 ;
- CGFloat btnW = kSize.width - btnX *2;
- CGFloat btnH = 50;
- CGFloat delY = 10;
-
- if (_titleList.count < 1) {
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(btnX, btnY, btnW, btnH)];
- [label setText:@"暂无章节目录" Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentCenter];
- label.backgroundColor = [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:.1];
- [scroll addSubview:label];
- }
- /**科目1的tag是 1-4
- **科目4的tag是 7-13
- */
- int tag = 0;
- int imgInd = 0;
-
- if (RQ_COMMON_MANAGER.YYXC_SERVICE_OPEN) {
- for (NSString* titleStr in _titleList)
- {
- CLButton* btn = [[CLButton alloc] initWithFrame:CGRectMake(btnX, btnY, btnW, btnH)];
- btn.tag = tag++;
- btnY = btnY + btnH + delY;
- btn.titleN = titleStr;
- btn.detailN = _countList[imgInd];
- btn.imgN = @"menu_order_normal_ico_f.png";
- btn.titleLabel.numberOfLines = 0;
- btn.backgroundColor = [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:.1];
- [scroll addSubview:btn];
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
-
- btn.layer.cornerRadius = 4;
- [btn.layer setMasksToBounds:YES];
- }
- } else {
-
- if ([defUser.car_type isEqualToString:@"2"]) {
- for (NSDictionary* dic in _titleList)
- {
- NSString *title = dic[@"title"];
- CLButton* btn = [[CLButton alloc] initWithFrame:CGRectMake(btnX, btnY, btnW, btnH)];
- btn.tag = tag++;
- btnY = btnY + btnH + delY;
- btn.titleN = title;
- btn.detailN = _countList[imgInd];
- btn.imgN = @"menu_order_normal_ico_f.png";
- btn.titleLabel.numberOfLines = 0;
- btn.backgroundColor = [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:.1];
- [scroll addSubview:btn];
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
-
- btn.layer.cornerRadius = 4;
- [btn.layer setMasksToBounds:YES];
- }
- } else {
- for (NSString* titleStr in _titleList)
- {
- CLButton* btn = [[CLButton alloc] initWithFrame:CGRectMake(btnX, btnY, btnW, btnH)];
- btn.tag = tag++;
- btnY = btnY + btnH + delY;
- btn.titleN = titleStr;
- btn.detailN = _countList[imgInd];
- btn.imgN = @"menu_order_normal_ico_f.png";
- btn.titleLabel.numberOfLines = 0;
- btn.backgroundColor = [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:.1];
- [scroll addSubview:btn];
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
-
- btn.layer.cornerRadius = 4;
- [btn.layer setMasksToBounds:YES];
- }
- }
-
- }
-
-
-
-
- scroll.contentSize = CGSizeMake(kSize.width, btnY + btnH +30);
- }
- -(void)gotoExerciseVC{
- ExerciseVC* vc = [[ExerciseVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- #pragma mark - LazyLoad
- - (NSArray *)chapterListArr {
- if (!_chapterListArr) {
- _chapterListArr = @[];
- }
- return _chapterListArr;
- }
- @end
|