RecordOfLearnVC.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. //点击后,要跳到topicesVC里面去。
  2. #import "RecordOfLearnVC.h"
  3. #import "TopicesVC.h"
  4. #import "RecordList.h"
  5. NSString* randomNum(int min,int off);
  6. @interface RecordOfLearnVC ()
  7. {
  8. NSArray *nums;
  9. }
  10. @end
  11. @implementation RecordOfLearnVC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. [self configNavigationBar];
  15. [self setTitle:@"学车记录"];
  16. // [self.view setBackgroundColor:[UIColor whiteColor]];
  17. [self.view setBackgroundColor:backGroundColor];
  18. self.navigationController.navigationBar.translucent = NO;
  19. nums = [NSArray array];
  20. [self getTopicCount];
  21. }
  22. - (void)didReceiveMemoryWarning {
  23. [super didReceiveMemoryWarning];
  24. // Dispose of any resources that can be recreated.
  25. }
  26. #pragma mark -
  27. -(void)myInit
  28. {
  29. //搞几个简单的按钮吧。、
  30. CGFloat x,y,w,h;
  31. NSInteger tag = 0;
  32. NSArray* titles = @[@"报名学员",@"科一学员",@"科二学员",@"科三学员",@"科四学员",@"下证学员"];
  33. w = h = (kSize.height - 60 - kNavOffSet)/4.0;
  34. x = (kSize.width - w*2)/3.0;
  35. y = w*.4;
  36. UIImageView* iv;
  37. UILabel* label;
  38. UIButton* btn;
  39. NSArray* images = @[@"learnRec0.png",@"learnRec1.png",@"learnRec2.png",
  40. @"learnRec3.png",@"learnRec4.png",@"learnRec5.png"];
  41. NSArray* colors = @[RGB_COLOR(251, 95, 69),defGreen,
  42. [UIColor purpleColor],[UIColor redColor],
  43. RGB_COLOR(35, 156, 255),RGB_COLOR(253, 167, 0)];
  44. //如果请求不到数据 就先显示假数据
  45. if (nums.count < 6)
  46. {
  47. nums = @[randomNum(10, 100),randomNum(40, 100),
  48. randomNum(20 , 20),randomNum(50, 50),
  49. randomNum(100 , 30),randomNum(50, 30)];
  50. }
  51. for (int i =0; i<titles.count; i++) {
  52. iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  53. btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
  54. [iv setImage:[UIImage imageNamed:images[i]]];
  55. [self.view addSubview:iv];
  56. [self.view addSubview:btn];
  57. [btn target:self];
  58. [btn setTag:tag++];
  59. label = [[UILabel alloc] initWithFrame:CGRectMake(0, iv.height/2.0 - h*.31, w, h*.26)];
  60. [label setTextAlignment:NSTextAlignmentCenter];
  61. [label setFont:[UIFont scaleSize:13]];
  62. [label setTextColor:subTitleColor];
  63. [label setText:titles[i]];
  64. [iv addSubview:label];
  65. label = [[UILabel alloc] initWithFrame:CGRectMake(0, iv.height/2.0 - h*.24/2, w, h*.24)];
  66. [label setTextAlignment:NSTextAlignmentCenter];
  67. [label setFont:[UIFont scaleSize:17*kSize.width/320.0]];
  68. [label setTextColor:colors[i]];
  69. [label setText:nums[i]];
  70. [iv addSubview:label];
  71. CGFloat x2 = label.width/2.0 + [label.text sizeForFont:NormalFont].width/2.0 + 15;
  72. label = [[UILabel alloc] initWithFrame:CGRectMake(x2, iv.height/2.0 - h*.24/2, 50, h*.24)];
  73. [label setText:@"人"];
  74. [label setFont:[UIFont scaleSize:12]];
  75. [label setTextColor:contentTextColor];
  76. [iv addSubview:label];
  77. label = [[UILabel alloc] initWithFrame:CGRectMake(0, iv.height/2.0 + h*.05, w, h*.26)];
  78. [label setTextAlignment:NSTextAlignmentCenter];
  79. [label setFont:[UIFont scaleSize:10*kSize.width/320.0]];
  80. [label setTextColor:[UIColor colorWithWhite:.01 alpha:.3]];
  81. [label setText:@"点击查看记录"];
  82. [iv addSubview:label];
  83. if ((i+1)%2 == 0) {//左到右
  84. x = (kSize.width - w*2)/3.0;
  85. y += w*1.1;
  86. }else{//右到左下
  87. x = kSize.width - w - (kSize.width - w*2)/3.0;
  88. }
  89. }
  90. //完全分隔开来
  91. x = 0;
  92. w = kSize.width;
  93. h = 60;
  94. y = kSize.height - h - kNavOffSet - kSafeAreaBottomHeight;
  95. UIView* vi;
  96. vi = [UIView new];
  97. [vi setFrame:CGRectMake(x, y, w, h)];
  98. [vi setBackgroundColor:backGroundColor];
  99. [self.view addSubview:vi];
  100. [vi addViewWithRect:CGRectMake(x, y, w, 1)];
  101. STButton* stBtn;
  102. y = 0;
  103. w = 80;
  104. x = (kSize.width - w)/2.0;
  105. stBtn = [STButton new];
  106. [stBtn setFrame:CGRectMake(x, y, w, h)];
  107. [vi addSubview:stBtn];
  108. [stBtn setImage:[UIImage imageNamed:@"community2.png"] withTitle:@"我要记录" Font:13 forState:UIControlStateNormal];
  109. [stBtn target:self];
  110. [stBtn setStyle:1];
  111. [stBtn setTag:tag++];
  112. [stBtn setTitleColor:contentTextColor forState:UIControlStateNormal];
  113. }
  114. -(void)getTopicCount
  115. {
  116. if (![Util connectedToNetWork]) {
  117. showMsgUnconnect();
  118. return;
  119. }
  120. NSMutableArray *array = [NSMutableArray arrayWithObjects:@"0",@"0",@"0",@"0",@"0",@"0",@"0", nil];
  121. NSMutableArray *arr=[NSMutableArray array];
  122. //传空表示获取所有
  123. [arr addPro:@"childGroupId" Value:[NSString stringWithFormat:@""]];
  124. NSString* method = @"getTopicInfosByChildGroupIdByType";
  125. [MBProgressHUD showLoadToView:self.view];
  126. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
  127. [MBProgressHUD hideHUDForView:self.view];
  128. if (!dict || [dict[@"code"] isEqualToString:@"1"])
  129. {
  130. [self myInit];
  131. return;
  132. }
  133. for (NSDictionary *dic in dict[@"body"]) {
  134. NSString *num = dic[@"NUM"];
  135. if (num.length == 0) {
  136. num = @"0";
  137. }
  138. if ([dic[@"ID"] intValue] < 7) {
  139. [array replaceObjectAtIndex:[dic[@"ID"] intValue] withObject:num];
  140. }
  141. }
  142. nums = array;
  143. [self myInit];
  144. }];
  145. }
  146. -(void)btnClick:(UIButton*)sender
  147. {
  148. //NSLog(@"btnClick %d",(int)sender.tag);
  149. NSInteger tag = sender.tag;
  150. if (6 == tag) {
  151. RecordList* vc = [RecordList new];
  152. [self navPushHideTabbarToVC:vc];
  153. return;
  154. }
  155. TopicesVC* vc = [[TopicesVC alloc] init];
  156. vc.type = @"2";
  157. if (0 == tag) {
  158. vc.groupId = @"18";
  159. }
  160. if (1 == tag) {
  161. vc.groupId = @"10";
  162. }
  163. if (2 == tag) {
  164. vc.groupId = @"12";
  165. }
  166. if (3 == tag) {
  167. vc.groupId = @"14";
  168. }
  169. if (4 == tag) {
  170. vc.groupId = @"16";
  171. }
  172. if (5 == tag) {
  173. vc.groupId = @"17";
  174. }
  175. vc.childID = [NSString stringWithFormat:@"%d",(int)tag];
  176. [self navPushHideTabbarToVC:vc];
  177. [self.parentViewController dismissViewControllerAnimated:YES completion:nil];
  178. }
  179. @end
  180. NSString* randomNum(int min,int off)
  181. {
  182. int num = arc4random()%off;
  183. return [NSString stringWithFormat:@"%d",min+num];
  184. }