FenceSiteCell.m 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. //
  2. // FenceSiteCell.m
  3. // jiaPei
  4. //
  5. // Created by apple on 2017/8/16.
  6. // Copyright © 2017年 JCZ. All rights reserved.
  7. //
  8. #import "FenceSiteCell.h"
  9. #import "descVC.h"
  10. #import "MapVC.h"
  11. @implementation FenceSiteCell
  12. - (void)awakeFromNib {
  13. [super awakeFromNib];
  14. }
  15. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  16. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  17. if (self) {
  18. CGFloat x,y,w,h;
  19. x = y = 10;
  20. w = 150;
  21. if (kSize.width == 320) {
  22. w = 130;
  23. }
  24. h = 120;
  25. headImg = [[UIImageView alloc] setxywh];
  26. headImg.layer.masksToBounds = YES;
  27. headImg.layer.cornerRadius = 5;
  28. headImg.clipsToBounds = YES;
  29. [headImg setContentMode:UIViewContentModeScaleAspectFit];
  30. [self.contentView addSubview:headImg];
  31. headImg.userInteractionEnabled = YES;
  32. [headImg addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImage:)]];
  33. x += w + 10;
  34. w = kSize.width - x - 10;
  35. h = 24;
  36. UILabel *label = [[UILabel alloc] setxywh];
  37. [label setText:@"" Font:FontLarger TextColor:defGreen];
  38. [self.contentView addSubview:label];
  39. nameLabel = label;
  40. y += h;
  41. label = [[UILabel alloc] setxywh];
  42. [label setText:@"" Font:Font17 TextColor:kTitleColor];
  43. [self.contentView addSubview:label];
  44. timeLabel = label;
  45. y += h;
  46. label = [[UILabel alloc] setxywh];
  47. [label setText:@"" Font:Font17 TextColor:kTitleColor];
  48. [self.contentView addSubview:label];
  49. carTypeLabel = label;
  50. y += h;
  51. label = [[UILabel alloc] setxywh];
  52. [label setText:@"" Font:Font17 TextColor:kTitleColor];
  53. [self.contentView addSubview:label];
  54. carModelLabel = label;
  55. y += h;
  56. label = [[UILabel alloc] setxywh];
  57. [label setText:@"" Font:Font17 TextColor:kTitleColor];
  58. [self.contentView addSubview:label];
  59. areaLabel = label;
  60. //简介
  61. x = 10;
  62. y += h + 15;
  63. w = kSize.width - 20;
  64. h = 29;
  65. label = [[UILabel alloc] setxywh];
  66. [label setText:@"场地简介" Font:FontTitle TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
  67. [self.contentView addSubview:label];
  68. label = [[UILabel alloc] setxywh];
  69. [label setText:@"更多 >" Font:Font17 TextColor:defGreen Alignment:NSTextAlignmentRight];
  70. [self.contentView addSubview:label];
  71. UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, y, kSize.width, h)];
  72. [btn target:self tag:1];
  73. [self.contentView addSubview:btn];
  74. lookMoreBtn = btn;
  75. [self.contentView addViewWithRect:CGRectMake(0, y - 7, kSize.width, 7)];
  76. [self.contentView addViewWithRect:CGRectMake(0, y + h, kSize.width, 1)];
  77. y += h + 5;
  78. h = 60;
  79. label = [[UILabel alloc] setxywh];
  80. [label setText:@"暂无简介" Font:NormalFont TextColor:kTitleColor];
  81. label.numberOfLines = 0;
  82. [self.contentView addSubview:label];
  83. remarkLabel = label;
  84. //地址
  85. y += h + 10;
  86. h = 30;
  87. w -= 85;
  88. label = [[UILabel alloc] setxywh];
  89. [label setText:@"" Font:Font17 TextColor:kTitleColor];
  90. [self.contentView addSubview:label];
  91. adressLabel = label;
  92. btn = [[UIButton alloc] initWithFrame:CGRectMake(x + w + 5, y, 80, h)];
  93. [btn setTitle:@"查看地图" textColor:defGreen font:Font17 fotState:UIControlStateNormal];
  94. [btn target:self tag:2];
  95. [self.contentView addSubview:btn];
  96. lookMapBtn = btn;
  97. y += h;
  98. w = kSize.width - 2*x;
  99. label = [[UILabel alloc] setxywh];
  100. [label setText:@"" Font:Font17 TextColor:kTitleColor];
  101. [self.contentView addSubview:label];
  102. lineLabel = label;
  103. y += h;
  104. label = [[UILabel alloc] setxywh];
  105. [label setText:@"" Font:Font17 TextColor:kTitleColor];
  106. [self.contentView addSubview:label];
  107. principalLabel = label;
  108. x += 120;
  109. w = kSize.width - x;;
  110. label = [[UILabel alloc] setxywh];
  111. [label setText:@"" Font:Font17 TextColor:kTitleColor];
  112. [self.contentView addSubview:label];
  113. mobileLabel = label;
  114. btn = [[UIButton alloc] setxywh];
  115. [btn target:self tag:3];
  116. [self.contentView addSubview:btn];
  117. mobileBtn = btn;
  118. y += h;
  119. label = [[UILabel alloc] setxywh];
  120. [label setText:@"" Font:Font17 TextColor:kTitleColor];
  121. [self.contentView addSubview:label];
  122. telLabel = label;
  123. btn = [[UIButton alloc] setxywh];
  124. [btn target:self tag:4];
  125. [self.contentView addSubview:btn];
  126. telBtn = btn;
  127. }
  128. return self;
  129. }
  130. -(void)setDataDic:(NSDictionary *)dataDic {
  131. _dataDic = dataDic;
  132. NSArray *imgs = dataDic[@"imgs"];
  133. if (imgs.count > 0) {
  134. NSString *img = [[imgs firstObject] objectForKey:@"IMGPATH"];
  135. [headImg sd_setImageWithURL:[NSURL URLWithString:img] placeholderImage:[UIImage imageNamed:@"暂无图片"]];
  136. }else{
  137. headImg.image = [UIImage imageNamed:@"暂无图片"];
  138. }
  139. nameLabel.text = dataDic[@"NAME"];
  140. timeLabel.text = [NSString stringWithFormat:@"训练时间:%@",dataDic[@"TRAINTIME"]];
  141. carTypeLabel.text = [NSString stringWithFormat:@"带教车型:%@",dataDic[@"TRAINTYPE"]];
  142. carModelLabel.text = [NSString stringWithFormat:@"训练车品牌:%@",dataDic[@"CARMODEL"]];
  143. areaLabel.text = [NSString stringWithFormat:@"场地占地面积:%@m2",dataDic[@"AREA"]];
  144. NSString *remarkString = @"暂无简介";
  145. if ([dataDic[@"REMARK"] length] > 0) {
  146. remarkString = dataDic[@"REMARK"];
  147. }
  148. remarkLabel.text = remarkString;
  149. adressLabel.text = [NSString stringWithFormat:@"地址:%@",dataDic[@"ADDRESS"]];
  150. lineLabel.text = [NSString stringWithFormat:@"接送点:%@",[dataDic[@"ISPICKUP"] intValue] == 0?@"不接送":dataDic[@"PICK_LINE"]];
  151. principalLabel.text = [NSString stringWithFormat:@"联系人:%@",dataDic[@"PRINCIPAL"]];
  152. [self setLabelTextWithLabel:mobileLabel textString:[NSString stringWithFormat:@"联系电话:%@",dataDic[@"MOBILE"]]];
  153. [self setLabelTextWithLabel:telLabel textString:[NSString stringWithFormat:@"固定电话:%@",dataDic[@"TELPHONE"]]];
  154. }
  155. - (void)btnClick:(UIButton *)sender {
  156. // NSLog(@"click-----><>%d",(int)sender.tag);
  157. if (sender.tag == 1) {
  158. descVC *vc = [[descVC alloc] init];
  159. vc.desc = _dataDic[@"REMARK"];
  160. vc.titleString = @"场地简介";
  161. [_superVC navPushHideTabbarToVC:vc];
  162. }
  163. if (sender.tag == 2) {
  164. MapVC *map = [[MapVC alloc] init];
  165. map.isJustLoad = YES;
  166. map.lat = [_dataDic[@"BDLAT"] floatValue];
  167. map.lng = [_dataDic[@"BDLNG"] floatValue];
  168. map.siteName = _dataDic[@"NAME"];
  169. [_superVC navPushHideTabbarToVC:map];
  170. }
  171. if (sender.tag == 3) {
  172. UIAlertController *alert = [UIAlertController alertControllerWithTitle:_dataDic[@"MOBILE"] message:nil preferredStyle:UIAlertControllerStyleAlert];
  173. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  174. [alert addAction:[UIAlertAction actionWithTitle:@"呼叫" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  175. NSMutableString * url=[[NSMutableString alloc] initWithFormat:@"tel:%@",_dataDic[@"MOBILE"]];
  176. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
  177. }]];
  178. [_superVC presentViewController:alert animated:YES completion:nil];
  179. }
  180. if (sender.tag == 4) {
  181. UIAlertController *alert = [UIAlertController alertControllerWithTitle:_dataDic[@"TELPHONE"] message:nil preferredStyle:UIAlertControllerStyleAlert];
  182. [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
  183. [alert addAction:[UIAlertAction actionWithTitle:@"呼叫" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  184. NSMutableString * url=[[NSMutableString alloc] initWithFormat:@"tel:%@",_dataDic[@"TELPHONE"]];
  185. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
  186. }]];
  187. [_superVC presentViewController:alert animated:YES completion:nil];
  188. }
  189. }
  190. //用富文本封装个方法供调用
  191. -(void)setLabelTextWithLabel:(UILabel *)label textString:(NSString *)str
  192. {
  193. NSMutableAttributedString *abs = [[NSMutableAttributedString alloc]initWithString:str];
  194. [abs beginEditing];
  195. //字体大小
  196. // [abs addAttribute:NSFontAttributeName
  197. // value:[UIFont scaleSize:30.0]
  198. // range:NSMakeRange(8, 1)];
  199. //字体颜色
  200. [abs addAttribute:NSForegroundColorAttributeName
  201. value:defGreen
  202. range:NSMakeRange(5, str.length - 5)];
  203. //下划线
  204. [abs addAttribute:NSUnderlineStyleAttributeName
  205. value:@(NSUnderlineStyleSingle)
  206. range:NSMakeRange(5, str.length - 5)];
  207. label.attributedText = abs;
  208. }
  209. -(void)tapImage:(UITapGestureRecognizer *)tap
  210. {
  211. NSArray *dataSource = _dataDic[@"imgs"];
  212. if (dataSource.count < 1) {
  213. return;
  214. }
  215. [RQ_SHARE_FUNCTION showPhotoBrowserWithDataSource:dataSource currentIndex:0 isCanSave:YES];
  216. }
  217. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  218. [super setSelected:selected animated:animated];
  219. }
  220. @end