EvaluationListCell.m 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. //
  2. // EvaluationListCell.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/3/27.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "EvaluationListCell.h"
  9. #import "ShowDetailVC.h"
  10. #import "YBImageView.h"
  11. @implementation EvaluationListCell
  12. - (void)awakeFromNib {
  13. [super awakeFromNib];
  14. // Initialization code
  15. }
  16. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  17. [super setSelected:selected animated:animated];
  18. // Configure the view for the selected state
  19. }
  20. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  21. {
  22. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  23. if (self) {
  24. _imgWidth =( _window_width-100-30)/4;
  25. [self creatUI];
  26. }
  27. return self;
  28. }
  29. -(void)creatUI{
  30. _headImg = [[UIImageView alloc]init];
  31. _headImg.frame = CGRectMake(15, 15, 24, 24);
  32. _headImg.layer.cornerRadius = 12;
  33. _headImg.layer.masksToBounds = YES;
  34. _headImg.tag = 1000;
  35. [self.contentView addSubview:_headImg];
  36. _nameLb = [[UILabel alloc]init];
  37. _nameLb.frame = CGRectMake(_headImg.right+10, 0, _window_width-_headImg.right-10, 20);
  38. _nameLb.centerY = _headImg.centerY;
  39. _nameLb.textColor = [UIColor grayColor];
  40. _nameLb.font = [UIFont systemFontOfSize:14];
  41. [self.contentView addSubview:_nameLb];
  42. _starView = [[CWStarRateView alloc]initWithFrame:CGRectMake(_nameLb.left, _headImg.bottom+5, 90, 12) numberOfStars:5 andSelImg:Comm_FOREGROUND_STAR_IMAGE_NAME andNormalImg:Comm_BACKGROUND_STAR_IMAGE_NAME];
  43. _starView.userInteractionEnabled = NO;
  44. _starView.delegate = self;
  45. [self.contentView addSubview:_starView];
  46. contentLb = [[UILabel alloc]init];
  47. contentLb.font = [UIFont systemFontOfSize:14];
  48. contentLb.numberOfLines = 0;
  49. contentLb.lineBreakMode = NSLineBreakByWordWrapping;
  50. contentLb.textColor = [UIColor blackColor];
  51. [self.contentView addSubview:contentLb];
  52. UILabel *line = [[UILabel alloc]init];
  53. line.backgroundColor = RGB(240, 240, 240);
  54. [self addSubview:line];
  55. [line mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.left.equalTo(self).offset(15);
  57. make.right.equalTo(self).offset(-15);
  58. make.bottom.equalTo(self);
  59. make.height.mas_equalTo(1);
  60. }];
  61. dateLb = [[UILabel alloc]init];
  62. dateLb.font = [UIFont systemFontOfSize:13];
  63. dateLb.textColor = [UIColor grayColor];
  64. [self.contentView addSubview:dateLb];
  65. standLb = [[UILabel alloc]init];
  66. standLb.font = [UIFont systemFontOfSize:13];
  67. standLb.textColor = [UIColor grayColor];
  68. [self.contentView addSubview:standLb];
  69. append_timeLb = [[UILabel alloc]init];
  70. append_timeLb.font = [UIFont systemFontOfSize:12];
  71. append_timeLb.numberOfLines = 0;
  72. append_timeLb.lineBreakMode = NSLineBreakByWordWrapping;
  73. append_timeLb.textColor = Normal_Color;
  74. [self.contentView addSubview:append_timeLb];
  75. append_contentLb = [[UILabel alloc]init];
  76. append_contentLb.font = [UIFont systemFontOfSize:14];
  77. append_contentLb.numberOfLines = 0;
  78. append_contentLb.lineBreakMode = NSLineBreakByWordWrapping;
  79. append_contentLb.textColor = [UIColor blackColor];
  80. [self.contentView addSubview:append_contentLb];
  81. appenline = [[UILabel alloc]init];
  82. appenline.backgroundColor = RGB(240, 240, 240);
  83. [self.contentView addSubview:appenline];
  84. }
  85. -(void)setModel:(EvaluationListModel *)model
  86. {
  87. NSLog(@"time----:%@ \n ---spec:%@",model.time_format, model.spec_name);
  88. _model = model;
  89. [_headImg sd_setImageWithURL:[NSURL URLWithString:model.avatar]];
  90. _nameLb.text = model.user_nickname;
  91. _starView.scorePercent = [model.quality_points floatValue]/5;
  92. CGFloat content_height = [PublicObj heightOfString:model.content andFont:[UIFont systemFontOfSize:14] andWidth:_window_width-50];
  93. contentLb.frame =CGRectMake(_headImg.right+10, _starView.bottom+5, _window_width-_headImg.right-30, content_height+5);
  94. contentLb.text = model.content;
  95. for(id tmpView in [self subviews])
  96. {
  97. if([tmpView isKindOfClass:[UIImageView class]]){
  98. UIImageView *selView = (UIImageView *)tmpView;
  99. if (selView.tag >= 5000) {
  100. [selView removeFromSuperview];
  101. }
  102. }
  103. }
  104. if (append_timeLb || append_contentLb) {
  105. append_timeLb.hidden = YES;
  106. append_contentLb.hidden = YES;
  107. appenline.hidden = YES;
  108. }
  109. NSMutableArray * _allArr = [NSMutableArray array];
  110. CGFloat imgY = contentLb.bottom+10;;
  111. NSLog(@"celllll--------thumb:%@", model.video_thumb);
  112. if (model.thumb_format.count > 0 && model.video_thumb.length > 10) {
  113. [_allArr addObject:model.video_thumb];
  114. [_allArr addObjectsFromArray:model.thumb_format];
  115. for (int i = 0; i < _allArr.count; i ++) {
  116. if (i < 3) {
  117. imgY =contentLb.bottom+10;
  118. }else{
  119. imgY =contentLb.bottom+20+_imgWidth;
  120. }
  121. UIImageView *img = [[UIImageView alloc]init];
  122. img.frame = CGRectMake(50+(i%3)*(_imgWidth + 10), imgY, _imgWidth, _imgWidth);
  123. [img sd_setImageWithURL:[NSURL URLWithString:_allArr[i]]];
  124. img.tag = 5000+i;
  125. img.userInteractionEnabled = YES;
  126. [self addSubview:img];
  127. UIButton *tapBtn = [UIButton buttonWithType:0];
  128. tapBtn.frame = CGRectMake(0, 0, img.width, img.height);
  129. tapBtn.tag =5000+i;
  130. [tapBtn addTarget:self action:@selector(detailBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  131. [img addSubview:tapBtn];
  132. if (i == 0) {
  133. [tapBtn setImage:[UIImage imageNamed:@"commodity_播放"] forState:0];
  134. }
  135. }
  136. }else if (model.thumb_format.count < 1 && model.video_thumb.length > 10){
  137. [_allArr addObject:model.video_thumb];
  138. imgY =contentLb.bottom+10;
  139. UIImageView *img = [[UIImageView alloc]init];
  140. img.frame = CGRectMake(50, imgY, _imgWidth, _imgWidth);
  141. [img sd_setImageWithURL:[NSURL URLWithString:model.video_thumb]];
  142. img.tag = 5000;
  143. img.userInteractionEnabled = YES;
  144. [self addSubview:img];
  145. UIButton *tapBtn = [UIButton buttonWithType:0];
  146. tapBtn.frame = CGRectMake(0, 0, img.width, img.height);
  147. tapBtn.tag =5000;
  148. [tapBtn addTarget:self action:@selector(detailBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  149. [img addSubview:tapBtn];
  150. [tapBtn setImage:[UIImage imageNamed:@"commodity_播放"] forState:0];
  151. }else if (model.thumb_format.count > 0 && model.video_thumb.length < 2){
  152. [_allArr addObjectsFromArray:model.thumb_format];
  153. for (int i = 0; i < _allArr.count; i ++) {
  154. if (i < 3) {
  155. imgY =contentLb.bottom+10;
  156. }else{
  157. imgY =contentLb.bottom+20+_imgWidth;
  158. }
  159. UIImageView *img = [[UIImageView alloc]init];
  160. img.frame = CGRectMake(50+(i%3)*(_imgWidth + 10), imgY, _imgWidth, _imgWidth);
  161. [img sd_setImageWithURL:[NSURL URLWithString:_allArr[i]]];
  162. img.tag = 5001+i;
  163. img.userInteractionEnabled = YES;
  164. [self addSubview:img];
  165. UIButton *tapBtn = [UIButton buttonWithType:0];
  166. tapBtn.frame = CGRectMake(0, 0, img.width, img.height);
  167. tapBtn.tag =5001+i;
  168. [tapBtn addTarget:self action:@selector(detailBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  169. [img addSubview:tapBtn];
  170. }
  171. }
  172. if (_allArr.count > 0 && _allArr.count < 4) {
  173. imgY =contentLb.bottom+20+_imgWidth;
  174. }else if (_allArr.count >3)
  175. {
  176. imgY =contentLb.bottom+30+_imgWidth*2;
  177. }else if(_allArr.count == 0){
  178. imgY =contentLb.bottom+10;
  179. }
  180. // dateLb = [[UILabel alloc]init];
  181. dateLb.frame = CGRectMake(_headImg.right+10, imgY, 100, 20);
  182. // dateLb.font = [UIFont systemFontOfSize:13];
  183. // dateLb.textColor = [UIColor grayColor];
  184. dateLb.text =model.time_format;
  185. // [self addSubview:dateLb];
  186. // standLb = [[UILabel alloc]init];
  187. standLb.frame = CGRectMake(dateLb.right+10, imgY, 100, 20);
  188. // standLb.font = [UIFont systemFontOfSize:13];
  189. // standLb.textColor = [UIColor grayColor];
  190. standLb.text =model.spec_name;
  191. // [self addSubview:standLb];
  192. imgY = dateLb.bottom+5;
  193. //如果有追评论
  194. if([model.has_append_comment isEqual:@"1"]){
  195. append_contentLb.hidden = NO;
  196. append_timeLb.hidden = NO;
  197. appenline.hidden = NO;
  198. appenline.frame = CGRectMake(_headImg.right+10, imgY+5, _window_width-_headImg.right-10-15, 1);
  199. append_timeLb.frame = CGRectMake(_headImg.right+10, imgY+10, _window_width, 18);
  200. // append_timeLb.text =[NSString stringWithFormat:@"%@%@",model.append_time_format,YZMsg(@"追评")] ;
  201. append_timeLb.text =[NSString stringWithFormat:@"%@",model.append_time_format] ;
  202. if ([append_timeLb.text isEqual:YZMsg(@"当日评论")]) {
  203. append_timeLb.textColor = Pink_Cor;
  204. }
  205. CGFloat append_content_height = [PublicObj heightOfString:model.append_content andFont:[UIFont systemFontOfSize:14] andWidth:_window_width-50];
  206. append_contentLb.frame =CGRectMake(_headImg.right+10, append_timeLb.bottom+5, _window_width-_headImg.right-30, append_content_height+5);
  207. append_contentLb.text = model.append_content;
  208. NSMutableArray * append_allArr = [NSMutableArray array];
  209. CGFloat append_imgY = append_contentLb.bottom+10;;
  210. if (model.append_thumb_format.count > 0 && model.append_video_thumb.length > 10) {
  211. [append_allArr addObject:model.append_video_thumb];
  212. [append_allArr addObjectsFromArray:model.append_thumb_format];
  213. for (int i = 0; i < append_allArr.count; i ++) {
  214. if (i < 3) {
  215. append_imgY =append_contentLb.bottom+10;
  216. }else{
  217. append_imgY =append_contentLb.bottom+20+_imgWidth;
  218. }
  219. UIImageView *img = [[UIImageView alloc]init];
  220. img.frame = CGRectMake(50+(i%3)*(_imgWidth + 10), append_imgY, _imgWidth, _imgWidth);
  221. [img sd_setImageWithURL:[NSURL URLWithString:append_allArr[i]]];
  222. img.tag = 6000+i;
  223. img.userInteractionEnabled = YES;
  224. [self addSubview:img];
  225. UIButton *tapBtn = [UIButton buttonWithType:0];
  226. tapBtn.frame = CGRectMake(0, 0, img.width, img.height);
  227. tapBtn.tag =6000+i;
  228. [tapBtn addTarget:self action:@selector(appendDetailBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  229. [img addSubview:tapBtn];
  230. if (i == 0) {
  231. [tapBtn setImage:[UIImage imageNamed:@"commodity_播放"] forState:0];
  232. }
  233. }
  234. }else if (model.append_thumb_format.count < 1 && model.append_video_thumb.length > 10){
  235. [append_allArr addObject:model.append_video_thumb];
  236. append_imgY =append_contentLb.bottom+10;
  237. UIImageView *img = [[UIImageView alloc]init];
  238. img.frame = CGRectMake(50, append_imgY, _imgWidth, _imgWidth);
  239. [img sd_setImageWithURL:[NSURL URLWithString:model.append_video_thumb]];
  240. img.tag = 6000;
  241. img.userInteractionEnabled = YES;
  242. [self addSubview:img];
  243. UIButton *tapBtn = [UIButton buttonWithType:0];
  244. tapBtn.frame = CGRectMake(0, 0, img.width, img.height);
  245. tapBtn.tag =6000;
  246. [tapBtn addTarget:self action:@selector(appendDetailBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  247. [img addSubview:tapBtn];
  248. [tapBtn setImage:[UIImage imageNamed:@"commodity_播放"] forState:0];
  249. }else if (model.append_thumb_format.count > 0 && model.append_video_thumb.length < 2){
  250. [append_allArr addObjectsFromArray:model.append_thumb_format];
  251. for (int i = 0; i < append_allArr.count; i ++) {
  252. if (i < 3) {
  253. append_imgY =append_contentLb.bottom+10;
  254. }else{
  255. append_imgY =append_contentLb.bottom+20+_imgWidth;
  256. }
  257. UIImageView *img = [[UIImageView alloc]init];
  258. img.frame = CGRectMake(50+(i%3)*(_imgWidth + 10), append_imgY, _imgWidth, _imgWidth);
  259. [img sd_setImageWithURL:[NSURL URLWithString:append_allArr[i]]];
  260. img.tag = 6001+i;
  261. img.userInteractionEnabled = YES;
  262. [self addSubview:img];
  263. UIButton *tapBtn = [UIButton buttonWithType:0];
  264. tapBtn.frame = CGRectMake(0, 0, img.width, img.height);
  265. tapBtn.tag =6001+i;
  266. [tapBtn addTarget:self action:@selector(appendDetailBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  267. [img addSubview:tapBtn];
  268. }
  269. }
  270. }
  271. }
  272. - (void)starRateView:(CWStarRateView *)starRateView scroePercentDidChange:(CGFloat)newScorePercent{
  273. NSLog(@"%f",newScorePercent);
  274. }
  275. -(void)detailBtnClick:(UIButton *)sender{
  276. if(sender.tag == 5000){
  277. ShowDetailVC *detail = [[ShowDetailVC alloc]init];
  278. detail.fromStr = @"trendlist";
  279. NSLog(@"=-=-=-=-=-=-=-:%@",_model.video_url);
  280. detail.videoPath =_model.video_url;
  281. detail.deleteEvent = ^(NSString *type) {
  282. };
  283. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:detail animated:NO];
  284. }else{
  285. NSInteger index = sender.tag - 5001;
  286. YBImageView *imgView = [[YBImageView alloc] initWithImageArray:_model.thumb_format andIndex:index andMine:NO isDtCell:NO andBlock:^(NSArray * _Nonnull array) {
  287. }];
  288. [[UIApplication sharedApplication].keyWindow addSubview:imgView];
  289. }
  290. }
  291. -(void)appendDetailBtnClick:(UIButton *)sender{
  292. if(sender.tag == 6000){
  293. ShowDetailVC *detail = [[ShowDetailVC alloc]init];
  294. detail.fromStr = @"trendlist";
  295. NSLog(@"=-=-=-=-=-=-=-:%@",_model.append_video_url);
  296. detail.videoPath =_model.append_video_url;
  297. detail.deleteEvent = ^(NSString *type) {
  298. };
  299. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:detail animated:NO];
  300. }else{
  301. NSInteger index = sender.tag - 6001;
  302. YBImageView *imgView = [[YBImageView alloc] initWithImageArray:_model.append_thumb_format andIndex:index andMine:NO isDtCell:NO andBlock:^(NSArray * _Nonnull array) {
  303. }];
  304. [[UIApplication sharedApplication].keyWindow addSubview:imgView];
  305. }
  306. }
  307. @end