// // YOUPAILCHomeCollectionCell.m // LiveChat // // Created by 张灿 on 2018/9/2. // Copyright © 2018年 caicai. All rights reserved. // #import "YOUPAILCHomeCollectionCell.h" //#import "CWStarRateView.h" #import "YYImage.h" #import "FSAudioStream.h" #import "YYAnimatedImageView.h" #import "YOUPAILZHomeTagLabelView.h" #import "YOUPAIZYLabelModel.h" #import "YOUPAILZLevelView.h" @interface YOUPAILCHomeCollectionCell() @property (nonatomic,strong)UIImageView *youpaipimageV; @property (nonatomic,strong)UIView *youpaiptopBkgView; @property (nonatomic,strong)UIView *youpaipbottomBkgView; //@property (strong, nonatomic) CWStarRateView *starRateView; @property (nonatomic,strong)UIView *youpaipstatusView; @property (nonatomic,strong)UILabel *youpaipstatusL; @property (nonatomic,strong)UILabel *youpaipnameLab; @property (nonatomic,strong)UILabel *youpaipsignL; /* iconAnimationImgV */ @property (strong, nonatomic) YYAnimatedImageView *youpaipiconAnimationImgV; /* textL */ @property (strong, nonatomic) UILabel *youpaiptextL; /* liveBgView */ @property (strong, nonatomic) UIView *youpaipliveBgView; // //@property (nonatomic,strong)UIView *scoreView; // //@property (nonatomic,strong)UILabel *scoreL; //@property (nonatomic,strong)UILabel *cityL; @property (nonatomic,weak) UILabel *youpaiptimerL; @property (nonatomic,weak) UIImageView *youpaipanimationImgV; @property (nonatomic, weak) UIImageView *youpaipvipV; // 语音播放器 @property (nonatomic, strong)FSAudioStream *youpaipaudioStream; @property (nonatomic, strong)NSTimer *youpaiptimer; /* YOUPAILZLevelView */ @property (strong, nonatomic) YOUPAILZLevelView *youpaiplevelView; /* 语音播放bgView */ @property (strong, nonatomic) UIView *youpaipaBgV; /* tagBgView */ @property (strong, nonatomic) UIView *youpaiptagBgView; /* tagLabel */ @property (strong, nonatomic) UILabel *youpaiptagLabel; /* rankTagBtn */ @property (strong, nonatomic) UIButton *youpaiprankTagBtn; /* goodPJLabel */ @property (strong, nonatomic) UILabel *youpaipgoodPJLabel; /* priceLabel */ @property (strong, nonatomic) UILabel *youpaippriceLabel; /* discountsPriceLabel */ @property (strong, nonatomic) UILabel *youpaipdiscountsPriceLabel; @property(nonatomic,strong) YOUPAILZHomeTagLabelView *youpaiplabelView; @end @implementation YOUPAILCHomeCollectionCell static NSString* HKHomeCellID = @"YOUPAILCHomeCollectionCell"; -(instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { [self youpaifsetSubView]; } return self; } #pragma mark-点击事件 //点击头像 -(void)youpaifdidclickIcontap{ if (self.youpaipdidClickIconBlock) { self.youpaipdidClickIconBlock(self.youpaiphomeListModel.youpaipuserid); } } -(void)youpaifvideoBtnClick{ if (self.youpaipdidVideoBlock) { self.youpaipdidVideoBlock(self.youpaiphomeListModel.youpaipuserid); } } -(void)youpaifsetSubView{ [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifremoveVoiceNotic) name:@"removeVoice" object:nil]; // self.userInteractionEnabled = NO; self.backgroundColor = LCSubBkgColor; self.youpaipimageV = [[UIImageView alloc] init]; [self.contentView addSubview:self.youpaipimageV]; [self.youpaipimageV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.width.mas_equalTo(125); make.height.mas_equalTo(125); }]; // self.imageV.backgroundColor = [LCTools getBkgRandomColor]; self.youpaipimageV.contentMode = UIViewContentModeScaleAspectFill; self.youpaipimageV.clipsToBounds = YES; self.youpaipimageV.userInteractionEnabled = YES; // UITapGestureRecognizer *iconTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(youpaifdidclickIcontap)]; // [self.imageV addGestureRecognizer:iconTap]; UIView *liveBgView = [UIView new]; self.youpaipliveBgView = liveBgView; [self.youpaipimageV addSubview:liveBgView]; [liveBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.top.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(46, 16)); }]; liveBgView.backgroundColor = [HexColorFromRGB(0x1C1D23) colorWithAlphaComponent:0.38]; NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_zhibo_peiban" ofType:@"gif"]; liveBgView.hidden = YES; YYAnimatedImageView *iconAnimationImgV = [[YYAnimatedImageView alloc] init]; iconAnimationImgV.image = [YYImage imageWithData:[NSData dataWithContentsOfFile:path]]; iconAnimationImgV.hidden = YES; [liveBgView addSubview:iconAnimationImgV]; self.youpaipiconAnimationImgV = iconAnimationImgV; [iconAnimationImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(2.5f); make.centerY.equalTo(0); make.size.mas_offset(CGSizeMake(10.0f, 10.0f)); }]; UILabel *textL = [[UILabel alloc] init]; textL.font = LCBoldFont(9.0f); textL.textColor = [UIColor whiteColor]; [liveBgView addSubview:textL]; self.youpaiptextL = textL; [textL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(iconAnimationImgV.mas_right).offset(3.0f); make.centerY.equalTo(0); }]; //语音播放 UIView *aBgV = [[UIView alloc] init]; self.youpaipaBgV = aBgV; [self.youpaipimageV addSubview:aBgV]; [aBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(0.0f); make.bottom.equalTo(0); make.size.mas_offset(CGSizeMake(62.0f, 21.0f)); }]; CAShapeLayer *sectionmaskLayer = [CAShapeLayer layer]; UIBezierPath *sectionpath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 62, 21) byRoundingCorners:UIRectCornerBottomRight|UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)]; sectionmaskLayer.path = sectionpath.CGPath; aBgV.layer.mask = sectionmaskLayer; aBgV.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.88f]; // UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifplayAudioEvent:)]; // [aBgV addGestureRecognizer:tapGesture]; UIButton *audioPlayBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [audioPlayBtn setImage:[UIImage imageNamed:@"vqu_images_H_home_show_audio_s"] forState:UIControlStateSelected]; [audioPlayBtn setImage:[UIImage imageNamed:@"vqu_images_H_home_show_audio_n"] forState:UIControlStateNormal]; audioPlayBtn.userInteractionEnabled = YES; [aBgV addSubview:audioPlayBtn]; self.youpaipaudioPlayBtn = audioPlayBtn; [audioPlayBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(5.0f); make.centerY.equalTo(aBgV.mas_centerY); make.size.mas_offset(CGSizeMake(15.0f, 15.0f)); }]; // [self.audioPlayBtn addTarget:self action:@selector(youpaifaudioPlayBtnClick) forControlEvents:UIControlEventTouchUpInside]; UILabel *timerL = [[UILabel alloc] init]; timerL.font = LCFont(10); timerL.textColor = HexColorFromRGB(0x666666); [aBgV addSubview:timerL]; self.youpaiptimerL = timerL; [timerL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(audioPlayBtn.mas_right).offset(5.0f); make.centerY.equalTo(aBgV); }]; UIImageView *animationImgV = [[UIImageView alloc] init]; animationImgV.image = [UIImage imageNamed:@"vqu_images_ic_user_show_audio_animation_3"]; NSMutableArray * animationArray = [NSMutableArray array]; for (NSInteger i = 0; i < 3; i ++) { [animationArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_ic_user_show_audio_animation_%@",@(i + 1)]]]; } //设置动画数组 [animationImgV setAnimationImages:animationArray]; //设置动画播放次数 [animationImgV setAnimationRepeatCount:INT32_MAX]; //设置动画播放时间 [animationImgV setAnimationDuration:3*0.35]; [aBgV addSubview:animationImgV]; self.youpaipanimationImgV = animationImgV; [animationImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(timerL.mas_right).offset(5.0f); make.centerY.equalTo(aBgV); make.size.mas_offset(CGSizeMake(15.0f, 15.0f)); }]; UIButton *audioPlayBtn1 = [UIButton buttonWithType:UIButtonTypeCustom]; audioPlayBtn1.userInteractionEnabled = YES; [aBgV addSubview:audioPlayBtn1]; [audioPlayBtn1 mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(0.0f); }]; audioPlayBtn1.backgroundColor = [UIColor clearColor]; [audioPlayBtn1 addTarget:self action:@selector(youpaifaudioPlayBtnClick) forControlEvents:UIControlEventTouchUpInside]; aBgV.hidden = YES; //昵称 self.youpaipnameLab = [[UILabel alloc]init]; [self.contentView addSubview:self.youpaipnameLab]; [self.youpaipnameLab mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(22); make.left.mas_equalTo(self.youpaipimageV.mas_right).offset(8); make.height.mas_equalTo(16); }]; self.youpaipnameLab.preferredMaxLayoutWidth = 150; self.youpaipnameLab.numberOfLines = 0; self.youpaipnameLab.textColor = HexColorFromRGB(0xFFFFFF); self.youpaipnameLab.textAlignment = NSTextAlignmentLeft; self.youpaipnameLab.font = LCBoldFont(16); self.youpaiptagBgView = [UIView new]; [self.contentView addSubview:self.youpaiptagBgView]; [self.youpaiptagBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.youpaipnameLab); make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(6); make.width.mas_equalTo(52); make.height.mas_equalTo(15); }]; self.youpaiptagBgView.backgroundColor = [UIColor whiteColor]; self.youpaiptagBgView.layer.cornerRadius = 7.5; self.youpaiptagBgView.layer.masksToBounds = YES; UILabel *tagLabel = [UILabel new]; self.youpaiptagLabel = tagLabel; [self.youpaiptagBgView addSubview:tagLabel]; [tagLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(5); make.centerY.mas_equalTo(0); }]; tagLabel.textColor = HexColorFromRGB(0x4F4B5B); tagLabel.font = [UIFont systemFontOfSize:10]; //排行榜标签 UIButton *rankTagBtn = [UIButton new]; self.youpaiprankTagBtn = rankTagBtn; [self.contentView addSubview:rankTagBtn]; [rankTagBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.youpaipnameLab); make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(8); make.width.mas_equalTo(60); make.height.mas_equalTo(15); }]; YOUPAILZLevelView *levelView = [[YOUPAILZLevelView alloc] init]; [self addSubview:levelView]; self.youpaiplevelView = levelView; // levelView.hidden = YES; [levelView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(rankTagBtn.mas_right).offset(3.0f); make.centerY.equalTo(rankTagBtn); }]; //好评率 UILabel *goodPJLabel = [UILabel new]; self.youpaipgoodPJLabel = goodPJLabel; [self.contentView addSubview:goodPJLabel]; [goodPJLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.youpaipnameLab); make.top.mas_equalTo(rankTagBtn.mas_bottom).offset(8); }]; self.youpaipgoodPJLabel.font = LCBoldFont(9); UIView *statusBgView = [[UIView alloc] init]; [self.contentView addSubview:statusBgView]; [statusBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(22); make.right.mas_equalTo(-10); make.width.mas_equalTo(60); make.height.mas_equalTo(17.6); }]; statusBgView.layer.cornerRadius = 8.81f; statusBgView.layer.masksToBounds = YES; statusBgView.backgroundColor = [UIColor clearColor]; self.youpaipstatusL = [[UILabel alloc] init]; self.youpaipstatusL.font = LCFont(9.0f); self.youpaipstatusL.textColor = [UIColor whiteColor]; [statusBgView addSubview:self.youpaipstatusL]; [self.youpaipstatusL mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(statusBgView); make.right.equalTo(0); }]; self.youpaipstatusL.textAlignment = NSTextAlignmentRight; self.youpaipstatusView = [[UIView alloc] init]; self.youpaipstatusView.layer.cornerRadius = 3.0f; self.youpaipstatusView.layer.masksToBounds = YES; [statusBgView addSubview:self.youpaipstatusView]; [self.youpaipstatusView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(statusBgView); make.right.mas_equalTo(self.youpaipstatusL.mas_left).offset(-3); make.size.mas_offset(CGSizeMake(6.0f, 6.0f)); }]; //视频 UIButton *videoBtn = [UIButton new]; [self.contentView addSubview:videoBtn]; [videoBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-10); make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(6); make.size.offset(CGSizeMake(ScaleSize(65), 29)); }]; // [_tandouBtn setTitle:[NSString stringWithFormat:@" %@钻石/分钟",self.skillModel.price] forState:UIControlStateNormal]; [videoBtn setTitle:@"视频" forState:UIControlStateNormal]; videoBtn.titleLabel.font = [UIFont systemFontOfSize:13]; [videoBtn setImage:[UIImage imageNamed:@"vqu_images_user_video"] forState:UIControlStateNormal]; [videoBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(ScaleSize(65), 29) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:1] forState:UIControlStateNormal]; videoBtn.layer.cornerRadius = 3; videoBtn.layer.masksToBounds = YES; [videoBtn addTarget:self action:@selector(youpaifvideoBtnClick) forControlEvents:UIControlEventTouchUpInside]; //价格 UILabel *priceLabel = [UILabel new]; self.youpaippriceLabel = priceLabel; [self.contentView addSubview:priceLabel]; [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(videoBtn); make.top.mas_equalTo(videoBtn.mas_bottom).offset(8); }]; priceLabel.textColor = [UIColor whiteColor]; priceLabel.font = [UIFont systemFontOfSize:10]; //优惠价格 // UILabel *discountsPriceLabel = [UILabel new]; self.youpaipdiscountsPriceLabel = discountsPriceLabel; [self.contentView addSubview:discountsPriceLabel]; [discountsPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(videoBtn); make.top.mas_equalTo(priceLabel.mas_bottom).offset(3); }]; discountsPriceLabel.textColor = HexColorFromRGB(0xFFDD8D); discountsPriceLabel.font = [UIFont systemFontOfSize:9]; // 贵族 UIImageView *vipV = [[UIImageView alloc] init]; [self.contentView addSubview:vipV]; self.youpaipvipV = vipV; [vipV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaipnameLab.mas_right).offset(3.0f); make.centerY.equalTo(self.youpaipnameLab); make.size.mas_offset(CGSizeMake(30.0f, 19.0f)); }]; self.youpaipvipV.hidden = YES; self.youpaipsignL = [[UILabel alloc]initWithFrame:CGRectMake(10.0f,self.youpaipbottomBkgView.mj_h - 10.0f - 16.0f,self.frame.size.width-20.0f,16.0f)]; self.youpaipsignL.textColor = HexColorFromRGB(0xFFFFFF); self.youpaipsignL.textAlignment = NSTextAlignmentLeft; self.youpaipsignL.font = LCFont(11); [self.youpaipbottomBkgView addSubview:self.youpaipsignL]; self.clipsToBounds = YES; YOUPAILZHomeTagLabelView *labelView = [[YOUPAILZHomeTagLabelView alloc]initWithFrame:CGRectZero LabelArr:self.youpaiphomeListModel.youpaiplaber];; self.youpaiplabelView =labelView; [self.contentView addSubview:labelView]; [labelView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.youpaiptagBgView.mas_right).offset(0); make.centerY.mas_equalTo(self.youpaiptagBgView); make.size.mas_equalTo(CGSizeMake(100, 15)); }]; } - (void)setYoupaiphomeListModel:(YOUPAILCHomeListModel *)homeListModel{ _youpaiphomeListModel = homeListModel; if (homeListModel.youpaipvip_icon.length != 0) { self.youpaipvipV.hidden = NO; self.youpaiptimerL.text = [NSString stringWithFormat:@"%@\"",@(homeListModel.youpaipmp3_second)]; }else{ self.youpaipvipV.hidden = YES; } if (homeListModel.youpaipvoice == 1) { self.youpaipaBgV.hidden = NO; }else{ self.youpaipaBgV.hidden = YES; } //最近连过|你关注的|同城 NSString *type; CGFloat width = 0.0; if (homeListModel.youpaipis_call == 1) { type = @"最近连过"; width = 52; }else if (homeListModel.youpaipis_follow == 1){ type = @"你关注的"; width = 52; }else if (homeListModel.youpaipis_same_city == 1){ if (homeListModel.youpaipcity.length<=2) { type = homeListModel.youpaipcity; width = 32; }else if (homeListModel.youpaipcity.length == 3){ type = homeListModel.youpaipcity; width = 42; }else if (homeListModel.youpaipcity.length>=4){ type = homeListModel.youpaipcity; width = 52; } }else{ width = 0.0f; } [self.youpaiptagBgView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.youpaipnameLab); make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(6); make.width.mas_equalTo(width); make.height.mas_equalTo(15); }]; self.youpaiptagLabel.text = type; //标签 CGFloat margin = 0; if (width==0) { margin = -3; }else{ margin = 3; } [self.youpaiplabelView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.youpaiptagBgView.mas_right).offset(margin); make.centerY.mas_equalTo(self.youpaiptagBgView); make.size.mas_equalTo(CGSizeMake(KScreenWidth-125-8-width-margin-ScaleSize(65)-10, 15)); }]; self.youpaiplabelView.youpaiplabArr = homeListModel.youpaiplaber; [self.youpaiplevelView youpaifreloadWithIcon:homeListModel.youpaipgrade.youpaipimg1 iconWidth:homeListModel.youpaipgrade.youpaipicon_width bgImg:homeListModel.youpaipgrade.youpaipimg2 bgImgWidth:homeListModel.youpaipgrade.youpaipicon1_width levelName:homeListModel.youpaipgrade.youpaipgrade_name level:homeListModel.youpaipgrade.youpaipgrade]; //排行榜 if (width == 0&&homeListModel.youpaiplaber.count<=0){ [self.youpaiprankTagBtn mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.youpaipnameLab); make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(8); make.width.mas_equalTo([LCTools widthWithString:homeListModel.youpaipis_rank.youpaipdes withFont:[UIFont systemFontOfSize:10]]+10); make.height.mas_equalTo(15); }]; [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.youpaipnameLab); make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(8); make.size.mas_offset(self.youpaiplevelView.mj_size); }]; }else{ [self.youpaiprankTagBtn mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.youpaipnameLab); make.top.mas_equalTo(self.youpaiptagBgView.mas_bottom).offset(8); make.width.mas_equalTo([LCTools widthWithString:homeListModel.youpaipis_rank.youpaipdes withFont:[UIFont systemFontOfSize:10]]+10); make.height.mas_equalTo(15); }]; [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.youpaiprankTagBtn.mas_right).offset(8.0f); make.top.equalTo(self.youpaiptagBgView.mas_bottom); make.size.mas_offset(self.youpaiplevelView.mj_size); }]; } self.youpaiplevelView.hidden = YES; NSString *shallow = [NSString stringWithFormat:@"%@",homeListModel.youpaipis_rank.youpaipstart_color]; NSString *deep = [NSString stringWithFormat:@"%@",homeListModel.youpaipis_rank.youpaipover_color]; self.youpaiprankTagBtn.layer.cornerRadius = 7.5; self.youpaiprankTagBtn.layer.masksToBounds = YES; [self.youpaiprankTagBtn setTitle:homeListModel.youpaipis_rank.youpaipdes forState:UIControlStateNormal]; self.youpaiprankTagBtn.titleLabel.font = [UIFont systemFontOfSize:10]; [self.youpaiprankTagBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; self.youpaiprankTagBtn.backgroundColor = [UIColor clearColor]; [self.youpaiprankTagBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake([LCTools widthWithString:homeListModel.youpaipis_rank.youpaipdes withFont:[UIFont systemFontOfSize:10]]+10, 15) FromColors:@[kColors(shallow),kColors(deep)] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal]; if (homeListModel.youpaipis_rank.youpaipsort >0) { self.youpaiprankTagBtn.hidden = NO; }else{ self.youpaiprankTagBtn.hidden = YES; } if (homeListModel.youpaipgood_evaluate_rate) { self.youpaipgoodPJLabel.attributedText = [LCTools setRichTextWithTitle:@"好评率:" subTitle:homeListModel.youpaipgood_evaluate_rate titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFDD8D) titleFontSize:9 subTitleFontSize:9]; } self.youpaippriceLabel.text =[NSString stringWithFormat:@"%ld钻石/分钟",(long)homeListModel.youpaipprice]; if (homeListModel.youpaipdiscount) { self.youpaipdiscountsPriceLabel.text =[NSString stringWithFormat:@"%@",homeListModel.youpaipdiscount]; } [self.youpaipvipV sd_setImageWithURL:[LCTools getImageUrlWithAddress:homeListModel.youpaipvip_icon]]; if (homeListModel.youpaiplive_status ==1) { self.youpaiptextL.text = @"直播中"; self.youpaipliveBgView.hidden = NO; self.youpaipiconAnimationImgV.hidden = NO; }else{ self.youpaipliveBgView.hidden = YES; self.youpaipiconAnimationImgV.hidden = YES; } [self.youpaipimageV sd_setImageWithURL:[LCTools getImageUrlWithAddress:homeListModel.youpaipcover] placeholderImage:nil]; self.youpaipnameLab.text = homeListModel.youpaipnickname; // CGRect frame = self.scoreView.frame; // frame.origin.x = CGRectGetMaxX(self.nameLab.frame)+3.5; // self.scoreView.frame = frame; // self.scoreL.text = [NSString stringWithFormat:@"%@",homeListModel.give_score]; // self.starRateView.scorePercent = [homeListModel.give_score floatValue]/5.0; //视频状态 0离线 1在线 2服务中 3勿扰 if (homeListModel.youpaipAddnewStatus == 1) {//空闲 绿色 }else if (homeListModel.youpaipAddnewStatus == 2){//忙碌中 红色 }else{ } self.youpaipstatusView.backgroundColor = kColors(homeListModel.youpaipAddnewColor); self.youpaipstatusL.text = homeListModel.youpaipAddnewMsg; // if (homeListModel.sign.length == 0) { // self.signL.hidden = YES; // self.nameLab.mj_y = self.bottomBkgView.mj_h - 10.0f - 16.0f; // }else{ // self.signL.hidden = NO; // self.nameLab.mj_y = self.bottomBkgView.mj_h - 26.0f - 16.0f; // } // NSString *price = [NSString stringWithFormat:@"%ld钻/分钟",homeListModel.price]; // CGRect rect = [price boundingRectWithSize: CGSizeMake(150, 10) options:NSStringDrawingUsesFontLeading|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : LCFont(12)} context:nil]; // // self.scoreView = [[UIView alloc]initWithFrame:CGRectMake(9,1.5,rect.size.width+25, 14)]; // self.scoreView.layer.cornerRadius = 7; // self.scoreView.layer.masksToBounds = YES; // CAGradientLayer * gradientLayer1 = [LCTools getGradientLayerWithSize:_scoreView.frame.size twoColors:@[ZYGradientOneColor,ZYGradientTwoColor] gradientType:(GradientLeftToRight)]; // [_scoreView.layer addSublayer:gradientLayer1]; // [self.bottomBkgView addSubview:self.scoreView]; // // UIImageView *scoreImg = [[UIImageView alloc] initWithFrame:CGRectMake(5,2,10,10)]; // scoreImg.image = [UIImage imageNamed:@"vqu_images_H_free_video"]; // [self.scoreView addSubview:scoreImg]; // // self.scoreL = [[UILabel alloc]initWithFrame:CGRectMake(18,2,rect.size.width, 10)]; // self.scoreL.textColor = [UIColor whiteColor]; // self.scoreL.font = LCFont(12); // self.scoreL.textAlignment = NSTextAlignmentLeft; // self.scoreL.text = price; // [self.scoreView addSubview:self.scoreL]; if (homeListModel.youpaipisPlay) { self.youpaipaudioPlayBtn.selected = YES; [self youpaifstartPlay]; [self youpaifstartTimer]; }else{ self.youpaipaudioPlayBtn.selected = NO; [self youpaifstopPlay]; } } //-(void)didVoiceBlock -(void)youpaifaudioPlayBtnClick{ if (self.youpaipdidVoiceBlock) { self.youpaipdidVoiceBlock(self.youpaipindex); } } /// 播放or暂停 - (void)youpaifplayAudioEvent:(UITapGestureRecognizer *)gesture{ self.youpaipaudioPlayBtn.selected = !self.youpaipaudioPlayBtn.selected; if (self.youpaipaudioPlayBtn.selected) { [self youpaifstartPlay]; [self youpaifstartTimer]; }else{ [self youpaifstopPlay]; } } /// 开始播放语音 - (void)youpaifstartPlay{ NSURL *url = [LCTools getImageUrlWithAddress:self.youpaiphomeListModel.youpaipmp3]; self.youpaipaudioStream.url = url; [self.youpaipaudioStream play]; [self.youpaipanimationImgV startAnimating]; } /// 停止播放语音 - (void)youpaifstopPlay{ self.youpaiphomeListModel.youpaipisPlay = NO; self.youpaipaudioPlayBtn.selected = NO; self.youpaiptimerL.text = [NSString stringWithFormat:@"%@\"",@(self.youpaiphomeListModel.youpaipmp3_second)]; // 停止播放 if ([self.youpaipaudioStream isPlaying]) { [self.youpaipaudioStream stop]; } [self youpaifstopTimer]; [self.youpaipanimationImgV stopAnimating]; } - (FSAudioStream *)youpaipaudioStream{ if (_youpaipaudioStream == nil) { _youpaipaudioStream = [[FSAudioStream alloc] init]; @weakify(self); _youpaipaudioStream.onFailure = ^(FSAudioStreamError error,NSString *description){ @strongify(self); [self youpaifstopPlay]; }; _youpaipaudioStream.onCompletion = ^(){ @strongify(self); [self youpaifstopPlay]; }; [_youpaipaudioStream setVolume:0.7];//设置声音 _youpaipaudioStream.strictContentTypeChecking = NO; _youpaipaudioStream.defaultContentType = @"audio/mpeg"; } return _youpaipaudioStream; } // 开始计时 - (void)youpaifstartTimer{ self.youpaiptimerL.text = [NSString stringWithFormat:@"%@\"",@(self.youpaiphomeListModel.youpaipmp3_second)]; self.youpaiptimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(youpaiftimerAction) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:self.youpaiptimer forMode:NSRunLoopCommonModes]; } // 结束计时 - (void)youpaifstopTimer{ [self.youpaiptimer invalidate]; self.youpaiptimer = nil; } - (void)youpaiftimerAction{ NSInteger timer = self.youpaiphomeListModel.youpaipmp3_second - self.youpaipaudioStream.currentTimePlayed.playbackTimeInSeconds; self.youpaiptimerL.text = [NSString stringWithFormat:@"%@\"",@(timer)]; } -(void)youpaifremoveVoiceNotic{ [self youpaifstopPlay]; } @end