SchDetailVC.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. #import "SchDetailVC.h"
  2. #import "CLButton.h"
  3. #import "STButton.h"
  4. #import "EXButton.h"
  5. #import "SchInfo.h"
  6. #import "SearchComment.h"
  7. #import "FaqVC.h"
  8. #import "ApplyVC.h"
  9. #import "descVC.h"
  10. #import "TopicesVC.h"
  11. #import "SchoolNewsVC.h"
  12. #import "MapVC.h"
  13. #import "KSchoolCell.h"
  14. @interface SchDetailVC ()<UIAlertViewDelegate,UITableViewDelegate,UITableViewDataSource>
  15. {
  16. UILabel *lbl00, *lbl01, *lbl02, *lbl03, *lbl10;
  17. UILabel *kName, *kPrice, *kType, *kCar, *kTime, *kAdress, *kPick;
  18. UIView *kHolder;
  19. CLButton *btn00, *btn01, *btn02, *btn3, *btn4, *btn5;
  20. UIScrollView *scroll;
  21. UITableView *mainTableView;
  22. SchInfo *schInfo;
  23. UIImageView *img00;
  24. NSMutableArray *starImgs;
  25. NSDictionary *model;
  26. NSArray *dataArray;
  27. NSArray *types;
  28. }
  29. @end
  30. @implementation SchDetailVC
  31. - (void)viewDidLoad
  32. {
  33. [super viewDidLoad];
  34. self.title = @"驾校详情";
  35. self.view.backgroundColor = [UIColor whiteColor];
  36. [self configNavigationBar];
  37. [self myInit];
  38. }
  39. - (void)didReceiveMemoryWarning
  40. {
  41. [super didReceiveMemoryWarning];
  42. }
  43. #pragma mark -
  44. -(void)myInit
  45. {
  46. dataArray = [NSArray array];
  47. types = @[@"陪练",@"复训",@"计时训练",@"报名",@"",@"",@""];
  48. scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height - kNavOffSet - kSafeAreaBottomHeight)];
  49. [self.view addSubview:scroll];
  50. [self.view setBackgroundColor:[UIColor whiteColor]];
  51. scroll.scrollEnabled = YES;
  52. //下方按钮条
  53. UIView* bar = [[UIView alloc] initWithFrame:CGRectMake(0, kSize.height - kNavOffSet - 60 - kSafeAreaBottomHeight, self.view.width, 60)];
  54. [bar setBackgroundColor:backGroundColor];
  55. [self.view addSubview:bar];
  56. [self.view bringSubviewToFront:bar];
  57. NSArray* titles = @[@"点评",@"问答"/*,@"报名"*/];
  58. NSArray* images = @[@"img03pen.png",@"img04talk.png"/*,@"img05Rig.png"*/];
  59. CGFloat w,bd;
  60. w = 60;
  61. // bd = (self.view.width - w*3)/4.0;
  62. bd = (self.view.width - w*2)/3.0;
  63. for (int i =0; i<titles.count; i++) {
  64. STButton* btn = [[STButton alloc] initWithFrame:CGRectMake((bd+w)*i+bd, 0, w, 60)];
  65. [btn setStyle:1];
  66. [btn setImage:[UIImage imageNamed:images[i]] withTitle:titles[i] Font:13 forState:UIControlStateNormal];
  67. [btn setTitleColor:subTitleColor forState:UIControlStateNormal];
  68. [btn target:self tag:i-3];
  69. [bar addSubview:btn];
  70. }
  71. UILabel* label;
  72. UIImageView* iv;
  73. CLButton* btn;
  74. CGFloat dx,dy;
  75. CGFloat imgw;
  76. CGFloat curTop;
  77. dx = 90; dy = dx*.6; bd = 8;
  78. iv = [[UIImageView alloc] initWithFrame:SGRectMake(bd, bd , dx, dy)];
  79. [iv setContentMode:UIViewContentModeScaleAspectFit];
  80. [iv setImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
  81. [scroll addSubview:iv];
  82. //头像
  83. img00 = iv;
  84. label = [[UILabel alloc] initWithFrame:SGRectMake(dx+bd*2, 0, dx*2 + 20, (dy+bd*2)/3)];
  85. [scroll addSubview:label];
  86. //名称
  87. lbl00 = label;
  88. imgw = 10;
  89. //星星
  90. starImgs = [NSMutableArray array];
  91. for (int i =0; i<5; i++)
  92. {
  93. iv = [[UIImageView alloc] initWithFrame:SGRectMake(dx+bd*2 + imgw*1.3*i, (dy+bd*2)/2-imgw/2, imgw, imgw)];
  94. [iv setImage:[UIImage imageNamed:@"rankstar0_img.png"]];
  95. iv.hidden = YES;
  96. [scroll addSubview:iv];
  97. [starImgs addObject:iv];
  98. }
  99. label = [[UILabel alloc] initWithFrame:SGRectMake(dx+bd*2, (dy+bd*2)*2/3, dx, (dy+bd*2)/3)];
  100. [label setText:@"" Font:FontTitle TextColor:[UIColor redColor]];
  101. [scroll addSubview:label];
  102. //价格
  103. lbl01 = label;
  104. label = [[UILabel alloc] initWithFrame:SGRectMake(320-dx-bd, (dy+bd*2)*2/3, dx, (dy+bd*2)/3)];
  105. [label setText:@"" Font:FontTitle TextColor:kTitleColor Alignment:NSTextAlignmentRight];
  106. [scroll addSubview:label];
  107. //关注
  108. lbl02 = label;
  109. curTop = dy+bd+bd+bd;
  110. dy = 35;
  111. btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop , 320, dy)];
  112. [btn setImage:[UIImage imageNamed:@"mobile_phone_ico.png"] withTitle:@"10086" Font:NormalFont forState:UIControlStateNormal];
  113. [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  114. [scroll addSubview:btn];
  115. [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  116. [btn setTag:0];
  117. //电话按钮(已添加拨打功能)tag=0
  118. btn00 = btn;
  119. [btn addViewWithRect:SGRectMake(0, curTop , 320, .5) Color:KlineColor];
  120. btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop+dy, 320, dy)];
  121. [btn setImage:[UIImage imageNamed:@"address_icon.png"] withTitle:@"辽宁省" Font:NormalFont forState:UIControlStateNormal];
  122. [btn target:self tag:1];
  123. [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  124. [scroll addSubview:btn];
  125. //地址按钮
  126. btn01 = btn;
  127. [btn addViewWithRect:SGRectMake(0, curTop +dy, 320, .5) Color:KlineColor];
  128. btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop+dy*2, 320, dy)];
  129. [btn setImage:[UIImage imageNamed:@"subject1_simulate_execercise_more_icon.png"] withTitle:@"路线" Font:NormalFont forState:UIControlStateNormal];
  130. [btn target:self tag:2];
  131. [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  132. [scroll addSubview:btn];
  133. //路线按钮
  134. btn02 = btn;
  135. [btn addViewWithRect:SGRectMake(0, curTop +dy*2, 320, .5) Color:KlineColor];
  136. curTop += dy*3 + bd;
  137. btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop, 320, dy)];
  138. [btn setDetailN:@"更多 >"];
  139. [scroll addSubview:btn];
  140. [btn target:self tag:10];
  141. //更多驾校详情按钮
  142. btn3 = btn;
  143. //添加黑色隔条
  144. [btn addViewWithRect:SGRectMake(0, curTop-bd, 320, bd) Color:KlineColor];
  145. label = [[UILabel alloc] initWithFrame:SGRectMake(bd, curTop, 80, dy)];
  146. [label setText:@"驾校简介"];
  147. [label setTextColor:contentTextColor];
  148. [scroll addSubview:label];
  149. lbl03= label;
  150. CGFloat lblh = 60;
  151. label = [[UILabel alloc] initWithFrame:SGRectMake(bd, curTop+dy, 320-bd*2, lblh)];
  152. [label setNumberOfLines:0];
  153. [label setTextColor:contentTextColor];
  154. [scroll addSubview:label];
  155. //简介内容
  156. lbl10 = label;
  157. [label addViewWithRect:SGRectMake(0, curTop+dy, 320, .5) Color:KlineColor];
  158. curTop += lblh + dy;
  159. UIButton* btnn;
  160. [btnn addViewWithRect:SGRectMake(0, curTop, 320, .5) Color:KlineColor];
  161. btnn = [[UIButton alloc] initWithFrame:SGRectMake(0, curTop, 320, dy)];
  162. [btnn setTitle:@"驾校新闻" textColor:defGreen font:16 fotState:UIControlStateNormal];
  163. [btnn target:self tag:12];
  164. [scroll addSubview:btnn];
  165. [btnn addSelfViewWithRect:SGRectMake(0, - 1 ,320, 1) Color:KlineColor];
  166. //驾校新闻按钮
  167. btn4 = (CLButton*)btnn;
  168. btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop + dy + bd, 320, dy)];
  169. [btn setTitle:@"" textColor:contentTextColor font:NormalFont fotState:UIControlStateNormal];
  170. [btn setImage:nil forState:UIControlStateNormal];
  171. [btn setDetailN:@"点击加入讨论 >"];
  172. [btn target:self tag:13];
  173. [scroll addSubview:btn];
  174. //跳转驾校社区按钮
  175. btn5 = btn;
  176. [btn addSelfViewWithRect:SGRectMake(0, - bd ,320, bd) Color:KlineColor];
  177. [btn addSelfViewWithRect:SGRectMake(0, dy ,320, bd) Color:KlineColor];
  178. //课程信息部分
  179. CGFloat y = curTop + 2*(dy + bd);
  180. label = [[UILabel alloc] initWithFrame:SGRectMake(bd, y, 320-bd, dy)];
  181. [label setText:@"培训类型"];
  182. [label setFont:[UIFont scaleSize:16]];
  183. [label setTextColor:contentTextColor];
  184. [scroll addSubview:label];
  185. y += dy;
  186. //用这个表来展示数据吧
  187. mainTableView = [[UITableView alloc] initWithFrame:SGRectMake(0, y, kSize.width, 0) style:UITableViewStylePlain];
  188. mainTableView.delegate = self;
  189. mainTableView.dataSource = self;
  190. mainTableView.scrollEnabled = NO;
  191. [scroll addSubview:mainTableView];
  192. kHolder = [[UIView alloc] initWithFrame:SGRectMake(0, y, kSize.width, 185)];
  193. kHolder.backgroundColor = backGroundColor;
  194. [scroll addSubview:kHolder];
  195. label = [[UILabel alloc] initWithFrame:SGRectMake(20, 0, kSize.width - 40, 30)];
  196. label.text = @"该驾校暂无课程信息哦~";
  197. label.textColor = defGreen;
  198. [label addSelfViewWithRect:SGRectMake(-20, 30 ,320, 1) Color:KlineColor];
  199. [kHolder addSubview:label];
  200. [scroll setContentSize:CGSizeMake(kSize.width, mainTableView.y + 120)];
  201. [self getSchInfoById];
  202. }
  203. //这个是刷新驾校的UI
  204. -(void)freshUI
  205. {
  206. int starNum = [model[@"star"] intValue];
  207. if (starNum == 0)
  208. {
  209. starNum = 3;
  210. }
  211. for (int i = 0; i < starNum; i ++)
  212. {
  213. UIImageView *img = starImgs[i];
  214. img.hidden = NO;
  215. }
  216. NSString *path = nil;
  217. NSString *str;
  218. if ([model[@"headimg"] length] > 1) {
  219. path = model[@"headimg"];
  220. }
  221. [img00 sd_setImageWithURL:[NSURL URLWithString:path] placeholderImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
  222. img00.userInteractionEnabled = YES;
  223. [img00 addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImage:)]];
  224. [lbl00 setText:model[@"name"] Font:FontTitle TextColor:kTitleColor];
  225. str = model[@"price"];
  226. if ([str isEqualToString:@""] || [str isEqualToString:@"0"]) {
  227. str = @"¥暂无";
  228. }else{
  229. str = [NSString stringWithFormat:@"¥%@",str];
  230. }
  231. [lbl01 setText:str];
  232. [lbl02 setText:[NSString stringWithFormat:@"%@人关注",model[@"watch"]]];
  233. [btn00 setTitle:model[@"telePhone"] forState:UIControlStateNormal];
  234. [btn01 setTitle:model[@"address"] forState:UIControlStateNormal];
  235. NSString *route = [NSString stringWithFormat:@"班车路线: %@",model[@"route"]];
  236. if ([model[@"route"] length] == 0) {
  237. route = @"班车路线: 暂无";
  238. }
  239. [btn02 setTitle:route forState:UIControlStateNormal];
  240. [btn5 setTitle:model[@"shortName"] forState:UIControlStateNormal];
  241. str = model[@"desc"];
  242. if (str.length == 0)
  243. {
  244. str = @"暂无相关简介";
  245. }
  246. [lbl10 setText:str];
  247. [btn5 setDetailN:@"点击加入讨论 >"];
  248. //课程信息
  249. NSArray *kArray = model[@"products"];
  250. if (kArray.count == 0) {
  251. [kHolder setHidden:NO];
  252. [scroll setContentSize:CGSizeMake(kSize.width, mainTableView.y + 120)];
  253. }else{
  254. [kHolder setHidden:YES];
  255. dataArray = [NSArray arrayWithArray:kArray];
  256. mainTableView.height = 44*dataArray.count + 55;
  257. [scroll setContentSize:CGSizeMake(kSize.width, mainTableView.y + mainTableView.height + 100)];
  258. [mainTableView reloadData];
  259. }
  260. }
  261. -(void)btnClick:(UIButton*)sender
  262. {
  263. int tag = (int)sender.tag;
  264. if (-1 == tag) {
  265. //报名
  266. NSString* str = model[@"jxbh"];
  267. NSString* str1 = model[@"name"];
  268. if (str && str1) {
  269. ApplyVC *appVC = [[ApplyVC alloc] init];
  270. appVC.jxbh = str;
  271. appVC.jxmc = str1;
  272. [self navPushHideTabbarToVC:appVC];
  273. }else{
  274. ShowMsgFailed();
  275. }
  276. }
  277. if ( 0 == tag)
  278. {
  279. NSString *telString = model[@"telePhone"];
  280. if (!telString || telString.length < 1) {
  281. return;
  282. }
  283. UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:model[@"telePhone"] delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"呼叫", nil];
  284. [alert show];
  285. return;
  286. }
  287. if (tag == 1)
  288. {
  289. //进入地图页面
  290. MapVC *mapVC = [[MapVC alloc] init];
  291. // mapVC.jxdz = model[@"address"];
  292. mapVC.lat = [model[@"latitude"] doubleValue];
  293. mapVC.lng = [model[@"longitude"] doubleValue];
  294. mapVC.isJustLoad = YES;
  295. mapVC.siteName = model[@"shortName"];
  296. [self navPushHideTabbarToVC:mapVC];
  297. }
  298. if (tag == 2)
  299. {
  300. descVC *vc = [[descVC alloc] init];
  301. vc.titleString = @"路线详情";
  302. vc.desc = model[@"route"];
  303. [self navPushHideTabbarToVC:vc];
  304. }
  305. if (tag == 10)
  306. {
  307. descVC *vc = [[descVC alloc] init];
  308. vc.desc = model[@"desc"];
  309. vc.titleString = @"驾校简介";
  310. [self navPushHideTabbarToVC:vc];
  311. }
  312. //下面需要有驾校编号才能进入
  313. NSString *jxbh = model[@"jxbh"];
  314. if (!jxbh || jxbh.length < 1) {
  315. return;
  316. }
  317. if (-3 == tag) {
  318. SearchComment* vc = [[SearchComment alloc] init];
  319. vc.bpjr = jxbh;
  320. vc.type = @"1";
  321. [self navPushHideTabbarToVC:vc];
  322. }
  323. if (-2 == tag) {
  324. FaqVC* vc = [FaqVC new];
  325. [vc setJxbh:jxbh];
  326. [self navPushHideTabbarToVC:vc];
  327. }
  328. if (tag == 12)
  329. {
  330. //NSLog(@"新闻");
  331. SchoolNewsVC *news = [[SchoolNewsVC alloc] init];
  332. news.jxbh = jxbh;
  333. [self navPushHideTabbarToVC:news];
  334. }
  335. if (tag == 13)
  336. {
  337. TopicesVC* vc = [[TopicesVC alloc] init];
  338. vc.type = @"1";
  339. vc.groupId = @"-1";
  340. vc.jxbh = jxbh;
  341. vc.jxjc = model[@"shortName"];
  342. [self navPushHideTabbarToVC:vc];
  343. }
  344. if (tag == 14)
  345. {
  346. //NSLog(@"更多课程");
  347. }
  348. }
  349. -(void)tapImage:(UITapGestureRecognizer *)tap
  350. {
  351. NSArray *images = model[@"schPlaces"];
  352. if (images.count < 1) {
  353. return;
  354. }
  355. NSMutableArray *urls = [NSMutableArray array];
  356. for (NSDictionary *dic in images) {
  357. if (dic[@"filePath"]) {
  358. [urls addObject:dic[@"filePath"]];
  359. }
  360. }
  361. [RQ_SHARE_FUNCTION showPhotoBrowserWithDataSource:urls currentIndex:0 isCanSave:YES];
  362. }
  363. //弹出显示详细课程信息
  364. -(void)getViewWithDic:(NSDictionary *)dic
  365. {
  366. UIView *vi = [[UIView alloc] initWithFrame:CGRectMake(-1, kSize.height/2.0 - 80, kSize.width + 2, 200)];
  367. vi.backgroundColor = backGroundColor;
  368. vi.layer.borderColor = defGreen.CGColor;
  369. vi.layer.borderWidth = 1;
  370. [self.view addSubview:vi];
  371. CGFloat kx,ky,kw,kh;
  372. kx = 8;
  373. ky = 0;
  374. kw = kSize.width/2.0 - 9;
  375. kh = 30;
  376. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, ky, 2*kw - 100, kh)];
  377. label.textColor = kTitleColor;
  378. label.textAlignment = NSTextAlignmentCenter;
  379. label.font = [UIFont scaleSize:18];
  380. label.text = @"培训详情";
  381. [vi addSubview:label];
  382. EXButton* btn = [[EXButton alloc] initWithFrame:CGRectMake(kSize.width - 50, 0, 30, 30)];
  383. [btn addTarget:self action:@selector(removeKView:) forControlEvents:UIControlEventTouchUpInside];
  384. [btn setImage:[[UIImage imageNamed:@"question_error.png"] tint:[UIColor grayColor]] forState:UIControlStateNormal];
  385. [btn setTitle:@"×" textColor:[UIColor whiteColor] font:30 fotState:UIControlStateNormal];
  386. [vi addSubview:btn];
  387. ky += kh + 8;
  388. label = [[UILabel alloc] initWithFrame:CGRectMake(kx, ky, kw, kh)];
  389. label.textColor = kTitleColor;
  390. [vi addSubview:label];
  391. kName = label;
  392. kx += kw;
  393. label = [[UILabel alloc] initWithFrame:CGRectMake(kx, ky, kw, kh)];
  394. label.textColor = kTitleColor;
  395. [vi addSubview:label];
  396. kPrice = label;
  397. ky += kh;
  398. label = [[UILabel alloc] initWithFrame:CGRectMake(kx, ky, kw, kh)];
  399. label.textColor = kTitleColor;
  400. [vi addSubview:label];
  401. kCar = label;
  402. kx -= kw;
  403. label = [[UILabel alloc] initWithFrame:CGRectMake(kx, ky, kw, kh)];
  404. label.textColor = kTitleColor;
  405. [vi addSubview:label];
  406. kType = label;
  407. kw *= 2;
  408. ky += kh;
  409. NSMutableArray *kLabels = [NSMutableArray arrayWithCapacity:3];
  410. for (int i = 0; i < 3; i ++) {
  411. label = [[UILabel alloc] initWithFrame:CGRectMake(kx, ky + i*kh, kw, kh)];
  412. label.textColor = kTitleColor;
  413. [vi addSubview:label];
  414. [kLabels addObject:label];
  415. }
  416. kTime = kLabels[0];
  417. kAdress = kLabels[1];
  418. kPick = kLabels[2];
  419. kName.text = [NSString stringWithFormat:@"课程:%@",types[[dic[@"shopType"] intValue] - 1]];
  420. kPrice.text = [NSString stringWithFormat:@"价格:%@%@",dic[@"price"],dic[@"priceUnit"]];
  421. kType.text = [NSString stringWithFormat:@"证件:%@",dic[@"permitCarType"]];
  422. kCar.text = [NSString stringWithFormat:@"车辆:%@",dic[@"carBrands"]];
  423. kTime.text = [NSString stringWithFormat:@"学车时间:%@",dic[@"time"]];
  424. kAdress.text = [NSString stringWithFormat:@"训练场地:%@",dic[@"address"]];
  425. if ([dic[@"shopType"] isEqualToString:@"4"]) {
  426. kPick.text = @"接送信息:不接送";
  427. }else{
  428. if ([dic[@"isPick"] isEqualToString:@"0"]) {
  429. kPick.text = @"接送信息:不接送";
  430. }else{
  431. kPick.text = [NSString stringWithFormat:@"接送信息:%@[%@]",dic[@"pickAddress"],dic[@"pickTime"]];
  432. }
  433. }
  434. }
  435. -(void)removeKView:(EXButton *)sender
  436. {
  437. UIView *view = sender.superview;
  438. if (view) {
  439. [view removeFromSuperview];
  440. }
  441. }
  442. #pragma mark tableView delegate
  443. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  444. {
  445. return dataArray.count;
  446. }
  447. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  448. {
  449. KSchoolCell *cell = [tableView dequeueReusableCellWithIdentifier:@"kCell"];
  450. if (cell == nil)
  451. {
  452. cell = [[KSchoolCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"kCell"];
  453. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  454. }
  455. NSDictionary *dic = dataArray[indexPath.row];
  456. cell.nameLabel.text = types[[dic[@"shopType"] intValue] - 1];
  457. cell.priceLabel.text = dic[@"price"];
  458. cell.unitLabel.text = dic[@"priceUnit"];
  459. cell.carTypeLabel.text = dic[@"permitCarType"];
  460. return cell;
  461. }
  462. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  463. {
  464. NSDictionary *dic = dataArray[indexPath.row];
  465. [self getViewWithDic:dic];
  466. }
  467. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  468. {
  469. UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, 50)];
  470. headerView.backgroundColor = backGroundColor;
  471. CGFloat width = (kSize.width - 16)/7.0;
  472. CGFloat x,y,w,h,bd;
  473. x = bd = 8;
  474. y = 5;
  475. w = 2*width;
  476. h = 40;
  477. UILabel *label = [[UILabel alloc] setxywh];
  478. label.textAlignment = NSTextAlignmentCenter;
  479. label.text = @"培训名称";
  480. [label setFont:[UIFont scaleSize:16]];
  481. [headerView addSubview:label];
  482. x += 2*width;
  483. w = 2*width;
  484. label = [[UILabel alloc] setxywh];
  485. label.textAlignment = NSTextAlignmentCenter;
  486. label.text = @"驾照";
  487. [label setFont:[UIFont scaleSize:16]];
  488. [headerView addSubview:label];
  489. x += 2.5*width;
  490. label = [[UILabel alloc] setxywh];
  491. label.textAlignment = NSTextAlignmentCenter;
  492. label.text = @"价格";
  493. [label setFont:[UIFont scaleSize:16]];
  494. [headerView addSubview:label];
  495. return headerView;
  496. }
  497. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  498. {
  499. return 50;
  500. }
  501. -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  502. return [UIView new];
  503. }
  504. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  505. {
  506. return .1;
  507. }
  508. #pragma mark - 获取驾校信息
  509. -(void)getSchInfoById
  510. {
  511. if (![Util connectedToNetWork]) {
  512. showMsgUnconnect();
  513. return;
  514. }
  515. NSMutableArray *arr=[NSMutableArray array];
  516. if (!_schoolId) {
  517. return;
  518. }
  519. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:_schoolId,@"id", nil]];
  520. NSString* method = @"getSchInfoById";
  521. [MBProgressHUD showLoadToView:self.view];
  522. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  523. [MBProgressHUD hideHUDForView:self.view];
  524. if (!root)
  525. {
  526. ShowMsgFailed();
  527. return;
  528. }
  529. NSString* code = root[@"code"];
  530. if ( 1 == code.intValue ) {
  531. [LoadingView showMsg:root[@"body"]];
  532. return;
  533. }
  534. NSDictionary* body = root[@"body"];
  535. model = body;
  536. [self freshUI];
  537. }];
  538. }
  539. #pragma mark - 呼叫功能
  540. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  541. {
  542. if (1 == buttonIndex)
  543. {
  544. NSString* str = model[@"telePhone"];
  545. NSMutableString * url=[[NSMutableString alloc] initWithFormat:@"tel:%@",str];
  546. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
  547. }
  548. }
  549. @end