123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715 |
- //
- // CoachPlanVC.m
- // jiaPei
- //
- // Created by apple on 16/3/25.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "CoachPlanVC.h"
- #import "HolderView.h"
- #import "CLWeeklyCalendarView.h"
- #import "PlanCollectionCell.h"
- #import "ApplyPlanStuListVC.h"
- #import "UIImageView+WebCache.h"
- @interface CoachPlanVC ()<CLWeeklyCalendarViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,UITableViewDelegate,UITableViewDataSource>
- {
- NSString *taskTime;
- NSArray *models;
- NSArray *coachsArray;
- NSMutableArray *mockDatas;
- CGFloat calendarY;
- NSIndexPath *lastIndex;
- NSString *coachNum;
- NSString *lackMoney;
-
- UICollectionView *mainCollection;
- HolderView *holderV;
- UILabel *nameLabel,*countLabel,*addressLabel;
-
- UITableView *stuListTV;
- NSArray *stuListArray;
- NSDictionary *stuDic;
-
-
- UIButton *applyPlanBtn;
- }
- @property (nonatomic, strong) CLWeeklyCalendarView *calendarView;
- //预约弹出框
- @property (nonatomic, strong) UIView *reserveBackView;
- @property (nonatomic, strong) UITextField *searchTF;
- @end
- @implementation CoachPlanVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- RemoveHUD();
- }
- -(void)myInit
- {
- [self setTitle:@"教练计划"];
- [self.view setBackgroundColor:KBackGroundColor];
- [self goBackByNavigation];
-
-
- //初始化数据容器
- mockDatas = [[NSMutableArray alloc] init];
- coachsArray = [NSArray array];
-
- CGFloat x,y,w,h,bd;
- x = bd = 10;
- y = 5;
- w = kSize.width - 20;
- h = 25;
- //上面显示的信息
- UILabel *label;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"当前计划信息:暂无" Font:Font18 TextColor:KTitleColor Alignment:NSTextAlignmentLeft];
- [self.view addSubview:label];
- nameLabel = label;
-
- y += h;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"场地信息:暂无" Font:Font18 TextColor:KTitleColor Alignment:NSTextAlignmentLeft];
- [self.view addSubview:label];
- addressLabel = label;
-
- y += h;
- h += bd;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"暂无预约人数信息" Font:Font17 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentLeft];
- label.numberOfLines = 0;
- [self.view addSubview:label];
- countLabel = label;
-
-
- //日历控件
- y += h;
- calendarY = y;
- [self.view addSubview:self.calendarView];
-
- y += self.calendarView.height;
- //因为Y是从64开始算的 即把64当做0 所以要有补偿
- h = kSize.height - y - kNavOffSet - 60;
- //用collection吧
- CGFloat width = (kSize.width - 45)/3.0;
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- [layout setItemSize:CGSizeMake(width, width)];
- [layout setSectionInset:UIEdgeInsetsMake(8, 10, 8, 10)];
-
- mainCollection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, y, kSize.width, h) collectionViewLayout:layout];
-
- mainCollection.backgroundColor = KBackGroundColor;
- mainCollection.delegate = self;
- mainCollection.dataSource = self;
- [self.view addSubview:mainCollection];
- [mainCollection addViewWithRect:CGRectMake(10, y + h, kSize.width - 20, 1)];
-
- [mainCollection registerNib:[UINib nibWithNibName:@"PlanCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"collection"];
-
-
- holderV = [[HolderView alloc] initWithFrame:mainCollection.frame];
- [self.view addSubview:holderV];
- [holderV setHidden:YES];
-
- //将日历放前边 防止被遮挡
- [self.view bringSubviewToFront:self.calendarView];
-
-
-
- x = 0;
- y += h + 1;
- w = kSize.width;
- h = 59;
- UIView *btnBar = [[UIView alloc] KSetxywh];
- btnBar.backgroundColor = kLineColor;
- [self.view addSubview:btnBar];
-
-
- x = 10;
- y = 5;
- w = kSize.width/2.0 - 20;
- h = 49;
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(x, y, w, h);
- [btn setTitle:@"预约" textColor:[UIColor whiteColor] font:20 fotState:UIControlStateNormal];
- btn.layer.masksToBounds = YES;
- btn.layer.cornerRadius = 10;
- btn.backgroundColor = [UIColor orangeColor];
- [btn target:self];
- btn.tag = 1;
- [btnBar addSubview:btn];
- applyPlanBtn = btn;
-
- x = kSize.width/2.0 + 10;
- btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(x, y, w, h);
- [btn setTitle:@"查看预约学员" textColor:[UIColor whiteColor] font:20 fotState:UIControlStateNormal];
- btn.layer.masksToBounds = YES;
- btn.layer.cornerRadius = 10;
- btn.backgroundColor = [UIColor orangeColor];
- [btn target:self];
- btn.tag = 2;
- [btnBar addSubview:btn];
- }
- -(void)btnClick:(UIButton*)sender
- {
- int tag = (int)sender.tag;
- if (1 == tag) {
-
- if (!lastIndex) {
- ShowMsg(@"请选择要预约的计划");
- return;
- }
-
- [myDelegate.window addSubview:self.reserveBackView];
- }
- if (2 == tag) {
- if (!lastIndex) {
- ShowMsg(@"请选择要查看的计划");
- return;
- }
-
- if (models.count > lastIndex.row) {
- NSDictionary *dic = models[lastIndex.row];
-
- ApplyPlanStuListVC *vc = [[ApplyPlanStuListVC alloc] init];
- vc.planDic = dic;
- [self navPushHideTabbarToVC:vc];
- }else {
- ShowMsg(@"请选择未过期教练排班");
- }
- }
-
- if (3 == tag) {
-
- if (_searchTF.text.length < 1) {
- ShowMsg(@"请输入学员信息");
- return;
- }
- [_reserveBackView endEditing:YES];
- [self getStudentData];
- }
-
- if (4 == tag) {//取消
- [_reserveBackView removeFromSuperview];
- }
-
- if (5 == tag) {//预约
- [_reserveBackView removeFromSuperview];
- [self saveReserve];
- }
- }
- -(void)setLabelUIWithDic:(NSDictionary *)dic
- {
- if (dic.allKeys.count == 1) {
- //这个if是应对虚拟数据的
- nameLabel.text = @"当前计划信息:暂无";
- countLabel.text = @"暂无预约人数信息";
- return;
- }
-
- NSString *kmString = @"科目二";
- if ([[NSString stringWithFormat:@"%@",dic[@"KM"]] isEqualToString:@"3"]) {
- kmString = @"科目三";
- }
- nameLabel.text = [NSString stringWithFormat:@"当前计划信息:%@ %@ %@元/小时",dic[@"USERNAME"],kmString,dic[@"MONEY"]];
- addressLabel.text = [NSString stringWithFormat:@"场地信息:%@",dic[@"JSADDRESS"]];
- if ([dic[@"JSADDRESS"] length] < 1) {
- addressLabel.text = @"场地信息:暂无";
- }
- countLabel.text = [NSString stringWithFormat:@"计划可预约%@人,已预约%@人,有%@人也申请了预约计划",dic[@"PI_NUM"],dic[@"PI_HAV_NUM"],dic[@"HAVNUM"]];
- }
- -(CLWeeklyCalendarView *)calendarView
- {
- if(!_calendarView){
- _calendarView = [[CLWeeklyCalendarView alloc] initWithFrame:CGRectMake(0, calendarY, kSize.width, 120)];
- _calendarView.delegate = self;
- }
- return _calendarView;
- }
- - (UIView *)reserveBackView {
-
- if (!_reserveBackView) {
- _reserveBackView = [[UIView alloc] initWithFrame:kFrame];
- _reserveBackView.backgroundColor = [UIColor colorWithWhite:.2 alpha:.4];
-
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBored)];
- [_reserveBackView addGestureRecognizer:tap];
-
-
- CGFloat w = kSize.width - 40;
- UIView *view = [[UIView alloc] initWithFrame:CGRectMake(20, kSize.height/2.0 - 140, w, 240)];
- view.backgroundColor = [UIColor whiteColor];
- [view borderCornorRadios:5];
- [_reserveBackView addSubview:view];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, w - 40, 30)];
- [label setText:@"请选择预约学员" Font:Font21 TextColor:KTitleColor Alignment:NSTextAlignmentCenter];
- [view addSubview:label];
-
- _searchTF = [[UITextField alloc] initWithFrame:CGRectMake(20, 40, w - 40 - 60, 30)];
- _searchTF.placeholder = @"请输入学员姓名或证件号码";
- _searchTF.font = [UIFont scaleSize:Font17];
- [_searchTF borderColor:kLineColor width:1 cornorRadios:3];
- [view addSubview:_searchTF];
-
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(w - 75, 40, 55, 30)];
- btn.backgroundColor = [UIColor orangeColor];
- [btn setTitle:@"搜索" textColor:[UIColor whiteColor] font:Font17 fotState:UIControlStateNormal];
- [btn borderCornorRadios:5];
- [btn target:self Tag:3];
- [view addSubview:btn];
-
- stuListArray = [NSArray array];
- stuListTV = [[UITableView alloc] initWithFrame:CGRectMake(20, 80, w - 40, 110) style:UITableViewStylePlain];
- stuListTV.delegate = self;
- stuListTV.dataSource = self;
- stuListTV.tableFooterView = [UIView new];
- [view addSubview:stuListTV];
- [stuListTV borderColor:kLineColor width:1 cornorRadios:4];
-
- // label = [[UILabel alloc] initWithFrame:CGRectMake(20, 80, w - 40, 110)];
- // [label setText:@"这里是个表 显示搜索到的学员信息" Font:Font17 TextColor:KTitleColor Alignment:NSTextAlignmentCenter];
- // label.numberOfLines = 0;
- // [label borderColor:kLineColor width:1 cornorRadios:4];
- // [view addSubview:label];
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(20, 200, w/2.0 - 30, 30)];
- btn.backgroundColor = [UIColor lightGrayColor];
- [btn setTitle:@"取消" textColor:KTitleColor font:Font17 fotState:UIControlStateNormal];
- [btn borderCornorRadios:5];
- [btn target:self Tag:4];
- [view addSubview:btn];
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(w/2.0 + 10, 200, w/2.0 - 30, 30)];
- btn.backgroundColor = [UIColor lightGrayColor];
- [btn setTitle:@"预约" textColor:KTitleColor font:Font17 fotState:UIControlStateNormal];
- [btn borderCornorRadios:5];
- [btn target:self Tag:5];
- [view addSubview:btn];
- }
-
- return _reserveBackView;
- }
- - (void)closeKeyBored {
- [_reserveBackView endEditing:YES];
- }
- #pragma mark - CLWeeklyCalendarViewDelegate
- -(NSDictionary *)CLCalendarBehaviorAttributes
- {
- //CLCalendarSelectedDatePrintFormatDefault 显示选中日期格式
- return @{
- //CLCalendarWeekStartDay : @2, //Start Day of the week, from 1-7 Mon-Sun -- default 1
- // CLCalendarDayTitleTextColor : [UIColor yellowColor],
- // CLCalendarSelectedDatePrintColor : [UIColor greenColor],
- };
- }
- -(void)dailyCalendarViewDidSelect:(NSDate *)date
- {
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- taskTime = [formatter stringFromDate:date];
-
- //ShowHUD();
-
- if (lastIndex) {
- PlanCollectionCell *lastCell = (PlanCollectionCell *)[mainCollection cellForItemAtIndexPath:lastIndex];
- lastCell.backImageView.image = [UIImage imageNamed:@"plancell3.png"];
- }
-
- [self getPlanInfos];
- }
- #pragma mark - collection dalegate
- -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
- if (models.count == 0) {
- return mockDatas.count;
- }
- return models.count;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- PlanCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collection" forIndexPath:indexPath];
-
- //每次获取cell 把隐藏的控件全显示出来 还有会改变的默认属性 这样的话 下面就方便了
- cell.countLabel.hidden = NO;
- cell.headImgView.hidden = NO;
- cell.timeLabel.textColor = KTitleColor;
- cell.kmLabel.textColor = KTitleColor;
- cell.countLabel.textColor = KTitleColor;
-
- //把所有情况设置为不可点击 然后在可以点击的情况改变这个状态
- cell.isCanSelect = NO;
-
- if (models.count == 0) {
-
- cell.timeLabel.text = mockDatas[indexPath.row];
- cell.countLabel.hidden = YES;
- cell.headImgView.hidden = YES;
- cell.backImageView.image = [UIImage imageNamed:@"plancell1.png"];
- cell.kmLabel.text = @"已过期";
- return cell;
- }
-
- NSDictionary *dic = models[indexPath.row];
-
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
-
- NSDate *crDate = [NSDate date];
- if ([dic[@"TIMES"] rangeOfString:@"-"].location != NSNotFound && [dic[@"TASKTIME"] rangeOfString:@"-"].location != NSNotFound) {
- NSString *endTime = [NSString stringWithFormat:@"%@ %@:00",dic[@"TASKTIME"],[[dic[@"TIMES"] componentsSeparatedByString:@"-"] lastObject]];
-
- crDate = [formatter dateFromString:endTime];
- }
-
- NSDate *nowDate = [NSDate date];
- NSComparisonResult result = [crDate compare:nowDate];
-
- //NSLog(@"result--->%d-crDate-%@-nowDate-%@",(int)result,crDate,nowDate);
-
- //过期不能预约 预约过不能预约 人数已经预约满不能预约 这个判断顺序是没问题的
- if (result == NSOrderedAscending){
- //NSLog(@"已过期");
- cell.backImageView.image = [UIImage imageNamed:@"plancell1.png"];
- cell.kmLabel.text = @"已过期";
- cell.headImgView.hidden = YES;
- cell.countLabel.hidden = YES;
- if ([[NSString stringWithFormat:@"%@",dic[@"STATUS"]] isEqualToString:@"0"]) {
- cell.kmLabel.text = @"被拒,已过期";
- }else if ([[NSString stringWithFormat:@"%@",dic[@"STATUS"]] isEqualToString:@"1"]){
- cell.kmLabel.text = @"已预约,已过期";
- }else if ([[NSString stringWithFormat:@"%@",dic[@"STATUS"]] isEqualToString:@"2"]){
- cell.kmLabel.text = @"预约中,已过期";
- }
- }
- if (result == NSOrderedDescending) {
- //NSLog(@"未过期");
- cell.backImageView.image = [UIImage imageNamed:@"plancell3.png"];
-
- cell.countLabel.text = [NSString stringWithFormat:@"%d/%d",[dic[@"PI_HAV_NUM"] intValue],[dic[@"PI_NUM"] intValue]];
-
-
- cell.kmLabel.text = [[NSString stringWithFormat:@"%@",dic[@"KM"]] isEqualToString:@"2"]?@"科目二":@"科目三";
- if (indexPath == lastIndex) {
- cell.backImageView.image = [UIImage imageNamed:@"plancell2.png"];
- }
-
- if ([[NSString stringWithFormat:@"%@",dic[@"STATUS"]] isEqualToString:@"0"]) {
- cell.kmLabel.text = @"预约被拒";
- cell.kmLabel.textColor = [UIColor orangeColor];
- }else if ([[NSString stringWithFormat:@"%@",dic[@"STATUS"]] isEqualToString:@"1"]){
- cell.kmLabel.text = @"已预约";
- cell.kmLabel.textColor = [UIColor orangeColor];
- }else if ([[NSString stringWithFormat:@"%@",dic[@"STATUS"]] isEqualToString:@"2"]){
- cell.kmLabel.text = @"预约中";
- cell.kmLabel.textColor = [UIColor orangeColor];
- }else if ([[NSString stringWithFormat:@"%@",dic[@"STATUS"]] isEqualToString:@"-1"]){
-
- if ([[NSString stringWithFormat:@"%@",dic[@"PI_HAV_NUM"]] isEqualToString:[NSString stringWithFormat:@"%@",dic[@"PI_NUM"]]]) {
- cell.kmLabel.text = @"已约满";
- cell.backImageView.image = [UIImage imageNamed:@"plancell1.png"];
-
- }else{
-
- cell.isCanSelect = YES;
- }
- }
- }
- cell.timeLabel.text = dic[@"TIMES"];
-
- return cell;
- }
- -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- {
- [collectionView deselectItemAtIndexPath:indexPath animated:YES];
-
- PlanCollectionCell *cell = (PlanCollectionCell *)[collectionView cellForItemAtIndexPath:indexPath];
-
- if (models.count > indexPath.row) {
-
- NSDictionary *dic = models[indexPath.row];
- [self setLabelUIWithDic:dic];
- }
- //如果之前操作过 找到改变状态 移除数据
- if (lastIndex) {
- if (![lastIndex isEqual:indexPath]) {
-
- PlanCollectionCell *lastCell = (PlanCollectionCell *)[collectionView cellForItemAtIndexPath:lastIndex];
- if (lastCell.isCanSelect) {
- lastCell.backImageView.image = [UIImage imageNamed:@"plancell3.png"];
- }else {
- lastCell.backImageView.image = [UIImage imageNamed:@"plancell1.png"];
- }
- }
- }
-
- cell.backImageView.image = [UIImage imageNamed:@"plancell2.png"];
-
-
- if (cell.isCanSelect == NO) {
- //不能点击预约按钮
- applyPlanBtn.backgroundColor = [UIColor lightGrayColor];
- applyPlanBtn.userInteractionEnabled = NO;
- }else {
- //可以点击预约按钮
- applyPlanBtn.backgroundColor = [UIColor orangeColor];
- applyPlanBtn.userInteractionEnabled = YES;
- }
-
- //记录上一次点击按钮
- lastIndex = indexPath;
- }
- #pragma mark tableView
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return stuListArray.count;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
- if (cell == nil) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
- [cell.imageView borderCornorRadios:3];
- cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
- }
-
- NSDictionary *dic = stuListArray[indexPath.row];
-
- NSString *faceImgPath = dic[@"TSO_PHOTO_PATH"];
- if (!faceImgPath) {
- faceImgPath = @"";
- }
- [cell.imageView sd_setImageWithURL:[NSURL URLWithString:faceImgPath] placeholderImage:[UIImage imageNamed:@"NOImg"]];
-
- cell.textLabel.text = dic[@"TSO_NAME"];
-
- cell.detailTextLabel.text = dic[@"TSO_IDCARD"];
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- stuDic = stuListArray[indexPath.row];
- }
- #pragma mark - 获取数据
- -(void)getPlanInfos
- {
- if (![NetManager connectedToNetWork]) {
- [holderV setHidden:NO];
- return;
- }
-
- if (!taskTime) {
- NSDateFormatter* fm = [NSDateFormatter new];
- [fm setDateFormat:@"yyyy-MM-dd"];
- taskTime = [fm stringFromDate:[NSDate date]];
- }
-
- if (_coachDic) {
- coachNum = _coachDic[@"SFZHM"];
- }
- if (coachNum.length < 1) {
- coachNum = @"";
- }
-
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
- [dic setObject:taskTime forKey:@"planTime"];
- [dic setObject:coachNum forKey:@"idcard"];
-
- NSString *method = @"getPlans";
- [NetManager requestAnythingWithURL:method dictionary:dic dataArray:nil completion:^(NSDictionary *root) {
-
- // NSLog(@"找计划------>%@------>%@",dic,root);
- if (!root)
- {
- ShowMsg(@"网络请求失败");
- [holderV setHidden:NO];
- return;
- }
-
- NSString* code = root[@"code"];
- if (code.intValue >0) {
- ShowMsg(root[@"body"]);
- [holderV setHidden:NO];
- return;
- }
-
- models = root[@"body"];
-
- if (models.count > 0) {
-
- NSDictionary *dic = [models firstObject];
- [self setLabelUIWithDic:dic];
- [mainCollection reloadData];
- [holderV setHidden:YES];
- }else{
-
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
-
- NSDate *taskDate = [formatter dateFromString:[NSString stringWithFormat:@"%@ 23:59:59",taskTime]];
- NSComparisonResult result = [taskDate compare:[NSDate date]];
-
- if (result == NSOrderedAscending){
- //NSLog(@"已过期");
- [holderV setHidden:YES];
- [self getMockDates];
- }
- if (result == NSOrderedDescending || result == NSOrderedSame) {
- //NSLog(@"未过期");
- ShowMsg(@"暂无计划");
- [holderV setHidden:NO];
- }
- }
- }];
- }
- -(void)getMockDates
- {
- mockDatas = [[NSMutableArray alloc] init];
-
- NSInteger time = 8;
- for (int i = 0; i < 10; i ++) {
-
- NSInteger beginTime = time;
- time += arc4random()%2 + 1;
-
- if (time > 18) {
- break;
- }
-
- NSString *timeString = [NSString stringWithFormat:@"%d:00-%d:00",(int)beginTime,(int)time];
- [mockDatas addObject:timeString];
- }
-
- //NSLog(@"---->%@",mockDatas);
- [mainCollection reloadData];
- NSDictionary *dic = [NSDictionary dictionaryWithObject:@"NOPLAN" forKey:@"NOPLAN"];
- [self setLabelUIWithDic:dic];
- }
- //获取学员信息
- -(void)getStudentData{
-
- //判断网络是否连接
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableDictionary * mdic = [NSMutableDictionary new];
-
- [mdic setValue:_searchTF.text forKey:@"keyWord"];
-
- [NetManager requestAnythingWithURL:@"getStudentList" dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
-
- if (!root) {
- ShowMsg(@"学员信息查询失败,请重试");
- return;
- }
- if ([root[@"code"] integerValue] == 1) {
- ShowMsg(root[@"msg"]);
- return;
- }
-
- if ([root[@"body"] count] < 1) {
- ShowMsg(@"查询不到该学员,请确认查询条件");
- return;
- }else {
-
- if ([root[@"body"] count] == 1) {
- stuDic = [root[@"body"] firstObject];
- }
-
- //查询到多个学员 展示列表
- stuListArray = root[@"body"];
- [stuListTV reloadData];
- }
- }];
- }
- //预约教练计划
- -(void)saveReserve{
-
- //判断网络是否连接
- if (![NetManager connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
-
- NSDictionary *planDic = [NSDictionary dictionary];
- if (models.count > lastIndex.row) {
- planDic = models[lastIndex.row];
- }
-
-
- NSMutableDictionary * mdic = [NSMutableDictionary new];
-
- [mdic setValue:planDic[@"ID"] forKey:@"planId"];
- [mdic setValue:stuDic[@"TSO_IDCARD"] forKey:@"idcard"];
- [mdic setValue:stuDic[@"TSO_PHONE"] forKey:@"telphone"];
-
- [NetManager requestAnythingWithURL:@"saveReserve" dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
-
- if (!root) {
- ShowMsg(@"预约失败,请重试");
- return;
- }
- if ([root[@"code"] integerValue] == 1) {
- ShowMsg(root[@"msg"]);
- return;
- }
-
- ShowMsg(@"预约成功!");
- [self getPlanInfos];
- }];
- }
- #pragma mark
- -(void)playAudioWithString:(NSString *)string
- {
- [Tools playAudioWithString:string];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|