MORankTopView.m 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. //
  2. // MORankTopView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/11/30.
  6. //
  7. #import "MORankTopView.h"
  8. #import "MOEllipseUpView.h"
  9. #import "MOHeatRankData.h"
  10. @interface MORankTopView ()
  11. @property (nonatomic, strong) MOEllipseUpView *upBgView;
  12. @property (nonatomic, strong) UIButton *firstTotalBtn;
  13. @property (nonatomic, strong) UIButton *secondTotalBtn;
  14. @property (nonatomic, strong) UIButton *thirdTotalBtn;
  15. @property (nonatomic, strong) UILabel *countDownLab;
  16. @end
  17. @implementation MORankTopView
  18. + (instancetype)moRankTopView{
  19. return [[[NSBundle mainBundle] loadNibNamed:@"MORankTopView" owner:self options:nil] firstObject];
  20. }
  21. - (void)awakeFromNib{
  22. [super awakeFromNib];
  23. self.firstFollowBtn.hidden = YES;
  24. self.secondFollowBtn.hidden = YES;
  25. self.thirdFollowBtn.hidden = YES;
  26. //icon_mine_placeHolder
  27. self.firstHeadBtn.layer.cornerRadius = 48.0 / 2.0;
  28. self.firstHeadBtn.layer.masksToBounds = YES;
  29. self.secondHeadBtn.layer.cornerRadius = 48.0 / 2.0;
  30. self.secondHeadBtn.layer.masksToBounds = YES;
  31. self.thirdHeadBtn.layer.cornerRadius = 48.0 / 2.0;
  32. self.thirdHeadBtn.layer.masksToBounds = YES;
  33. CGFloat bgImgWidth = SCREENWIDTH - 30.0 * 2;
  34. CGFloat bgImgHeight = bgImgWidth * 532.0 / 636.0;
  35. self.rankBgImgHeight.constant = bgImgHeight;
  36. self.layer.masksToBounds = YES;
  37. UIImage *btnImage = [MOTools createImageWithColor:kBaseBtnBgColor];
  38. UIImage *grayImg = [MOTools createImageWithColor:[UIColor grayColor]];
  39. self.firstFollowBtn.layer.cornerRadius = 20.0 / 2;
  40. self.firstFollowBtn.layer.masksToBounds = YES;
  41. [self.firstFollowBtn setBackgroundImage:btnImage forState:UIControlStateNormal];
  42. [self.firstFollowBtn setBackgroundImage:grayImg forState:UIControlStateSelected];
  43. self.secondFollowBtn.layer.cornerRadius = 20.0 / 2;
  44. self.secondFollowBtn.layer.masksToBounds = YES;
  45. [self.secondFollowBtn setBackgroundImage:btnImage forState:UIControlStateNormal];
  46. [self.secondFollowBtn setBackgroundImage:grayImg forState:UIControlStateSelected];
  47. self.thirdFollowBtn.layer.cornerRadius = 20.0 / 2;
  48. self.thirdFollowBtn.layer.masksToBounds = YES;
  49. [self.thirdFollowBtn setBackgroundImage:btnImage forState:UIControlStateNormal];
  50. [self.thirdFollowBtn setBackgroundImage:grayImg forState:UIControlStateSelected];
  51. [self addSubview:self.upBgView];
  52. [self.upBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.centerX.equalTo(self);
  54. make.bottom.equalTo(self).offset(10.0);
  55. make.width.equalTo(@280.0);
  56. make.height.equalTo(@30.0);
  57. }];
  58. [self.firstFollowBtn setTitle:NSLocalString(@"mimo_room_user_info_follow") forState:UIControlStateNormal];
  59. [self.secondFollowBtn setTitle:NSLocalString(@"mimo_room_user_info_follow") forState:UIControlStateNormal];
  60. [self.thirdFollowBtn setTitle:NSLocalString(@"mimo_room_user_info_follow") forState:UIControlStateNormal];
  61. self.firstHeadBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
  62. self.secondHeadBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
  63. self.thirdHeadBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
  64. [self.firstView addSubview:self.firstTotalBtn];
  65. [self.firstTotalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.bottom.equalTo(self.firstView).offset(-28.0);
  67. make.left.equalTo(self.firstView).offset(5.0);
  68. make.right.equalTo(self.firstView).offset(-5.0);
  69. make.height.equalTo(@26.0);
  70. }];
  71. self.firstTotalBtn.hidden = YES;
  72. [self.secondView addSubview:self.secondTotalBtn];
  73. [self.secondTotalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.bottom.equalTo(self.secondView).offset(-28.0);
  75. make.left.equalTo(self.secondView).offset(5.0);
  76. make.right.equalTo(self.secondView).offset(-5.0);
  77. make.height.equalTo(@26.0);
  78. }];
  79. self.secondTotalBtn.hidden = YES;
  80. [self.thirdView addSubview:self.thirdTotalBtn];
  81. [self.thirdTotalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.bottom.equalTo(self.thirdView).offset(-28.0);
  83. make.left.equalTo(self.thirdView).offset(5.0);
  84. make.right.equalTo(self.thirdView).offset(-5.0);
  85. make.height.equalTo(@26.0);
  86. }];
  87. self.thirdTotalBtn.hidden = YES;
  88. [self.firstView insertSubview:self.firstHeadBgView belowSubview:self.rankFirstImg];
  89. [self.firstHeadBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.centerX.equalTo(self.firstHeadBtn);
  91. make.centerY.equalTo(self.firstHeadBtn);
  92. make.width.height.equalTo(@48.0);
  93. }];
  94. self.firstHeadBgView.headImgWidth = 48.0;
  95. [self.secondView insertSubview:self.secondHeadBgView belowSubview:self.rankFirstImg];
  96. [self.secondHeadBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.centerX.equalTo(self.secondHeadBtn);
  98. make.centerY.equalTo(self.secondHeadBtn);
  99. make.width.height.equalTo(@48.0);
  100. }];
  101. self.secondHeadBgView.headImgWidth = 48.0;
  102. [self.thirdView insertSubview:self.thirdHeadBgView belowSubview:self.rankFirstImg];
  103. [self.thirdHeadBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.centerX.equalTo(self.thirdHeadBtn);
  105. make.centerY.equalTo(self.thirdHeadBtn);
  106. make.width.height.equalTo(@48.0);
  107. }];
  108. self.thirdHeadBgView.headImgWidth = 48.0;
  109. self.secondNameLab.font = [MOTextTools poppinsMediumFont:16];
  110. self.secondNameLab.textColor = kBaseTextColor_1;
  111. [self.secondFollowBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr]];
  112. self.firstNameLab.font = [MOTextTools poppinsMediumFont:16];
  113. self.firstNameLab.textColor = kBaseTextColor_1;
  114. [self.firstFollowBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr]];
  115. self.thirdNameLab.font = [MOTextTools poppinsMediumFont:16];
  116. self.thirdNameLab.textColor = kBaseTextColor_1;
  117. [self.thirdFollowBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr]];
  118. // [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
  119. self.firstGoldBtn.titleLabel.font = [MOTextTools mediumFont:12];
  120. [self.firstGoldBtn setTitleColor:[MOTools colorWithHexString:@"#5C5E66"] forState:UIControlStateNormal];
  121. // [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
  122. self.secondGoldBtn.titleLabel.font = [MOTextTools mediumFont:12];
  123. [self.secondGoldBtn setTitleColor:[MOTools colorWithHexString:@"#5C5E66"] forState:UIControlStateNormal];
  124. // [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
  125. self.thirdGoldBtn.titleLabel.font = [MOTextTools mediumFont:12];
  126. [self.thirdGoldBtn setTitleColor:[MOTools colorWithHexString:@"#5C5E66"] forState:UIControlStateNormal];
  127. self.firstViewHeight.constant = 140.0;
  128. self.secondViewHeight.constant = 140.0;
  129. self.thirdViewHeight.constant = 140.0;
  130. [self addSubview:self.countDownLab];
  131. [self.countDownLab mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.height.equalTo(@24.0);
  133. make.centerX.equalTo(self);
  134. make.width.equalTo(@166.0);
  135. make.bottom.equalTo(self.firstView.mas_top).offset(-4.0);
  136. }];
  137. self.countDownLab.hidden = YES;
  138. }
  139. - (void)setIsShowCountDownLab:(BOOL)isShowCountDownLab{
  140. _isShowCountDownLab = isShowCountDownLab;
  141. if(isShowCountDownLab){
  142. self.countDownLab.hidden = NO;
  143. }
  144. }
  145. - (void)layoutSubviews {
  146. [super layoutSubviews];
  147. self.firstView.layer.masksToBounds = YES;
  148. self.firstView.layer.cornerRadius = 8;
  149. [self setupGradientLayerWithView:self.firstView
  150. startColor:[MOTools colorWithHexString:@"#FFEC9E"]
  151. endColor:[MOTools colorWithHexString:@"#FFFFFF" alpha:1.0]
  152. layerName:@"gradientLayer"
  153. startPoint:(CGPoint) { 0.5, 0 }
  154. endPoint:(CGPoint){0.5, 1}];
  155. self.secondView.layer.masksToBounds = YES;
  156. self.secondView.layer.cornerRadius = 8;
  157. [self setupGradientLayerWithView:self.secondView
  158. startColor:[MOTools colorWithHexString:@"#E9DDFF"]
  159. endColor:[MOTools colorWithHexString:@"#FFFFFF" alpha:1.0]
  160. layerName:@"gradientLayer"
  161. startPoint:(CGPoint) { 0.5, 0 }
  162. endPoint:(CGPoint){0.5, 1}];
  163. self.thirdView.layer.masksToBounds = YES;
  164. self.thirdView.layer.cornerRadius = 8;
  165. [self setupGradientLayerWithView:self.thirdView
  166. startColor:[MOTools colorWithHexString:@"#FAEADD"]
  167. endColor:[MOTools colorWithHexString:@"#FFFFFF" alpha:1.0]
  168. layerName:@"gradientLayer"
  169. startPoint:(CGPoint) { 0.5, 0 }
  170. endPoint:(CGPoint){0.5, 1}];
  171. }
  172. - (void)setDataArr:(NSArray *)dataArr{
  173. _dataArr = dataArr;
  174. self.firstView.hidden = NO;
  175. self.secondView.hidden = NO;
  176. self.thirdView.hidden = NO;
  177. //每次都需要初始化
  178. [self.firstHeadBtn setImage:nil forState:UIControlStateNormal];
  179. self.firstNameLab.text = @"";
  180. self.firstFollowBtn.selected = NO;
  181. self.rankFirstImg.hidden = YES;
  182. self.firstGoldBtn.hidden = YES;
  183. [self.secondHeadBtn setImage:nil forState:UIControlStateNormal];
  184. self.secondNameLab.text = @"";
  185. self.secondFollowBtn.selected = NO;
  186. self.rankSecondImg.hidden = YES;
  187. self.secondGoldBtn.hidden = YES;
  188. [self.thirdHeadBtn setImage:nil forState:UIControlStateNormal];
  189. self.thirdNameLab.text = @"";
  190. self.thirdFollowBtn.selected = NO;
  191. self.rankThirdImg.hidden = YES;
  192. self.thirdGoldBtn.hidden = YES;
  193. self.firstHeadBgView.hidden = YES;
  194. self.secondHeadBgView.hidden = YES;
  195. self.thirdHeadBgView.hidden = YES;
  196. int x = 0;
  197. for (MORanklist *model in dataArr) {
  198. if(x == 0){
  199. if (!model.userBase.userProfile) {
  200. continue;
  201. }
  202. self.firstView.hidden = NO;
  203. [self.firstHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.userBase.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
  204. if(model.userBase.remark.length > 0){
  205. self.firstNameLab.text = model.userBase.remark;
  206. }
  207. else{
  208. self.firstNameLab.text = model.userBase.userProfile.nickname;
  209. }
  210. self.firstFollowBtn.selected = model.userBase.follow;
  211. NSString *firstStr = [MOTextTools numberToStringWith:model.total];
  212. [self.firstTotalBtn setTitle:firstStr forState:UIControlStateNormal];
  213. if(model.userBase.liveRoomId.length > 0){
  214. self.firstHeadBgView.hidden = NO;
  215. self.firstHeadBgView.isLiving = YES;
  216. [self.firstHeadBgView updataViewStatus];
  217. self.firstHeadBgView.imgUrlStr = @"";
  218. }
  219. // else{
  220. // if(model.userBase.userProfile.adornment.headgearRes.length > 0){
  221. // self.firstHeadBgView.hidden = NO;
  222. // self.firstHeadBgView.isLiving = NO;
  223. // self.firstHeadBgView.effectType = model.userBase.userProfile.adornment.headgearType;
  224. // self.firstHeadBgView.imgUrlStr = model.userBase.userProfile.adornment.headgearRes;
  225. // }
  226. // else{
  227. // self.firstHeadBgView.hidden = YES;
  228. // }
  229. // }
  230. if(model.userBase.vipType == 0){
  231. ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  232. config.shimmerStyle = ShimmerStyleNone;
  233. self.firstNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
  234. [self.firstNameLab startShimmerWithConfig:config];
  235. }
  236. else{
  237. // if(model.userBase.vipType == 1 || model.userBase.vipType == 5 || model.userBase.vipType == 6){
  238. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  239. // config.shimmerStyle = ShimmerStyleColorsFlow;
  240. // config.shimmerColorArray = VipNameColorArr_white_1;
  241. // config.shimmerSpeed = 20;
  242. // [self.firstNameLab startShimmerWithConfig:config];
  243. // }
  244. // else if (model.userBase.vipType == 2){
  245. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  246. // config.shimmerStyle = ShimmerStyleColorsFlow;
  247. // config.shimmerColorArray = VipNameColorArr_white_2;
  248. // config.shimmerSpeed = 20;
  249. // [self.firstNameLab startShimmerWithConfig:config];
  250. // }
  251. // else if (model.userBase.vipType == 3){
  252. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  253. // config.shimmerStyle = ShimmerStyleGradient;
  254. // config.shimmerColorArray = VipNameColorArr_3;
  255. // [self.firstNameLab startShimmerWithConfig:config];
  256. // }
  257. // else if (model.userBase.vipType == 4){
  258. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  259. // config.shimmerStyle = ShimmerStyleNone;
  260. // self.firstNameLab.textColor = VipNameColor_White_4;
  261. // [self.firstNameLab startShimmerWithConfig:config];
  262. // }
  263. }
  264. NSString *goldNumStr = [MOTextTools numberToStringWith:model.total];
  265. [self.firstGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
  266. if (self.typeNum == 3) {//收入榜,隐藏关注,换成金豆
  267. [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
  268. } else if (self.typeNum == 2) {//探索-财富榜,显示关注,换成钻石
  269. [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
  270. } else if (self.typeNum == 1) {//房间贡献榜,隐藏关注,换成钻石
  271. [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
  272. } else {//pk
  273. [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_pk"] forState:UIControlStateNormal];
  274. [self.firstGoldBtn setTitle:[NSString stringWithFormat:@"%.0f", model.winNum] forState:UIControlStateNormal];
  275. }
  276. self.firstGoldBtn.hidden = NO;
  277. self.rankFirstImg.hidden = NO;
  278. }
  279. else if (x == 1){
  280. if (!model.userBase.userProfile) {
  281. continue;
  282. }
  283. self.secondView.hidden = NO;
  284. [self.secondHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.userBase.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
  285. if(model.userBase.remark.length > 0){
  286. self.secondNameLab.text = model.userBase.remark;
  287. }
  288. else{
  289. self.secondNameLab.text = model.userBase.userProfile.nickname;
  290. }
  291. self.secondFollowBtn.selected = model.userBase.follow;
  292. NSString *firstStr = [MOTextTools numberToStringWith:model.total];
  293. [self.secondTotalBtn setTitle:firstStr forState:UIControlStateNormal];
  294. if(model.userBase.liveRoomId.length > 0){
  295. self.secondHeadBgView.hidden = NO;
  296. self.secondHeadBgView.isLiving = YES;
  297. [self.secondHeadBgView updataViewStatus];
  298. self.secondHeadBgView.imgUrlStr = @"";
  299. }
  300. // else{
  301. // if(model.userBase.userProfile.adornment.headgearRes.length > 0){
  302. // self.secondHeadBgView.hidden = NO;
  303. // self.secondHeadBgView.isLiving = NO;
  304. // self.secondHeadBgView.effectType = model.userBase.userProfile.adornment.headgearType;
  305. // self.secondHeadBgView.imgUrlStr = model.userBase.userProfile.adornment.headgearRes;
  306. // }
  307. // else{
  308. // self.secondHeadBgView.hidden = YES;
  309. // }
  310. // }
  311. if(model.userBase.vipType == 0){
  312. ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  313. config.shimmerStyle = ShimmerStyleNone;
  314. self.secondNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
  315. [self.secondNameLab startShimmerWithConfig:config];
  316. }
  317. else{
  318. // if(model.userBase.vipType == 1 || model.userBase.vipType == 5 || model.userBase.vipType == 6){
  319. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  320. // config.shimmerStyle = ShimmerStyleColorsFlow;
  321. // config.shimmerColorArray = VipNameColorArr_white_1;
  322. // config.shimmerSpeed = 20;
  323. // [self.secondNameLab startShimmerWithConfig:config];
  324. // }
  325. // else if (model.userBase.vipType == 2){
  326. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  327. // config.shimmerStyle = ShimmerStyleColorsFlow;
  328. // config.shimmerColorArray = VipNameColorArr_white_2;
  329. // config.shimmerSpeed = 20;
  330. // [self.secondNameLab startShimmerWithConfig:config];
  331. // }
  332. // else if (model.userBase.vipType == 3){
  333. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  334. // config.shimmerStyle = ShimmerStyleGradient;
  335. // config.shimmerColorArray = VipNameColorArr_3;
  336. // [self.secondNameLab startShimmerWithConfig:config];
  337. // }
  338. // else if (model.userBase.vipType == 4){
  339. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  340. // config.shimmerStyle = ShimmerStyleNone;
  341. // self.secondNameLab.textColor = VipNameColor_White_4;
  342. // [self.secondNameLab startShimmerWithConfig:config];
  343. // }
  344. }
  345. NSString *goldNumStr = [MOTextTools numberToStringWith:model.total];
  346. [self.secondGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
  347. if (self.typeNum == 3) {//收入榜,隐藏关注,换成金豆
  348. [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
  349. } else if (self.typeNum == 2) {//探索-财富榜,显示关注,换成钻石
  350. [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
  351. } else if (self.typeNum == 1) {//房间贡献榜,隐藏关注,换成钻石
  352. [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
  353. } else {//pk
  354. [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_pk"] forState:UIControlStateNormal];
  355. [self.secondGoldBtn setTitle:[NSString stringWithFormat:@"%.0f", model.winNum] forState:UIControlStateNormal];
  356. }
  357. self.secondGoldBtn.hidden = NO;
  358. self.rankSecondImg.hidden = NO;
  359. }
  360. else if (x == 2){
  361. if (!model.userBase.userProfile) {
  362. continue;
  363. }
  364. self.thirdView.hidden = NO;
  365. [self.thirdHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.userBase.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
  366. if(model.userBase.remark.length > 0){
  367. self.thirdNameLab.text = model.userBase.remark;
  368. }
  369. else{
  370. self.thirdNameLab.text = model.userBase.userProfile.nickname;
  371. }
  372. self.thirdFollowBtn.selected = model.userBase.follow;
  373. NSString *firstStr = [MOTextTools numberToStringWith:model.total];
  374. [self.thirdTotalBtn setTitle:firstStr forState:UIControlStateNormal];
  375. if(model.userBase.liveRoomId.length > 0){
  376. self.thirdHeadBgView.hidden = NO;
  377. self.thirdHeadBgView.isLiving = YES;
  378. [self.thirdHeadBgView updataViewStatus];
  379. self.thirdHeadBgView.imgUrlStr = @"";
  380. }
  381. // else{
  382. // if(model.userBase.userProfile.adornment.headgearRes.length > 0){
  383. // self.thirdHeadBgView.hidden = NO;
  384. // self.thirdHeadBgView.isLiving = NO;
  385. // self.thirdHeadBgView.effectType = model.userBase.userProfile.adornment.headgearType;
  386. // self.thirdHeadBgView.imgUrlStr = model.userBase.userProfile.adornment.headgearRes;
  387. // }
  388. // else{
  389. // self.thirdHeadBgView.hidden = YES;
  390. // }
  391. // }
  392. if(model.userBase.vipType == 0){
  393. ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  394. config.shimmerStyle = ShimmerStyleNone;
  395. self.thirdNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
  396. [self.thirdNameLab startShimmerWithConfig:config];
  397. }
  398. else{
  399. // if(model.userBase.vipType == 1 || model.userBase.vipType== 5 || model.userBase.vipType == 6){
  400. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  401. // config.shimmerStyle = ShimmerStyleColorsFlow;
  402. // config.shimmerColorArray = VipNameColorArr_white_1;
  403. // config.shimmerSpeed = 20;
  404. // [self.thirdNameLab startShimmerWithConfig:config];
  405. // }
  406. // else if (model.userBase.vipType == 2){
  407. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  408. // config.shimmerStyle = ShimmerStyleColorsFlow;
  409. // config.shimmerColorArray = VipNameColorArr_white_2;
  410. // config.shimmerSpeed = 20;
  411. // [self.thirdNameLab startShimmerWithConfig:config];
  412. // }
  413. // else if (model.userBase.vipType == 3){
  414. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  415. // config.shimmerStyle = ShimmerStyleGradient;
  416. // config.shimmerColorArray = VipNameColorArr_3;
  417. // [self.thirdNameLab startShimmerWithConfig:config];
  418. // }
  419. // else if (model.userBase.vipType == 4){
  420. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  421. // config.shimmerStyle = ShimmerStyleNone;
  422. // self.thirdNameLab.textColor = VipNameColor_White_4;
  423. // [self.thirdNameLab startShimmerWithConfig:config];
  424. // }
  425. }
  426. NSString *goldNumStr = [MOTextTools numberToStringWith:model.total];
  427. [self.thirdGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
  428. if (self.typeNum == 3) {//收入榜,隐藏关注,换成金豆
  429. [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
  430. } else if (self.typeNum == 2) {//探索-财富榜,显示关注,换成钻石
  431. [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
  432. } else if (self.typeNum == 1) {//房间贡献榜,隐藏关注,换成钻石
  433. [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
  434. } else {//pk
  435. [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_pk"] forState:UIControlStateNormal];
  436. [self.thirdGoldBtn setTitle:[NSString stringWithFormat:@"%.0f", model.winNum] forState:UIControlStateNormal];
  437. }
  438. self.thirdGoldBtn.hidden = NO;
  439. self.rankThirdImg.hidden = NO;
  440. }
  441. x++;
  442. }
  443. [self.firstView bringSubviewToFront:self.rankFirstImg];
  444. [self.secondView bringSubviewToFront:self.rankSecondImg];
  445. [self.thirdView bringSubviewToFront:self.rankThirdImg];
  446. }
  447. - (void)setHeatDataArr:(NSArray<MOHeatRankItem *> *)heatDataArr {
  448. _heatDataArr = heatDataArr;
  449. self.firstView.hidden = NO;
  450. self.secondView.hidden = NO;
  451. self.thirdView.hidden = NO;
  452. //每次都需要初始化
  453. [self.firstHeadBtn setImage:nil forState:UIControlStateNormal];
  454. self.firstNameLab.text = @"";
  455. self.firstFollowBtn.selected = NO;
  456. self.rankFirstImg.hidden = YES;
  457. self.firstGoldBtn.hidden = YES;
  458. [self.secondHeadBtn setImage:nil forState:UIControlStateNormal];
  459. self.secondNameLab.text = @"";
  460. self.secondFollowBtn.selected = NO;
  461. self.rankSecondImg.hidden = YES;
  462. self.secondGoldBtn.hidden = YES;
  463. [self.thirdHeadBtn setImage:nil forState:UIControlStateNormal];
  464. self.thirdNameLab.text = @"";
  465. self.thirdFollowBtn.selected = NO;
  466. self.rankThirdImg.hidden = YES;
  467. self.thirdGoldBtn.hidden = YES;
  468. self.firstHeadBgView.hidden = YES;
  469. self.secondHeadBgView.hidden = YES;
  470. self.thirdHeadBgView.hidden = YES;
  471. int x = 0;
  472. for (MOHeatRankItem *model in heatDataArr) {
  473. if(x == 0){
  474. if (!model.user.userProfile) {
  475. continue;
  476. }
  477. self.firstView.hidden = NO;
  478. [self.firstHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.user.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
  479. if(model.user.remark.length > 0){
  480. self.firstNameLab.text = model.user.remark;
  481. }
  482. else{
  483. self.firstNameLab.text = model.user.userProfile.nickname;
  484. }
  485. self.firstFollowBtn.selected = model.user.follow;
  486. NSString *firstStr = [MOTextTools numberToStringWith:model.heat];
  487. [self.firstTotalBtn setTitle:firstStr forState:UIControlStateNormal];
  488. if(model.user.liveRoomId.length > 0){
  489. self.firstHeadBgView.hidden = NO;
  490. self.firstHeadBgView.isLiving = YES;
  491. [self.firstHeadBgView updataViewStatus];
  492. self.firstHeadBgView.imgUrlStr = @"";
  493. }
  494. // else{
  495. // if(model.user.userProfile.adornment.headgearRes.length > 0){
  496. // self.firstHeadBgView.hidden = NO;
  497. // self.firstHeadBgView.isLiving = NO;
  498. // self.firstHeadBgView.effectType = model.user.userProfile.adornment.headgearType;
  499. // self.firstHeadBgView.imgUrlStr = model.user.userProfile.adornment.headgearRes;
  500. // }
  501. // else{
  502. // self.firstHeadBgView.hidden = YES;
  503. // }
  504. // }
  505. if(model.user.vipType == 0){
  506. ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  507. config.shimmerStyle = ShimmerStyleNone;
  508. self.firstNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
  509. [self.firstNameLab startShimmerWithConfig:config];
  510. }
  511. else{
  512. // if(model.userBase.vipType == 1 || model.userBase.vipType == 5 || model.userBase.vipType == 6){
  513. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  514. // config.shimmerStyle = ShimmerStyleColorsFlow;
  515. // config.shimmerColorArray = VipNameColorArr_white_1;
  516. // config.shimmerSpeed = 20;
  517. // [self.firstNameLab startShimmerWithConfig:config];
  518. // }
  519. // else if (model.userBase.vipType == 2){
  520. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  521. // config.shimmerStyle = ShimmerStyleColorsFlow;
  522. // config.shimmerColorArray = VipNameColorArr_white_2;
  523. // config.shimmerSpeed = 20;
  524. // [self.firstNameLab startShimmerWithConfig:config];
  525. // }
  526. // else if (model.userBase.vipType == 3){
  527. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  528. // config.shimmerStyle = ShimmerStyleGradient;
  529. // config.shimmerColorArray = VipNameColorArr_3;
  530. // [self.firstNameLab startShimmerWithConfig:config];
  531. // }
  532. // else if (model.userBase.vipType == 4){
  533. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  534. // config.shimmerStyle = ShimmerStyleNone;
  535. // self.firstNameLab.textColor = VipNameColor_White_4;
  536. // [self.firstNameLab startShimmerWithConfig:config];
  537. // }
  538. }
  539. NSString *goldNumStr = [MOTextTools numberToStringAboutTwoWith:model.heat];
  540. [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_heat"] forState:UIControlStateNormal];
  541. [self.firstGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
  542. self.firstGoldBtn.titleLabel.font = [MOTextTools semiboldFont:12];
  543. [self.firstGoldBtn setTitleColor:[MOTools colorWithHexString:@"#F23051"] forState:UIControlStateNormal];
  544. self.firstGoldBtn.hidden = NO;
  545. self.rankFirstImg.hidden = NO;
  546. }
  547. else if (x == 1){
  548. if (!model.user.userProfile) {
  549. continue;
  550. }
  551. self.secondView.hidden = NO;
  552. [self.secondHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.user.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
  553. if(model.user.remark.length > 0){
  554. self.secondNameLab.text = model.user.remark;
  555. }
  556. else{
  557. self.secondNameLab.text = model.user.userProfile.nickname;
  558. }
  559. self.secondFollowBtn.selected = model.user.follow;
  560. NSString *firstStr = [MOTextTools numberToStringWith:model.heat];
  561. [self.secondTotalBtn setTitle:firstStr forState:UIControlStateNormal];
  562. if(model.user.liveRoomId.length > 0){
  563. self.secondHeadBgView.hidden = NO;
  564. self.secondHeadBgView.isLiving = YES;
  565. [self.secondHeadBgView updataViewStatus];
  566. self.secondHeadBgView.imgUrlStr = @"";
  567. }
  568. // else{
  569. // if(model.user.userProfile.adornment.headgearRes.length > 0){
  570. // self.secondHeadBgView.hidden = NO;
  571. // self.secondHeadBgView.isLiving = NO;
  572. // self.secondHeadBgView.effectType = model.user.userProfile.adornment.headgearType;
  573. // self.secondHeadBgView.imgUrlStr = model.user.userProfile.adornment.headgearRes;
  574. // }
  575. // else{
  576. // self.secondHeadBgView.hidden = YES;
  577. // }
  578. // }
  579. if(model.user.vipType == 0){
  580. ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  581. config.shimmerStyle = ShimmerStyleNone;
  582. self.secondNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
  583. [self.secondNameLab startShimmerWithConfig:config];
  584. }
  585. else{
  586. // if(model.userBase.vipType == 1 || model.userBase.vipType == 5 || model.userBase.vipType == 6){
  587. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  588. // config.shimmerStyle = ShimmerStyleColorsFlow;
  589. // config.shimmerColorArray = VipNameColorArr_white_1;
  590. // config.shimmerSpeed = 20;
  591. // [self.secondNameLab startShimmerWithConfig:config];
  592. // }
  593. // else if (model.userBase.vipType == 2){
  594. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  595. // config.shimmerStyle = ShimmerStyleColorsFlow;
  596. // config.shimmerColorArray = VipNameColorArr_white_2;
  597. // config.shimmerSpeed = 20;
  598. // [self.secondNameLab startShimmerWithConfig:config];
  599. // }
  600. // else if (model.userBase.vipType == 3){
  601. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  602. // config.shimmerStyle = ShimmerStyleGradient;
  603. // config.shimmerColorArray = VipNameColorArr_3;
  604. // [self.secondNameLab startShimmerWithConfig:config];
  605. // }
  606. // else if (model.userBase.vipType == 4){
  607. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  608. // config.shimmerStyle = ShimmerStyleNone;
  609. // self.secondNameLab.textColor = VipNameColor_White_4;
  610. // [self.secondNameLab startShimmerWithConfig:config];
  611. // }
  612. }
  613. NSString *goldNumStr = [MOTextTools numberToStringAboutTwoWith:model.heat];
  614. [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_heat"] forState:UIControlStateNormal];
  615. [self.secondGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
  616. self.secondGoldBtn.titleLabel.font = [MOTextTools semiboldFont:12];
  617. [self.secondGoldBtn setTitleColor:[MOTools colorWithHexString:@"#F23051"] forState:UIControlStateNormal];
  618. self.secondGoldBtn.hidden = NO;
  619. self.rankSecondImg.hidden = NO;
  620. }
  621. else if (x == 2){
  622. if (!model.user.userProfile) {
  623. continue;
  624. }
  625. self.thirdView.hidden = NO;
  626. [self.thirdHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.user.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
  627. if(model.user.remark.length > 0){
  628. self.thirdNameLab.text = model.user.remark;
  629. }
  630. else{
  631. self.thirdNameLab.text = model.user.userProfile.nickname;
  632. }
  633. self.thirdFollowBtn.selected = model.user.follow;
  634. NSString *firstStr = [MOTextTools numberToStringWith:model.heat];
  635. [self.thirdTotalBtn setTitle:firstStr forState:UIControlStateNormal];
  636. if(model.user.liveRoomId.length > 0){
  637. self.thirdHeadBgView.hidden = NO;
  638. self.thirdHeadBgView.isLiving = YES;
  639. [self.thirdHeadBgView updataViewStatus];
  640. self.thirdHeadBgView.imgUrlStr = @"";
  641. }
  642. // else{
  643. // if(model.user.userProfile.adornment.headgearRes.length > 0){
  644. // self.thirdHeadBgView.hidden = NO;
  645. // self.thirdHeadBgView.isLiving = NO;
  646. // self.thirdHeadBgView.effectType = model.user.userProfile.adornment.headgearType;
  647. // self.thirdHeadBgView.imgUrlStr = model.user.userProfile.adornment.headgearRes;
  648. // }
  649. // else{
  650. // self.thirdHeadBgView.hidden = YES;
  651. // }
  652. // }
  653. if(model.user.vipType == 0){
  654. ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  655. config.shimmerStyle = ShimmerStyleNone;
  656. self.thirdNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
  657. [self.thirdNameLab startShimmerWithConfig:config];
  658. }
  659. else{
  660. // if(model.userBase.vipType == 1 || model.userBase.vipType== 5 || model.userBase.vipType == 6){
  661. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  662. // config.shimmerStyle = ShimmerStyleColorsFlow;
  663. // config.shimmerColorArray = VipNameColorArr_white_1;
  664. // config.shimmerSpeed = 20;
  665. // [self.thirdNameLab startShimmerWithConfig:config];
  666. // }
  667. // else if (model.userBase.vipType == 2){
  668. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  669. // config.shimmerStyle = ShimmerStyleColorsFlow;
  670. // config.shimmerColorArray = VipNameColorArr_white_2;
  671. // config.shimmerSpeed = 20;
  672. // [self.thirdNameLab startShimmerWithConfig:config];
  673. // }
  674. // else if (model.userBase.vipType == 3){
  675. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  676. // config.shimmerStyle = ShimmerStyleGradient;
  677. // config.shimmerColorArray = VipNameColorArr_3;
  678. // [self.thirdNameLab startShimmerWithConfig:config];
  679. // }
  680. // else if (model.userBase.vipType == 4){
  681. // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
  682. // config.shimmerStyle = ShimmerStyleNone;
  683. // self.thirdNameLab.textColor = VipNameColor_White_4;
  684. // [self.thirdNameLab startShimmerWithConfig:config];
  685. // }
  686. }
  687. NSString *goldNumStr = [MOTextTools numberToStringAboutTwoWith:model.heat];
  688. [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_heat"] forState:UIControlStateNormal];
  689. [self.thirdGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
  690. self.thirdGoldBtn.titleLabel.font = [MOTextTools semiboldFont:12];
  691. [self.thirdGoldBtn setTitleColor:[MOTools colorWithHexString:@"#F23051"] forState:UIControlStateNormal];
  692. self.thirdGoldBtn.hidden = NO;
  693. self.rankThirdImg.hidden = NO;
  694. }
  695. x++;
  696. }
  697. [self.firstView bringSubviewToFront:self.rankFirstImg];
  698. [self.secondView bringSubviewToFront:self.rankSecondImg];
  699. [self.thirdView bringSubviewToFront:self.rankThirdImg];
  700. }
  701. + (CGFloat)theViewHeight{
  702. CGFloat height = 160.0;
  703. return height;
  704. }
  705. + (CGFloat)theLiveRoomViewHeight{
  706. CGFloat height = 133.0 + 128.0 + 5.0 + 26.0;
  707. return height;
  708. }
  709. - (IBAction)headBtnClick:(UIButton *)sender {
  710. if(self.dataArr.count == 0 && self.heatDataArr == 0){//heatDataArr有值代表当前是在热度榜
  711. return;
  712. }
  713. if(sender == self.firstHeadBtn){
  714. if (self.dataArr.count > 0) {
  715. MORanklist *model = self.dataArr.firstObject;
  716. self.headBtnClickBlock ? self.headBtnClickBlock(model.userBase) : nil;
  717. } else {
  718. MOHeatRankItem *model = self.heatDataArr.firstObject;
  719. self.headBtnClickBlock ? self.headBtnClickBlock(model.user) : nil;
  720. }
  721. }
  722. else if (sender == self.secondHeadBtn){
  723. if(self.dataArr.count <= 1 && self.heatDataArr.count <= 1){
  724. return;
  725. }
  726. if (self.dataArr.count > 0) {
  727. MORanklist *model = self.dataArr[1];
  728. self.headBtnClickBlock ? self.headBtnClickBlock(model.userBase) : nil;
  729. } else {
  730. MOHeatRankItem *model = self.heatDataArr[1];
  731. self.headBtnClickBlock ? self.headBtnClickBlock(model.user) : nil;
  732. }
  733. }
  734. else{
  735. if(self.dataArr.count <= 2 && self.heatDataArr.count <= 2){
  736. return;
  737. }
  738. if (self.dataArr.count > 0) {
  739. MORanklist *model = self.dataArr[2];
  740. self.headBtnClickBlock ? self.headBtnClickBlock(model.userBase) : nil;
  741. } else {
  742. MOHeatRankItem *model = self.heatDataArr[2];
  743. self.headBtnClickBlock ? self.headBtnClickBlock(model.user) : nil;
  744. }
  745. }
  746. }
  747. - (IBAction)firstFollowBtnClick:(id)sender {
  748. UIButton *btn = (UIButton *)sender;
  749. if(btn.selected){
  750. return;
  751. }
  752. else{
  753. if(self.dataArr.count >= 1){
  754. MORanklist *ranklist = self.dataArr[0];
  755. [self followSomeOneWith:ranklist.userBase.userProfile.id AndIndex:0];
  756. }
  757. }
  758. }
  759. - (IBAction)secondFollowBtnClick:(id)sender {
  760. UIButton *btn = (UIButton *)sender;
  761. if(btn.selected){
  762. return;
  763. }
  764. else{
  765. if(self.dataArr.count >= 2){
  766. MORanklist *ranklist = self.dataArr[1];
  767. [self followSomeOneWith:ranklist.userBase.userProfile.id AndIndex:1];
  768. }
  769. }
  770. }
  771. - (IBAction)thirdFollowBtnClick:(id)sender {
  772. UIButton *btn = (UIButton *)sender;
  773. if(btn.selected){
  774. return;
  775. }
  776. else{
  777. if(self.dataArr.count >= 3){
  778. MORanklist *ranklist = self.dataArr[2];
  779. [self followSomeOneWith:ranklist.userBase.userProfile.id AndIndex:2];
  780. }
  781. }
  782. }
  783. - (void)followSomeOneWith:(NSString *)targetId AndIndex:(NSInteger)index{
  784. WEAKSELF
  785. if(targetId.length == 0){
  786. return;
  787. }
  788. if([targetId isEqualToString:GetUserId]){
  789. [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_cannot_to_yourself")];
  790. return;
  791. }
  792. NSArray *targetArr = @[targetId];
  793. NSDictionary *dict;
  794. if(self.roomId.length > 0){
  795. dict = @{@"type":@"1",
  796. @"target":targetArr,
  797. @"roomId":self.roomId};
  798. }
  799. else{
  800. dict = @{@"type":@"1",
  801. @"target":targetArr};
  802. }
  803. [kHttpManager toSubmitForFollowWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  804. if(kCode_Success){
  805. [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_Tip_Follow_Success")];
  806. if(weakSelf.dataArr.count >= index){
  807. MORanklist *model = weakSelf.dataArr[index];
  808. model.userBase.follow = YES;
  809. //刷新数据
  810. weakSelf.dataArr = weakSelf.dataArr;
  811. weakSelf.followSomeOneBlock ? weakSelf.followSomeOneBlock(model) : nil;
  812. }
  813. }
  814. else{
  815. kShowNetError(data)
  816. }
  817. }];
  818. }
  819. - (MOEllipseUpView *)upBgView{
  820. if(!_upBgView){
  821. _upBgView = [[MOEllipseUpView alloc] initWithFrame:CGRectMake(0.0, 0.0, 280.0, 30.0)];
  822. _upBgView.backgroundColor = [UIColor whiteColor];
  823. _upBgView.hidden = YES;
  824. }
  825. return _upBgView;
  826. }
  827. - (UIButton *)firstTotalBtn{
  828. if(!_firstTotalBtn){
  829. _firstTotalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  830. _firstTotalBtn.backgroundColor = [UIColor clearColor];
  831. [_firstTotalBtn setImage:[UIImage imageNamed:@"icon_live_golder_bean"] forState:UIControlStateNormal];
  832. [_firstTotalBtn setTitle:@"0" forState:UIControlStateNormal];
  833. _firstTotalBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
  834. _firstTotalBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 3.0, 0, 0);
  835. [_firstTotalBtn setTitleColor:[MOTools colorWithHexString:@"#333333" alpha:1.0] forState:UIControlStateNormal];
  836. _firstTotalBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  837. }
  838. return _firstTotalBtn;
  839. }
  840. - (UIButton *)secondTotalBtn{
  841. if(!_secondTotalBtn){
  842. _secondTotalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  843. _secondTotalBtn.backgroundColor = [UIColor clearColor];
  844. [_secondTotalBtn setImage:[UIImage imageNamed:@"icon_live_golder_bean"] forState:UIControlStateNormal];
  845. [_secondTotalBtn setTitle:@"0" forState:UIControlStateNormal];
  846. _secondTotalBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
  847. _secondTotalBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 3.0, 0, 0);
  848. [_secondTotalBtn setTitleColor:[MOTools colorWithHexString:@"#333333" alpha:1.0] forState:UIControlStateNormal];
  849. _secondTotalBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  850. }
  851. return _secondTotalBtn;
  852. }
  853. - (UIButton *)thirdTotalBtn{
  854. if(!_thirdTotalBtn){
  855. _thirdTotalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  856. _thirdTotalBtn.backgroundColor = [UIColor clearColor];
  857. [_thirdTotalBtn setImage:[UIImage imageNamed:@"icon_live_golder_bean"] forState:UIControlStateNormal];
  858. [_thirdTotalBtn setTitle:@"0" forState:UIControlStateNormal];
  859. _thirdTotalBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
  860. _thirdTotalBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 3.0, 0, 0);
  861. [_thirdTotalBtn setTitleColor:[MOTools colorWithHexString:@"#333333" alpha:1.0] forState:UIControlStateNormal];
  862. _thirdTotalBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  863. }
  864. return _thirdTotalBtn;
  865. }
  866. - (MOHeadCustomView *)firstHeadBgView{
  867. if(!_firstHeadBgView){
  868. _firstHeadBgView = [[MOHeadCustomView alloc] init];
  869. }
  870. return _firstHeadBgView;
  871. }
  872. - (MOHeadCustomView *)secondHeadBgView{
  873. if(!_secondHeadBgView){
  874. _secondHeadBgView = [[MOHeadCustomView alloc] init];
  875. }
  876. return _secondHeadBgView;
  877. }
  878. - (MOHeadCustomView *)thirdHeadBgView{
  879. if(!_thirdHeadBgView){
  880. _thirdHeadBgView = [[MOHeadCustomView alloc] init];
  881. }
  882. return _thirdHeadBgView;
  883. }
  884. - (UILabel *)countDownLab{
  885. if(!_countDownLab){
  886. _countDownLab = [[UILabel alloc] init];
  887. _countDownLab.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA" alpha:1.0];
  888. _countDownLab.layer.cornerRadius = 12.0;
  889. _countDownLab.layer.masksToBounds = YES;
  890. _countDownLab.textColor = [MOTools colorWithHexString:@"#5C5E66" alpha:1.0];
  891. _countDownLab.font = [MOTextTools poppinsMediumFont:12.0];
  892. _countDownLab.text = @"Countdown: 00d 00h 00m";
  893. _countDownLab.textAlignment = NSTextAlignmentCenter;
  894. }
  895. return _countDownLab;
  896. }
  897. - (void)setEndTime:(double)endTime{
  898. _endTime = endTime;
  899. if(endTime <= 0){
  900. return;
  901. }
  902. [self toUpdateTheCountDownLab];
  903. }
  904. - (void)toUpdateTheCountDownLab{
  905. if(self.endTime <= 0){
  906. return;
  907. }
  908. NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970];
  909. NSTimeInterval interval = self.endTime / 1000.0 - currentTime;
  910. NSDateComponents *components = [[NSCalendar currentCalendar]
  911. components:(NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond)
  912. fromDate:[NSDate dateWithTimeIntervalSince1970:0]
  913. toDate:[NSDate dateWithTimeIntervalSince1970:interval]
  914. options:0];
  915. if(interval > 0){
  916. NSString *result = [NSString stringWithFormat:@"%02ldm %02lds",
  917. (long)components.minute,
  918. (long)components.second];
  919. NSString *timeStr = [NSString stringWithFormat:NSLocalString(@"C60011"),result];
  920. //富文本 宽度
  921. NSAttributedString *contentStr = [MOTextTools base_colorObjectStringWith:timeStr AndNameStr:result AndBaseColor:kBaseTextColor_2 AndNameColor:kBaseTextColor_1];
  922. self.countDownLab.attributedText = contentStr;
  923. CGFloat labWidth = [MOTools getWidthWithString:timeStr font:[MOTextTools poppinsMediumFont:12.0]] + 20.0;
  924. [self.countDownLab mas_updateConstraints:^(MASConstraintMaker *make) {
  925. make.width.equalTo(@(labWidth));
  926. }];
  927. }
  928. else{
  929. self.timeEndBlock ? self.timeEndBlock() : nil;
  930. }
  931. }
  932. - (void)oneSecondPassed{
  933. [self toUpdateTheCountDownLab];
  934. }
  935. @end