123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656 |
- //
- // 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
|