DetPlanVC.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. #import "DetPlanVC.h"
  2. #define kNavOffSet 64
  3. @interface DetPlanVC ()<UITextViewDelegate>
  4. {
  5. //直接用的教练里边的内容 要将textfield设为不与用户交互的状态 --已设置
  6. // UIButton;
  7. UIButton* holder0,*holder1;
  8. UIButton *cancelBtn;
  9. UILabel *appointLabel;
  10. }
  11. @end
  12. @implementation DetPlanVC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. [self myInit];
  16. }
  17. - (void)didReceiveMemoryWarning {
  18. [super didReceiveMemoryWarning];
  19. // Dispose of any resources that can be recreated.
  20. }
  21. -(void)myInit
  22. {
  23. [self configNavigationBar];
  24. [self.view setBackgroundColor:backGroundColor];
  25. [self setTitle:@"预约详情"];
  26. NSString* str;
  27. UIView* vi; UIButton*btn;
  28. UILabel* label;
  29. vi = [UIView new];
  30. [self.view addSubview:vi];
  31. UIScrollView* sv = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height - kNavOffSet)];
  32. [sv setShowsVerticalScrollIndicator:NO];
  33. [self.view addSubview:sv];
  34. scroll = sv;
  35. CGFloat x,y,w,h,bd;
  36. CGFloat sRate = .75;//图标缩放比率
  37. bd = 10;
  38. x = y = bd ;
  39. w = kSize.width - bd*2;
  40. h = 6* 40;
  41. vi = [[UIView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  42. // [vi setBackgroundColor:defGreen];
  43. [vi setBackgroundColor:[UIColor whiteColor]];
  44. [sv addSubview:vi];
  45. [vi borderColor:lineColor width:1 cornorRadios:.01];
  46. //------------------------------------------------------------------
  47. UIImageView* iv;
  48. w = h = 40;
  49. iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  50. // [iv imageName:@"send_title_icon.png"];
  51. [iv setImage:[UIImage imageNamed:@"send_title_icon.png"]];
  52. [iv scale:sRate];
  53. [sv addSubview:iv];
  54. UITextView* textV;
  55. x += w + 15;
  56. w = kSize.width - bd*2 - x;
  57. textV = [[UITextView alloc] initWithFrame:CGRectMake(x, y+1, w, h-1)];//防止遮住边框
  58. [textV setFont:[UIFont scaleSize:FontTitle]];
  59. textV.userInteractionEnabled = NO;
  60. [sv addSubview:textV];
  61. [textV setDelegate:self];
  62. msgTit = textV;
  63. btn = [[UIButton alloc] initWithFrame:textV.frame];
  64. str = @"请输入培训标题";
  65. btn.width = [str sizeForFont:FontTitle].width;
  66. btn.x += (textV.width - btn.width)/2.0;
  67. // btn.x = kSize.width - btn.width - 10;
  68. [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
  69. [btn setTitle:str forState:UIControlStateNormal];
  70. [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
  71. [sv addSubview:btn];
  72. holder0 = btn;
  73. //------------------------------------------------------------------
  74. w = h;
  75. x = bd;
  76. y += h;
  77. iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  78. [iv setImage:[UIImage imageNamed:@"send_content_icon.png"]];
  79. [iv scale:sRate];
  80. [sv addSubview:iv];
  81. x += w + 15;
  82. h *= 5;
  83. w = kSize.width - bd*2 - x;
  84. textV = [[UITextView alloc] initWithFrame:CGRectMake(x, y, w, h-1)];
  85. [textV setFont:[UIFont scaleSize:FontTitle]];
  86. [textV setBackgroundColor:[UIColor clearColor]];
  87. textV.userInteractionEnabled = NO;
  88. [sv addSubview:textV];
  89. textV.tag = 1;//用于隐藏holder
  90. msgCont = textV;
  91. [textV setDelegate:self];
  92. btn = [[UIButton alloc] initWithFrame:textV.frame];
  93. btn.titleLabel.numberOfLines = 0;
  94. str = @"请输入培训任务内容(最大限制50字)";
  95. [btn setTitle:str forState:UIControlStateNormal];
  96. btn.size = [str sizeForFont:FontTitle];
  97. btn.center = textV.center;
  98. [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
  99. [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
  100. [sv addSubview:btn];
  101. holder1 = btn;
  102. [vi addViewWithRect:CGRectMake(bd, 50, kSize.width - bd*2, 1)];
  103. //------------------------------------------------------------------
  104. UIView* aView;
  105. y = vi.bottom + 25;
  106. x = bd;
  107. w = kSize.width - bd*2;
  108. h = 40*5;
  109. aView = [[UIView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  110. [aView setBackgroundColor:[UIColor whiteColor]];
  111. [sv addSubview:aView];
  112. [aView borderColor:lineColor width:1 cornorRadios:.01];
  113. w = h = 40;
  114. iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  115. [iv setImage:[UIImage imageNamed:@"send_people_num_icon.png"]];
  116. [iv scale:sRate];
  117. [sv addSubview:iv];
  118. x += w + 15;
  119. str = @"培训人数:";
  120. w = [str sizeForFont:FontTitle].width;
  121. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
  122. [label setText:str];
  123. [label setFont:[UIFont scaleSize:FontTitle]];
  124. [sv addSubview:label];
  125. x += w + 15;
  126. w = 100;
  127. textV = [[UITextView alloc] initWithFrame:CGRectMake(x, y+1, w, h-1)];//防止遮住边框
  128. [textV setTextColor:contentTextColor];
  129. [textV setFont:[UIFont systemFontOfSize:FontTitle]];
  130. textV.keyboardType = UIKeyboardTypeNumberPad;
  131. textV.userInteractionEnabled = NO;
  132. [sv addSubview:textV];
  133. msgNum = textV;
  134. // x += w ;
  135. x += w +10;
  136. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
  137. [label setFont:[UIFont scaleSize:FontTitle]];
  138. [label setText:@"人"];
  139. [sv addSubview:label];
  140. //------------------------------------------------------------------
  141. x = bd;
  142. y += h;
  143. w = h = 40;
  144. iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  145. [iv setImage:[UIImage imageNamed:@"send_date_icon.png"]];
  146. [iv scale:sRate];
  147. [sv addSubview:iv];
  148. x += w + 15;
  149. str = @"培训日期:";
  150. w = [str sizeForFont:FontTitle].width;
  151. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
  152. [label setText:str];
  153. [label setFont:[UIFont scaleSize:FontTitle]];
  154. [sv addSubview:label];
  155. x += w + 15;
  156. w = kSize.width - x - 10;
  157. btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
  158. [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  159. [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
  160. [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
  161. [sv addSubview:btn];
  162. btnDate = btn;
  163. w = h;
  164. x = kSize.width - w - bd;
  165. iv = [[UIImageView alloc] initWithFrame:CGRectMake(x+10, y+10, w-20, h-20)];
  166. [iv setImage:[UIImage imageNamed:@"arrow_next.png"]];
  167. [iv scale:sRate];
  168. [sv addSubview:iv];
  169. //------------------------------------------------------------------
  170. x = bd;
  171. y += h;
  172. w = h = 40;
  173. iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  174. [iv setImage:[UIImage imageNamed:@"send_time_icon.png"]];
  175. [iv scale:sRate];
  176. [sv addSubview:iv];
  177. x += w + 15;
  178. str = @"培训时间:";
  179. w = [str sizeForFont:FontTitle].width;
  180. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
  181. [label setText:str];
  182. [label setFont:[UIFont scaleSize:FontTitle]];
  183. [sv addSubview:label];
  184. x += w + 15;
  185. w = kSize.width - x - 10;
  186. btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h-1)];
  187. [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  188. [btn setTitleColor:contentTextColor forState:UIControlStateNormal];
  189. [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
  190. [sv addSubview:btn];
  191. btnTime = btn;
  192. w = h;
  193. x = kSize.width - w - bd;
  194. btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
  195. [btn setImage:[UIImage imageNamed:@"planPen.png"] forState:UIControlStateNormal];
  196. [btn scale:sRate];
  197. // [sv addSubview:btn];
  198. // btnCrTime = btn;
  199. //------------------------------------------------------------------
  200. x = bd;
  201. y += h;
  202. w = h = 40;
  203. iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  204. [iv setImage:[UIImage imageNamed:@"send_tel_icon.png"]];
  205. [iv scale:sRate];
  206. [sv addSubview:iv];
  207. x += w + 15;
  208. str = @"培训电话:";
  209. w = [str sizeForFont:FontTitle].width;
  210. label = [[UILabel alloc] initWithFrame:CGRectMake(x, y+1, w, h)];
  211. [label setText:str];
  212. [label setFont:[UIFont scaleSize:FontTitle]];
  213. [sv addSubview:label];
  214. x += w + 12;
  215. w = kSize.width - x - 10;
  216. textV = [[UITextView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  217. [textV setFont:[UIFont systemFontOfSize:FontTitle]];
  218. [textV setTextColor:contentTextColor];
  219. [textV setTextAlignment:NSTextAlignmentLeft];
  220. textV.keyboardType = UIKeyboardTypeNumberPad;
  221. textV.userInteractionEnabled = NO;
  222. [sv addSubview:textV];
  223. msgTel = textV;
  224. //------------------------------------------------------------------
  225. x = bd;
  226. y += h;
  227. w = h = 40;
  228. iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
  229. [iv setImage:[UIImage imageNamed:@"send_subject_icon.png"]];
  230. [iv scale:sRate];
  231. [sv addSubview:iv];
  232. x += w + 15;
  233. w = kSize.width - bd - x;
  234. btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
  235. [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  236. [btn setTitle:@"请选择培训科目" forState:UIControlStateNormal];
  237. [btn setTitleColor:titleColor forState:UIControlStateNormal];
  238. [btn.titleLabel setFont:[UIFont scaleSize:FontTitle]];
  239. [sv addSubview:btn];
  240. btnSubj = btn;
  241. for (int i =0; i<4; i++) {
  242. [aView addViewWithRect:CGRectMake(10,aView.y + 40*(i+1), kSize.width - 20, 1)];
  243. }
  244. y+= h+bd;
  245. w = 100;
  246. x = kSize.width - w - bd;
  247. btn = [[UIButton alloc] initWithFrame:CGRectMake(x, y, w, h)];
  248. [btn setBackgroundColor:defGreen];
  249. [btn setTitle:@"取消预约" forState:UIControlStateNormal];
  250. [scroll addSubview:btn];
  251. btn.layer.cornerRadius = btn.height*.5;
  252. btn.layer.masksToBounds = YES;
  253. [btn target:self tag:1];
  254. cancelBtn = btn;
  255. x = bd;
  256. w = kSize.width - w - 2*bd;
  257. label = [[UILabel alloc] setxywh];
  258. [scroll addSubview:label];
  259. appointLabel = label;
  260. [msgTit setText:_model[@"TITLE"]];
  261. [msgCont setText:_model[@"CONTENT"]];
  262. [msgNum setText:_model[@"PI_NUM"]];
  263. [btnDate setTitle:_model[@"TASKTIME"] forState:UIControlStateNormal];
  264. [btnTime setTitle:_model[@"TIMES"] forState:UIControlStateNormal];
  265. [msgTel setText:_model[@"TEL"]];
  266. str = _model[@"KM"];
  267. if ( 2 == str.intValue ) {
  268. [btnSubj setTitle:@"科目二" forState:UIControlStateNormal];
  269. }else{
  270. [btnSubj setTitle:@"科目三" forState:UIControlStateNormal];
  271. }
  272. [self textViewDidChange:msgTit];
  273. //如果能进来 要么有过发起预约操作 要么就是过期了
  274. if ([_model[@"STATUS"] isEqualToString:@"0"]) {
  275. cancelBtn.hidden = YES;
  276. appointLabel.hidden = NO;
  277. appointLabel.text = @"教练拒绝了您的预约";
  278. }else if ([_model[@"STATUS"] isEqualToString:@"1"]){
  279. cancelBtn.hidden = NO;
  280. appointLabel.hidden = NO;
  281. appointLabel.text = @"教练同意了您的预约";
  282. }else if ([_model[@"STATUS"] isEqualToString:@"2"]){
  283. cancelBtn.hidden = NO;
  284. appointLabel.hidden = NO;
  285. appointLabel.text = @"教练还未审核该预约哦!";
  286. }else if ([_model[@"STATUS"] isEqualToString:@"-1"]){
  287. cancelBtn.hidden = YES;
  288. appointLabel.hidden = NO;
  289. appointLabel.text = @"该预约已过期";
  290. }
  291. NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  292. [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  293. NSDate *crDate = [NSDate date];
  294. if ([_model[@"TIMES"] rangeOfString:@"-"].location != NSNotFound && [_model[@"TASKTIME"] rangeOfString:@"-"].location != NSNotFound) {
  295. NSString *startTime = [NSString stringWithFormat:@"%@ %@:00",_model[@"TASKTIME"],[[_model[@"TIMES"] componentsSeparatedByString:@"-"] firstObject]];
  296. crDate = [formatter dateFromString:startTime];
  297. }
  298. NSDate *nowDate = [NSDate date];
  299. NSComparisonResult result = [crDate compare:nowDate];
  300. if (result == NSOrderedAscending){
  301. //NSLog(@"已过期");
  302. cancelBtn.hidden = YES;
  303. }
  304. [sv setContentSize:CGSizeMake(0, [sv.subviews lastObject].bottom)];
  305. }
  306. -(void)btnClick:(UIButton*)sender
  307. {
  308. //这个地方要写取消预约的操作
  309. [self cancelReserve];
  310. }
  311. -(void)textViewDidChange:(UITextView *)textView
  312. {
  313. holder0.hidden = msgTit.text.length >0;
  314. holder1.hidden = msgCont.text.length >0;
  315. }
  316. -(void)cancelReserve
  317. {
  318. ShowHUD();
  319. if (![Util connectedToNetWork]) {
  320. showMsgUnconnect();
  321. return;
  322. }
  323. NSMutableArray *arr=[NSMutableArray array];
  324. [arr addPro:@"pid" Value:_model[@"ID"]];
  325. [arr addPro:@"reserveId" Value:_model[@"RESERVE_ID"]];
  326. [arr addPro:@"jxbh" Value:defUser.userSchoolId];
  327. NSString* method = @"cancelReserve";
  328. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  329. RemoveHUD();
  330. //NSLog(@"取消预约---->%@---->%@",method,root);
  331. if (!root)
  332. {
  333. [LoadingView showMsg:@"操作失败"];
  334. return;
  335. }
  336. if ([root[@"code"] isEqualToString:@"1"]) {
  337. [LoadingView showMsg:root[@"body"]];
  338. return;
  339. }
  340. ShowMsgSuc();
  341. self.coachVC.isRefresh = YES;
  342. [self.navigationController popViewControllerAnimated:YES];
  343. }];
  344. }
  345. @end