123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- //点击后,要跳到topicesVC里面去。
- #import "RecordOfLearnVC.h"
- #import "TopicesVC.h"
- #import "RecordList.h"
- NSString* randomNum(int min,int off);
- @interface RecordOfLearnVC ()
- {
- NSArray *nums;
- }
- @end
- @implementation RecordOfLearnVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self configNavigationBar];
- [self setTitle:@"学车记录"];
- // [self.view setBackgroundColor:[UIColor whiteColor]];
- [self.view setBackgroundColor:backGroundColor];
- self.navigationController.navigationBar.translucent = NO;
-
- nums = [NSArray array];
- [self getTopicCount];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- #pragma mark -
- -(void)myInit
- {
- //搞几个简单的按钮吧。、
- CGFloat x,y,w,h;
- NSInteger tag = 0;
- NSArray* titles = @[@"报名学员",@"科一学员",@"科二学员",@"科三学员",@"科四学员",@"下证学员"];
-
- w = h = (kSize.height - 60 - kNavOffSet)/4.0;
- x = (kSize.width - w*2)/3.0;
- y = w*.4;
- UIImageView* iv;
- UILabel* label;
- UIButton* btn;
- NSArray* images = @[@"learnRec0.png",@"learnRec1.png",@"learnRec2.png",
- @"learnRec3.png",@"learnRec4.png",@"learnRec5.png"];
- NSArray* colors = @[RGB_COLOR(251, 95, 69),defGreen,
- [UIColor purpleColor],[UIColor redColor],
- RGB_COLOR(35, 156, 255),RGB_COLOR(253, 167, 0)];
-
- //如果请求不到数据 就先显示假数据
- if (nums.count < 6)
- {
- nums = @[randomNum(10, 100),randomNum(40, 100),
- randomNum(20 , 20),randomNum(50, 50),
- randomNum(100 , 30),randomNum(50, 30)];
- }
-
- for (int i =0; i<titles.count; i++) {
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [iv setImage:[UIImage imageNamed:images[i]]];
- [self.view addSubview:iv];
- [self.view addSubview:btn];
- [btn target:self];
- [btn setTag:tag++];
-
- label = [[UILabel alloc] initWithFrame:CGRectMake(0, iv.height/2.0 - h*.31, w, h*.26)];
- [label setTextAlignment:NSTextAlignmentCenter];
- [label setFont:[UIFont scaleSize:13]];
- [label setTextColor:subTitleColor];
- [label setText:titles[i]];
- [iv addSubview:label];
- label = [[UILabel alloc] initWithFrame:CGRectMake(0, iv.height/2.0 - h*.24/2, w, h*.24)];
- [label setTextAlignment:NSTextAlignmentCenter];
- [label setFont:[UIFont scaleSize:17*kSize.width/320.0]];
- [label setTextColor:colors[i]];
- [label setText:nums[i]];
- [iv addSubview:label];
-
- CGFloat x2 = label.width/2.0 + [label.text sizeForFont:NormalFont].width/2.0 + 15;
- label = [[UILabel alloc] initWithFrame:CGRectMake(x2, iv.height/2.0 - h*.24/2, 50, h*.24)];
- [label setText:@"人"];
- [label setFont:[UIFont scaleSize:12]];
- [label setTextColor:contentTextColor];
- [iv addSubview:label];
-
- label = [[UILabel alloc] initWithFrame:CGRectMake(0, iv.height/2.0 + h*.05, w, h*.26)];
- [label setTextAlignment:NSTextAlignmentCenter];
- [label setFont:[UIFont scaleSize:10*kSize.width/320.0]];
- [label setTextColor:[UIColor colorWithWhite:.01 alpha:.3]];
- [label setText:@"点击查看记录"];
- [iv addSubview:label];
-
- if ((i+1)%2 == 0) {//左到右
- x = (kSize.width - w*2)/3.0;
- y += w*1.1;
- }else{//右到左下
- x = kSize.width - w - (kSize.width - w*2)/3.0;
- }
- }
-
- //完全分隔开来
- x = 0;
- w = kSize.width;
- h = 60;
- y = kSize.height - h - kNavOffSet - kSafeAreaBottomHeight;
- UIView* vi;
- vi = [UIView new];
- [vi setFrame:CGRectMake(x, y, w, h)];
- [vi setBackgroundColor:backGroundColor];
- [self.view addSubview:vi];
- [vi addViewWithRect:CGRectMake(x, y, w, 1)];
-
-
- STButton* stBtn;
- y = 0;
- w = 80;
- x = (kSize.width - w)/2.0;
- stBtn = [STButton new];
- [stBtn setFrame:CGRectMake(x, y, w, h)];
- [vi addSubview:stBtn];
- [stBtn setImage:[UIImage imageNamed:@"community2.png"] withTitle:@"我要记录" Font:13 forState:UIControlStateNormal];
- [stBtn target:self];
- [stBtn setStyle:1];
- [stBtn setTag:tag++];
- [stBtn setTitleColor:contentTextColor forState:UIControlStateNormal];
- }
- -(void)getTopicCount
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *array = [NSMutableArray arrayWithObjects:@"0",@"0",@"0",@"0",@"0",@"0",@"0", nil];
- NSMutableArray *arr=[NSMutableArray array];
- //传空表示获取所有
- [arr addPro:@"childGroupId" Value:[NSString stringWithFormat:@""]];
- NSString* method = @"getTopicInfosByChildGroupIdByType";
-
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
-
- [MBProgressHUD hideHUDForView:self.view];
-
- if (!dict || [dict[@"code"] isEqualToString:@"1"])
- {
- [self myInit];
- return;
- }
-
- for (NSDictionary *dic in dict[@"body"]) {
-
- NSString *num = dic[@"NUM"];
- if (num.length == 0) {
- num = @"0";
- }
-
- if ([dic[@"ID"] intValue] < 7) {
- [array replaceObjectAtIndex:[dic[@"ID"] intValue] withObject:num];
- }
- }
-
- nums = array;
-
- [self myInit];
- }];
- }
- -(void)btnClick:(UIButton*)sender
- {
- //NSLog(@"btnClick %d",(int)sender.tag);
- NSInteger tag = sender.tag;
- if (6 == tag) {
- RecordList* vc = [RecordList new];
- [self navPushHideTabbarToVC:vc];
- return;
- }
-
- TopicesVC* vc = [[TopicesVC alloc] init];
- vc.type = @"2";
- if (0 == tag) {
- vc.groupId = @"18";
- }
- if (1 == tag) {
- vc.groupId = @"10";
- }
- if (2 == tag) {
- vc.groupId = @"12";
- }
- if (3 == tag) {
- vc.groupId = @"14";
- }
- if (4 == tag) {
- vc.groupId = @"16";
- }
- if (5 == tag) {
- vc.groupId = @"17";
- }
-
- vc.childID = [NSString stringWithFormat:@"%d",(int)tag];
-
- [self navPushHideTabbarToVC:vc];
- [self.parentViewController dismissViewControllerAnimated:YES completion:nil];
- }
- @end
- NSString* randomNum(int min,int off)
- {
- int num = arc4random()%off;
- return [NSString stringWithFormat:@"%d",min+num];
- }
|