123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- //
- // CoachDetailVC.m
- // jiaPei
- //
- // Created by apple on 16/4/28.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "CoachDetailVC.h"
- #import "CLButton.h"
- #import "STButton.h"
- #import "SearchComment.h"
- #import "descVC.h"
- @interface CoachDetailVC ()<UIAlertViewDelegate>
- {
- UILabel *nameLabel,*priceLabel,*lbl02,*lbl03,*lbl10;
- //添加项
- UILabel *scoreLabel;
- UILabel *cartypeLabel;
- UILabel *PermitLabel;
- UILabel *label11;
-
- UIImageView *headImgView;
- NSMutableArray *imgs0;
-
- CLButton* telBtn,*btn01,*btn02,*btn10,*btn11,*btn12,*btn20;
-
- UIScrollView* scroll;
-
-
- NSDictionary* model;
-
- UIButton *sizeBtn;
- }
- @end
- @implementation CoachDetailVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.title = @"教练详情";
- self.navigationController.navigationBar.translucent = NO;
- [self configNavigationBar];
- self.view.backgroundColor = [UIColor whiteColor];
-
- model = [[NSDictionary alloc] initWithDictionary:self.infoDic];
-
- NSLog(@"教练-->%@",self.infoDic);
-
- self.orderType = @"0";
-
- [self myInit];
-
- [self getCoachInfoById];
- }
- -(void)myInit
- {
- scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height-kNavOffSet-kSafeAreaBottomHeight)];
- [self.view addSubview:scroll];
- [self.view setBackgroundColor:[UIColor whiteColor]];
-
- UIView* bar = [[UIView alloc] initWithFrame:CGRectMake(0, kSize.height - kNavOffSet - kSafeAreaBottomHeight - 60, self.view.width, 60)];
- [bar setBackgroundColor:backGroundColor];
- [self.view addSubview:bar];
- [self.view bringSubviewToFront:bar];
-
-
- CGFloat bd = (self.view.width - 180)/4.0;
- STButton* commebtBtn = [[STButton alloc] initWithFrame:CGRectMake(2*bd+60, 0, 60, 60)];
- [commebtBtn setStyle:1];
- [commebtBtn setImage:[UIImage imageNamed:@"img03pen.png"] withTitle:@"点评" Font:13 forState:UIControlStateNormal];
- [commebtBtn setTitleColor:subTitleColor forState:UIControlStateNormal];
- [commebtBtn target:self tag:-1];
- [bar addSubview:commebtBtn];
-
-
- UILabel* label;
- UIImageView* imageView;
- CLButton* btn;
-
- CGFloat dx,dy,curTop,imgw;
-
- dx = 90; dy = dx*.6; bd = 8;
- imageView = [[UIImageView alloc] initWithFrame:SGRectMake(bd, bd , dx, dy)];
- [imageView setContentMode:UIViewContentModeScaleAspectFit];
- [imageView setImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
- [scroll addSubview:imageView];
- //头像
- headImgView = imageView;
-
- label = [[UILabel alloc] initWithFrame:SGRectMake(dx+bd*2, 5, dx*2, (dy+bd*2)/3)];
- [scroll addSubview:label];
- //名称
- nameLabel = label;
-
- imgw = 10;
- //星星
- imgs0 = [NSMutableArray array];
- for (int i =0; i<5; i++)
- {
- imageView = [[UIImageView alloc] initWithFrame:SGRectMake(dx+bd*2 + imgw*1.3*i, (dy+bd*2)/2-imgw/2 + 5, imgw, imgw)];
- [imageView setImage:[UIImage imageNamed:@"rankstar0_img.png"]];
- imageView.hidden = YES;
- [scroll addSubview:imageView];
- [imgs0 addObject:imageView];
- }
-
- label = [[UILabel alloc] initWithFrame:SGRectMake(dx+bd*2, (dy+bd*2)*2/3 + 5, dx, (dy+bd*2)/3)];
- [label setTextColor:[UIColor redColor]];
- [scroll addSubview:label];
- //价格
- priceLabel = label;
-
- curTop = dy+bd+bd+bd;
- dy = 35;
- btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop , 320, dy)];
- [btn setImage:[UIImage imageNamed:@"mobile_phone_ico.png"] withTitle:@"10086" Font:NormalFont forState:UIControlStateNormal];
- [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
- [scroll addSubview:btn];
- [btn target:self tag:0];
- //电话按钮(已添加拨打功能)tag=0
- telBtn = btn;
- [btn addViewWithRect:SGRectMake(0, curTop , 320, 1) Color:KlineColor];
-
- btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop+dy, 320, dy)];
- [btn setImage:[UIImage imageNamed:@"drawer_img01"] withTitle:@"竟达汽车公司" Font:NormalFont forState:UIControlStateNormal];
- [btn target:self tag:1];
- [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
- [scroll addSubview:btn];
- //所属公司
- btn01 = btn;
- [btn addViewWithRect:SGRectMake(0, curTop +dy, 320, .5) Color:KlineColor];
-
- btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop+dy*2, 320, dy)];
- [btn setImage:[UIImage imageNamed:@"address_icon.png"] withTitle:@"公司地址" Font:NormalFont forState:UIControlStateNormal];
- [btn target:self tag:2];
- [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
- [scroll addSubview:btn];
- //公司地址
- btn02 = btn;
- [btn addViewWithRect:SGRectMake(0, curTop +dy*2, 320, .5) Color:KlineColor];
-
- curTop += dy*3 + bd;
-
- btn = [[CLButton alloc] initWithFrame:SGRectMake(0, curTop, 320, dy)];
- [btn setDetailN:@"更多 >"];
- [scroll addSubview:btn];
- [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- [btn setTag:10];
- //教练简介
- btn10 = btn;
- //添加黑色隔条
- [btn addViewWithRect:SGRectMake(0, curTop-bd, 320, bd) Color:KlineColor];
- label = [[UILabel alloc] initWithFrame:SGRectMake(bd, curTop, 80, dy)];
- [label setText:@"教练简介"];
- [label setTextColor:contentTextColor];
- [scroll addSubview:label];
- //只是简介
- lbl03= label;
-
- CGFloat lblh = 60;
- label = [[UILabel alloc] initWithFrame:SGRectMake(bd, curTop+dy, 320-bd*2, lblh)];
- [label setText:_infoDic[@"desc"]];
- [label setNumberOfLines:0];
- [label setTextColor:contentTextColor];
- [scroll addSubview:label];
- //简介内容
- lbl10 = label;
- [label addViewWithRect:SGRectMake(0, curTop+dy, 320, 1) Color:KlineColor];
-
- curTop += lblh + dy;
-
- scoreLabel = [[UILabel alloc] initWithFrame:SGRectMake(0, curTop, 160, dy)];
- scoreLabel.x +=8;
- scoreLabel.width -= 8;
- [scoreLabel setFont:[UIFont scaleSize:FontTitle]];
- [scoreLabel setTextColor:contentTextColor];
- [scroll addSubview:scoreLabel];
- [scoreLabel addSelfViewWithRect:SGRectMake(160-1, 5, 1, dy-10) Color:KlineColor];
-
- cartypeLabel = [[UILabel alloc] initWithFrame:SGRectMake(160, curTop, 160, dy)];
- cartypeLabel.x += 8;
- cartypeLabel.width -= 8;
- [cartypeLabel setFont:[UIFont scaleSize:FontTitle]];
- [cartypeLabel setTextColor:contentTextColor];
- [scroll addSubview:cartypeLabel];
-
- PermitLabel = [[UILabel alloc] initWithFrame:SGRectMake(0, curTop + dy + bd, 320, dy)];
- PermitLabel.x += 8;
- PermitLabel.width -= 8;
- [PermitLabel setFont:[UIFont scaleSize:FontTitle]];
- [PermitLabel setTextColor:contentTextColor];
- [scroll addSubview:PermitLabel];
- [PermitLabel addSelfViewWithRect:SGRectMake(0, -.5, 320, 1) Color:KlineColor];
- [PermitLabel addSelfViewWithRect:SGRectMake(0, dy, 320, 1) Color:KlineColor];
-
- // [PermitLabel addSelfViewWithRect:SGRectMake(0, - bd ,320, bd) Color:KlineColor];
- // [PermitLabel addSelfViewWithRect:SGRectMake(0, dy ,320, bd) Color:KlineColor];
-
-
- UIView *vi = [scroll.subviews lastObject];
- [scroll setContentSize:CGSizeMake(0, vi.y + vi.height + 100)];
-
- [self freshCoachUI];
- }
- -(void)setHeadImageView:(UIImageView *)image withImg:(NSString *)img
- {
- //设置图片大小不变 超出部分截掉
- if (img && img.length > 0) {
- image.contentMode = UIViewContentModeScaleAspectFit;
- }
-
- image.clipsToBounds = YES;
-
- NSString * imgStr = @"";
- if (img && img.length > 0) {
- imgStr = img;
- }
-
- [image sd_setImageWithURL:[NSURL URLWithString:imgStr] placeholderImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
- }
- -(void)btnClick:(UIButton*)sender
- {
- int tag = (int)sender.tag;
-
- if (tag == -1) {
-
- SearchComment* vc = [[SearchComment alloc] init];
- vc.bpjr = model[@"idcard"];
- vc.type = @"2";
- [self navPushHideTabbarToVC:vc];
- }
-
- if ( 0 == tag)
- {
- NSString *str = model[@"ciMobile"];
- if (!str) {
- str = model[@"ciTelephone"];
- }
- UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil message:str delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"呼叫", nil];
- [alert show];
- return;
- }
-
- if (tag == 10)
- {
- descVC *vc = [[descVC alloc] init];
- vc.desc = _infoDic[@"desc"];
- vc.titleString = @"教练简介";
- [self navPushHideTabbarToVC:vc];
- }
- }
- -(void)freshCoachUI
- {
- int starNum = [model[@"star"] intValue]/3;
- if (starNum == 0){
- starNum = 3;
- }
- if (starNum >5) {
- starNum = 5;
- }
-
- for (int i = 0; i < starNum; i ++)
- {
- UIImageView *img = imgs0[i];
- img.hidden = NO;
- }
-
- if ([self.orderType intValue] == 0)
- {
- //NSLog(@"headImg--->%@photo--->%@",model[@"headImg"],model[@"photo"]);
- NSString *headString = [Tools imageStringWithPhotoString:model[@"photo"] HeadImgString:model[@"headImg"] Type:2];
- [headImgView sd_setImageWithURL:[NSURL URLWithString:headString] placeholderImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
-
- [nameLabel setText:model[@"name"]];
- NSString *str = model[@"price"];
- if ([str isEqualToString:@""] || [str isEqualToString:@"0"]) {
- str = @"¥暂无";
- }else{
- str = [NSString stringWithFormat:@"¥%@",str];
- }
- [priceLabel setText:str];
-
- /*
- provinceName = 福建省,
- provinceId = 35,
- countryName = 思明区,
- id = 84092,
- pwd = e10adc3949ba59abbe56e057f20f883e,
- drivingDate = ,
- serviceStar = 5.0,
- watch = 57,
- address = 福建省厦门市思明区西林村东坪山社,
- py = fwk,
- teachCarType = C1,
- photo = ,
- teachStar = 5.0,
- jxbh = 14000108,
- sex = 1,
- idcard = 350211196506141511,
- occupationNO = ,
- outId = 1,
- star = 15.0,
- name = 傅维昆,
- count = ,
- schoolShortName = ,
- countryId = 350203,
- price = 100,
- cityName = 厦门市,
- mobile = 15060063160,
- cityId = 3502,
- cars = ,
- schoolName = 厦门市思明区启帆机动车驾驶员培训队,
- bindInfo = ,
- groupId = ,
- initPwd = 123456,
- occupationLevel = ,
- vip = 0,
- tollStar = 5.0
- */
-
-
- [telBtn setTitleN:model[@"mobile"]];
- [btn01 setTitleN:model[@"schoolShortName"]];
- [btn02 setTitleN:[NSString stringWithFormat:@"%@%@",model[@"cityName"],model[@"countryName"]]];
- str = model[@"desc"];
- if ( !str || [str isEqualToString:@""]) {
- str = @"暂无相关简介";
- }
- [lbl10 setText:str];
- [lbl03 setText:@"教练简介"];
- str = model[@"score"];
- if (str.length == 0)
- {
- str = @"暂无";
- }
- [scoreLabel setText:[NSString stringWithFormat:@"综合评分:%@",str]];
- [cartypeLabel setText:[NSString stringWithFormat:@"培训车型:%@",model[@"teachCarType"]]];
- [PermitLabel setText:[NSString stringWithFormat:@"许可培训:%@",model[@"cars"]]];
-
- }
- else
- {
- NSString* str = [Tools imageStringWithPhotoString:model[@"photo"] HeadImgString:model[@"headimg"] Type:2];
- [headImgView sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"nope_pic_icon.png"]];
-
- [nameLabel setText:model[@"name"]];
-
- if (self.orderType.intValue == 1)
- {
- str = model[@"fxPrice"];
- }else if (self.orderType.intValue == 2)
- {
- str = model[@"plPrice"];
- }else
- {
- str = model[@"qzPrice"];
- }
- [priceLabel setText:str];
-
- [telBtn setTitleN:model[@"mobile"]];
- if ([model[@"belong"] length] == 0)
- {
- [btn01 setTitleN:model[@"所属公司暂无"]];
- }
- else
- {
- [btn01 setTitleN:model[@"belong"]];
- }
-
- [btn02 setTitleN:[NSString stringWithFormat:@"%@",model[@"address"]]];
- str = model[@"desc"];
- if ( !str || [str isEqualToString:@""]) {
- str = @"暂无相关简介";
- }
- [lbl10 setText:str];
- [lbl03 setText:@"教练简介"];
- [scoreLabel setText:[NSString stringWithFormat:@"性别:%@",[model[@"sex"] intValue]==1?@"男":@"女"]];
- [cartypeLabel setText:[NSString stringWithFormat:@"年龄:%@",model[@"age"]]];
- [PermitLabel setText:[NSString stringWithFormat:@"教练人气:%@",model[@"watch"]]];
- }
- }
- -(void)getCoachInfoById
- {
- NSMutableArray *arr=[NSMutableArray array];
- [arr addObject:[NSDictionary dictionaryWithObjectsAndKeys:model[@"id"],@"id", nil]];
- NSString* method = @"getCoachInfoById";
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
- // NSLog(@"使教练关注度加1");
- }];
- }
- #pragma mark - 呼叫功能
- -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (1 == buttonIndex)
- {
- NSString* str = model[@"dh"];
- if (!str) {
- str = model[@"ciTelephone"];
- }
-
- NSMutableString * url=[[NSMutableString alloc] initWithFormat:@"tel:%@",str];
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|