ReviewsTableHearV.m 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. //
  2. // ReviewsTableHearV.m
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2024/1/6.
  6. //
  7. #import "ReviewsTableHearV.h"
  8. #import "HCSStarRatingView.h"
  9. #import "GoodsInformationM.h"
  10. #import "YJLAttributesLabel.h"
  11. #import "AS_SignUpC.h"
  12. @interface ReviewsTableHearV ()
  13. @property (nonatomic, strong) UILabel *customLab;
  14. @property (nonatomic, strong) QMUILabel *reviewsLab;
  15. @property (nonatomic, strong) HCSStarRatingView *reviews_startV;
  16. @property (nonatomic, strong) QMUIButton *writeBtn;
  17. @property (nonatomic, strong) YJLAttributesLabel *tipsLab;
  18. @end
  19. @implementation ReviewsTableHearV
  20. +(CGFloat)xxx_viewHeight{
  21. if ([ASUserInfoManager shared].isLogin) {
  22. return 10+86+10+34;
  23. } else {
  24. return 10+86+10+34+40;
  25. }
  26. }
  27. - (void)tt_setupViews{
  28. UIView *topBgV = [[UIView alloc]init];
  29. topBgV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  30. topBgV.layer.cornerRadius = 8;
  31. topBgV.clipsToBounds = YES;
  32. [self addSubview:topBgV];
  33. [topBgV addSubview:self.customLab];
  34. [topBgV addSubview:self.reviewsLab];
  35. [topBgV addSubview:self.reviews_startV];
  36. [topBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.mas_equalTo(10);
  38. make.right.mas_equalTo(-10);
  39. make.top.mas_equalTo(10);
  40. make.height.mas_equalTo(86);
  41. }];
  42. [self.customLab mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_equalTo(10);
  44. make.top.mas_equalTo(20);
  45. make.height.mas_equalTo(15);
  46. }];
  47. [self.reviewsLab mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.equalTo(self.customLab.mas_right);
  49. make.top.mas_equalTo(20);
  50. make.height.mas_equalTo(15);
  51. }];
  52. [self.reviews_startV mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.mas_equalTo(10);
  54. make.top.equalTo(self.reviewsLab.mas_bottom).offset(10);
  55. make.height.mas_equalTo(20);
  56. make.width.mas_equalTo(120);
  57. }];
  58. [self addSubview:self.writeBtn];
  59. [self.writeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.top.equalTo(topBgV.mas_bottom).offset(10);
  61. make.left.mas_equalTo(10);
  62. make.height.mas_equalTo(34);
  63. make.width.mas_equalTo(105);
  64. }];
  65. [self layoutIfNeeded];
  66. [self.writeBtn layoutIfNeeded];
  67. [self addSubview:self.tipsLab];
  68. // [self.tipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
  69. // make.top.equalTo(self.writeBtn.mas_bottom);
  70. // make.left.mas_equalTo(20);
  71. // make.right.mas_equalTo(-20);
  72. // //40;
  73. // }];
  74. }
  75. - (void)tt_confignewdata:(id)data{
  76. GoodsInformationM *model = (GoodsInformationM *)data;
  77. self.reviewsLab.text = [NSString stringWithFormat:@"(%@ Reviews)",model.review_nums];
  78. if ([ASUserInfoManager shared].isLogin) {
  79. self.tipsLab.hidden = YES;
  80. } else {
  81. self.tipsLab.hidden = NO;
  82. }
  83. }
  84. #pragma mark - **************** handle ****************
  85. -(void)handle_writeEvent:(UIButton *)btn{
  86. [self generaltriggermethodType:0 data:@""];
  87. }
  88. - (UILabel *)customLab {
  89. if (!_customLab) {
  90. _customLab = [[UILabel alloc] initWithFrame:CGRectZero];
  91. _customLab.textAlignment = NSTextAlignmentLeft;
  92. _customLab.textColor = [UIColor blackColor];
  93. _customLab.font = [UIFont fontWithName:Rob_Bold size:12];
  94. _customLab.text = @"CUSTOMER REVIEWS";
  95. }
  96. return _customLab;
  97. }
  98. - (QMUILabel *)reviewsLab {
  99. if (!_reviewsLab) {
  100. _reviewsLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  101. _reviewsLab.textAlignment = NSTextAlignmentLeft;
  102. _reviewsLab.textColor = [UIColor colorWithHexString:@"#666666"];
  103. _reviewsLab.font = [UIFont fontWithName:Rob_Regular size:12];
  104. }
  105. return _reviewsLab;
  106. }
  107. -(HCSStarRatingView *)reviews_startV{
  108. if(!_reviews_startV){
  109. _reviews_startV = [[HCSStarRatingView alloc]initWithFrame:CGRectMake(10, 20,100+20, 30)];
  110. _reviews_startV.value =5;
  111. _reviews_startV.userInteractionEnabled = NO;
  112. _reviews_startV.filledStarImage = IMAGE(@"reviews_full_star");
  113. _reviews_startV.emptyStarImage = IMAGE(@"reviews_empty_star");
  114. _reviews_startV.maximumValue = 5;
  115. _reviews_startV.backgroundColor = [UIColor clearColor];
  116. }
  117. return _reviews_startV;
  118. }
  119. - (QMUIButton *)writeBtn {
  120. if (!_writeBtn) {
  121. _writeBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  122. NSMutableAttributedString *atr = [[NSMutableAttributedString alloc]initWithString:@"WRITE A REVIEW"];
  123. atr.underlineStyle = NSUnderlineStyleSingle;
  124. [_writeBtn setAttributedTitle:atr forState:UIControlStateNormal];
  125. [_writeBtn addTarget:self action:@selector(handle_writeEvent:) forControlEvents:UIControlEventTouchUpInside];
  126. _writeBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:12];
  127. _writeBtn.titleLabel.textColor = [UIColor colorWithHexString:@"#000000"];
  128. _writeBtn.frame = CGRectMake(10, 0, 105, 40);
  129. }
  130. return _writeBtn;
  131. }
  132. //- (QMUILabel *)tipsLab {
  133. // if (!_tipsLab) {
  134. // _tipsLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
  135. // _tipsLab.textAlignment = NSTextAlignmentLeft;
  136. // _tipsLab.textColor = [UIColor colorWithHexString:@"#666666"];
  137. // _tipsLab.font = [UIFont fontWithName:Rob_Regular size:12];
  138. // _tipsLab.text = @"Only Registered Users Can Write Reviews.Please,Log In Or Register";
  139. // _tipsLab.numberOfLines =2;
  140. // }
  141. // return _tipsLab;
  142. //}
  143. -(YJLAttributesLabel *)tipsLab{
  144. if (!_tipsLab) {
  145. _tipsLab = [[YJLAttributesLabel alloc]init];
  146. _tipsLab.numberOfLines = 0;
  147. _tipsLab.userInteractionEnabled = YES;
  148. _tipsLab.frame = CGRectMake(20, CGRectGetMaxY(self.writeBtn.frame), KScreenWidth - 40, 45);
  149. NSString *string = @"Only Registered Users Can Write Reviews. Please,Log In Or Register";
  150. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:string];
  151. NSMutableArray *arr_text = [[NSMutableArray alloc]initWithObjects:@"Log In Or Register" ,nil];
  152. attrStr = [self textArr:arr_text AttributedString:attrStr Connet:string];
  153. NSMutableArray * arr_range = [[NSMutableArray alloc]initWithObjects:@"48", nil];//点击的文字开始位置设置
  154. [_tipsLab setAttributesText:attrStr actionText:arr_text actionRange:arr_range];//d添加到UILabel上面
  155. _tipsLab.YJLAttributesBlock = ^(NSString * _Nonnull clicktext) {//点击事件的d返回
  156. if([clicktext isEqualToString:@"Log In Or Register"]){
  157. [Fuction_Tool pop_toLoginVC];
  158. }
  159. };
  160. _tipsLab.font = [UIFont fontWithName:Rob_Regular size:12];
  161. }
  162. return _tipsLab;
  163. }
  164. #pragma mark 多个点击位置进行简单设置
  165. -(NSMutableAttributedString *)textArr:(NSMutableArray *)textarr AttributedString:(NSMutableAttributedString *)String Connet:(NSString *)connet{
  166. for (int i=0; i<textarr.count; i++) {
  167. NSRange range = [connet rangeOfString:textarr[i]];
  168. [String addAttribute:NSLinkAttributeName
  169. value:textarr[i]
  170. range: range];
  171. [String addAttribute:NSForegroundColorAttributeName
  172. value:ThemeColor
  173. range:range];
  174. [String addAttribute:NSUnderlineStyleAttributeName
  175. value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
  176. range:range];
  177. }
  178. return String;
  179. }
  180. @end