123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848 |
- //
- // IssuePlanVC.m
- // jiaPeiC
- //
- // Created by apple on 16/6/13.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "IssuePlanVC.h"
- #import "CLWeeklyCalendarView.h"
- #import "PlanCollectionViewCell.h"
- #import "IssueBaseSettingVC.h"
- #import "myCollectionHeadView.h"
- @interface IssuePlanVC ()<CLWeeklyCalendarViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,UICollectionViewDelegate,UIActionSheetDelegate>
- {
- UICollectionView *mainCollection;
- UIView *backView;
- UIButton *sendBtn, *keErBtn, *keSanBtn, *yesBtn, *noBtn, *priceBtn;
- UITextField *numField, *priceField;
- HolderView *holderV;
-
- NSMutableArray *dataArray;
- NSMutableArray *dataSendArray;
- NSMutableArray *allData;
- NSString *keMuString;
- NSString *payAfterLearn;
- NSString *dateString;
- NSArray *moneyArray;
- NSDictionary *currentDic;
- }
- @property (nonatomic, strong) CLWeeklyCalendarView *calendarView;
- @end
- @implementation IssuePlanVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- dataArray = [NSMutableArray array];
- dataSendArray = [NSMutableArray array];
- allData = [NSMutableArray array];
- [self myInit];
- }
- -(void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
- [self getPlanInfos];
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [self.view endEditing:YES];
- }
- -(void)myInit
- {
- self.title = @"预约练车";
- self.view.backgroundColor = backGroundColor;
- [self configNavBar];
- self.navigationController.navigationBar.translucent = YES;
- UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"创建" style:UIBarButtonItemStyleDone target:self action:@selector(clickToAddPlan)];
- [item setTintColor:defGreen];
- [self.navigationItem setRightBarButtonItem:item];
-
- [self.view addSubview:self.calendarView];
-
-
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- CGFloat width = (kSize.width - 40) / 3.0;
- [layout setItemSize:CGSizeMake(width, width * .7)];
- layout.minimumLineSpacing = 10;
- layout.minimumInteritemSpacing = 8;
- [layout setSectionInset:UIEdgeInsetsMake(0, 10, 5, 10)];
- //区头高度 这个如果不设置 下面代理不会执行
- layout.headerReferenceSize = CGSizeMake(kSize.width, 40);
- //尾部高度
- layout.footerReferenceSize = CGSizeMake(kSize.width, .1);
-
-
- CGFloat y = kNavOffSet + self.calendarView.height;
- mainCollection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, y, kSize.width, kSize.height - y - 100) collectionViewLayout:layout];
- mainCollection.backgroundColor = backGroundColor;
- //自适应大小
- mainCollection.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- mainCollection.delegate = self;
- mainCollection.dataSource = self;
- [self addV:mainCollection];
-
- [mainCollection registerClass:[PlanCollectionViewCell class] forCellWithReuseIdentifier:@"PlanCollectionViewCell"];
- [mainCollection registerClass:[myCollectionHeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"myCollectionHeadView"];
- [mainCollection registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"UICollectionReusableView"];
-
- holderV = [[HolderView alloc] initWithFrame:mainCollection.frame];
- [holderV freshBlock:^{
- [self getPlanInfos];
- }];
- [self addV:holderV];
-
- //获取驾校分配价格
- [self getTrainPrice];
-
-
- UIView *issueBar = [[UIView alloc] initWithFrame:CGRectMake(0, kSize.height - 100, kSize.width, 100)];
- issueBar.backgroundColor = backGroundColor;
- [self addV:issueBar];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 50)];
- label.numberOfLines = 0;
- [label setText:@"点击时间段可修改对应时间段信息\n发布后,学员可以在“优易学车学员版”进行预约" Font:Font14 TextColor:contentTextColor Alignment:NSTextAlignmentCenter];
- [issueBar addSubview:label];
-
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- btn.frame = CGRectMake(20, 50, kSize.width - 40, 35);
- btn.backgroundColor = defGreen;
- [btn setTitle:@"确认发布" textColor:[UIColor whiteColor] font:Font16 fotState:UIControlStateNormal];
- [btn borderCornorRadios:5];
- [btn target:self Tag:1];
- sendBtn = btn;
- [issueBar addSubview:btn];
- }
- -(void)initPlanInformationWithIndexPath:(NSIndexPath *)indexPath
- {
- backView = [[UIView alloc] initWithFrame:kFrame];
- backView.backgroundColor = [UIColor colorWithWhite:.01 alpha:.4];
- //用window添加才能遮盖住导航栏
- [[UIApplication sharedApplication].keyWindow addSubview:backView];
-
- UIView *informationView = [[UIView alloc] initWithFrame:CGRectMake(10, kSize.height/2.0 - 150, kSize.width - 20, 240)];
- informationView.backgroundColor = backGroundColor;
- [informationView borderColor:lineColor width:1 cornorRadios:10];
- [backView addSubview:informationView];
-
- //crash
- if (dataArray.count > 0 && dataSendArray.count > 0) {
-
- if (indexPath.section == 0) {
- currentDic = dataSendArray[indexPath.row];
- }else{
- currentDic = dataArray[indexPath.row];
- }
- }else{
- currentDic = allData[indexPath.row];
- }
-
-
- keMuString = currentDic[@"km"];
- payAfterLearn = currentDic[@"isPay"];
-
- CGFloat x,y,w,h,wid;
- x = 0;
- y = 0;
- w = wid = kSize.width - 20;
- h = 50;
-
- //------时间------
- UILabel *label = [[UILabel alloc] setxywh];
- [label setText:currentDic[@"times"] Font:Font16 TextColor:titleColor Alignment:NSTextAlignmentCenter];
- [informationView addSubview:label];
-
- //------科目------
- x = 20;
- y += h;
- w = (wid-40)/3.0;
- h = 30;
- label = [[UILabel alloc] setxywh];
- [label setText:@"培训科目:" Font:Font16 TextColor:titleColor Alignment:NSTextAlignmentLeft];
- [informationView addSubview:label];
-
- x += w;
- 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:titleColor forState:UIControlStateNormal];
- [button setTitleColor:defGreen forState:UIControlStateSelected];
- [button target:self Tag:2];
- [informationView addSubview:button];
- 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:titleColor forState:UIControlStateNormal];
- [button setTitleColor:defGreen forState:UIControlStateSelected];
- [button target:self Tag:3];
- [informationView addSubview:button];
- keSanBtn = button;
-
- if ([currentDic[@"km"] isEqualToString:@"2"]) {
- keErBtn.selected = YES;
- }else{
- keSanBtn.selected = YES;
- }
-
- //------先学后付------
- // x = 20;
- // y += h;
- // w = (wid-40)/3.0;
- // h = 30;
- // label = [[UILabel alloc] setxywh];
- // [label setText:@"先学后付:" Font:Font16 TextColor:titleColor Alignment:NSTextAlignmentLeft];
- // [informationView addSubview:label];
- //
- // 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:titleColor forState:UIControlStateNormal];
- // [button setTitleColor:defGreen forState:UIControlStateSelected];
- // [button target:self Tag:4];
- // [informationView addSubview:button];
- // yesBtn = 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:titleColor forState:UIControlStateNormal];
- // [button setTitleColor:defGreen forState:UIControlStateSelected];
- // [button target:self Tag:5];
- // [informationView addSubview:button];
- // noBtn = button;
- //
- // if ([currentDic[@"isPay"] isEqualToString:@"1"]) {
- // yesBtn.selected = YES;
- //
- // }else{
- // noBtn.selected = YES;
- // }
-
- //-----练车人数及价格设置-------
- NSString *textString = @"练车人数";
- x = 20;
- y += h;
- w = [textString sizeForFont:Font16].width;
- h = 30;
- label = [[UILabel alloc] setxywh];
- [label setText:textString Font:Font16 TextColor:titleColor Alignment:NSTextAlignmentLeft];
- [informationView addSubview:label];
-
- x += w;
- w = 30;
- numField = [[UITextField alloc] setxywh];
- numField.textColor = [UIColor orangeColor];
- numField.font = [UIFont scaleSize:Font16];
- numField.textAlignment = NSTextAlignmentCenter;
- numField.keyboardType = UIKeyboardTypeNumberPad;
- numField.text = currentDic[@"num"];
- [informationView addSubview:numField];
-
- [numField addViewWithRect:CGRectMake(x + 2, y + h - 5, 26, 1) Color:[UIColor orangeColor]];
-
- x += w;
- label = [[UILabel alloc] setxywh];
- [label setText:@"人" Font:Font16 TextColor:titleColor Alignment:NSTextAlignmentLeft];
- [informationView addSubview:label];
-
-
- x = wid - 60;
- w = 45;
- label = [[UILabel alloc] setxywh];
- [label setText:@"元/时" Font:Font16 TextColor:titleColor Alignment:NSTextAlignmentLeft];
- [informationView addSubview:label];
- x -= w;
- //NSLog(@"moneyDic--->%@",moneyDic);
- NSString *money = currentDic[@"money"];
- if ([money containsString:@"."]) {
- money = [[money componentsSeparatedByString:@"."] firstObject];
- }
-
- button = [UIButton buttonWithType:UIButtonTypeCustom];
- button.frame = setDIYFrame;
- [button setTitle:money textColor:[UIColor orangeColor] font:Font16 fotState:UIControlStateNormal];
- [button target:self Tag:6];
- [informationView addSubview:button];
- priceBtn = button;
-
- [priceBtn addViewWithRect:CGRectMake(x + 2, y + h - 5, 36, 1) Color:[UIColor orangeColor]];
-
- x -= 80;
- w = 80;
- label = [[UILabel alloc] setxywh];
- [label setText:@"培训价格" Font:Font16 TextColor:titleColor Alignment:NSTextAlignmentRight];
- [informationView addSubview:label];
-
- x = 20;
- y = informationView.height - 90;
- w = wid - 40;
- h = 40;
- UILabel *remindLabel = [[UILabel alloc] setxywh];
- [remindLabel setText:@"提示:已有预约的计划不能做任何操作" Font:Font16 TextColor:[UIColor orangeColor] Alignment:NSTextAlignmentCenter];
- remindLabel.numberOfLines = 2;
- [informationView addSubview:remindLabel];
-
- x = 0;
- y = informationView.height - 50;;
- w = wid/3.0;
- h = 50;
- button = [[UIButton alloc] setxywh];
- [button setTitle:@"取消" textColor:titleColor font:Font18 fotState:UIControlStateNormal];
- [button target:self Tag:7];
- [informationView addSubview:button];
-
- x += w;
- button = [[UIButton alloc] setxywh];
- [button setTitle:@"删除" textColor:titleColor font:Font18 fotState:UIControlStateNormal];
- [button target:self Tag:8];
- [informationView addSubview:button];
- [button addViewWithRect:CGRectMake(x - .5, y, 1, h)];
-
- x += w;
- button = [[UIButton alloc] setxywh];
- [button setTitle:@"修改" textColor:defGreen font:Font18 fotState:UIControlStateNormal];
- [button target:self Tag:9];
- [informationView addSubview:button];
- [button addViewWithRect:CGRectMake(0, y - 1, wid, 1)];
- [button addViewWithRect:CGRectMake(x - .5, y, 1, h)];
- }
- //日历控件的初始化和点击回调
- -(CLWeeklyCalendarView *)calendarView
- {
- if(!_calendarView){
- _calendarView = [[CLWeeklyCalendarView alloc] initWithFrame:CGRectMake(0, kNavOffSet, kSize.width, 120)];
- _calendarView.delegate = self;
- }
- return _calendarView;
- }
- #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"];
-
- dateString = [formatter stringFromDate:date];
- //这里做个接口 是请求这一页的数据的
- [self getPlanInfos];
- }
- #pragma mark 按钮事件
- -(void)clickToAddPlan
- {
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
-
- NSString *todayString = [formatter stringFromDate:[NSDate date]];
- todayString = [NSString stringWithFormat:@"%@ 23:59:59",[todayString substringToIndex:10]];
- NSDate *today = [formatter dateFromString:todayString];
- NSTimeInterval todayTime = [today timeIntervalSince1970];
-
- NSString *playDateString = [NSString stringWithFormat:@"%@ 23:59:59",dateString];
- NSDate *playDay = [formatter dateFromString:playDateString];
- NSTimeInterval playTime = [playDay timeIntervalSince1970];
-
- if (todayTime > playTime) {
- ShowMsg(@"所选时间已过期,请核对日期!");
- return;
- }
-
-
- IssueBaseSettingVC *setting = [[IssueBaseSettingVC alloc] init];
- setting.dateString = dateString;
- setting.dataArray = allData;
- setting.moneyArray = moneyArray;
- [self.navigationController pushViewController:setting animated:YES];
- }
- -(void)btnClick:(UIButton *)sender
- {
- //按钮 如果有键盘 要先将键盘搞下去
- [backView endEditing:YES];
- //NSLog(@"btnClick-->%d",(int)sender.tag);
- switch (sender.tag) {
- case 1:
- //发布
- [self updatePlanStatus:@"1"];
-
- break;
- case 6:
- if ([currentDic[@"havNum"] integerValue] > 0) {
- ShowMsg(@"已有学员预约,无法修改价格");
- return;
- }
- [self selectPrice];
- break;
- case 7:
- [backView removeFromSuperview];
- break;
- case 8:
- {
- //确认删除
- if ([currentDic[@"havNum"] integerValue] > 0) {
- ShowMsg(@"已有学员预约,无法删除");
- return;
- }
- [self deletePlanInfo];
- [backView removeFromSuperview];
- }
- break;
- case 9:
- //确定修改
- if (numField.text.length == 0 || [numField.text integerValue]==0 || [numField.text integerValue]>10) {
- ShowMsg(@"请设置合理的练车人数");
- return;
- }
-
- [self updatePlanInfoNew];
- [backView removeFromSuperview];
- break;
-
- default:
- [self setWhiceSelectWithTag:sender.tag];
- break;
- }
- }
- -(void)setWhiceSelectWithTag:(NSInteger)tag
- {
- if ([currentDic[@"havNum"] integerValue] > 0) {
- ShowMsg(@"已有学员预约,无法修改");
- return;
- }
- //设置信息也是在这里边写的
- if (tag == 2) {
- if (keSanBtn.isSelected == YES) {
- keSanBtn.selected = NO;
- }
- keErBtn.selected = YES;
- keMuString = @"2";
- }
-
- if (tag == 3) {
- if (keErBtn.isSelected == YES) {
- keErBtn.selected = NO;
- }
- keSanBtn.selected = YES;
- keMuString = @"3";
- }
-
-
- NSString *money = currentDic[@"money"];
- if ([money containsString:@"."]) {
- money = [[money componentsSeparatedByString:@"."] firstObject];
- }
- if (money == nil) {
- money = @"0";
- }
- if (tag == 4) {
- noBtn.selected = NO;
- yesBtn.selected = YES;
- payAfterLearn = @"1";
-
- [priceBtn setTitle:money forState:UIControlStateNormal];
- }
- if (tag == 5) {
- yesBtn.selected = NO;
- noBtn.selected = YES;
- payAfterLearn = @"0";
-
- [priceBtn setTitle:@"0" forState:UIControlStateNormal];
- }
- }
- -(void)selectPrice
- {
- NSMutableArray *titleArray = [NSMutableArray array];
- [titleArray addObject:@"免费模式"];
-
- for (NSDictionary *dic in moneyArray) {
- NSString * strSD = @"";
- switch ([dic[@"CSI_TRAINNINGTIME"] integerValue]) {
- case 1:
- strSD = @"普通时段";
- break;
- case 2:
- strSD = @"高峰时段";
- break;
- case 3:
- strSD = @"节假日时段";
- break;
- default:
- break;
- }
-
- NSString *titleString = [NSString stringWithFormat:@"%@ %@ %@元 ",strSD,dic[@"CSI_VEHICLETYPE"],dic[@"CSI_PRICE"]];
- [titleArray addObject:titleString];
- }
-
- //UIActionSheet对按钮数量不确定时候的处理
- UIActionSheet* sheet = [[UIActionSheet alloc] initWithTitle:@"选择培训价格" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
-
- for (NSString *title in titleArray) {
- [sheet addButtonWithTitle:title];
- }
-
- [sheet addButtonWithTitle:@"取消"];
- sheet.cancelButtonIndex = sheet.numberOfButtons - 1;
- sheet.actionSheetStyle = UIActionSheetStyleDefault;
- [sheet showInView:self.view];
- }
- -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (buttonIndex == actionSheet.cancelButtonIndex) {
- return;
- }
-
- if (buttonIndex == 0) {
- [priceBtn setTitle:@"免费模式" forState:UIControlStateNormal];
- return;
- }
-
- NSDictionary *dic = moneyArray[buttonIndex - 1];
- [priceBtn setTitle:dic[@"CSI_PRICE"] forState:UIControlStateNormal];
- }
- #pragma mark collection delegate
- -(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
- {
- UICollectionReusableView *reusableview = nil;
- if (kind == UICollectionElementKindSectionHeader){
-
- myCollectionHeadView *headerV = (myCollectionHeadView *)[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"myCollectionHeadView" forIndexPath:indexPath];
-
- if (dataArray.count > 0 && dataSendArray.count > 0) {
- //这个有已发布的和未发布的
- if (indexPath.section == 0) {
- [headerV setTextTitle:@"已发布计划"];
- }else{
- [headerV setTextTitle:@"未发布计划"];
- }
- }else if (dataArray.count > 0){
- //未发布
- [headerV setTextTitle:@"未发布计划"];
- }else{
- //已发布
- [headerV setTextTitle:@"已发布计划"];
- }
-
- reusableview = headerV;
- }else{
-
- reusableview = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"UICollectionReusableView" forIndexPath:indexPath];
- }
-
- return reusableview;
- }
- -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
- {
- if (dataArray.count > 0 && dataSendArray.count > 0) {
- return 2;
- }else{
- return 1;
- }
- }
- -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
- if (dataArray.count > 0 && dataSendArray.count > 0) {
- //这个有已发布的和未发布的
- if (section == 0) {
- return dataSendArray.count;
- }else{
- return dataArray.count;
- }
- }else if (dataArray.count > 0){
- //未发布
- return dataArray.count;
- }else{
- //已发布
- return dataSendArray.count;
- }
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- PlanCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"PlanCollectionViewCell" forIndexPath:indexPath];
- [cell setNeedsDisplay];
-
-
- NSDictionary *dic;
- if (dataArray.count > 0 && dataSendArray.count > 0) {
- //这个有已发布的和未发布的
- if (indexPath.section == 0) {
- dic = dataSendArray[indexPath.row];
- }else{
- dic = dataArray[indexPath.row];
- }
- }else if (dataArray.count > 0){
- //未发布
- dic = dataArray[indexPath.row];
- }else{
- //已发布
- dic = dataSendArray[indexPath.row];
- }
-
-
- cell.timeLabel.text = dic[@"times"];
-
- if ([dic[@"km"] isEqualToString:@"2"]) {
- cell.kemuLabel.text = @"科目二";
- }else{
- cell.kemuLabel.text = @"科目三";
- }
-
- cell.countLabel.text = [NSString stringWithFormat:@"已约%@人 可约%@人",dic[@"havNum"],dic[@"num"]];
-
- return cell;
- }
- -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
- {
- //这个地方 对数组中某串信息进行修改
- [self initPlanInformationWithIndexPath:indexPath];
- }
- #pragma mark - 数据请求
- - (void)getPlanInfos
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"taskTime" Value:dateString];
- [arr addPro:@"user" Value:defUser.sfzmhm];
- [arr addPro:@"isPage" Value:@""];
- [arr addPro:@"pageSize" Value:@""];
- [arr addPro:@"currentPage" Value:@""];
- [arr addPro:@"status" Value:@""];
-
- NSString* method = @"getPlanInfosForCoa";
- ShowHUD();
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- //NSLog(@"我的计划-->%@---->%@",arr,root);
- //一旦发起 就要remove之前的数据
- [allData removeAllObjects];
- [dataArray removeAllObjects];
- [dataSendArray removeAllObjects];
- [holderV setHidden:NO];
-
- if (!root) {
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
-
- ShowMsg(root[@"body"]);
- return;
- }
-
- NSArray *array = root[@"body"];
- if (array.count < 1) {
- sendBtn.hidden = YES;
- return;
- }
-
- [allData addObjectsFromArray:root[@"body"]];
- for (NSDictionary *dic in array) {
-
- if ([dic[@"status"] isEqualToString:@"0"]) {
- //未发布
- [dataArray addObject:dic];
- }
-
- if ([dic[@"status"] isEqualToString:@"1"]) {
- //已发布
- [dataSendArray addObject:dic];
- }
- }
-
- if (dataArray.count < 1) {
- sendBtn.hidden = YES;
- }else{
- sendBtn.hidden = NO;
- }
-
- [holderV setHidden:YES];
- [mainCollection reloadData];
- }];
- }
- //获取价格
- -(void)getTrainPrice
- {
- 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) {
- RemoveHUD();
- //NSLog(@"获取价格-->%@->%@",arr,dict);
- if (!dict) {
- return ;
- }
- if ( [dict[@"code"] isEqualToString:@"1"]) {
- return ;
- }
-
- moneyArray = dict[@"body"];
- }];
- }
- //更改发布状态
- -(void)updatePlanStatus:(NSString *)state
- {
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"taskTime" Value:dateString];
- [arr addPro:@"status" Value:state];
- [arr addPro:@"coach" Value:defUser.sfzmhm];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"cityId"]];
-
- NSString* method = @"updatePlanStatus";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * dict) {
- RemoveHUD();
- //NSLog(@"更改状态---->%@---->%@",arr,dict);
-
- if (!dict) {
- ShowMsgFailed();
- return ;
- }
- if ([dict[@"code"] isEqualToString:@"1"]) {
- [LoadingView showMsg:dict[@"body"]];
- return ;
- }
-
- ShowMsgSuc();
- [self getPlanInfos];
- }];
- }
- //修改计划
- - (void)updatePlanInfoNew
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSString *money = priceBtn.titleLabel.text;
- if ([money isEqualToString:@"免费模式"]) {
- money = @"0";
- }
-
- // if ([payAfterLearn isEqualToString:@"1"] && [money isEqualToString:@"0"]) {
- // ShowMsg(@"当前价格为0元,不能更改为先学后付计划");
- // return;
- // }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"id" Value:currentDic[@"id"]];
- [arr addPro:@"num" Value:numField.text];
- [arr addPro:@"tel" Value:payAfterLearn];
- [arr addPro:@"subject" Value:keMuString];
- [arr addPro:@"price" Value:money];
-
- NSString* method = @"updatePlanInfo";
- ShowHUD();
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
-
- //NSLog(@"修改计划---%@----->%@",arr,root);
- if (!root) {
- ShowMsgFailed();
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- //修改完毕之后 要重新刷新
- [self getPlanInfos];
- }];
- }
- //删除计划
- - (void)deletePlanInfo
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"id" Value:currentDic[@"id"]];
-
- NSString* method = @"deletePlanInfo";
- ShowHUD();
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- RemoveHUD();
- //NSLog(@"删除计划---%@----->%@",arr,root);
- if (!root) {
- ShowMsgFailed();
- return ;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- //删除完毕之后 要重新刷新
- [self getPlanInfos];
- }];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- @end
|