CoachDetailVC.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. //
  2. // CoachDetailVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/4/28.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "CoachDetailVC.h"
  9. #import "CLButton.h"
  10. #import "STButton.h"
  11. #import "SearchComment.h"
  12. #import "descVC.h"
  13. @interface CoachDetailVC ()<UIAlertViewDelegate>
  14. {
  15. UILabel *nameLabel,*priceLabel,*lbl02,*lbl03,*lbl10;
  16. //添加项
  17. UILabel *scoreLabel;
  18. UILabel *cartypeLabel;
  19. UILabel *PermitLabel;
  20. UILabel *label11;
  21. UIImageView *headImgView;
  22. NSMutableArray *imgs0;
  23. CLButton* telBtn,*btn01,*btn02,*btn10,*btn11,*btn12,*btn20;
  24. UIScrollView* scroll;
  25. NSDictionary* model;
  26. UIButton *sizeBtn;
  27. }
  28. @end
  29. @implementation CoachDetailVC
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. self.title = @"教练详情";
  33. self.navigationController.navigationBar.translucent = NO;
  34. [self configNavigationBar];
  35. self.view.backgroundColor = [UIColor whiteColor];
  36. model = [[NSDictionary alloc] initWithDictionary:self.infoDic];
  37. NSLog(@"教练-->%@",self.infoDic);
  38. self.orderType = @"0";
  39. [self myInit];
  40. [self getCoachInfoById];
  41. }
  42. -(void)myInit
  43. {
  44. scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet-kSafeAreaBottomHeight)];
  45. [self.view addSubview:scroll];
  46. [self.view setBackgroundColor:[UIColor whiteColor]];
  47. UIView* bar = [[UIView alloc] initWithFrame:CGRectMake(0, kSize.height - kNavOffSet - kSafeAreaBottomHeight - 60, self.view.width, 60)];
  48. [bar setBackgroundColor:backGroundColor];
  49. [self.view addSubview:bar];
  50. [self.view bringSubviewToFront:bar];
  51. CGFloat bd = (self.view.width - 180)/4.0;
  52. STButton* commebtBtn = [[STButton alloc] initWithFrame:CGRectMake(2*bd+60, 0, 60, 60)];
  53. [commebtBtn setStyle:1];
  54. [commebtBtn setImage:[UIImage imageNamed:@"img03pen.png"] withTitle:@"点评" Font:13 forState:UIControlStateNormal];
  55. [commebtBtn setTitleColor:subTitleColor forState:UIControlStateNormal];
  56. [commebtBtn target:self tag:-1];
  57. [bar addSubview:commebtBtn];
  58. UILabel* label;
  59. UIImageView* imageView;
  60. CLButton* btn;
  61. CGFloat dx,dy,curTop,imgw;
  62. dx = 90; dy = dx*.6; bd = 8;
  63. imageView = [[UIImageView alloc] initWithFrame:SGRectMake(bd, bd , dx, dy)];
  64. [imageView setContentMode:UIViewContentModeScaleAspectFit];
  65. [imageView setImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
  66. [scroll addSubview:imageView];
  67. //头像
  68. headImgView = imageView;
  69. label = [[UILabel alloc] initWithFrame:SGRectMake(dx+bd*2, 5, dx*2, (dy+bd*2)/3)];
  70. [scroll addSubview:label];
  71. //名称
  72. nameLabel = label;
  73. imgw = 10;
  74. //星星
  75. imgs0 = [NSMutableArray array];
  76. for (int i =0; i<5; i++)
  77. {
  78. imageView = [[UIImageView alloc] initWithFrame:SGRectMake(dx+bd*2 + imgw*1.3*i, (dy+bd*2)/2-imgw/2 + 5, imgw, imgw)];
  79. [imageView setImage:[UIImage imageNamed:@"rankstar0_img.png"]];
  80. imageView.hidden = YES;
  81. [scroll addSubview:imageView];
  82. [imgs0 addObject:imageView];
  83. }
  84. label = [[UILabel alloc] initWithFrame:SGRectMake(dx+bd*2, (dy+bd*2)*2/3 + 5, dx, (dy+bd*2)/3)];
  85. [label setTextColor:[UIColor redColor]];
  86. [scroll addSubview:label];
  87. //价格
  88. priceLabel = label;
  89. curTop = dy+bd+bd+bd;
  90. dy = 35;
  91. btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop , 320, dy)];
  92. [btn setImage:[UIImage imageNamed:@"mobile_phone_ico.png"] withTitle:@"10086" Font:NormalFont forState:UIControlStateNormal];
  93. [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  94. [scroll addSubview:btn];
  95. [btn target:self tag:0];
  96. //电话按钮(已添加拨打功能)tag=0
  97. telBtn = btn;
  98. [btn addViewWithRect:SGRectMake(0, curTop , 320, 1) Color:KlineColor];
  99. btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop+dy, 320, dy)];
  100. [btn setImage:[UIImage imageNamed:@"drawer_img01"] withTitle:@"竟达汽车公司" Font:NormalFont forState:UIControlStateNormal];
  101. [btn target:self tag:1];
  102. [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  103. [scroll addSubview:btn];
  104. //所属公司
  105. btn01 = btn;
  106. [btn addViewWithRect:SGRectMake(0, curTop +dy, 320, .5) Color:KlineColor];
  107. btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop+dy*2, 320, dy)];
  108. [btn setImage:[UIImage imageNamed:@"address_icon.png"] withTitle:@"公司地址" Font:NormalFont forState:UIControlStateNormal];
  109. [btn target:self tag:2];
  110. [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
  111. [scroll addSubview:btn];
  112. //公司地址
  113. btn02 = btn;
  114. [btn addViewWithRect:SGRectMake(0, curTop +dy*2, 320, .5) Color:KlineColor];
  115. curTop += dy*3 + bd;
  116. btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop, 320, dy)];
  117. [btn setDetailN:@"更多 >"];
  118. [scroll addSubview:btn];
  119. [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  120. [btn setTag:10];
  121. //教练简介
  122. btn10 = btn;
  123. //添加黑色隔条
  124. [btn addViewWithRect:SGRectMake(0, curTop-bd, 320, bd) Color:KlineColor];
  125. label = [[UILabel alloc] initWithFrame:SGRectMake(bd, curTop, 80, dy)];
  126. [label setText:@"教练简介"];
  127. [label setTextColor:contentTextColor];
  128. [scroll addSubview:label];
  129. //只是简介
  130. lbl03= label;
  131. CGFloat lblh = 60;
  132. label = [[UILabel alloc] initWithFrame:SGRectMake(bd, curTop+dy, 320-bd*2, lblh)];
  133. [label setText:_infoDic[@"desc"]];
  134. [label setNumberOfLines:0];
  135. [label setTextColor:contentTextColor];
  136. [scroll addSubview:label];
  137. //简介内容
  138. lbl10 = label;
  139. [label addViewWithRect:SGRectMake(0, curTop+dy, 320, 1) Color:KlineColor];
  140. curTop += lblh + dy;
  141. scoreLabel = [[UILabel alloc] initWithFrame:SGRectMake(0, curTop, 160, dy)];
  142. scoreLabel.x +=8;
  143. scoreLabel.width -= 8;
  144. [scoreLabel setFont:[UIFont scaleSize:FontTitle]];
  145. [scoreLabel setTextColor:contentTextColor];
  146. [scroll addSubview:scoreLabel];
  147. [scoreLabel addSelfViewWithRect:SGRectMake(160-1, 5, 1, dy-10) Color:KlineColor];
  148. cartypeLabel = [[UILabel alloc] initWithFrame:SGRectMake(160, curTop, 160, dy)];
  149. cartypeLabel.x += 8;
  150. cartypeLabel.width -= 8;
  151. [cartypeLabel setFont:[UIFont scaleSize:FontTitle]];
  152. [cartypeLabel setTextColor:contentTextColor];
  153. [scroll addSubview:cartypeLabel];
  154. PermitLabel = [[UILabel alloc] initWithFrame:SGRectMake(0, curTop + dy + bd, 320, dy)];
  155. PermitLabel.x += 8;
  156. PermitLabel.width -= 8;
  157. [PermitLabel setFont:[UIFont scaleSize:FontTitle]];
  158. [PermitLabel setTextColor:contentTextColor];
  159. [scroll addSubview:PermitLabel];
  160. [PermitLabel addSelfViewWithRect:SGRectMake(0, -.5, 320, 1) Color:KlineColor];
  161. [PermitLabel addSelfViewWithRect:SGRectMake(0, dy, 320, 1) Color:KlineColor];
  162. // [PermitLabel addSelfViewWithRect:SGRectMake(0, - bd ,320, bd) Color:KlineColor];
  163. // [PermitLabel addSelfViewWithRect:SGRectMake(0, dy ,320, bd) Color:KlineColor];
  164. UIView *vi = [scroll.subviews lastObject];
  165. [scroll setContentSize:CGSizeMake(0, vi.y + vi.height + 100)];
  166. [self freshCoachUI];
  167. }
  168. -(void)setHeadImageView:(UIImageView *)image withImg:(NSString *)img
  169. {
  170. //设置图片大小不变 超出部分截掉
  171. if (img && img.length > 0) {
  172. image.contentMode = UIViewContentModeScaleAspectFit;
  173. }
  174. image.clipsToBounds = YES;
  175. NSString * imgStr = @"";
  176. if (img && img.length > 0) {
  177. imgStr = img;
  178. }
  179. [image sd_setImageWithURL:[NSURL URLWithString:imgStr] placeholderImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
  180. }
  181. -(void)btnClick:(UIButton*)sender
  182. {
  183. int tag = (int)sender.tag;
  184. if (tag == -1) {
  185. SearchComment* vc = [[SearchComment alloc] init];
  186. vc.bpjr = model[@"idcard"];
  187. vc.type = @"2";
  188. [self navPushHideTabbarToVC:vc];
  189. }
  190. if ( 0 == tag)
  191. {
  192. NSString *str = model[@"ciMobile"];
  193. if (!str) {
  194. str = model[@"ciTelephone"];
  195. }
  196. UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:str delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"呼叫", nil];
  197. [alert show];
  198. return;
  199. }
  200. if (tag == 10)
  201. {
  202. descVC *vc = [[descVC alloc] init];
  203. vc.desc = _infoDic[@"desc"];
  204. vc.titleString = @"教练简介";
  205. [self navPushHideTabbarToVC:vc];
  206. }
  207. }
  208. -(void)freshCoachUI
  209. {
  210. int starNum = [model[@"star"] intValue]/3;
  211. if (starNum == 0){
  212. starNum = 3;
  213. }
  214. if (starNum >5) {
  215. starNum = 5;
  216. }
  217. for (int i = 0; i < starNum; i ++)
  218. {
  219. UIImageView *img = imgs0[i];
  220. img.hidden = NO;
  221. }
  222. if ([self.orderType intValue] == 0)
  223. {
  224. //NSLog(@"headImg--->%@photo--->%@",model[@"headImg"],model[@"photo"]);
  225. NSString *headString = [Tools imageStringWithPhotoString:model[@"photo"] HeadImgString:model[@"headImg"] Type:2];
  226. [headImgView sd_setImageWithURL:[NSURL URLWithString:headString] placeholderImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
  227. [nameLabel setText:model[@"name"]];
  228. NSString *str = model[@"price"];
  229. if ([str isEqualToString:@""] || [str isEqualToString:@"0"]) {
  230. str = @"¥暂无";
  231. }else{
  232. str = [NSString stringWithFormat:@"¥%@",str];
  233. }
  234. [priceLabel setText:str];
  235. /*
  236. provinceName = 福建省,
  237. provinceId = 35,
  238. countryName = 思明区,
  239. id = 84092,
  240. pwd = e10adc3949ba59abbe56e057f20f883e,
  241. drivingDate = ,
  242. serviceStar = 5.0,
  243. watch = 57,
  244. address = 福建省厦门市思明区西林村东坪山社,
  245. py = fwk,
  246. teachCarType = C1,
  247. photo = ,
  248. teachStar = 5.0,
  249. jxbh = 14000108,
  250. sex = 1,
  251. idcard = 350211196506141511,
  252. occupationNO = ,
  253. outId = 1,
  254. star = 15.0,
  255. name = 傅维昆,
  256. count = ,
  257. schoolShortName = ,
  258. countryId = 350203,
  259. price = 100,
  260. cityName = 厦门市,
  261. mobile = 15060063160,
  262. cityId = 3502,
  263. cars = ,
  264. schoolName = 厦门市思明区启帆机动车驾驶员培训队,
  265. bindInfo = ,
  266. groupId = ,
  267. initPwd = 123456,
  268. occupationLevel = ,
  269. vip = 0,
  270. tollStar = 5.0
  271. */
  272. [telBtn setTitleN:model[@"mobile"]];
  273. [btn01 setTitleN:model[@"schoolShortName"]];
  274. [btn02 setTitleN:[NSString stringWithFormat:@"%@%@",model[@"cityName"],model[@"countryName"]]];
  275. str = model[@"desc"];
  276. if ( !str || [str isEqualToString:@""]) {
  277. str = @"暂无相关简介";
  278. }
  279. [lbl10 setText:str];
  280. [lbl03 setText:@"教练简介"];
  281. str = model[@"score"];
  282. if (str.length == 0)
  283. {
  284. str = @"暂无";
  285. }
  286. [scoreLabel setText:[NSString stringWithFormat:@"综合评分:%@",str]];
  287. [cartypeLabel setText:[NSString stringWithFormat:@"培训车型:%@",model[@"teachCarType"]]];
  288. [PermitLabel setText:[NSString stringWithFormat:@"许可培训:%@",model[@"cars"]]];
  289. }
  290. else
  291. {
  292. NSString* str = [Tools imageStringWithPhotoString:model[@"photo"] HeadImgString:model[@"headimg"] Type:2];
  293. [headImgView sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
  294. [nameLabel setText:model[@"name"]];
  295. if (self.orderType.intValue == 1)
  296. {
  297. str = model[@"fxPrice"];
  298. }else if (self.orderType.intValue == 2)
  299. {
  300. str = model[@"plPrice"];
  301. }else
  302. {
  303. str = model[@"qzPrice"];
  304. }
  305. [priceLabel setText:str];
  306. [telBtn setTitleN:model[@"mobile"]];
  307. if ([model[@"belong"] length] == 0)
  308. {
  309. [btn01 setTitleN:model[@"所属公司暂无"]];
  310. }
  311. else
  312. {
  313. [btn01 setTitleN:model[@"belong"]];
  314. }
  315. [btn02 setTitleN:[NSString stringWithFormat:@"%@",model[@"address"]]];
  316. str = model[@"desc"];
  317. if ( !str || [str isEqualToString:@""]) {
  318. str = @"暂无相关简介";
  319. }
  320. [lbl10 setText:str];
  321. [lbl03 setText:@"教练简介"];
  322. [scoreLabel setText:[NSString stringWithFormat:@"性别:%@",[model[@"sex"] intValue]==1?@"男":@"女"]];
  323. [cartypeLabel setText:[NSString stringWithFormat:@"年龄:%@",model[@"age"]]];
  324. [PermitLabel setText:[NSString stringWithFormat:@"教练人气:%@",model[@"watch"]]];
  325. }
  326. }
  327. -(void)getCoachInfoById
  328. {
  329. NSMutableArray *arr=[NSMutableArray array];
  330. [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:model[@"id"],@"id", nil]];
  331. NSString* method = @"getCoachInfoById";
  332. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  333. // NSLog(@"使教练关注度加1");
  334. }];
  335. }
  336. #pragma mark - 呼叫功能
  337. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  338. {
  339. if (1 == buttonIndex)
  340. {
  341. NSString* str = model[@"dh"];
  342. if (!str) {
  343. str = model[@"ciTelephone"];
  344. }
  345. NSMutableString * url=[[NSMutableString alloc] initWithFormat:@"tel:%@",str];
  346. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
  347. }
  348. }
  349. - (void)didReceiveMemoryWarning {
  350. [super didReceiveMemoryWarning];
  351. // Dispose of any resources that can be recreated.
  352. }
  353. @end