YOUPAILCHomeCollectionCell.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. //
  2. // YOUPAILCHomeCollectionCell.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/9/2.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCHomeCollectionCell.h"
  9. //#import "CWStarRateView.h"
  10. #import "YYImage.h"
  11. #import "FSAudioStream.h"
  12. #import "YYAnimatedImageView.h"
  13. #import "YOUPAILZHomeTagLabelView.h"
  14. #import "YOUPAIZYLabelModel.h"
  15. #import "YOUPAILZLevelView.h"
  16. @interface YOUPAILCHomeCollectionCell()
  17. @property (nonatomic,strong)UIImageView *youpaipimageV;
  18. @property (nonatomic,strong)UIView *youpaiptopBkgView;
  19. @property (nonatomic,strong)UIView *youpaipbottomBkgView;
  20. //@property (strong, nonatomic) CWStarRateView *starRateView;
  21. @property (nonatomic,strong)UIView *youpaipstatusView;
  22. @property (nonatomic,strong)UILabel *youpaipstatusL;
  23. @property (nonatomic,strong)UILabel *youpaipnameLab;
  24. @property (nonatomic,strong)UILabel *youpaipsignL;
  25. /* iconAnimationImgV */
  26. @property (strong, nonatomic) YYAnimatedImageView *youpaipiconAnimationImgV;
  27. /* textL */
  28. @property (strong, nonatomic) UILabel *youpaiptextL;
  29. /* liveBgView */
  30. @property (strong, nonatomic) UIView *youpaipliveBgView;
  31. //
  32. //@property (nonatomic,strong)UIView *scoreView;
  33. //
  34. //@property (nonatomic,strong)UILabel *scoreL;
  35. //@property (nonatomic,strong)UILabel *cityL;
  36. @property (nonatomic,weak) UILabel *youpaiptimerL;
  37. @property (nonatomic,weak) UIImageView *youpaipanimationImgV;
  38. @property (nonatomic, weak) UIImageView *youpaipvipV;
  39. // 语音播放器
  40. @property (nonatomic, strong)FSAudioStream *youpaipaudioStream;
  41. @property (nonatomic, strong)NSTimer *youpaiptimer;
  42. /* YOUPAILZLevelView */
  43. @property (strong, nonatomic) YOUPAILZLevelView *youpaiplevelView;
  44. /* 语音播放bgView */
  45. @property (strong, nonatomic) UIView *youpaipaBgV;
  46. /* tagBgView */
  47. @property (strong, nonatomic) UIView *youpaiptagBgView;
  48. /* tagLabel */
  49. @property (strong, nonatomic) UILabel *youpaiptagLabel;
  50. /* rankTagBtn */
  51. @property (strong, nonatomic) UIButton *youpaiprankTagBtn;
  52. /* goodPJLabel */
  53. @property (strong, nonatomic) UILabel *youpaipgoodPJLabel;
  54. /* priceLabel */
  55. @property (strong, nonatomic) UILabel *youpaippriceLabel;
  56. /* discountsPriceLabel */
  57. @property (strong, nonatomic) UILabel *youpaipdiscountsPriceLabel;
  58. @property(nonatomic,strong) YOUPAILZHomeTagLabelView *youpaiplabelView;
  59. @end
  60. @implementation YOUPAILCHomeCollectionCell
  61. static NSString* HKHomeCellID = @"YOUPAILCHomeCollectionCell";
  62. -(instancetype)initWithFrame:(CGRect)frame{
  63. self = [super initWithFrame:frame];
  64. if (self) {
  65. [self youpaifsetSubView];
  66. }
  67. return self;
  68. }
  69. #pragma mark-点击事件
  70. //点击头像
  71. -(void)youpaifdidclickIcontap{
  72. if (self.youpaipdidClickIconBlock) {
  73. self.youpaipdidClickIconBlock(self.youpaiphomeListModel.youpaipuserid);
  74. }
  75. }
  76. -(void)youpaifvideoBtnClick{
  77. if (self.youpaipdidVideoBlock) {
  78. self.youpaipdidVideoBlock(self.youpaiphomeListModel.youpaipuserid);
  79. }
  80. }
  81. -(void)youpaifsetSubView{
  82. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifremoveVoiceNotic) name:@"removeVoice" object:nil];
  83. // self.userInteractionEnabled = NO;
  84. self.backgroundColor = LCSubBkgColor;
  85. self.youpaipimageV = [[UIImageView alloc] init];
  86. [self.contentView addSubview:self.youpaipimageV];
  87. [self.youpaipimageV mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.left.mas_equalTo(0);
  89. make.top.mas_equalTo(0);
  90. make.width.mas_equalTo(125);
  91. make.height.mas_equalTo(125);
  92. }];
  93. // self.imageV.backgroundColor = [LCTools getBkgRandomColor];
  94. self.youpaipimageV.contentMode = UIViewContentModeScaleAspectFill;
  95. self.youpaipimageV.clipsToBounds = YES;
  96. self.youpaipimageV.userInteractionEnabled = YES;
  97. // UITapGestureRecognizer *iconTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(youpaifdidclickIcontap)];
  98. // [self.imageV addGestureRecognizer:iconTap];
  99. UIView *liveBgView = [UIView new];
  100. self.youpaipliveBgView = liveBgView;
  101. [self.youpaipimageV addSubview:liveBgView];
  102. [liveBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.left.mas_equalTo(0);
  104. make.top.mas_equalTo(0);
  105. make.size.mas_equalTo(CGSizeMake(46, 16));
  106. }];
  107. liveBgView.backgroundColor = [HexColorFromRGB(0x1C1D23) colorWithAlphaComponent:0.38];
  108. NSString *path = [[NSBundle mainBundle] pathForResource:@"ic_live_zhibo_peiban" ofType:@"gif"];
  109. liveBgView.hidden = YES;
  110. YYAnimatedImageView *iconAnimationImgV = [[YYAnimatedImageView alloc] init];
  111. iconAnimationImgV.image = [YYImage imageWithData:[NSData dataWithContentsOfFile:path]];
  112. iconAnimationImgV.hidden = YES;
  113. [liveBgView addSubview:iconAnimationImgV];
  114. self.youpaipiconAnimationImgV = iconAnimationImgV;
  115. [iconAnimationImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.left.offset(2.5f);
  117. make.centerY.equalTo(0);
  118. make.size.mas_offset(CGSizeMake(10.0f, 10.0f));
  119. }];
  120. UILabel *textL = [[UILabel alloc] init];
  121. textL.font = LCBoldFont(9.0f);
  122. textL.textColor = [UIColor whiteColor];
  123. [liveBgView addSubview:textL];
  124. self.youpaiptextL = textL;
  125. [textL mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.left.equalTo(iconAnimationImgV.mas_right).offset(3.0f);
  127. make.centerY.equalTo(0);
  128. }];
  129. //语音播放
  130. UIView *aBgV = [[UIView alloc] init];
  131. self.youpaipaBgV = aBgV;
  132. [self.youpaipimageV addSubview:aBgV];
  133. [aBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  134. make.left.offset(0.0f);
  135. make.bottom.equalTo(0);
  136. make.size.mas_offset(CGSizeMake(62.0f, 21.0f));
  137. }];
  138. CAShapeLayer *sectionmaskLayer = [CAShapeLayer layer];
  139. UIBezierPath *sectionpath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 62, 21) byRoundingCorners:UIRectCornerBottomRight|UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)];
  140. sectionmaskLayer.path = sectionpath.CGPath;
  141. aBgV.layer.mask = sectionmaskLayer;
  142. aBgV.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.88f];
  143. // UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaifplayAudioEvent:)];
  144. // [aBgV addGestureRecognizer:tapGesture];
  145. UIButton *audioPlayBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  146. [audioPlayBtn setImage:[UIImage imageNamed:@"vqu_images_H_home_show_audio_s"] forState:UIControlStateSelected];
  147. [audioPlayBtn setImage:[UIImage imageNamed:@"vqu_images_H_home_show_audio_n"] forState:UIControlStateNormal];
  148. audioPlayBtn.userInteractionEnabled = YES;
  149. [aBgV addSubview:audioPlayBtn];
  150. self.youpaipaudioPlayBtn = audioPlayBtn;
  151. [audioPlayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  152. make.left.offset(5.0f);
  153. make.centerY.equalTo(aBgV.mas_centerY);
  154. make.size.mas_offset(CGSizeMake(15.0f, 15.0f));
  155. }];
  156. // [self.audioPlayBtn addTarget:self action:@selector(youpaifaudioPlayBtnClick) forControlEvents:UIControlEventTouchUpInside];
  157. UILabel *timerL = [[UILabel alloc] init];
  158. timerL.font = LCFont(10);
  159. timerL.textColor = HexColorFromRGB(0x666666);
  160. [aBgV addSubview:timerL];
  161. self.youpaiptimerL = timerL;
  162. [timerL mas_makeConstraints:^(MASConstraintMaker *make) {
  163. make.left.equalTo(audioPlayBtn.mas_right).offset(5.0f);
  164. make.centerY.equalTo(aBgV);
  165. }];
  166. UIImageView *animationImgV = [[UIImageView alloc] init];
  167. animationImgV.image = [UIImage imageNamed:@"vqu_images_ic_user_show_audio_animation_3"];
  168. NSMutableArray * animationArray = [NSMutableArray array];
  169. for (NSInteger i = 0; i < 3; i ++) {
  170. [animationArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"vqu_images_ic_user_show_audio_animation_%@",@(i + 1)]]];
  171. }
  172. //设置动画数组
  173. [animationImgV setAnimationImages:animationArray];
  174. //设置动画播放次数
  175. [animationImgV setAnimationRepeatCount:INT32_MAX];
  176. //设置动画播放时间
  177. [animationImgV setAnimationDuration:3*0.35];
  178. [aBgV addSubview:animationImgV];
  179. self.youpaipanimationImgV = animationImgV;
  180. [animationImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  181. make.left.equalTo(timerL.mas_right).offset(5.0f);
  182. make.centerY.equalTo(aBgV);
  183. make.size.mas_offset(CGSizeMake(15.0f, 15.0f));
  184. }];
  185. UIButton *audioPlayBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
  186. audioPlayBtn1.userInteractionEnabled = YES;
  187. [aBgV addSubview:audioPlayBtn1];
  188. [audioPlayBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
  189. make.edges.mas_equalTo(0.0f);
  190. }];
  191. audioPlayBtn1.backgroundColor = [UIColor clearColor];
  192. [audioPlayBtn1 addTarget:self action:@selector(youpaifaudioPlayBtnClick) forControlEvents:UIControlEventTouchUpInside];
  193. aBgV.hidden = YES;
  194. //昵称
  195. self.youpaipnameLab = [[UILabel alloc]init];
  196. [self.contentView addSubview:self.youpaipnameLab];
  197. [self.youpaipnameLab mas_makeConstraints:^(MASConstraintMaker *make) {
  198. make.top.mas_equalTo(22);
  199. make.left.mas_equalTo(self.youpaipimageV.mas_right).offset(8);
  200. make.height.mas_equalTo(16);
  201. }];
  202. self.youpaipnameLab.preferredMaxLayoutWidth = 150;
  203. self.youpaipnameLab.numberOfLines = 0;
  204. self.youpaipnameLab.textColor = HexColorFromRGB(0xFFFFFF);
  205. self.youpaipnameLab.textAlignment = NSTextAlignmentLeft;
  206. self.youpaipnameLab.font = LCBoldFont(16);
  207. self.youpaiptagBgView = [UIView new];
  208. [self.contentView addSubview:self.youpaiptagBgView];
  209. [self.youpaiptagBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  210. make.left.mas_equalTo(self.youpaipnameLab);
  211. make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(6);
  212. make.width.mas_equalTo(52);
  213. make.height.mas_equalTo(15);
  214. }];
  215. self.youpaiptagBgView.backgroundColor = [UIColor whiteColor];
  216. self.youpaiptagBgView.layer.cornerRadius = 7.5;
  217. self.youpaiptagBgView.layer.masksToBounds = YES;
  218. UILabel *tagLabel = [UILabel new];
  219. self.youpaiptagLabel = tagLabel;
  220. [self.youpaiptagBgView addSubview:tagLabel];
  221. [tagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  222. make.left.mas_equalTo(5);
  223. make.centerY.mas_equalTo(0);
  224. }];
  225. tagLabel.textColor = HexColorFromRGB(0x4F4B5B);
  226. tagLabel.font = [UIFont systemFontOfSize:10];
  227. //排行榜标签
  228. UIButton *rankTagBtn = [UIButton new];
  229. self.youpaiprankTagBtn = rankTagBtn;
  230. [self.contentView addSubview:rankTagBtn];
  231. [rankTagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  232. make.left.mas_equalTo(self.youpaipnameLab);
  233. make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(8);
  234. make.width.mas_equalTo(60);
  235. make.height.mas_equalTo(15);
  236. }];
  237. YOUPAILZLevelView *levelView = [[YOUPAILZLevelView alloc] init];
  238. [self addSubview:levelView];
  239. self.youpaiplevelView = levelView;
  240. // levelView.hidden = YES;
  241. [levelView mas_makeConstraints:^(MASConstraintMaker *make) {
  242. make.left.equalTo(rankTagBtn.mas_right).offset(3.0f);
  243. make.centerY.equalTo(rankTagBtn);
  244. }];
  245. //好评率
  246. UILabel *goodPJLabel = [UILabel new];
  247. self.youpaipgoodPJLabel = goodPJLabel;
  248. [self.contentView addSubview:goodPJLabel];
  249. [goodPJLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  250. make.left.mas_equalTo(self.youpaipnameLab);
  251. make.top.mas_equalTo(rankTagBtn.mas_bottom).offset(8);
  252. }];
  253. self.youpaipgoodPJLabel.font = LCBoldFont(9);
  254. UIView *statusBgView = [[UIView alloc] init];
  255. [self.contentView addSubview:statusBgView];
  256. [statusBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  257. make.top.mas_equalTo(22);
  258. make.right.mas_equalTo(-10);
  259. make.width.mas_equalTo(60);
  260. make.height.mas_equalTo(17.6);
  261. }];
  262. statusBgView.layer.cornerRadius = 8.81f;
  263. statusBgView.layer.masksToBounds = YES;
  264. statusBgView.backgroundColor = [UIColor clearColor];
  265. self.youpaipstatusL = [[UILabel alloc] init];
  266. self.youpaipstatusL.font = LCFont(9.0f);
  267. self.youpaipstatusL.textColor = [UIColor whiteColor];
  268. [statusBgView addSubview:self.youpaipstatusL];
  269. [self.youpaipstatusL mas_makeConstraints:^(MASConstraintMaker *make) {
  270. make.centerY.equalTo(statusBgView);
  271. make.right.equalTo(0);
  272. }];
  273. self.youpaipstatusL.textAlignment = NSTextAlignmentRight;
  274. self.youpaipstatusView = [[UIView alloc] init];
  275. self.youpaipstatusView.layer.cornerRadius = 3.0f;
  276. self.youpaipstatusView.layer.masksToBounds = YES;
  277. [statusBgView addSubview:self.youpaipstatusView];
  278. [self.youpaipstatusView mas_makeConstraints:^(MASConstraintMaker *make) {
  279. make.centerY.equalTo(statusBgView);
  280. make.right.mas_equalTo(self.youpaipstatusL.mas_left).offset(-3);
  281. make.size.mas_offset(CGSizeMake(6.0f, 6.0f));
  282. }];
  283. //视频
  284. UIButton *videoBtn = [UIButton new];
  285. [self.contentView addSubview:videoBtn];
  286. [videoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  287. make.right.mas_equalTo(-10);
  288. make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(6);
  289. make.size.offset(CGSizeMake(ScaleSize(65), 29));
  290. }];
  291. // [_tandouBtn setTitle:[NSString stringWithFormat:@" %@钻石/分钟",self.skillModel.price] forState:UIControlStateNormal];
  292. [videoBtn setTitle:@"视频" forState:UIControlStateNormal];
  293. videoBtn.titleLabel.font = [UIFont systemFontOfSize:13];
  294. [videoBtn setImage:[UIImage imageNamed:@"vqu_images_user_video"] forState:UIControlStateNormal];
  295. [videoBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(ScaleSize(65), 29) FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:1] forState:UIControlStateNormal];
  296. videoBtn.layer.cornerRadius = 3;
  297. videoBtn.layer.masksToBounds = YES;
  298. [videoBtn addTarget:self action:@selector(youpaifvideoBtnClick) forControlEvents:UIControlEventTouchUpInside];
  299. //价格
  300. UILabel *priceLabel = [UILabel new];
  301. self.youpaippriceLabel = priceLabel;
  302. [self.contentView addSubview:priceLabel];
  303. [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  304. make.right.mas_equalTo(videoBtn);
  305. make.top.mas_equalTo(videoBtn.mas_bottom).offset(8);
  306. }];
  307. priceLabel.textColor = [UIColor whiteColor];
  308. priceLabel.font = [UIFont systemFontOfSize:10];
  309. //优惠价格
  310. //
  311. UILabel *discountsPriceLabel = [UILabel new];
  312. self.youpaipdiscountsPriceLabel = discountsPriceLabel;
  313. [self.contentView addSubview:discountsPriceLabel];
  314. [discountsPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  315. make.right.mas_equalTo(videoBtn);
  316. make.top.mas_equalTo(priceLabel.mas_bottom).offset(3);
  317. }];
  318. discountsPriceLabel.textColor = HexColorFromRGB(0xFFDD8D);
  319. discountsPriceLabel.font = [UIFont systemFontOfSize:9];
  320. // 贵族
  321. UIImageView *vipV = [[UIImageView alloc] init];
  322. [self.contentView addSubview:vipV];
  323. self.youpaipvipV = vipV;
  324. [vipV mas_makeConstraints:^(MASConstraintMaker *make) {
  325. make.left.equalTo(self.youpaipnameLab.mas_right).offset(3.0f);
  326. make.centerY.equalTo(self.youpaipnameLab);
  327. make.size.mas_offset(CGSizeMake(30.0f, 19.0f));
  328. }];
  329. self.youpaipvipV.hidden = YES;
  330. self.youpaipsignL = [[UILabel alloc]initWithFrame:CGRectMake(10.0f,self.youpaipbottomBkgView.mj_h - 10.0f - 16.0f,self.frame.size.width-20.0f,16.0f)];
  331. self.youpaipsignL.textColor = HexColorFromRGB(0xFFFFFF);
  332. self.youpaipsignL.textAlignment = NSTextAlignmentLeft;
  333. self.youpaipsignL.font = LCFont(11);
  334. [self.youpaipbottomBkgView addSubview:self.youpaipsignL];
  335. self.clipsToBounds = YES;
  336. YOUPAILZHomeTagLabelView *labelView = [[YOUPAILZHomeTagLabelView alloc]initWithFrame:CGRectZero LabelArr:self.youpaiphomeListModel.youpaiplaber];;
  337. self.youpaiplabelView =labelView;
  338. [self.contentView addSubview:labelView];
  339. [labelView mas_makeConstraints:^(MASConstraintMaker *make) {
  340. make.left.mas_equalTo(self.youpaiptagBgView.mas_right).offset(0);
  341. make.centerY.mas_equalTo(self.youpaiptagBgView);
  342. make.size.mas_equalTo(CGSizeMake(100, 15));
  343. }];
  344. }
  345. - (void)setYoupaiphomeListModel:(YOUPAILCHomeListModel *)homeListModel{
  346. _youpaiphomeListModel = homeListModel;
  347. if (homeListModel.youpaipvip_icon.length != 0) {
  348. self.youpaipvipV.hidden = NO;
  349. self.youpaiptimerL.text = [NSString stringWithFormat:@"%@\"",@(homeListModel.youpaipmp3_second)];
  350. }else{
  351. self.youpaipvipV.hidden = YES;
  352. }
  353. if (homeListModel.youpaipvoice == 1) {
  354. self.youpaipaBgV.hidden = NO;
  355. }else{
  356. self.youpaipaBgV.hidden = YES;
  357. }
  358. //最近连过|你关注的|同城
  359. NSString *type;
  360. CGFloat width = 0.0;
  361. if (homeListModel.youpaipis_call == 1) {
  362. type = @"最近连过";
  363. width = 52;
  364. }else if (homeListModel.youpaipis_follow == 1){
  365. type = @"你关注的";
  366. width = 52;
  367. }else if (homeListModel.youpaipis_same_city == 1){
  368. if (homeListModel.youpaipcity.length<=2) {
  369. type = homeListModel.youpaipcity;
  370. width = 32;
  371. }else if (homeListModel.youpaipcity.length == 3){
  372. type = homeListModel.youpaipcity;
  373. width = 42;
  374. }else if (homeListModel.youpaipcity.length>=4){
  375. type = homeListModel.youpaipcity;
  376. width = 52;
  377. }
  378. }else{
  379. width = 0.0f;
  380. }
  381. [self.youpaiptagBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  382. make.left.mas_equalTo(self.youpaipnameLab);
  383. make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(6);
  384. make.width.mas_equalTo(width);
  385. make.height.mas_equalTo(15);
  386. }];
  387. self.youpaiptagLabel.text = type;
  388. //标签
  389. CGFloat margin = 0;
  390. if (width==0) {
  391. margin = -3;
  392. }else{
  393. margin = 3;
  394. }
  395. [self.youpaiplabelView mas_remakeConstraints:^(MASConstraintMaker *make) {
  396. make.left.mas_equalTo(self.youpaiptagBgView.mas_right).offset(margin);
  397. make.centerY.mas_equalTo(self.youpaiptagBgView);
  398. make.size.mas_equalTo(CGSizeMake(KScreenWidth-125-8-width-margin-ScaleSize(65)-10, 15));
  399. }];
  400. self.youpaiplabelView.youpaiplabArr = homeListModel.youpaiplaber;
  401. [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];
  402. //排行榜
  403. if (width == 0&&homeListModel.youpaiplaber.count<=0){
  404. [self.youpaiprankTagBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  405. make.left.mas_equalTo(self.youpaipnameLab);
  406. make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(8);
  407. make.width.mas_equalTo([LCTools widthWithString:homeListModel.youpaipis_rank.youpaipdes withFont:[UIFont systemFontOfSize:10]]+10);
  408. make.height.mas_equalTo(15);
  409. }];
  410. [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) {
  411. make.left.mas_equalTo(self.youpaipnameLab);
  412. make.top.mas_equalTo(self.youpaipnameLab.mas_bottom).offset(8);
  413. make.size.mas_offset(self.youpaiplevelView.mj_size);
  414. }];
  415. }else{
  416. [self.youpaiprankTagBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  417. make.left.mas_equalTo(self.youpaipnameLab);
  418. make.top.mas_equalTo(self.youpaiptagBgView.mas_bottom).offset(8);
  419. make.width.mas_equalTo([LCTools widthWithString:homeListModel.youpaipis_rank.youpaipdes withFont:[UIFont systemFontOfSize:10]]+10);
  420. make.height.mas_equalTo(15);
  421. }];
  422. [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) {
  423. make.left.equalTo(self.youpaiprankTagBtn.mas_right).offset(8.0f);
  424. make.top.equalTo(self.youpaiptagBgView.mas_bottom);
  425. make.size.mas_offset(self.youpaiplevelView.mj_size);
  426. }];
  427. }
  428. self.youpaiplevelView.hidden = YES;
  429. NSString *shallow = [NSString stringWithFormat:@"%@",homeListModel.youpaipis_rank.youpaipstart_color];
  430. NSString *deep = [NSString stringWithFormat:@"%@",homeListModel.youpaipis_rank.youpaipover_color];
  431. self.youpaiprankTagBtn.layer.cornerRadius = 7.5;
  432. self.youpaiprankTagBtn.layer.masksToBounds = YES;
  433. [self.youpaiprankTagBtn setTitle:homeListModel.youpaipis_rank.youpaipdes forState:UIControlStateNormal];
  434. self.youpaiprankTagBtn.titleLabel.font = [UIFont systemFontOfSize:10];
  435. [self.youpaiprankTagBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  436. self.youpaiprankTagBtn.backgroundColor = [UIColor clearColor];
  437. [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];
  438. if (homeListModel.youpaipis_rank.youpaipsort >0) {
  439. self.youpaiprankTagBtn.hidden = NO;
  440. }else{
  441. self.youpaiprankTagBtn.hidden = YES;
  442. }
  443. if (homeListModel.youpaipgood_evaluate_rate) {
  444. self.youpaipgoodPJLabel.attributedText = [LCTools setRichTextWithTitle:@"好评率:" subTitle:homeListModel.youpaipgood_evaluate_rate titleColor:[UIColor whiteColor] subTitleColor:HexColorFromRGB(0xFFDD8D) titleFontSize:9 subTitleFontSize:9];
  445. }
  446. self.youpaippriceLabel.text =[NSString stringWithFormat:@"%ld钻石/分钟",(long)homeListModel.youpaipprice];
  447. if (homeListModel.youpaipdiscount) {
  448. self.youpaipdiscountsPriceLabel.text =[NSString stringWithFormat:@"%@",homeListModel.youpaipdiscount];
  449. }
  450. [self.youpaipvipV sd_setImageWithURL:[LCTools getImageUrlWithAddress:homeListModel.youpaipvip_icon]];
  451. if (homeListModel.youpaiplive_status ==1) {
  452. self.youpaiptextL.text = @"直播中";
  453. self.youpaipliveBgView.hidden = NO;
  454. self.youpaipiconAnimationImgV.hidden = NO;
  455. }else{
  456. self.youpaipliveBgView.hidden = YES;
  457. self.youpaipiconAnimationImgV.hidden = YES;
  458. }
  459. [self.youpaipimageV sd_setImageWithURL:[LCTools getImageUrlWithAddress:homeListModel.youpaipcover] placeholderImage:nil];
  460. self.youpaipnameLab.text = homeListModel.youpaipnickname;
  461. // CGRect frame = self.scoreView.frame;
  462. // frame.origin.x = CGRectGetMaxX(self.nameLab.frame)+3.5;
  463. // self.scoreView.frame = frame;
  464. // self.scoreL.text = [NSString stringWithFormat:@"%@",homeListModel.give_score];
  465. // self.starRateView.scorePercent = [homeListModel.give_score floatValue]/5.0;
  466. //视频状态 0离线 1在线 2服务中 3勿扰
  467. if (homeListModel.youpaipAddnewStatus == 1) {//空闲 绿色
  468. }else if (homeListModel.youpaipAddnewStatus == 2){//忙碌中 红色
  469. }else{
  470. }
  471. self.youpaipstatusView.backgroundColor = kColors(homeListModel.youpaipAddnewColor);
  472. self.youpaipstatusL.text = homeListModel.youpaipAddnewMsg;
  473. // if (homeListModel.sign.length == 0) {
  474. // self.signL.hidden = YES;
  475. // self.nameLab.mj_y = self.bottomBkgView.mj_h - 10.0f - 16.0f;
  476. // }else{
  477. // self.signL.hidden = NO;
  478. // self.nameLab.mj_y = self.bottomBkgView.mj_h - 26.0f - 16.0f;
  479. // }
  480. // NSString *price = [NSString stringWithFormat:@"%ld钻/分钟",homeListModel.price];
  481. // CGRect rect = [price boundingRectWithSize: CGSizeMake(150, 10) options:NSStringDrawingUsesFontLeading|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : LCFont(12)} context:nil];
  482. //
  483. // self.scoreView = [[UIView alloc]initWithFrame:CGRectMake(9,1.5,rect.size.width+25, 14)];
  484. // self.scoreView.layer.cornerRadius = 7;
  485. // self.scoreView.layer.masksToBounds = YES;
  486. // CAGradientLayer * gradientLayer1 = [LCTools getGradientLayerWithSize:_scoreView.frame.size twoColors:@[ZYGradientOneColor,ZYGradientTwoColor] gradientType:(GradientLeftToRight)];
  487. // [_scoreView.layer addSublayer:gradientLayer1];
  488. // [self.bottomBkgView addSubview:self.scoreView];
  489. //
  490. // UIImageView *scoreImg = [[UIImageView alloc] initWithFrame:CGRectMake(5,2,10,10)];
  491. // scoreImg.image = [UIImage imageNamed:@"vqu_images_H_free_video"];
  492. // [self.scoreView addSubview:scoreImg];
  493. //
  494. // self.scoreL = [[UILabel alloc]initWithFrame:CGRectMake(18,2,rect.size.width, 10)];
  495. // self.scoreL.textColor = [UIColor whiteColor];
  496. // self.scoreL.font = LCFont(12);
  497. // self.scoreL.textAlignment = NSTextAlignmentLeft;
  498. // self.scoreL.text = price;
  499. // [self.scoreView addSubview:self.scoreL];
  500. if (homeListModel.youpaipisPlay) {
  501. self.youpaipaudioPlayBtn.selected = YES;
  502. [self youpaifstartPlay];
  503. [self youpaifstartTimer];
  504. }else{
  505. self.youpaipaudioPlayBtn.selected = NO;
  506. [self youpaifstopPlay];
  507. }
  508. }
  509. //-(void)didVoiceBlock
  510. -(void)youpaifaudioPlayBtnClick{
  511. if (self.youpaipdidVoiceBlock) {
  512. self.youpaipdidVoiceBlock(self.youpaipindex);
  513. }
  514. }
  515. /// 播放or暂停
  516. - (void)youpaifplayAudioEvent:(UITapGestureRecognizer *)gesture{
  517. self.youpaipaudioPlayBtn.selected = !self.youpaipaudioPlayBtn.selected;
  518. if (self.youpaipaudioPlayBtn.selected) {
  519. [self youpaifstartPlay];
  520. [self youpaifstartTimer];
  521. }else{
  522. [self youpaifstopPlay];
  523. }
  524. }
  525. /// 开始播放语音
  526. - (void)youpaifstartPlay{
  527. NSURL *url = [LCTools getImageUrlWithAddress:self.youpaiphomeListModel.youpaipmp3];
  528. self.youpaipaudioStream.url = url;
  529. [self.youpaipaudioStream play];
  530. [self.youpaipanimationImgV startAnimating];
  531. }
  532. /// 停止播放语音
  533. - (void)youpaifstopPlay{
  534. self.youpaiphomeListModel.youpaipisPlay = NO;
  535. self.youpaipaudioPlayBtn.selected = NO;
  536. self.youpaiptimerL.text = [NSString stringWithFormat:@"%@\"",@(self.youpaiphomeListModel.youpaipmp3_second)];
  537. // 停止播放
  538. if ([self.youpaipaudioStream isPlaying]) {
  539. [self.youpaipaudioStream stop];
  540. }
  541. [self youpaifstopTimer];
  542. [self.youpaipanimationImgV stopAnimating];
  543. }
  544. - (FSAudioStream *)youpaipaudioStream{
  545. if (_youpaipaudioStream == nil) {
  546. _youpaipaudioStream = [[FSAudioStream alloc] init];
  547. @weakify(self);
  548. _youpaipaudioStream.onFailure = ^(FSAudioStreamError error,NSString *description){
  549. @strongify(self);
  550. [self youpaifstopPlay];
  551. };
  552. _youpaipaudioStream.onCompletion = ^(){
  553. @strongify(self);
  554. [self youpaifstopPlay];
  555. };
  556. [_youpaipaudioStream setVolume:0.7];//设置声音
  557. _youpaipaudioStream.strictContentTypeChecking = NO;
  558. _youpaipaudioStream.defaultContentType = @"audio/mpeg";
  559. }
  560. return _youpaipaudioStream;
  561. }
  562. // 开始计时
  563. - (void)youpaifstartTimer{
  564. self.youpaiptimerL.text = [NSString stringWithFormat:@"%@\"",@(self.youpaiphomeListModel.youpaipmp3_second)];
  565. self.youpaiptimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(youpaiftimerAction) userInfo:nil repeats:YES];
  566. [[NSRunLoop currentRunLoop] addTimer:self.youpaiptimer forMode:NSRunLoopCommonModes];
  567. }
  568. // 结束计时
  569. - (void)youpaifstopTimer{
  570. [self.youpaiptimer invalidate];
  571. self.youpaiptimer = nil;
  572. }
  573. - (void)youpaiftimerAction{
  574. NSInteger timer = self.youpaiphomeListModel.youpaipmp3_second - self.youpaipaudioStream.currentTimePlayed.playbackTimeInSeconds;
  575. self.youpaiptimerL.text = [NSString stringWithFormat:@"%@\"",@(timer)];
  576. }
  577. -(void)youpaifremoveVoiceNotic{
  578. [self youpaifstopPlay];
  579. }
  580. @end