123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 |
- //
- // 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 ()<UITableViewDelegate,UITableViewDataSource>
- {
- 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
|