JXNearCell.m 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. //
  2. // JXExpertCell.m
  3. // shiku_im
  4. //
  5. // Created by MacZ on 2016/10/20.
  6. // Copyright © 2016年 Reese. All rights reserved.
  7. //
  8. #import "JXNearCell.h"
  9. //#import "JXVideoPlayer.h"
  10. @interface JXNearCell (){
  11. // JXVideoPlayer* _player;
  12. // UIImageView *_jobSalaryImg;
  13. // UILabel *_jobSalary;
  14. }
  15. @property (nonatomic,strong) UIImageView *imgview;
  16. @property (nonatomic,strong) UILabel *skillName;
  17. //@property (nonatomic,strong) UIImageView *salaryImg;
  18. @property (nonatomic,strong) UILabel *salary; //创建时间
  19. @property (nonatomic,strong) UILabel *loginTime; //登录时间
  20. //@property (nonatomic,strong) UIImageView *siteImg;
  21. //@property (nonatomic,strong) UIImageView *playImgV;
  22. //@property (nonatomic,strong) UILabel *site; //工作地点
  23. //@property (nonatomic,strong) UIImageView *experienceImg;
  24. //@property (nonatomic,strong) UILabel *experience; //工作年限
  25. //@property (nonatomic,strong) UIImageView *academyImg;
  26. //@property (nonatomic,strong) UILabel *academy; //学历要求
  27. @property (nonatomic,strong) JXImageView *headImg;
  28. @property (nonatomic,strong) UILabel *expertName;
  29. //@property (nonatomic,strong) UILabel *distance;
  30. //头像上性别
  31. @property (nonatomic,strong) UIImageView *sexImgview;
  32. // 广告标识
  33. //@property (nonatomic, strong) UILabel *adLabel;
  34. @property (nonatomic,strong) UILabel *phoneNum;
  35. @property (nonatomic,strong) UILabel *callTime;
  36. @property (nonatomic,strong) UILabel *authLabel;
  37. @property (nonatomic, strong) UIImageView *locateImgV;
  38. @end
  39. @implementation JXNearCell
  40. - (instancetype)initWithFrame:(CGRect)frame{
  41. self = [super initWithFrame:frame];
  42. if (self) {
  43. self.layer.cornerRadius = 5;
  44. self.layer.masksToBounds = YES;
  45. [self customViewWithFrame:frame];
  46. // _player= [[JXVideoPlayer alloc] initWithParent:_imgview];
  47. }
  48. return self;
  49. }
  50. - (void)customViewWithFrame:(CGRect)frame{
  51. // self.contentView.layer.masksToBounds = YES;
  52. // self.contentView.layer.cornerRadius = 5.f;
  53. //专长图片
  54. _imgview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.width)];
  55. _imgview.image = [UIImage imageNamed:@"loading"];
  56. _imgview.userInteractionEnabled = YES;
  57. [self.contentView addSubview:_imgview];
  58. // _playImgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
  59. // _playImgV.center = _imgview.center;
  60. //// _playImgV.backgroundColor = [UIColor redColor];
  61. // _playImgV.image = [UIImage imageNamed:@"开始"];
  62. //// _playImgV.userInteractionEnabled = YES;
  63. // [self.contentView addSubview:_playImgV];
  64. // NSString *perStr = @"大神直播";
  65. //
  66. // CGSize perSize = [perStr boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:SYSFONT(13.0)} context:nil].size;
  67. // self.adLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, perSize.width + 6, 18)];
  68. // self.adLabel.text = perStr;
  69. // self.adLabel.textAlignment = NSTextAlignmentCenter;
  70. // self.adLabel.layer.cornerRadius = 5;
  71. // self.adLabel.layer.masksToBounds = YES;
  72. // self.adLabel.backgroundColor = THEMECOLOR;
  73. // self.adLabel.textColor = [UIColor whiteColor];
  74. // self.adLabel.font = SYSFONT(14.0);
  75. // [self.contentView addSubview:self.adLabel];
  76. // self.adLabel.hidden = YES;
  77. //专家头像
  78. _headImg = [[JXImageView alloc] init];
  79. _headImg.frame = CGRectMake(10, CGRectGetMaxY(_imgview.frame)+10, 33, 33);
  80. _headImg.userInteractionEnabled = NO;
  81. _headImg.layer.cornerRadius = _headImg.frame.size.width/2;
  82. _headImg.layer.masksToBounds = YES;
  83. _headImg.image = [UIImage imageNamed:@"11111"];
  84. [self.contentView addSubview:_headImg];
  85. //昵称
  86. _skillName = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_headImg.frame)+6, CGRectGetMinY(_headImg.frame), frame.size.width - 5*2, 15)];
  87. _skillName.text = Localized(@"Setting_CodecsViewController_Title");
  88. _skillName.font = SYSFONT(13);
  89. _skillName.textColor = HEXCOLOR(0x666666);
  90. [self.contentView addSubview:_skillName];
  91. if (!_sexImgview) {
  92. _sexImgview = [[UIImageView alloc] initWithFrame:CGRectMake(_headImg.frame.origin.x+_headImg.frame.size.width-8, _headImg.frame.origin.y-2, 10, 10)];
  93. // _sexImgview.image = [UIImage imageNamed:@"manicon"];
  94. [self.contentView addSubview:_sexImgview];
  95. }
  96. // 位置下方的模版
  97. UIImageView *fuzzyView = [[UIImageView alloc] initWithFrame:CGRectMake(0, frame.size.height-33-53, frame.size.width, 33)];
  98. fuzzyView.image = [UIImage imageNamed:@"fuzzy_view"];
  99. [self.contentView addSubview:fuzzyView];
  100. //距离(位置)
  101. _expertName = [[UILabel alloc] initWithFrame:CGRectMake(0, frame.size.height-10-13-53, frame.size.width-10, 13)];
  102. _expertName.text = Localized(@"UserInfoVC_Fans");
  103. _expertName.font = SYSFONT(13);
  104. _expertName.textColor = [UIColor whiteColor];
  105. _expertName.textAlignment = NSTextAlignmentRight;
  106. [self.contentView addSubview:_expertName];
  107. //位置图标
  108. _locateImgV = [[UIImageView alloc] init];
  109. _locateImgV.image = [UIImage imageNamed:@"near_location_tag"];
  110. [self.contentView addSubview:_locateImgV];
  111. // 创建时间
  112. _salary = [self labelWithTitle:Localized(@"JX_ChinaMoney") textColor:HEXCOLOR(0x666666) font:SYSFONT(13)];
  113. _salary.frame = CGRectMake(CGRectGetMaxX(_headImg.frame)+6, CGRectGetMaxY(_skillName.frame)+6, 80, 13);
  114. [self.contentView addSubview:_salary];
  115. //18938880001
  116. if ([g_myself.telephone rangeOfString:@"18938880001"].location != NSNotFound) {
  117. // 手机号
  118. _phoneNum = [[UILabel alloc] initWithFrame:CGRectMake(self.contentView.frame.size.width - 140, _skillName.frame.origin.y, 140, 13)];
  119. _phoneNum.text = @"12345678910";
  120. _phoneNum.font = SYSFONT(13);
  121. _phoneNum.textAlignment = NSTextAlignmentRight;
  122. _phoneNum.textColor = [UIColor darkGrayColor];
  123. // _expertName.center = CGPointMake(_expertName.center.x, _headImg.center.y-6);
  124. [self.contentView addSubview:_phoneNum];
  125. _callTime = [[UILabel alloc] initWithFrame:CGRectMake(self.contentView.frame.size.width - 140, CGRectGetMinY(_salary.frame), 140, 13)];
  126. _callTime.font = SYSFONT(13);
  127. _callTime.textAlignment = NSTextAlignmentRight;
  128. _callTime.textColor = [UIColor darkGrayColor];
  129. // _expertName.center = CGPointMake(_expertName.center.x, _headImg.center.y-6);
  130. [self.contentView addSubview:_callTime];
  131. // 登录时间
  132. _loginTime = [[UILabel alloc] initWithFrame:CGRectMake(10, _expertName.frame.origin.y, 75, 15)];
  133. _loginTime.text = @"1970-1-1";
  134. _loginTime.font = SYSFONT(13);
  135. _loginTime.backgroundColor = [UIColor whiteColor];
  136. _loginTime.textColor = [UIColor blackColor];
  137. [self.contentView addSubview:_loginTime];
  138. _authLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 20)];
  139. _authLabel.hidden = YES;
  140. _authLabel.textColor = [UIColor redColor];
  141. _authLabel.font = [UIFont systemFontOfSize:15.0];
  142. _authLabel.text = Localized(@"JX_TheAuthenticated");
  143. [_imgview addSubview:_authLabel];
  144. }
  145. // //距离
  146. // UIImageView *distanceImgview = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width - 12 - 15, _headImg.frame.origin.y, 15, 15)];
  147. // distanceImgview.image = [UIImage imageNamed:@"location"];
  148. // [self.contentView addSubview:distanceImgview];
  149. // _distance = [[UILabel alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-distanceImgview.frame.size.width-10, distanceImgview.frame.origin.y + distanceImgview.frame.size.height + 2, 40, 10)];
  150. // _distance.text = @"56 KM";
  151. // _distance.textAlignment = NSTextAlignmentCenter;
  152. // _distance.font = SYSFONT(8);
  153. // _distance.center = CGPointMake(distanceImgview.center.x, _distance.center.y);
  154. // [self.contentView addSubview:_distance];
  155. // // _distance.backgroundColor = [UIColor cyanColor];
  156. }
  157. - (UILabel *)labelWithTitle:(NSString *)title textColor:(UIColor *)color font:(UIFont *)font{
  158. UILabel *label = [[UILabel alloc] init];
  159. label.text = title;
  160. label.textColor = color;
  161. label.font = font;
  162. return label;
  163. }
  164. - (void)doRefreshNearExpert:(NSDictionary *)dict{
  165. if (!dict) {
  166. return;
  167. }
  168. // [cell setTitle:[dict objectForKey:@"nickname"]];
  169. // [cell setSuLabel:[self getDistance:indexPath.row]];
  170. // cell.userId = [[dict objectForKey:@"userId"] stringValue];
  171. // [cell getHeadImage];
  172. // int n = [[[dict objectForKey:@"loginLog"] objectForKey:@"loginTime"] longLongValue];
  173. // [cell setForTimeLabel:[TimeUtil getTimeStrStyle1:n]];
  174. _skillName.text = [dict objectForKey:@"nickname"];
  175. _expertName.text = [self getDistance:dict];
  176. CGSize size = [_expertName.text boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:_expertName.font} context:nil].size;
  177. _expertName.frame = CGRectMake(self.contentView.frame.size.width-size.width-10, _expertName.frame.origin.y, size.width, _expertName.frame.size.height);
  178. _locateImgV.frame = CGRectMake(CGRectGetMinX(_expertName.frame)-9-4, CGRectGetMinY(_expertName.frame)+1, 9, 11);
  179. long long n = [[(NSDictionary *)[dict objectForKey:@"loginLog"] objectForKey:@"loginTime"] longLongValue];
  180. long long m = [[dict objectForKey:@"createTime"] longLongValue];
  181. _loginTime.text = [TimeUtil getTimeStrStyle1:n];
  182. _salary.text = [TimeUtil getTimeStrStyle1:m];
  183. CGSize size1 = [_loginTime.text sizeWithAttributes:@{NSFontAttributeName:SYSFONT(13)}];
  184. _loginTime.frame = CGRectMake(_loginTime.frame.origin.x, _loginTime.frame.origin.y, size1.width, _loginTime.frame.size.height);
  185. if ([[dict[@"telephone"] substringToIndex:2] isEqualToString:@"86"]) {
  186. _phoneNum.text = [dict[@"telephone"] substringFromIndex:2];
  187. }else {
  188. _phoneNum.text = dict[@"telephone"];
  189. }
  190. NSDate *date = [g_myself.phoneDic objectForKey:_phoneNum.text];
  191. if (date) {
  192. _callTime.hidden = NO;
  193. long long n = (long long)[date timeIntervalSince1970];
  194. NSString *time = [TimeUtil getTimeStrStyle1:n];
  195. NSString *str = [NSString stringWithFormat:@"%@:%@",Localized(@"JX_HaveToDial"),time];
  196. _callTime.text = str;
  197. }else {
  198. _callTime.hidden = YES;
  199. }
  200. if ([[dict objectForKey:@"isAuth"] intValue] == 1) {
  201. _authLabel.hidden = NO;
  202. }else {
  203. _authLabel.hidden = YES;
  204. }
  205. // _headImg.delegate = _delegate;
  206. // _headImg.didTouch = _didTouch;
  207. // NSString *videoUrl = [[dict objectForKey:@"videoUrl"] rangeOfString:@"http"].location == NSNotFound ? nil : [dict objectForKey:@"videoUrl"];
  208. _imgview.image = nil;
  209. _headImg.image = nil;
  210. [g_server getHeadImageLarge:[dict objectForKey:@"userId"] userName:[dict objectForKey:@"nickname"] imageView:_imgview];
  211. // [_imgview.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
  212. [g_server getHeadImageLarge:[dict objectForKey:@"userId"] userName:[dict objectForKey:@"nickname"] imageView:_headImg];
  213. // NSTimeInterval t = [[dict objectForKey:@"createTime"] longLongValue];
  214. // NSDate* d = [NSDate dateWithTimeIntervalSince1970:t];
  215. // _salary.text = [TimeUtil formatDate:d format:@"MM-dd HH:mm"];
  216. // //性别
  217. // NSNumber *sex = [dict objectForKey:@"sex"];
  218. // if ([sex intValue] == 1) {
  219. // _sexImgview.hidden = NO;
  220. // _sexImgview.image = [UIImage imageNamed:@"wemanicon"];
  221. // }else if ([sex intValue] == 2){
  222. // _sexImgview.hidden = NO;
  223. // _sexImgview.image = [UIImage imageNamed:@"manicon"];
  224. // }else{
  225. // _sexImgview.hidden = YES;
  226. // }
  227. // _site.text = [g_constant.city objectForKey:[dict objectForKey:@"cityId"]];
  228. // _experience.text = [g_constant.workexp objectForKey:[dict objectForKey:@"workTime"]];
  229. // _academy.text = [g_constant.diploma objectForKey:[dict objectForKey:@"degree"]];
  230. //
  231. // CGSize makeSize;
  232. //// makeSize = [_site.text sizeWithFont:_site.font];
  233. // makeSize = [_site.text sizeWithAttributes:@{NSFontAttributeName:_site.font}];
  234. // _site.frame = CGRectMake(_site.frame.origin.x, _site.frame.origin.y, makeSize.width, makeSize.height);
  235. // _experienceImg.frame = CGRectMake(_site.frame.origin.x+_site.frame.size.width+5, _siteImg.frame.origin.y, _siteImg.frame.size.width,_siteImg.frame.size.height );
  236. // // makeSize = [_experience.text sizeWithFont:_experience.font];
  237. // makeSize = [_experience.text sizeWithAttributes:@{NSFontAttributeName:_experience.font}];
  238. // _experience.frame = CGRectMake(_experienceImg.frame.origin.x+_experienceImg.frame.size.width+2, _site.frame.origin.y, makeSize.width, makeSize.height);
  239. // _academyImg.frame = CGRectMake(_experience.frame.origin.x+_experience.frame.size.width+5, _siteImg.frame.origin.y, _siteImg.frame.size.width,_siteImg.frame.size.height);
  240. //
  241. // // makeSize = [_academy.text sizeWithFont:_academy.font];
  242. // makeSize = [_academy.text sizeWithAttributes:@{NSFontAttributeName:_academy.font}];
  243. // _academy.frame = CGRectMake(_academyImg.frame.origin.x+_academyImg.frame.size.width+2, _site.frame.origin.y, makeSize.width, makeSize.height);
  244. //
  245. //
  246. //
  247. // _skillName.text = [dict objectForKey:@"name"];
  248. // _expertName.text = [dict objectForKey:@"nickName"];
  249. //
  250. // double latitude = [[dict objectForKey:@"coord"][1] doubleValue];
  251. // double longitude = [[dict objectForKey:@"coord"][0] doubleValue];
  252. // if (latitude == 0 && longitude == 0) {
  253. //// _distance.text = Localized(@"DataMissing");
  254. // _distance.hidden = YES;
  255. // }else{
  256. // _distance.hidden = NO;
  257. // double dist = [g_server getLocation:latitude longitude:longitude];
  258. // if (dist > 1000000) {
  259. // _distance.text = [NSString stringWithFormat:@"%dkm",(int)dist/1000];
  260. // }else{
  261. //// _distance.text = [NSString stringWithFormat:@"%.3fkm",dist/1000];
  262. // _distance.text = [NSString stringWithFormat:@"%.1fm",dist];
  263. // }
  264. // }
  265. // CGSize distLabelSize = [_distance.text sizeWithFont:SYSFONT(8)];
  266. // _distance.frame = CGRectMake(self.contentView.frame.size.width-distLabelSize.width-4, _distance.frame.origin.y, distLabelSize.width, _distance.frame.size.height);
  267. //
  268. // int adType = [[[dict objectForKey:@"ad"] objectForKey:@"type"] intValue];
  269. // if (adType > 0) {
  270. // _skillName.text = @"美女主播";
  271. // self.adLabel.hidden = NO;
  272. // }else {
  273. // if ([g_constant.function objectForKey:dict[@"fnId"]]) {
  274. // _skillName.text = [g_constant.function objectForKey:dict[@"fnId"]];
  275. // }else {
  276. // _skillName.text = @"未填";
  277. // }
  278. // self.adLabel.hidden = YES;
  279. // }
  280. }
  281. #pragma mark --------------获取距离-------------
  282. - (NSString *)getDistance:(NSDictionary* ) dict{
  283. NSString* diploma = [g_constant.diploma objectForKey:[dict objectForKey:@"dip"]];
  284. NSString* salary = [g_constant.salary objectForKey:[dict objectForKey:@"salary"]];
  285. // NSString* address = [g_constant getAddressForNumber:[dict objectForKey:@"provinceId"] cityId:[dict objectForKey:@"cityId"] areaId:[dict objectForKey:@"areaId"]];
  286. double latitude = [[(NSDictionary *)[dict objectForKey:@"loc"] objectForKey:@"lat"] doubleValue];
  287. double longitude = [[(NSDictionary *)[dict objectForKey:@"loc"] objectForKey:@"lng"] doubleValue];
  288. double m = [g_server getLocation:latitude longitude:longitude];
  289. NSString* s=[NSString stringWithFormat:@"%.2lfkm ",m/1000];
  290. // if(address)
  291. // s = [s stringByAppendingString:address];
  292. if(diploma){
  293. s = [s stringByAppendingString:@" | "];
  294. s = [s stringByAppendingString:diploma];
  295. }
  296. if(salary){
  297. s = [s stringByAppendingString:@" | "];
  298. s = [s stringByAppendingString:salary];
  299. }
  300. if (latitude <= 0 && longitude <= 0 && [g_myself.telephone rangeOfString:@"18938880001"].location == NSNotFound) {
  301. // 未开启位置权限
  302. s = Localized(@"JX_FriendLocationNotEnabled");
  303. }
  304. return s;
  305. }
  306. @end