123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- //
- // FenceSiteCell.m
- // jiaPei
- //
- // Created by apple on 2017/8/16.
- // Copyright © 2017年 JCZ. All rights reserved.
- //
- #import "FenceSiteCell.h"
- #import "MJPhotoBrowser.h"
- #import "MJPhoto.h"
- #import "descVC.h"
- #import "MapVC.h"
- #import "UIImageView+WebCache.h"
- @implementation FenceSiteCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
-
- CGFloat x,y,w,h;
- x = y = 10;
-
- w = 150;
- if (kSize.width == 320) {
- w = 130;
- }
- h = 120;
-
- headImg = [[UIImageView alloc] KSetxywh];
- headImg.layer.masksToBounds = YES;
- headImg.layer.cornerRadius = 5;
- headImg.clipsToBounds = YES;
- [headImg setContentMode:UIViewContentModeScaleAspectFit];
- [self.contentView addSubview:headImg];
- // headImg.userInteractionEnabled = YES;
- // [headImg addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImage:)]];
-
-
- x += w + 10;
- w = kSize.width - x - 10;
- h = 24;
- UILabel *label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font21 TextColor:RQMianColor];
- [self.contentView addSubview:label];
- nameLabel = label;
-
- y += h;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font17 TextColor:KTitleColor];
- [self.contentView addSubview:label];
- timeLabel = label;
-
- y += h;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font17 TextColor:KTitleColor];
- [self.contentView addSubview:label];
- carTypeLabel = label;
-
- y += h;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font17 TextColor:KTitleColor];
- [self.contentView addSubview:label];
- carModelLabel = label;
-
- y += h;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font17 TextColor:KTitleColor];
- [self.contentView addSubview:label];
- areaLabel = label;
- //简介
- x = 10;
- y += h + 15;
- w = kSize.width - 20;
- h = 29;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"场地简介" Font:Font18 TextColor:KTitleColor Alignment:NSTextAlignmentLeft];
- [self.contentView addSubview:label];
-
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"更多 >" Font:Font17 TextColor:RQMianColor Alignment:NSTextAlignmentRight];
- [self.contentView addSubview:label];
-
- UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, y, kSize.width, h)];
- [btn target:self Tag:1];
- [self.contentView addSubview:btn];
- lookMoreBtn = btn;
-
- [self.contentView addViewWithRect:CGRectMake(0, y - 7, kSize.width, 7)];
- [self.contentView addViewWithRect:CGRectMake(0, y + h, kSize.width, 1)];
-
- y += h + 5;
- h = 60;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"暂无简介" Font:Font17 TextColor:KTitleColor];
- label.numberOfLines = 0;
- [self.contentView addSubview:label];
- remarkLabel = label;
-
- //地址
- y += h + 10;
- h = 30;
- w -= 85;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font17 TextColor:KTitleColor];
- [self.contentView addSubview:label];
- adressLabel = label;
-
- btn = [[UIButton alloc] initWithFrame:CGRectMake(x + w + 5, y, 80, h)];
- [btn setTitle:@"查看地图" textColor:RQMianColor font:Font17 fotState:UIControlStateNormal];
- [btn target:self Tag:2];
- [self.contentView addSubview:btn];
- lookMapBtn = btn;
-
-
- y += h;
- w = kSize.width - 2*x;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font17 TextColor:KTitleColor];
- [self.contentView addSubview:label];
- lineLabel = label;
-
-
- y += h;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font17 TextColor:KTitleColor];
- [self.contentView addSubview:label];
- principalLabel = label;
-
-
- x += 120;
- w = kSize.width - x;;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font17 TextColor:KTitleColor];
- [self.contentView addSubview:label];
- mobileLabel = label;
-
- btn = [[UIButton alloc] KSetxywh];
- [btn target:self Tag:3];
- [self.contentView addSubview:btn];
- mobileBtn = btn;
-
- y += h;
- label = [[UILabel alloc] KSetxywh];
- [label setText:@"" Font:Font17 TextColor:KTitleColor];
- [self.contentView addSubview:label];
- telLabel = label;
-
- btn = [[UIButton alloc] KSetxywh];
- [btn target:self Tag:4];
- [self.contentView addSubview:btn];
- telBtn = btn;
- }
- return self;
- }
- -(void)setDataDic:(NSDictionary *)dataDic {
-
- _dataDic = dataDic;
- NSArray *imgs = dataDic[@"imgs"];
- if (imgs.count > 0) {
- NSString *img = [[imgs firstObject] objectForKey:@"IMGPATH"];
- [headImg sd_setImageWithURL:[NSURL URLWithString:img] placeholderImage:[UIImage imageNamed:@"NOIMG"]];
- }else{
- [headImg sd_setImageWithURL:nil placeholderImage:[UIImage imageNamed:@"NOImg"]];
- }
-
- nameLabel.text = dataDic[@"NAME"];
- timeLabel.text = [NSString stringWithFormat:@"训练时间:%@",dataDic[@"TRAINTIME"]];
- carTypeLabel.text = [NSString stringWithFormat:@"带教车型:%@",dataDic[@"TRAINTYPE"]];
- carModelLabel.text = [NSString stringWithFormat:@"训练车品牌:%@",dataDic[@"CARMODEL"]];
- areaLabel.text = [NSString stringWithFormat:@"场地占地面积:%@m2",dataDic[@"AREA"]];
-
- NSString *remarkString = @"暂无简介";
- if ([dataDic[@"REMARK"] length] > 0) {
- remarkString = dataDic[@"REMARK"];
- }
- remarkLabel.text = remarkString;
- adressLabel.text = [NSString stringWithFormat:@"地址:%@",dataDic[@"ADDRESS"]];
-
- lineLabel.text = [NSString stringWithFormat:@"接送点:%@",[dataDic[@"ISPICKUP"] intValue] == 0?@"不接送":dataDic[@"PICK_LINE"]];
-
- principalLabel.text = [NSString stringWithFormat:@"联系人:%@",dataDic[@"PRINCIPAL"]];
- [self setLabelTextWithLabel:mobileLabel textString:[NSString stringWithFormat:@"联系电话:%@",dataDic[@"MOBILE"]]];
- [self setLabelTextWithLabel:telLabel textString:[NSString stringWithFormat:@"固定电话:%@",dataDic[@"TELPHONE"]]];
- }
- - (void)btnClick:(UIButton *)sender {
-
- // NSLog(@"click-----><>%d",(int)sender.tag);
-
- if (sender.tag == 1) {
- descVC *vc = [[descVC alloc] init];
- vc.desc = _dataDic[@"REMARK"];
- vc.titleString = @"场地简介";
- [_superVC navPushHideTabbarToVC:vc];
- }
-
- if (sender.tag == 2) {
-
- MapVC *map = [[MapVC alloc] init];
- map.isJustLoad = YES;
- map.lat = [_dataDic[@"BDLAT"] floatValue];
- map.lng = [_dataDic[@"BDLNG"] floatValue];
- map.siteName = _dataDic[@"NAME"];
- [_superVC navPushHideTabbarToVC:map];
- }
-
- if (sender.tag == 3) {
- [RQ_SHARE_FUNCTION showAlertAtViewController:_superVC WithTitle:_dataDic[@"MOBILE"] message:nil alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[@"呼叫"] otherButtonStyles:nil preferredActionTitle:nil completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex == 0) {
- NSMutableString * url=[[NSMutableString alloc] initWithFormat:@"tel:%@",_dataDic[@"MOBILE"]];
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
- }
- }];
- }
-
- if (sender.tag == 4) {
- [RQ_SHARE_FUNCTION showAlertAtViewController:_superVC WithTitle:_dataDic[@"TELPHONE"] message:nil alertControllerStyle:UIAlertControllerStyleAlert cancelButtonTitle:@"取消" otherButtonTitles:@[@"呼叫"] otherButtonStyles:nil preferredActionTitle:nil completion:^(NSUInteger selectedOtherButtonIndex) {
- if (selectedOtherButtonIndex == 0) {
- NSMutableString * url=[[NSMutableString alloc] initWithFormat:@"tel:%@",_dataDic[@"TELPHONE"]];
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
- }
- }];
- }
- }
- //用富文本封装个方法供调用
- -(void)setLabelTextWithLabel:(UILabel *)label textString:(NSString *)str
- {
- NSMutableAttributedString *abs = [[NSMutableAttributedString alloc]initWithString:str];
- [abs beginEditing];
- //字体大小
- // [abs addAttribute:NSFontAttributeName
- // value:[UIFont scaleSize:30.0]
- // range:NSMakeRange(8, 1)];
- //字体颜色
- [abs addAttribute:NSForegroundColorAttributeName
- value:RQMianColor
- range:NSMakeRange(5, str.length - 5)];
- //下划线
- [abs addAttribute:NSUnderlineStyleAttributeName
- value:@(NSUnderlineStyleSingle)
- range:NSMakeRange(5, str.length - 5)];
- label.attributedText = abs;
- }
- -(void)tapImage:(UITapGestureRecognizer *)tap
- {
- NSArray *imgArray = _dataDic[@"imgs"];
-
- if (imgArray.count < 1) {
- return;
- }
-
- // 1.封装图片数据
- NSMutableArray *photos = [NSMutableArray arrayWithCapacity:imgArray.count];
- for (NSDictionary *dic in imgArray) {
- MJPhoto *photo = [[MJPhoto alloc] init];
- photo.url = [NSURL URLWithString:dic[@"IMGPATH"]]; //图片路径
- photo.srcImageView = headImg; // 来源于哪个UIImageView
- [photos addObject:photo];
- }
-
- // 2.显示相册
- MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
- browser.currentPhotoIndex = 0; //弹出相册时显示的第一张图片
- browser.photos = photos; // 设置所有的图片
- [browser show];
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- @end
|