// // ReviewsTableHearV.m // Asteria // // Created by 王猛 on 2024/1/6. // #import "ReviewsTableHearV.h" #import "HCSStarRatingView.h" #import "GoodsInformationM.h" #import "YJLAttributesLabel.h" #import "AS_SignUpC.h" @interface ReviewsTableHearV () @property (nonatomic, strong) UILabel *customLab; @property (nonatomic, strong) QMUILabel *reviewsLab; @property (nonatomic, strong) HCSStarRatingView *reviews_startV; @property (nonatomic, strong) QMUIButton *writeBtn; @property (nonatomic, strong) YJLAttributesLabel *tipsLab; @end @implementation ReviewsTableHearV +(CGFloat)xxx_viewHeight{ if ([ASUserInfoManager shared].isLogin) { return 10+86+10+34; } else { return 10+86+10+34+40; } } - (void)tt_setupViews{ UIView *topBgV = [[UIView alloc]init]; topBgV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"]; topBgV.layer.cornerRadius = 8; topBgV.clipsToBounds = YES; [self addSubview:topBgV]; [topBgV addSubview:self.customLab]; [topBgV addSubview:self.reviewsLab]; [topBgV addSubview:self.reviews_startV]; [topBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.right.mas_equalTo(-10); make.top.mas_equalTo(10); make.height.mas_equalTo(86); }]; [self.customLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.mas_equalTo(20); make.height.mas_equalTo(15); }]; [self.reviewsLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.customLab.mas_right); make.top.mas_equalTo(20); make.height.mas_equalTo(15); }]; [self.reviews_startV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.equalTo(self.reviewsLab.mas_bottom).offset(10); make.height.mas_equalTo(20); make.width.mas_equalTo(120); }]; [self addSubview:self.writeBtn]; [self.writeBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(topBgV.mas_bottom).offset(10); make.left.mas_equalTo(10); make.height.mas_equalTo(34); make.width.mas_equalTo(105); }]; [self layoutIfNeeded]; [self.writeBtn layoutIfNeeded]; [self addSubview:self.tipsLab]; // [self.tipsLab mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(self.writeBtn.mas_bottom); // make.left.mas_equalTo(20); // make.right.mas_equalTo(-20); // //40; // }]; } - (void)tt_confignewdata:(id)data{ GoodsInformationM *model = (GoodsInformationM *)data; self.reviewsLab.text = [NSString stringWithFormat:@"(%@ Reviews)",model.review_nums]; if ([ASUserInfoManager shared].isLogin) { self.tipsLab.hidden = YES; } else { self.tipsLab.hidden = NO; } } #pragma mark - **************** handle **************** -(void)handle_writeEvent:(UIButton *)btn{ [self generaltriggermethodType:0 data:@""]; } - (UILabel *)customLab { if (!_customLab) { _customLab = [[UILabel alloc] initWithFrame:CGRectZero]; _customLab.textAlignment = NSTextAlignmentLeft; _customLab.textColor = [UIColor blackColor]; _customLab.font = [UIFont fontWithName:Rob_Bold size:12]; _customLab.text = @"CUSTOMER REVIEWS"; } return _customLab; } - (QMUILabel *)reviewsLab { if (!_reviewsLab) { _reviewsLab = [[QMUILabel alloc] initWithFrame:CGRectZero]; _reviewsLab.textAlignment = NSTextAlignmentLeft; _reviewsLab.textColor = [UIColor colorWithHexString:@"#666666"]; _reviewsLab.font = [UIFont fontWithName:Rob_Regular size:12]; } return _reviewsLab; } -(HCSStarRatingView *)reviews_startV{ if(!_reviews_startV){ _reviews_startV = [[HCSStarRatingView alloc]initWithFrame:CGRectMake(10, 20,100+20, 30)]; _reviews_startV.value =5; _reviews_startV.userInteractionEnabled = NO; _reviews_startV.filledStarImage = IMAGE(@"reviews_full_star"); _reviews_startV.emptyStarImage = IMAGE(@"reviews_empty_star"); _reviews_startV.maximumValue = 5; _reviews_startV.backgroundColor = [UIColor clearColor]; } return _reviews_startV; } - (QMUIButton *)writeBtn { if (!_writeBtn) { _writeBtn = [QMUIButton buttonWithType:UIButtonTypeCustom]; NSMutableAttributedString *atr = [[NSMutableAttributedString alloc]initWithString:@"WRITE A REVIEW"]; atr.underlineStyle = NSUnderlineStyleSingle; [_writeBtn setAttributedTitle:atr forState:UIControlStateNormal]; [_writeBtn addTarget:self action:@selector(handle_writeEvent:) forControlEvents:UIControlEventTouchUpInside]; _writeBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:12]; _writeBtn.titleLabel.textColor = [UIColor colorWithHexString:@"#000000"]; _writeBtn.frame = CGRectMake(10, 0, 105, 40); } return _writeBtn; } //- (QMUILabel *)tipsLab { // if (!_tipsLab) { // _tipsLab = [[QMUILabel alloc] initWithFrame:CGRectZero]; // _tipsLab.textAlignment = NSTextAlignmentLeft; // _tipsLab.textColor = [UIColor colorWithHexString:@"#666666"]; // _tipsLab.font = [UIFont fontWithName:Rob_Regular size:12]; // _tipsLab.text = @"Only Registered Users Can Write Reviews.Please,Log In Or Register"; // _tipsLab.numberOfLines =2; // } // return _tipsLab; //} -(YJLAttributesLabel *)tipsLab{ if (!_tipsLab) { _tipsLab = [[YJLAttributesLabel alloc]init]; _tipsLab.numberOfLines = 0; _tipsLab.userInteractionEnabled = YES; _tipsLab.frame = CGRectMake(20, CGRectGetMaxY(self.writeBtn.frame), KScreenWidth - 40, 45); NSString *string = @"Only Registered Users Can Write Reviews. Please,Log In Or Register"; NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:string]; NSMutableArray *arr_text = [[NSMutableArray alloc]initWithObjects:@"Log In Or Register" ,nil]; attrStr = [self textArr:arr_text AttributedString:attrStr Connet:string]; NSMutableArray * arr_range = [[NSMutableArray alloc]initWithObjects:@"48", nil];//点击的文字开始位置设置 [_tipsLab setAttributesText:attrStr actionText:arr_text actionRange:arr_range];//d添加到UILabel上面 _tipsLab.YJLAttributesBlock = ^(NSString * _Nonnull clicktext) {//点击事件的d返回 if([clicktext isEqualToString:@"Log In Or Register"]){ [Fuction_Tool pop_toLoginVC]; } }; _tipsLab.font = [UIFont fontWithName:Rob_Regular size:12]; } return _tipsLab; } #pragma mark 多个点击位置进行简单设置 -(NSMutableAttributedString *)textArr:(NSMutableArray *)textarr AttributedString:(NSMutableAttributedString *)String Connet:(NSString *)connet{ for (int i=0; i