123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- #import "DetPlanVC.h"
- #define kNavOffSet 64
- @interface DetPlanVC ()<UITextViewDelegate>
- {
- //直接用的教练里边的内容 要将textfield设为不与用户交互的状态 --已设置
- // UIButton;
- UIButton* holder0,*holder1;
-
- UIButton *cancelBtn;
-
- UILabel *appointLabel;
- }
- @end
- @implementation DetPlanVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
-
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void)myInit
- {
- [self configNavigationBar];
- [self.view setBackgroundColor:backGroundColor];
- [self setTitle:@"预约详情"];
-
- NSString* str;
- UIView* vi; UIButton*btn;
- UILabel* label;
- vi = [UIView new];
- [self.view addSubview:vi];
-
- UIScrollView* sv = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height - kNavOffSet)];
- [sv setShowsVerticalScrollIndicator:NO];
- [self.view addSubview:sv];
- scroll = sv;
-
- CGFloat x,y,w,h,bd;
- CGFloat sRate = .75;//图标缩放比率
-
- bd = 10;
- x = y = bd ;
- w = kSize.width - bd*2;
- h = 6* 40;
-
- vi = [[UIView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- // [vi setBackgroundColor:defGreen];
- [vi setBackgroundColor:[UIColor whiteColor]];
- [sv addSubview:vi];
- [vi borderColor:lineColor width:1 cornorRadios:.01];
-
- //------------------------------------------------------------------
- UIImageView* iv;
- w = h = 40;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- // [iv imageName:@"send_title_icon.png"];
- [iv setImage:[UIImage imageNamed:@"send_title_icon.png"]];
- [iv scale:sRate];
- [sv addSubview:iv];
-
- UITextView* textV;
- x += w + 15;
- w = kSize.width - bd*2 - x;
-
- textV = [[UITextView alloc] initWithFrame:CGRectMake(x, y+1, w, h-1)];//防止遮住边框
- [textV setFont:[UIFont scaleSize:FontTitle]];
- textV.userInteractionEnabled = NO;
- [sv addSubview:textV];
- [textV setDelegate:self];
- msgTit = textV;
-
- btn = [[UIButton alloc] initWithFrame:textV.frame];
- str = @"请输入培训标题";
- btn.width = [str sizeForFont:FontTitle].width;
- btn.x += (textV.width - btn.width)/2.0;
- // btn.x = kSize.width - btn.width - 10;
- [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
- [btn setTitle:str forState:UIControlStateNormal];
- [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
- [sv addSubview:btn];
- holder0 = btn;
-
- //------------------------------------------------------------------
- w = h;
- x = bd;
- y += h;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [iv setImage:[UIImage imageNamed:@"send_content_icon.png"]];
- [iv scale:sRate];
- [sv addSubview:iv];
-
- x += w + 15;
- h *= 5;
- w = kSize.width - bd*2 - x;
-
- textV = [[UITextView alloc] initWithFrame:CGRectMake(x, y, w, h-1)];
- [textV setFont:[UIFont scaleSize:FontTitle]];
- [textV setBackgroundColor:[UIColor clearColor]];
- textV.userInteractionEnabled = NO;
- [sv addSubview:textV];
- textV.tag = 1;//用于隐藏holder
- msgCont = textV;
- [textV setDelegate:self];
-
- btn = [[UIButton alloc] initWithFrame:textV.frame];
- btn.titleLabel.numberOfLines = 0;
- str = @"请输入培训任务内容(最大限制50字)";
- [btn setTitle:str forState:UIControlStateNormal];
- btn.size = [str sizeForFont:FontTitle];
- btn.center = textV.center;
- [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
- [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
- [sv addSubview:btn];
-
- holder1 = btn;
-
- [vi addViewWithRect:CGRectMake(bd, 50, kSize.width - bd*2, 1)];
-
- //------------------------------------------------------------------
- UIView* aView;
- y = vi.bottom + 25;
- x = bd;
- w = kSize.width - bd*2;
- h = 40*5;
- aView = [[UIView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [aView setBackgroundColor:[UIColor whiteColor]];
- [sv addSubview:aView];
- [aView borderColor:lineColor width:1 cornorRadios:.01];
-
- w = h = 40;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [iv setImage:[UIImage imageNamed:@"send_people_num_icon.png"]];
- [iv scale:sRate];
- [sv addSubview:iv];
-
-
- x += w + 15;
- str = @"培训人数:";
- w = [str sizeForFont:FontTitle].width;
- label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [label setText:str];
- [label setFont:[UIFont scaleSize:FontTitle]];
- [sv addSubview:label];
-
- x += w + 15;
- w = 100;
- textV = [[UITextView alloc] initWithFrame:CGRectMake(x, y+1, w, h-1)];//防止遮住边框
- [textV setTextColor:contentTextColor];
- [textV setFont:[UIFont systemFontOfSize:FontTitle]];
- textV.keyboardType = UIKeyboardTypeNumberPad;
- textV.userInteractionEnabled = NO;
- [sv addSubview:textV];
- msgNum = textV;
-
-
- // x += w ;
- x += w +10;
- label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [label setFont:[UIFont scaleSize:FontTitle]];
- [label setText:@"人"];
- [sv addSubview:label];
-
- //------------------------------------------------------------------
- x = bd;
- y += h;
- w = h = 40;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [iv setImage:[UIImage imageNamed:@"send_date_icon.png"]];
- [iv scale:sRate];
- [sv addSubview:iv];
-
-
- x += w + 15;
- str = @"培训日期:";
- w = [str sizeForFont:FontTitle].width;
- label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [label setText:str];
- [label setFont:[UIFont scaleSize:FontTitle]];
- [sv addSubview:label];
-
- x += w + 15;
- w = kSize.width - x - 10;
- btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
- [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
- [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
- [sv addSubview:btn];
- btnDate = btn;
-
- w = h;
- x = kSize.width - w - bd;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(x+10, y+10, w-20, h-20)];
- [iv setImage:[UIImage imageNamed:@"arrow_next.png"]];
- [iv scale:sRate];
- [sv addSubview:iv];
-
-
- //------------------------------------------------------------------
- x = bd;
- y += h;
- w = h = 40;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [iv setImage:[UIImage imageNamed:@"send_time_icon.png"]];
- [iv scale:sRate];
- [sv addSubview:iv];
-
-
- x += w + 15;
- str = @"培训时间:";
- w = [str sizeForFont:FontTitle].width;
- label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [label setText:str];
- [label setFont:[UIFont scaleSize:FontTitle]];
- [sv addSubview:label];
-
-
- x += w + 15;
- w = kSize.width - x - 10;
- btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h-1)];
- [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
- [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
- [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
- [sv addSubview:btn];
- btnTime = btn;
-
-
- w = h;
- x = kSize.width - w - bd;
- btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [btn setImage:[UIImage imageNamed:@"planPen.png"] forState:UIControlStateNormal];
- [btn scale:sRate];
- // [sv addSubview:btn];
- // btnCrTime = btn;
- //------------------------------------------------------------------
- x = bd;
- y += h;
- w = h = 40;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [iv setImage:[UIImage imageNamed:@"send_tel_icon.png"]];
- [iv scale:sRate];
- [sv addSubview:iv];
-
-
- x += w + 15;
- str = @"培训电话:";
- w = [str sizeForFont:FontTitle].width;
- label = [[UILabel alloc] initWithFrame:CGRectMake(x, y+1, w, h)];
- [label setText:str];
- [label setFont:[UIFont scaleSize:FontTitle]];
- [sv addSubview:label];
-
-
- x += w + 12;
- w = kSize.width - x - 10;
- textV = [[UITextView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [textV setFont:[UIFont systemFontOfSize:FontTitle]];
- [textV setTextColor:contentTextColor];
- [textV setTextAlignment:NSTextAlignmentLeft];
- textV.keyboardType = UIKeyboardTypeNumberPad;
- textV.userInteractionEnabled = NO;
- [sv addSubview:textV];
- msgTel = textV;
- //------------------------------------------------------------------
- x = bd;
- y += h;
- w = h = 40;
- iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [iv setImage:[UIImage imageNamed:@"send_subject_icon.png"]];
- [iv scale:sRate];
- [sv addSubview:iv];
-
-
- x += w + 15;
- w = kSize.width - bd - x;
- btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
- [btn setTitle:@"请选择培训科目" forState:UIControlStateNormal];
- [btn setTitleColor:titleColor forState:UIControlStateNormal];
- [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
- [sv addSubview:btn];
- btnSubj = btn;
-
- for (int i =0; i<4; i++) {
- [aView addViewWithRect:CGRectMake(10,aView.y + 40*(i+1), kSize.width - 20, 1)];
- }
-
- y+= h+bd;
- w = 100;
- x = kSize.width - w - bd;
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [btn setBackgroundColor:defGreen];
- [btn setTitle:@"取消预约" forState:UIControlStateNormal];
- [scroll addSubview:btn];
- btn.layer.cornerRadius = btn.height*.5;
- btn.layer.masksToBounds = YES;
- [btn target:self tag:1];
- cancelBtn = btn;
-
- x = bd;
- w = kSize.width - w - 2*bd;
- label = [[UILabel alloc] setxywh];
- [scroll addSubview:label];
- appointLabel = label;
-
- [msgTit setText:_model[@"TITLE"]];
- [msgCont setText:_model[@"CONTENT"]];
- [msgNum setText:_model[@"PI_NUM"]];
- [btnDate setTitle:_model[@"TASKTIME"] forState:UIControlStateNormal];
- [btnTime setTitle:_model[@"TIMES"] forState:UIControlStateNormal];
- [msgTel setText:_model[@"TEL"]];
- str = _model[@"KM"];
- if ( 2 == str.intValue ) {
- [btnSubj setTitle:@"科目二" forState:UIControlStateNormal];
- }else{
- [btnSubj setTitle:@"科目三" forState:UIControlStateNormal];
- }
- [self textViewDidChange:msgTit];
-
- //如果能进来 要么有过发起预约操作 要么就是过期了
- if ([_model[@"STATUS"] isEqualToString:@"0"]) {
-
- cancelBtn.hidden = YES;
- appointLabel.hidden = NO;
- appointLabel.text = @"教练拒绝了您的预约";
- }else if ([_model[@"STATUS"] isEqualToString:@"1"]){
-
- cancelBtn.hidden = NO;
- appointLabel.hidden = NO;
- appointLabel.text = @"教练同意了您的预约";
- }else if ([_model[@"STATUS"] isEqualToString:@"2"]){
-
- cancelBtn.hidden = NO;
- appointLabel.hidden = NO;
- appointLabel.text = @"教练还未审核该预约哦!";
- }else if ([_model[@"STATUS"] isEqualToString:@"-1"]){
-
- cancelBtn.hidden = YES;
- appointLabel.hidden = NO;
- appointLabel.text = @"该预约已过期";
- }
-
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSDate *crDate = [NSDate date];
- if ([_model[@"TIMES"] rangeOfString:@"-"].location != NSNotFound && [_model[@"TASKTIME"] rangeOfString:@"-"].location != NSNotFound) {
-
- NSString *startTime = [NSString stringWithFormat:@"%@ %@:00",_model[@"TASKTIME"],[[_model[@"TIMES"] componentsSeparatedByString:@"-"] firstObject]];
-
- crDate = [formatter dateFromString:startTime];
- }
-
- NSDate *nowDate = [NSDate date];
- NSComparisonResult result = [crDate compare:nowDate];
-
- if (result == NSOrderedAscending){
- //NSLog(@"已过期");
- cancelBtn.hidden = YES;
- }
- [sv setContentSize:CGSizeMake(0, [sv.subviews lastObject].bottom)];
- }
- -(void)btnClick:(UIButton*)sender
- {
- //这个地方要写取消预约的操作
- [self cancelReserve];
- }
- -(void)textViewDidChange:(UITextView *)textView
- {
- holder0.hidden = msgTit.text.length >0;
- holder1.hidden = msgCont.text.length >0;
- }
- -(void)cancelReserve
- {
- ShowHUD();
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"pid" Value:_model[@"ID"]];
- [arr addPro:@"reserveId" Value:_model[@"RESERVE_ID"]];
- [arr addPro:@"jxbh" Value:defUser.userSchoolId];
-
- NSString* method = @"cancelReserve";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- RemoveHUD();
- //NSLog(@"取消预约---->%@---->%@",method,root);
- if (!root)
- {
- [LoadingView showMsg:@"操作失败"];
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
-
- [LoadingView showMsg:root[@"body"]];
- return;
- }
-
- ShowMsgSuc();
- self.coachVC.isRefresh = YES;
- [self.navigationController popViewControllerAnimated:YES];
- }];
- }
- @end
|