YOUPAIZYUserZiLiaoPJCell.m 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. //
  2. // YOUPAIZYUserZiLiaoDTCell.m
  3. // VQU
  4. //
  5. // Created by 肖浩然的mac on 2021/7/10.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAIZYUserZiLiaoPJCell.h"
  9. #import "YOUPAILZLabelCollectionCell.h"
  10. @interface YOUPAIZYUserZiLiaoPJCell()<UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>
  11. @property (nonatomic, strong) UICollectionView *youpaipcollectionView;
  12. /* countLabel */
  13. @property (strong, nonatomic) UILabel *youpaipcountLabel;
  14. @property (strong, nonatomic) UILabel *youpaipcountLabel1;
  15. /* arrowBtn */
  16. @property (strong, nonatomic) UIButton *youpaiparrowBtn;
  17. /* titleView */
  18. @property (strong, nonatomic) UIView *youpaiptitleView;
  19. /* goodPJLabel */
  20. @property (strong, nonatomic) UILabel *youpaipgoodPJLabel;
  21. @end
  22. @implementation YOUPAIZYUserZiLiaoPJCell
  23. -(instancetype)initWithFrame:(CGRect)frame{
  24. if (self = [super initWithFrame:frame]) {
  25. [self youpaifsetSubView];
  26. }
  27. return self;
  28. }
  29. -(void)youpaifsetSubView{
  30. UIView *titleView = [UIView new];
  31. self.youpaiptitleView = titleView;
  32. [self.contentView addSubview:titleView];
  33. [titleView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.mas_equalTo(0);
  35. make.right.mas_equalTo(0);
  36. make.top.mas_equalTo(0);
  37. make.height.mas_equalTo(20);
  38. }];
  39. titleView.backgroundColor = LCWhiteColor;
  40. self.youpaiptitleLabel = [[UILabel alloc] init];
  41. self.youpaiptitleLabel.font = LCBoldFont(14);
  42. [titleView addSubview:self.youpaiptitleLabel];
  43. [self.youpaiptitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.centerY.mas_equalTo(0);
  45. make.left.mas_equalTo(14);
  46. }];
  47. self.youpaiptitleLabel.textColor = LZ273145Color;
  48. // //视频接通率
  49. // UILabel *countLabel = [UILabel new];
  50. // self.youpaipcountLabel = countLabel;
  51. // [self.contentView addSubview:countLabel];
  52. // [countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  53. // make.top.mas_equalTo(titleView.mas_bottom).offset(5);
  54. // make.left.mas_equalTo(14);
  55. // make.height.mas_equalTo(12);
  56. // }];
  57. //
  58. //
  59. //// countLabel.text = @"视频接通率:98%(接通365次)";
  60. //
  61. // countLabel.font = [UIFont systemFontOfSize:12];
  62. // //接通次数
  63. // UILabel *countLabel1 = [UILabel new];
  64. // self.youpaipcountLabel1 = countLabel1;
  65. // [self.contentView addSubview:countLabel1];
  66. // [countLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
  67. // make.top.mas_equalTo(titleView.mas_bottom).offset(5);
  68. // make.left.mas_equalTo(countLabel.mas_right);
  69. // make.height.mas_equalTo(12);
  70. // }];
  71. //
  72. // countLabel1.font = [UIFont systemFontOfSize:12];
  73. // countLabel1.textColor = HexColorFromRGB(0xFFB800);
  74. // //好评率
  75. //
  76. //
  77. // UILabel *goodPJLabel = [UILabel new];
  78. // self.youpaipgoodPJLabel = goodPJLabel;
  79. // [self.contentView addSubview:goodPJLabel];
  80. // [goodPJLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  81. // make.left.mas_equalTo(countLabel);
  82. // make.top.mas_equalTo(countLabel.mas_bottom).offset(5);;
  83. // }];
  84. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  85. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  86. self.youpaipcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
  87. [self.contentView addSubview:self.youpaipcollectionView];
  88. [self.youpaipcollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.top.mas_equalTo(titleView.mas_bottom).offset(0);
  90. make.left.mas_offset(12.f);
  91. make.right.mas_offset(-12.f);
  92. make.bottom.mas_offset(0.f);
  93. }];
  94. // self.collectionView.userInteractionEnabled = NO;
  95. self.youpaipcollectionView.backgroundColor = LCWhiteColor;
  96. self.youpaipcollectionView.showsVerticalScrollIndicator = NO;
  97. self.youpaipcollectionView.showsHorizontalScrollIndicator = NO;
  98. self.youpaipcollectionView.bounces = NO;
  99. self.youpaipcollectionView.scrollEnabled = NO;
  100. self.youpaipcollectionView.delegate = self;
  101. self.youpaipcollectionView.dataSource = self;
  102. [self.youpaipcollectionView registerClass:[YOUPAILZLabelCollectionCell class] forCellWithReuseIdentifier:NSStringFromClass([YOUPAILZLabelCollectionCell class])];
  103. }
  104. -(void)setYoupaipmodel:(YOUPAILCUserShowModel *)model{
  105. _youpaipmodel = model;
  106. // if (model.youpaipskill_list.count>0) {
  107. // YOUPAILCSkillModel *skillModel = model.youpaipskill_list.firstObject;
  108. //
  109. // if (model.youpaiporder_switch == 2) {
  110. // self.youpaipcountLabel.attributedText = [LCTools setRichTextWithTitle:@"视频接通率:" subTitle:[NSString stringWithFormat:@"%@",skillModel.youpaiprate] titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFB800) titleFontSize:12 subTitleFontSize:12];
  111. // self.youpaipcountLabel1.text = [NSString stringWithFormat:@"(接通%ld次)",(long)skillModel.youpaipservice_count];
  112. // }else{
  113. // self.youpaipcountLabel.attributedText = [LCTools setRichTextWithTitle:@"视频接通率:" subTitle:@"" titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFB800) titleFontSize:12 subTitleFontSize:12];
  114. // self.youpaipcountLabel1.text = @"";
  115. // self.youpaipcountLabel.hidden = YES;
  116. // self.youpaipcountLabel1.hidden = YES;
  117. //
  118. //
  119. //
  120. // }
  121. //
  122. //
  123. // }
  124. // if (model.youpaipevaluate&&model.youpaiporder_switch == 2) {
  125. // self.youpaipgoodPJLabel.attributedText = [LCTools setRichTextWithTitle:@"好评率:" subTitle:model.youpaipevaluate titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFB800) titleFontSize:12 subTitleFontSize:12];
  126. //
  127. // [self.youpaipcollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  128. // make.top.mas_equalTo(self.youpaipgoodPJLabel.mas_bottom).offset(5);
  129. // make.left.mas_offset(14.f);
  130. // make.right.mas_offset(-14.f);
  131. // make.bottom.mas_offset(0.f);
  132. // }];
  133. // }else if(model.youpaipevaluate &&model.youpaiporder_switch != 2){
  134. // self.youpaipcountLabel.hidden = YES;
  135. // self.youpaipcountLabel1.hidden = YES;
  136. // [self.youpaipgoodPJLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  137. // make.top.mas_equalTo(self.youpaiptitleView.mas_bottom).offset(5);
  138. // make.left.mas_equalTo(14);
  139. // make.height.mas_equalTo(12);
  140. // }];
  141. // [self.youpaipcollectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
  142. // make.top.mas_equalTo(self.youpaipgoodPJLabel.mas_bottom).offset(5);
  143. // make.left.mas_offset(14.f);
  144. // make.right.mas_offset(-14.f);
  145. // make.bottom.mas_offset(0.f);
  146. // }];
  147. // self.youpaipgoodPJLabel.attributedText = [LCTools setRichTextWithTitle:@"好评率:" subTitle:model.youpaipevaluate titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFB800) titleFontSize:12 subTitleFontSize:12];
  148. //
  149. // }else if (!model.youpaipevaluate &&model.youpaiporder_switch == 2){
  150. // self.youpaipgoodPJLabel.hidden = YES;
  151. // }else{
  152. // self.youpaipgoodPJLabel.hidden = YES;
  153. // }
  154. }
  155. -(void)setYoupaiplabelArray:(NSArray *)labelArray{
  156. _youpaiplabelArray = labelArray;
  157. }
  158. #pragma mark <UICollectionViewDataSource>
  159. /**
  160. 返回区数
  161. @param collectionView 集合视图
  162. @return 返回区数
  163. */
  164. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  165. return 1;
  166. }
  167. /**
  168. 返回项目数
  169. @param collectionView 集合视图
  170. @param section 区
  171. @return 项目数
  172. */
  173. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  174. return self.youpaiplabelArray.count;
  175. }
  176. -(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  177. YOUPAILZLabelCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([YOUPAILZLabelCollectionCell class]) forIndexPath:indexPath];
  178. YOUPAIZYLabelModel *model = _youpaiplabelArray[indexPath.row];
  179. model.youpaipisSelect = YES;
  180. [cell youpaifreloadWithModel:model];
  181. return cell;
  182. }
  183. #pragma mark UICollectionViewDelegateFlowLayout
  184. /**
  185. 项目大小
  186. @param collectionView 集合视图
  187. @param collectionViewLayout 布局
  188. @param indexPath 布局
  189. @return 大小
  190. */
  191. #pragma mark - item宽高
  192. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  193. YOUPAIZYLabelModel *model = _youpaiplabelArray[indexPath.row];
  194. NSString *str = [NSString stringWithFormat:@"%@",model.youpaipname];
  195. CGRect rect = [str boundingRectWithSize:CGSizeMake(KScreenWidth,20) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName :LCFont(12)} context:nil];
  196. return CGSizeMake(rect.size.width + 24 ,24.5);
  197. }
  198. #pragma mark - X间距
  199. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  200. return 9.0;
  201. }
  202. #pragma mark - Y间距
  203. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
  204. return 9.0;
  205. }
  206. //设置段落的内边距
  207. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  208. {
  209. return UIEdgeInsetsMake(0,0,0,0);//UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right)
  210. }
  211. -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  212. {
  213. YOUPAIZYLabelModel *model = _youpaiplabelArray[indexPath.row];
  214. [self.youpaipdelegate youpaifclickLabel:model];
  215. }
  216. @end