// // TerminalScreenVC.m // JSJPCoach // // Created by apple on 2017/6/19. // Copyright © 2017年 Danson. All rights reserved. // #import "TerminalScreenVC.h" #import "PriceCell.h" #import "MinRescord.h" #import "SelectImgVC.h" #import "ViewController.h" #import "MyUINavigationController.h" @interface TerminalScreenVC () { UILabel *subjectLabel, *priceLabel; UIView *stuInfoView; UIView *setTrainInfoView; UIButton *setTrainInfoBtn; UILabel *stuNamelabel; //当前培训信息 UILabel *allTimeLabel, *valueTimeLabel, *invalidTimeLabel, *waitTimeLabel, *mileAndSpeedLabel; NSTimer *timer; NSTimer *preTimer; UIButton *keErBtn, *keSanBtn; UITableView *priceTableView; UITableViewCell *priceCell; NSArray *moneyArr; NSString *keMuString; NSString *priceString; NSDictionary *dataDic; } @end @implementation TerminalScreenVC - (void)viewDidLoad { [super viewDidLoad]; if (_isNotification == YES){ //推送状态 要将根视图变回去 UIBarButtonItem* backBtn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(dismissNavgation)]; [backBtn setTintColor:defGreen]; // self.navigationController.navigationBar.translucent = NO; [self.navigationItem setLeftBarButtonItem:backBtn]; } UIImageView *backImageView = [[UIImageView alloc] initWithFrame:kFrame]; backImageView.image = [UIImage imageNamed:@"bgImage"]; [self.view addSubview:backImageView]; //带教科目&价格 CGFloat y = kNavOffSet + 30; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, y, kSize.width - 40, 30)]; [label setText:@"带教科目:未设置" Font:Font18 TextColor:newTitleColor]; [self.view addSubview:label]; subjectLabel = label; y += 30; label = [[UILabel alloc] initWithFrame:CGRectMake(20, y, kSize.width - 40, 30)]; [label setText:@"带教价格:未设置" Font:Font18 TextColor:newTitleColor]; [self.view addSubview:label]; priceLabel = label; y = kNavOffSet + 40; UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(kSize.width - 100, y, 80, 40)]; btn.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2]; [btn setTitle:@"设置科目" textColor:defGreen font:Font18 fotState:UIControlStateNormal]; [btn borderColor:defGreen width:1 cornorRadios:5]; [btn target:self Tag:-1]; [self.view addSubview:btn]; setTrainInfoBtn = btn; //学员info stuInfoView = [[UIView alloc] initWithFrame:CGRectMake(0, kNavOffSet + 100, kSize.width, kSize.height - kNavOffSet - 100)]; [self.view addSubview:stuInfoView]; label = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, kSize.width - 40, 50)]; [label setText:@"暂未查询到正在带教学员!" Font:Font18 TextColor:newTitleColor]; [stuInfoView addSubview:label]; //设置带教info CGFloat x, w, h; x = 20; y = kNavOffSet + 110; w = kSize.width - 2*x; h = kSize.height - y - kSize.height/6.0; setTrainInfoView = [[UIView alloc] setxywh]; setTrainInfoView.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2]; [self.view addSubview:setTrainInfoView]; y = 10; w -= 2*x; h = 40; label = [[UILabel alloc] setxywh]; [label setText:@"设置培训信息" Font:Font17 TextColor:[UIColor whiteColor] Alignment:NSTextAlignmentCenter]; [setTrainInfoView addSubview:label]; [label addViewWithRect:CGRectMake(x + 30, y + 19, w/2.0 - 100, 1) Color:[UIColor colorWithWhite:.7 alpha:.5]]; [label addViewWithRect:CGRectMake(kSize.width/2.0 + 50, y + 19, w/2.0 - 100, 1) Color:[UIColor colorWithWhite:.7 alpha:.5]]; x = 10; y += h + 20; w = (setTrainInfoView.width - 2*x)/3.0; h = 30; label = [[UILabel alloc] setxywh]; [label setText:@"培训科目:" Font:Font17 TextColor:newTitleColor Alignment:NSTextAlignmentLeft]; [setTrainInfoView addSubview:label]; x += w; keMuString = @"2"; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = setDIYFrame; [button setImage:[UIImage imageNamed:@"selectAll"] Tit:@"科目二" Font:Font16 State:UIControlStateNormal]; [button setImage:[UIImage imageNamed:@"selectedAll"] forState:UIControlStateSelected]; [button setTitleColor:newTitleColor forState:UIControlStateNormal]; [button setTitleColor:defGreen forState:UIControlStateSelected]; [button target:self Tag:2]; [setTrainInfoView addSubview:button]; button.selected = YES; keErBtn = button; x += w; button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = setDIYFrame; [button setImage:[UIImage imageNamed:@"selectAll"] Tit:@"科目三" Font:Font16 State:UIControlStateNormal]; [button setImage:[UIImage imageNamed:@"selectedAll"] forState:UIControlStateSelected]; [button setTitleColor:newTitleColor forState:UIControlStateNormal]; [button setTitleColor:defGreen forState:UIControlStateSelected]; [button target:self Tag:3]; [setTrainInfoView addSubview:button]; keSanBtn = button; x = 10; y += h + 20; w = setTrainInfoView.width - 2*x; label = [[UILabel alloc] setxywh]; [label setText:@"培训价格:" Font:Font17 TextColor:newTitleColor Alignment:NSTextAlignmentLeft]; [setTrainInfoView addSubview:label]; [label addViewWithRect:CGRectMake(x, y+h, w, 1) Color:backGroundColor]; y += h + 1; h = setTrainInfoView.height - y; priceString = @"免费"; UITableView *tableView = [[UITableView alloc] initWithFrame:setDIYFrame style:UITableViewStyleGrouped]; tableView.backgroundColor = [UIColor clearColor]; tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLineEtched; tableView.delegate = self; tableView.dataSource = self; tableView.estimatedSectionHeaderHeight = 0; tableView.estimatedSectionFooterHeight = 0; [setTrainInfoView addSubview:tableView]; priceTableView = tableView; setTrainInfoView.hidden = YES; moneyArr = [NSArray array]; [self getStudentTrainInfos]; [self getTrainPrice]; } -(void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; if (timer) { [timer invalidate]; timer = nil; } if (preTimer) { [preTimer invalidate]; preTimer = nil; } } -(void)dismissNavgation { //推送过来 返回主页面 不晓得能不能行--推送 待测试 dansonmark ViewController *vc = [ViewController new]; MyUINavigationController *nav = [[MyUINavigationController alloc] initWithRootViewController:vc]; [UIApplication sharedApplication].delegate.window.rootViewController = nav; } - (void)loadStudentInfoWithDic:(NSDictionary *)dic { //这里还没有生成展示学员信息的控件 或者已换学员带教 重新布局 /* body = { HEADIMG = "http://image.jppt.com.cn/tms/student/201703/14897144128021583.jpg"; STATE = 2; STUNAME = "\U6768\U4e3d\U4e3d"; SCHOOLNAME = "\U798f\U5efa\U6781\U901f\U9a7e\U57f9\U6d4b\U8bd5\U9a7e\U6821"; IDCARD = 350881199205290949; PHONE = 13235006144; ONE = 720; 科目一已完成学时 ONESEND = 0; ONESTATUS = 1; TWO = 18716; TWOSEND = 0; TWOSTATUS = 1; THREE = 0; THREESEND = 0; THREESTATUS = 0; FOUR = 0; FOURSEND = 0; FOURSTATUS = 0; TRAINTYPE = C1;//培训车型 TOTALMILE = 0;//总里程 noVaildTime = 43;//无效学时 notAuditTime = 0;//未审核学时 totalTime = 1;//总时长 vaildTime = 0;//有效学时 subject = 2; AVGSPEED = 0;//平均速度 }; */ for (UIView *view in stuInfoView.subviews) { [view removeFromSuperview]; } subjectLabel.text = [NSString stringWithFormat:@"带教科目:%@",[dic[@"STATE"] isEqualToString:@"2"]?@"科目二":@"科目三"]; priceLabel.text = [NSString stringWithFormat:@"带教价格:已设置"]; UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:stuInfoView.bounds]; [stuInfoView addSubview:scroll]; CGFloat x, y, w, h; x = 20; y = 10; w = 70; h = 80; UIImageView *headerImg = [[UIImageView alloc] setxywh]; headerImg.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2]; [headerImg borderColor:[UIColor whiteColor] width:.3 cornorRadios:3]; [headerImg sd_setImageWithURL:[NSURL URLWithString:dic[@"HEADIMG"]] placeholderImage:[UIImage imageNamed:@"noHeadImg"]]; [scroll addSubview:headerImg]; x += w + 10; w = kSize.width - x - 20; h = 30; //姓名 UILabel *label = [[UILabel alloc] setxywh]; [label setText:[dic[@"STATE"] isEqualToString:@"2"]?@"科目二学员":@"科目三学员" Font:Font17 TextColor:newSubTitleColor Alignment:NSTextAlignmentRight]; [scroll addSubview:label]; stuNamelabel = label; //科目 label = [[UILabel alloc] setxywh]; [label setText:dic[@"STUNAME"] Font:Font21 TextColor:newTitleColor]; [scroll addSubview:label]; y += h; h = 25; //电话 label = [[UILabel alloc] setxywh]; [label setText:dic[@"PHONE"] Font:Font18 TextColor:newSubTitleColor]; [scroll addSubview:label]; y += h; //驾校 label = [[UILabel alloc] setxywh]; [label setText:dic[@"SCHOOLNAME"] Font:Font18 TextColor:newSubTitleColor]; [scroll addSubview:label]; y += h + 20; x = 15; w = kSize.width - 2*x; h = 30; label = [[UILabel alloc] setxywh]; [label setText:@"学员学时信息" Font:Font18 TextColor:newTitleColor Alignment:NSTextAlignmentCenter]; [scroll addSubview:label]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem]; btn.backgroundColor = [UIColor brownColor]; btn.frame = CGRectMake(kSize.width - 120 - x, y, 120, h); btn.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2]; [btn setTitle:@"查看训练照片" textColor:defGreen font:Font18 fotState:UIControlStateNormal]; // [btn borderColor:defGreen width:1 cornorRadios:5]; [btn target:self Tag:101]; [scroll addSubview:btn]; y += h + 5; [label addViewWithRect:CGRectMake(x, y, w, 1) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x, y + 50, w, 1) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x, y + 75, w, 1) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x, y + 100, w, 1) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x, y + 125, w, 1) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x, y + 150, w, 1) Color:newSubTitleColor]; w = w/4.0; [label addViewWithRect:CGRectMake(x, y, 1, 150) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x + w, y, 1, 150) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x + 2*w, y, 1, 150) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x + 3*w, y, 1, 150) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x + 4*w, y, 1, 150) Color:newSubTitleColor]; NSArray *titleArray = @[@"培训阶段",@"当前完成学时",@"学时审核状态",@"学时是否已传输"]; for (int i = 0; i < titleArray.count; i ++) { label = [[UILabel alloc] initWithFrame:CGRectMake(x + 5 + i*w, y + 1, w - 10, 49)]; [label setText:titleArray[i] Font:Font17 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter]; label.numberOfLines = 0; [scroll addSubview:label]; } y += 50; NSArray *subjectArray = @[@"第一阶段",@"第二阶段",@"第三阶段",@"第四阶段"]; NSArray *trainTimeArray = @[dic[@"ONE"],dic[@"TWO"],dic[@"THREE"],dic[@"FOUR"]]; NSArray *stateArray = @[dic[@"ONESTATUS"],dic[@"TWOSTATUS"],dic[@"THREESTATUS"],dic[@"FOURSTATUS"]]; NSArray *sendArray = @[dic[@"ONESEND"],dic[@"TWOSEND"],dic[@"THREESEND"],dic[@"FOURSEND"]]; for (int i = 0; i < subjectArray.count; i ++) { //阶段 label = [[UILabel alloc] initWithFrame:CGRectMake(x, y + 1 + i*25, w, 24)]; [label setText:subjectArray[i] Font:Font16 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter]; [scroll addSubview:label]; //学时 label = [[UILabel alloc] initWithFrame:CGRectMake(x + w, y + 1 + i*25, w, 24)]; int time = [trainTimeArray[i] intValue]; int hour = time/60; int min = time%60; NSString *timeString = @""; if (hour == 0) { timeString = [NSString stringWithFormat:@"%d分钟",min]; }else{ timeString = [NSString stringWithFormat:@"%d时%d分",hour,min]; } [label setText:timeString Font:Font16 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter]; [scroll addSubview:label]; //审核状态 label = [[UILabel alloc] initWithFrame:CGRectMake(x + 2*w, y + 1 + i*25, w, 24)]; NSString *stateString = stateArray[i]; switch ([stateString intValue]) { case 0: stateString = @"不允许送审"; break; case 1: stateString = @"允许送审"; break; case 2: stateString = @"审核通过"; break; case 3: stateString = @"退回"; break; case 4: stateString = @"待审核"; break; default: stateString = @""; break; } [label setText:stateString Font:Font16 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter]; [scroll addSubview:label]; //是否传至交警 label = [[UILabel alloc] initWithFrame:CGRectMake(x + 3*w, y + 1 + i*25, w, 24)]; NSString *sendString = sendArray[i]; switch ([sendString intValue]) { case 0: sendString = @"未传输"; break; case 1: sendString = @"已传至运管"; break; case 2: sendString = @"已传至交警"; break; default: sendString = @""; break; } [label setText:sendString Font:Font16 TextColor:newSubTitleColor Alignment:NSTextAlignmentCenter]; [scroll addSubview:label]; } x = 15; y += 100 + 20; w = kSize.width - 2*x; h = 30; label = [[UILabel alloc] setxywh]; [label setText:@"当前培训信息" Font:Font18 TextColor:newTitleColor Alignment:NSTextAlignmentCenter]; [scroll addSubview:label]; btn = [UIButton buttonWithType:UIButtonTypeSystem]; btn.backgroundColor = [UIColor brownColor]; btn.frame = CGRectMake(kSize.width-120-x, y, 120, h); btn.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2]; [btn setTitle:@"查看分钟学时" textColor:defGreen font:Font18 fotState:UIControlStateNormal]; // [btn borderColor:defGreen width:1 cornorRadios:5]; [btn target:self Tag:100]; [scroll addSubview:btn]; y += h+5; [label addViewWithRect:CGRectMake(x, y, w, 1) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x, y + 59, w, 1) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x, y, 1, 60) Color:newSubTitleColor]; [label addViewWithRect:CGRectMake(x + w, y, 1, 60) Color:newSubTitleColor]; w = w/4.0; h = 30; NSArray *titles = @[@"总时长",@"有效时长",@"无效时长",@"待审核"]; NSArray *textArray = @[dic[@"totalTime"],dic[@"vaildTime"],dic[@"noVaildTime"],dic[@"notAuditTime"]]; NSArray *colors = @[newTitleColor,[UIColor greenColor],[UIColor redColor],defGreen]; NSMutableArray *labels = [NSMutableArray arrayWithCapacity:4]; for (int i = 0; i < titles.count; i ++) { label = [[UILabel alloc] initWithFrame:CGRectMake(x + i*w, y, w, h)]; label.backgroundColor = [UIColor colorWithWhite:.7 alpha:.2]; [label setText:titles[i] Font:Font16 TextColor:newTitleColor Alignment:NSTextAlignmentCenter]; [scroll addSubview:label]; label = [[UILabel alloc] initWithFrame:CGRectMake(x + i*w, y + h, w, h)]; [label setText:[NSString stringWithFormat:@"%@分钟",textArray[i]] Font:Font16 TextColor:colors[i] Alignment:NSTextAlignmentCenter]; [scroll addSubview:label]; [labels addObject:label]; if (i != 0) { [label addViewWithRect:CGRectMake(x + i*w, y, 1, 2*h) Color:newSubTitleColor]; } } allTimeLabel = labels[0]; valueTimeLabel = labels[1]; invalidTimeLabel = labels[2]; waitTimeLabel = labels[3]; x = 20; y += 70; w = kSize.width - 2*x; h = 60; label = [[UILabel alloc] setxywh]; [label setText:[NSString stringWithFormat:@"当前培训过程中,车辆平均速度为%.2fKm/h,行驶总里程为%.2fKm,有效学时占比为%.1f%%",[dic[@"AVGSPEED"] floatValue],[dic[@"TOTALMILE"] floatValue], ([dic[@"vaildTime"] floatValue] == 0 || [dic[@"totalTime"] floatValue] == 0)? 0 : [dic[@"vaildTime"] floatValue]/[dic[@"totalTime"] floatValue]*100] Font:Font17 TextColor:newTitleColor]; label.numberOfLines = 0; [scroll addSubview:label]; mileAndSpeedLabel = label; [scroll setContentSize:CGSizeMake(stuInfoView.width, CGRectGetMaxY(mileAndSpeedLabel.frame) + 50)]; } - (void)setStudentInfoWithDic:(NSDictionary *)dic { //这里已经有展示学员信息的控件了 直接填入数据 allTimeLabel.text = [NSString stringWithFormat:@"%@分钟",dic[@"totalTime"]]; valueTimeLabel.text = [NSString stringWithFormat:@"%@分钟",dic[@"vaildTime"]]; invalidTimeLabel.text = [NSString stringWithFormat:@"%@分钟",dic[@"noVaildTime"]]; waitTimeLabel.text = [NSString stringWithFormat:@"%@分钟",dic[@"notAuditTime"]]; mileAndSpeedLabel.text = [NSString stringWithFormat:@"当前培训过程中,车辆平均速度为%.2fKm/h,行驶总里程为%.2fKm,有效学时占比为%.1f%%",[dic[@"AVGSPEED"] floatValue],[dic[@"TOTALMILE"] floatValue],([dic[@"vaildTime"] floatValue] == 0 || [dic[@"totalTime"] floatValue] == 0)? 0 : [dic[@"vaildTime"] floatValue]/[dic[@"totalTime"] floatValue]*100]; } - (void)btnClick:(UIButton *)sender { if (sender.tag == -1) { //正在调接口 现在还不能请求 ShowMsg(@"数据加载中,请稍后!"); return; } if (sender.tag == -2) { //正在带教学员 不能更改价格信息 ShowMsg(@"终端正在带教学员,不能更改培训信息!"); return; } if (sender.tag == 1) { setTrainInfoView.hidden = !setTrainInfoView.isHidden; stuInfoView.hidden = !stuInfoView.isHidden; if (setTrainInfoView.isHidden) {//点击完成按钮 设置价格科目 [setTrainInfoBtn setTitle:@"设置" forState:UIControlStateNormal]; [self setDevTrainSubjectAndMoney]; }else { [setTrainInfoBtn setTitle:@"完成" forState:UIControlStateNormal]; } return; } if (sender.tag == 2) { if (keSanBtn.isSelected == YES) { keSanBtn.selected = NO; } keErBtn.selected = YES; keMuString = @"2"; subjectLabel.text = @"带教科目:科目二"; return; } if (sender.tag == 3) { if (keErBtn.isSelected == YES) { keErBtn.selected = NO; } keSanBtn.selected = YES; keMuString = @"3"; subjectLabel.text = @"带教科目:科目三"; return; } //查看分钟学时 if (sender.tag == 100) { MinRescord *vc = [[MinRescord alloc]init]; vc.stuID = dataDic[@"stuId"]; vc.classId = dataDic[@"classId"]; [self.navigationController pushViewController:vc animated:YES]; } //查看训练照片 if (sender.tag == 101) { SelectImgVC *vc = [[SelectImgVC alloc] init]; vc.stuDic = dataDic; [self.navigationController pushViewController:vc animated:YES]; } } #pragma mark tableView -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return moneyArr.count + 1; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //表示是价格选择的表 PriceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"priceCell"]; if (cell == nil) { cell = [[[NSBundle mainBundle] loadNibNamed:@"PriceCell" owner:nil options:nil] firstObject]; cell.backgroundColor = [UIColor clearColor]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } NSDictionary *dic; if (indexPath.row == 0) { NSString *carType = @""; if (moneyArr.count > 0) { carType = [[moneyArr firstObject] objectForKey:@"CSI_VEHICLETYPE"]; } dic = @{@"CSI_PRICE":@"免费",@"CSI_VEHICLETYPE":carType,@"CSI_TRAINNINGTIME":@"0"}; }else{ dic = moneyArr[indexPath.row - 1]; } [cell.indexLabel setText:[NSString stringWithFormat:@"%d、",(int)indexPath.row + 1] Font:Font16 TextColor:newTitleColor Alignment:NSTextAlignmentRight]; cell.priceDic = dic; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0) { priceString = @"免费"; }else{ NSDictionary *dic = moneyArr[indexPath.row - 1]; priceString = dic[@"CSI_PRICE"]; } priceLabel.text = [NSString stringWithFormat:@"带教价格:%@",priceString]; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; [cell.textLabel setTextColor:defGreen]; if (priceCell) { [priceCell.textLabel setTextColor:newTitleColor]; } priceCell = cell; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 0.1; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 0.1; } #pragma mark 数据请求 - (void)getStudentTrainInfos { [LoadingView showHUD]; if (![Util connectedToNetWork]) { showMsgUnconnect(); setTrainInfoBtn.tag = 1; return; } //查询学员签到列表 科目传空 查全部 NSMutableArray *arr = [NSMutableArray array]; [arr addPro:@"coachId" Value:defUser.userDict[@"outId"]]; [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]]; NSString* method = @"getStudentTrainInfos"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) { RemoveHUD(); setTrainInfoBtn.tag = 1; if (!root) { return ; } if ([root[@"code"] isEqualToString:@"1"]) { //没有带教学员0.0 for (UIView *view in stuInfoView.subviews) { [view removeFromSuperview]; } UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, kSize.width - 40, 50)]; [label setText:@"暂未查询到正在带教学员!" Font:Font18 TextColor:newTitleColor]; [stuInfoView addSubview:label]; if (preTimer == nil) { preTimer = [NSTimer scheduledTimerWithTimeInterval:7 target:self selector:@selector(getStudentTrainInfos) userInfo:nil repeats:YES]; } if (timer) { [timer invalidate]; timer = nil; } return; } dataDic = root[@"body"]; //生成学员信息 setTrainInfoBtn.tag = -2; if (stuInfoView.subviews.count < 2) { [self loadStudentInfoWithDic:root[@"body"]]; }else{ if (![[root[@"body"] objectForKey:@"STUNAME"] isEqualToString:stuNamelabel.text]) { [self loadStudentInfoWithDic:root[@"body"]]; }else { [self setStudentInfoWithDic:root[@"body"]]; } } if (preTimer) { [preTimer invalidate]; preTimer = nil; } if (timer == nil) { timer = [NSTimer scheduledTimerWithTimeInterval:70 target:self selector:@selector(getStudentTrainInfos) userInfo:nil repeats:YES]; } }]; } //获取价格 -(void)getTrainPrice { [priceTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop]; NSMutableArray *arr=[NSMutableArray array]; [arr addPro:@"schoolId" Value:defUser.userDict[@"jxbh"]]; [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]]; NSString* method = @"getPrice"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) { //NSLog(@"获取价格-->%@->%@",arr,dict); if (!dict) { return ; } if ( [dict[@"code"] isEqualToString:@"1"]) { return ; } moneyArr = dict[@"body"]; [priceTableView reloadData]; [priceTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop]; }]; } //设置价格 -(void)setDevTrainSubjectAndMoney { NSMutableArray *arr=[NSMutableArray array]; [arr addPro:@"coachId" Value:defUser.userDict[@"jxbh"]]; [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]]; [arr addPro:@"isPay" Value:[priceString isEqualToString:@"免费"]?@"0":@"1"]; [arr addPro:@"money" Value:priceString]; NSString* method = @"setDevTrainSubjectAndMoney"; [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) { if (!dict) { ShowMsg(@"设置培训信息失败,请重试!"); subjectLabel.text = @"带教科目:未设置"; priceLabel.text = @"带教价格:未设置"; return ; } if ( [dict[@"code"] isEqualToString:@"1"]) { ShowMsg(dict[@"body"]); subjectLabel.text = @"带教科目:未设置"; priceLabel.text = @"带教价格:未设置"; return ; } ShowMsg(@"培训信息设置成功!"); }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end