123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- /**
- */
- #import "SchCell.h"
- #import "Tools.h"
- #define schCellHeight 100
- @interface SchCell ()
- {
- NSInteger star;
- NSDictionary* modict;
-
- UILabel *_watchLab;
- }
- @property (weak, nonatomic) IBOutlet UILabel *nameLabel;
- @property (weak, nonatomic) IBOutlet UILabel *addrLabel;
- @property (weak, nonatomic) IBOutlet UILabel *telLabel;
- @property (weak, nonatomic) IBOutlet UILabel *cntLabel;
- @property (weak, nonatomic) IBOutlet UIImageView *vipImg;
- @property (strong, nonatomic) NSMutableArray* ivs;
- @end
- @implementation SchCell
- +(id)cellWithTableView:(UITableView*)tableView
- {
- SchCell* cell = [tableView dequeueReusableCellWithIdentifier:@"SchCell"];
- if (!cell) {
- NSBundle *rootBundle = [NSBundle mainBundle];
- cell = [[rootBundle loadNibNamed:@"SchCell" owner:nil options:nil] lastObject];
-
- cell.ivs = [NSMutableArray array];
- CGFloat sX = 96;
- CGFloat sW = 16;
- CGFloat sH = sW;
- CGFloat sY = 40;
- for (int i =0; i<5; i++)
- {
- UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(sX, sY, sW, sH)];
- // iv.frame = CGRectMake(sX, sY, sW, sH);
- [cell.contentView addSubview:iv];
- sX += (sW + 2);
- [cell.ivs addObject:iv];
- }
- }
- return cell;
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- _countLabel = _telLabel;
-
- _headImg.layer.masksToBounds = YES;
- _headImg.layer.cornerRadius = 3;
-
- //教练计划--进来教练列表cell
- CGRect frame = _addrLabel.frame;
- _watchLab = [[UILabel alloc]initWithFrame:CGRectMake(kSize.width-180, frame.origin.y, 100, frame.size.height)];
- [_watchLab setText:@"" Font:14 TextColor:contentTextColor Alignment:NSTextAlignmentRight];
- _watchLab.hidden = YES;
- [self.contentView addSubview:_watchLab];
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- //推荐驾校
- -(void)setSchool:(SchInfo *)school
- {
-
- _school = school;
- [self setHeadImageView:_headImg withImg:school.headImg];
- _nameLabel.text = school.jxjc;
- _addrLabel.text = school.price;
- _telLabel.text = [NSString stringWithFormat:@"%@人关注",[Tools isWan:school.watch]];
- _cntLabel.text = [NSString stringWithFormat:@"距您%@公里",school.distance];
- [_vipImg setHidden:![school.vip intValue]];
-
- if ([school.price isEqualToString:@"0"])
- {
- _addrLabel.text = @"暂无";
- }
- star = [school.starCnt intValue];
- if (star == 0)
- {
- star = 3;
- }
- [self configStars];
-
- }
- //驾校列表
- -(void)setSelectDic:(NSDictionary *)selectDic
- {
- _selectDic = selectDic;
-
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
- CGFloat bd = 0;
- NSString *str = selectDic[@"HEADIMG"];
- if (str && str.length!= 0) {
- NSURL * url = [NSURL URLWithString:str];
- NSData * imgData = [NSData dataWithContentsOfURL:url];
- UIImage *header = [UIImage imageWithData:imgData];
- bd = header.size.width - header.size.height;
- }
-
- dispatch_async(dispatch_get_main_queue(), ^{
- //NSLog(@"图片宽高差-->%f-->%f-->%f",header.size.width,header.size.height,bd);
- if (bd < 10 && bd > -10 && bd != 0) {
- _headImg.width = _headImg.height;
- }else{
- _headImg.width = 80;
- }
- });
-
- });
-
- [self setHeadImageView:_headImg withImg:selectDic[@"HEADIMG"]];
- _nameLabel.text = selectDic[@"SHORTNAME"];
- _watchLab.text = [NSString stringWithFormat:@"%@人关注",selectDic[@"WATCH"]];
- if (_watchLab.hidden == YES){
- _watchLab.hidden = NO;
- }
- _addrLabel.text = selectDic[@"PRICE"];
- _telLabel.text = [NSString stringWithFormat:@"%@",selectDic[@"ADDRESS"]];
- _cntLabel.text = [NSString stringWithFormat:@"距您%.1fkm",[selectDic[@"DISTANCE"] floatValue]];
- [_vipImg setHidden:![selectDic[@"VIP"] intValue]];
- if ([selectDic[@"PRICE"] isEqualToString:@""] || [selectDic[@"PRICE"] isEqualToString:@"0"])
- {
- _addrLabel.text = @"暂无";
- }
-
- star = [selectDic[@"STAR"] integerValue]/3;
- //NSLog(@"%d",(int)star);
- //因为现在服务器取到的都是0 所以先模拟数据
- if (star == 0)
- {
- star = 3;
- }
- [self configStars];
- }
- //排行榜--驾校--dict
- -(void)setSchDict:(NSDictionary*)dict
- {
- dispatch_async(dispatch_get_global_queue(0, 0), ^{
-
- CGFloat bd = 0;
- NSString *str = dict[@"headimg"];
- if (str && str.length!= 0) {
- NSURL * url = [NSURL URLWithString:str];
- NSData * imgData = [NSData dataWithContentsOfURL:url];
- UIImage *header = [UIImage imageWithData:imgData];
- bd = header.size.width - header.size.height;
- }
- //NSLog(@"图片宽高差-->%f-->%f-->%f",header.size.width,header.size.height,bd);
- if (str.length > 0 && bd < 10 && bd > -10 && bd != 0) {
- _headImg.width = _headImg.height;
- }else{
- _headImg.width = 80;
- }
-
- });
- [self setHeadImageView:_headImg withImg:dict[@"headimg"]];
-
- _nameLabel.text = dict[@"name"];
- _addrLabel.text = dict[@"price"];
- _telLabel.text = [NSString stringWithFormat:@"%@人关注",[Tools isWan:dict[@"watch"]]];
- _cntLabel.text = [NSString stringWithFormat:@"距你%@公里",dict[@"distance"]];
- [_vipImg setHidden:![dict[@"vip"] intValue]];
- if ([dict[@"price"] isEqualToString:@""] || [dict[@"price"] isEqualToString:@"0"])
- {
- _addrLabel.text = @"暂无";
- }
-
- star = [dict[@"star"] integerValue]/3;
- //NSLog(@"%d",(int)star);
- //因为现在服务器取到的都是0 所以先模拟数据
- if (star == 0)
- {
- star = 3;
- }
-
- [self configStars];
-
- }
- //普通--教练--驾校--dict
- -(void)setSparDict:(NSDictionary *)dict
- {
- [self setHeadImageView:_headImg withImg:dict[@"headimg"]];
- [_nameLabel setText:dict[@"name"]];
- [_telLabel setText:[NSString stringWithFormat:@"交易量:%@",dict[@"ordernum"]]];
- [_cntLabel setText:[NSString stringWithFormat:@"人气:%@",dict[@"watch"]]];
- [_vipImg setHidden:YES];
- //NSLog(@"传过来的trainType---->%d",(int)_trainType);
- if (_trainType == 1)
- {
- _addrLabel.text = dict[@"fxPrice"];
- }
- else if (_trainType == 2)
- {
- _addrLabel.text = dict[@"plPrice"];
- }
- else
- {
- _addrLabel.text = dict[@"qzPrice"];
- }
- if ([_addrLabel.text isEqualToString:@""] || [_addrLabel.text isEqualToString:@"0"])
- {
- _addrLabel.text = @"暂无";
- }
-
- star = [dict[@"star"] intValue];
- //模拟数据
- if (star == 0)
- {
- star = 3;
- }
- [self configStars];
- }
- //排行榜--教练--dict--
- -(void)setCoaDict:(NSDictionary*)dict
- {
- //NSLog(@"教练排行榜-->%@",dict);
- //教练头像 优先显示真实头像 如果没有再显示上传的头像
- //NSLog(@"head-->%@--photo-->%@",dict[@"headImg"],dict[@"photo"]);
-
- NSString *headString = [Tools imageStringWithPhotoString:dict[@"photo"] HeadImgString:dict[@"headImg"] Type:1];
- //NSLog(@"----->%@",headString);
- _headImg.contentMode = UIViewContentModeScaleAspectFit;
- [_headImg sd_setImageWithURL:[NSURL URLWithString:headString] placeholderImage:[UIImage imageNamed:@"NOIMG"]];
-
- [_nameLabel setText:dict[@"name"]];
- [_telLabel setText:dict[@"mobile"]];
- [_addrLabel setText:dict[@"price"]];
- //关注度的问题 如果count不是关注度 这栏就改为综合评分吧
- [_cntLabel setText:[NSString stringWithFormat:@"关注:%@",dict[@"count"]]];
- [_vipImg setHidden:![dict[@"vip"] intValue]];
-
- if ([dict[@"price"] isEqualToString:@""] || [dict[@"price"] isEqualToString:@"0"])
- {
- [_addrLabel setText:@"暂无"];
- }
- star = [dict[@"star"] intValue];
- //因为现在服务器取到的都是0 所以先模拟数据
- if (star == 0)
- {
- star = 3;
- }
- [self configStars];
- }
- //普通的--教练--dict--
- -(void)setCoaSparDict:(NSDictionary*)dict{
-
- NSString *path = dict[@"headImg"];
- if (path && ![path hasPrefix:@"http"]){
- path = [imgPreFix stringByAppendingString:path];
- }
- [_headImg sd_setImageWithURL:[NSURL URLWithString:path] placeholderImage:[UIImage imageNamed:@"NOIMG"]];
-
- [_nameLabel setText:dict[@"ciName"]];
- //这个参数
- [_cntLabel setText:dict[@"watch"]];
- [_telLabel setText:dict[@"ciTelephone"]];
- //如果教练有VIP 再打开 --danson
- [_vipImg setHidden:YES];
-
- if ([dict[@"price"] isEqualToString:@""] || [dict[@"price"] isEqualToString:@"0"]) {
- [_addrLabel setText:@"暂无"];
- }else{
- [_addrLabel setText:dict[@"price"]];
- }
- star = [dict[@"star"] intValue];
- [self configStars];
- }
- +(CGFloat)cellHeight
- {
- return schCellHeight;
- }
- -(void)setHeadImageView:(UIImageView *)image withImg:(NSString *)img
- {
- //设置图片大小不变 超出部分截掉
- // image.contentMode = UIViewContentModeScaleAspectFill;
- // image.clipsToBounds = YES;
- //
- NSString * imgStr = @"";
- if (img && img.length > 0) {
- imgStr = img;
- }
-
- [_headImg sd_setImageWithURL:[NSURL URLWithString:imgStr] placeholderImage:[UIImage imageNamed:@"NOIMG"]];
- }
- /**添加星级
- */
- -(void)configStars
- {
- for (int i =0; i<5; i++)
- {
- UIImage* img = [UIImage imageNamed:@"rankstar0_img.png"];
- if (i >= star)
- {
- img = [img tint:backGroundColor];
- }
- UIImageView*iv= _ivs[i];
- [iv setImage:img];
- }
- }
- @end
|