MORankListTableView.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. //
  2. // MORankListTableView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/11/30.
  6. //
  7. //一页的size
  8. #define kPageSize 100
  9. #import "MORankListTableView.h"
  10. #import "MORankTopView.h"
  11. #import "MORankCurrentView.h"
  12. #import "YYTimer.h"
  13. #import "MORankCountdownTopView.h"
  14. #import "MORankNoDataView.h"
  15. @interface MORankListTableView ()<UITableViewDelegate,UITableViewDataSource>
  16. @property (nonatomic, strong) MORankTopView *topView;//三排名顶部
  17. @property (nonatomic, strong) MORankCountdownTopView *topTwoView;//倒计时View
  18. @property (nonatomic, strong) UITableView *tableView;
  19. @property (nonatomic, strong) MORankCurrentView *bottomView;
  20. @property (nonatomic, strong) MORankBasedata *baseData;
  21. /** 游标 */
  22. @property (nonatomic, copy) NSString *next;
  23. @property (nonatomic, strong) YYTimer *liveTimer;
  24. @property (nonatomic, strong) MORankNoDataView *noDataView;
  25. @property (nonatomic, assign) BOOL needAddTimer;//是否添加定时器
  26. @end
  27. @implementation MORankListTableView
  28. - (instancetype)init{
  29. self = [super init];
  30. if (self)
  31. {
  32. [self setupUI];
  33. }
  34. return self;
  35. }
  36. - (instancetype)initWithFrame:(CGRect)frame
  37. {
  38. self = [super initWithFrame:frame];
  39. if (self)
  40. {
  41. [self setupUI];
  42. }
  43. return self;
  44. }
  45. - (void)setupUI{
  46. self.next = @"";
  47. self.isNeedUpdata = NO;
  48. // [self addSubview:self.bgExtImgView];
  49. // [self.bgExtImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  50. // make.top.equalTo(self).offset(280.0);
  51. // make.left.right.equalTo(self);
  52. // make.bottom.equalTo(self);
  53. // }];
  54. //
  55. // UIImage *extImg = [MOTools createImageWithColor:[MOTools colorWithHexString:@"#FBF8F8" alpha:1.0]];
  56. // [self.bgExtImgView setImage:extImg];
  57. [self addSubview:self.tableView];
  58. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.left.right.bottom.equalTo(self);
  60. }];
  61. [self addSubview:self.bottomView];
  62. [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.left.right.bottom.mas_equalTo(0);
  64. make.height.mas_equalTo(68 + kBottomSafeAreaInset);
  65. }];
  66. }
  67. #pragma mark - JXCategoryListContentViewDelegate
  68. - (void)listWillAppear{
  69. if(self.dataArr.count == 0 || self.isNeedUpdata)
  70. {
  71. if(self.typeNum == 1){
  72. //直播间贡献榜
  73. self.next = @"";
  74. if(self.roomId.length == 0){
  75. return;
  76. }
  77. NSDictionary *basePage = @{@"size":@(kPageSize),@"next":self.next};
  78. NSDictionary *baseDict = @{@"type":@(self.typeTime),
  79. @"page":basePage,
  80. @"id":self.roomId};
  81. [self toGetRankOutcomeAboutRoomWith:baseDict];
  82. }
  83. else if (self.typeNum == 2){
  84. //总贡献榜
  85. self.next = @"";
  86. NSDictionary *basePage = @{@"size":@(kPageSize),@"next":self.next};
  87. NSDictionary *baseDict;
  88. if(self.countryStr.length > 0){
  89. baseDict = @{@"type":@(self.typeTime),
  90. @"page":basePage,
  91. @"country":self.countryStr};
  92. }
  93. else{
  94. baseDict = @{@"type":@(self.typeTime),
  95. @"page":basePage};
  96. }
  97. [self toGetRankOutcomeListWith:baseDict];
  98. }
  99. else{
  100. //收益榜
  101. self.next = @"";
  102. NSDictionary *basePage = @{@"size":@(kPageSize),@"next":self.next};
  103. NSDictionary *baseDict ;
  104. if(self.countryStr.length > 0){
  105. baseDict = @{@"type":@(self.typeTime),
  106. @"page":basePage,
  107. @"country":self.countryStr,
  108. @"roomId":self.roomId ?: @"",
  109. @"newer": @(self.isNewer)};
  110. }
  111. else{
  112. baseDict = @{@"type":@(self.typeTime),
  113. @"page":basePage,
  114. @"roomId":self.roomId ?: @"",
  115. @"newer": @(self.isNewer)};
  116. }
  117. [self toGetRankIncomeListWith:baseDict];
  118. }
  119. }
  120. else{
  121. [self.tableView reloadData];
  122. }
  123. if (self.needAddTimer) {
  124. [self.liveTimer fire];
  125. }
  126. }
  127. - (void)listDidDisappear {
  128. if (self.needAddTimer && _liveTimer) {
  129. [_liveTimer invalidate];
  130. _liveTimer = nil;
  131. }
  132. }
  133. - (void)setTypeTime:(NSInteger)typeTime{
  134. _typeTime = typeTime;
  135. if(typeTime == 4 && self.typeNum == 3){//直播间收益榜 && 小时榜
  136. if(self.isNewer){
  137. self.tableView.tableHeaderView = self.topTwoView;
  138. [self.topTwoView mas_remakeConstraints:^(MASConstraintMaker *make) {
  139. make.top.offset(0);
  140. make.left.offset(0.0);
  141. make.height.mas_equalTo(32.0);
  142. make.width.mas_equalTo(SCREENWIDTH);
  143. }];
  144. }
  145. else{
  146. self.topView.isShowCountDownLab = YES;
  147. CGFloat topViewHeigth = [MORankTopView theViewHeight] + 24.0;
  148. self.tableView.tableHeaderView = self.topView;
  149. [self.topView mas_remakeConstraints:^(MASConstraintMaker *make) {
  150. make.top.offset(0);
  151. make.left.offset(0.0);
  152. make.height.mas_equalTo(topViewHeigth);
  153. make.width.mas_equalTo(SCREENWIDTH);
  154. }];
  155. }
  156. }
  157. }
  158. - (void)setCountryStr:(NSString *)countryStr{
  159. _countryStr = countryStr;
  160. }
  161. - (void)setupNoDataView {
  162. self.tableView.backgroundView.hidden = YES;
  163. if (self.dataArr.count > 0) {
  164. return;
  165. }
  166. self.tableView.backgroundView.hidden = NO;
  167. self.tableView.tableHeaderView = nil;
  168. self.tableView.backgroundView = self.noDataView;
  169. self.noDataView.sendButton.hidden = YES;
  170. if (self.baseData.rankHit && !self.outSideRoom) {
  171. self.noDataView.sendButton.hidden = NO;
  172. [self.noDataView.sendButton configureWithCount:[NSString stringWithFormat:@"x %@", [MOTextTools numberToStringWith:self.baseData.rankHit.hitAmount]] desc:NSLocalString(@"C60020") isGradient:YES];
  173. [self.noDataView.sendButton.iconView sd_setImageWithURL:[NSURL URLWithString:self.baseData.rankHit.giftImg]];
  174. [self.noDataView.sendButton addTarget:self action:@selector(sendGiftAction) forControlEvents:UIControlEventTouchUpInside];
  175. }
  176. }
  177. - (void)sendGiftAction {
  178. if (self.hitBlock) {
  179. self.hitBlock(self.baseData.rankHit);
  180. }
  181. }
  182. /// 排行榜 - 直播间贡献榜
  183. - (void)toGetRankOutcomeAboutRoomWith:(NSDictionary *)dict{
  184. WEAKSELF
  185. [kHttpManager toGetRankOutcomeRoomWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  186. [weakSelf.tableView.mj_header endRefreshing];
  187. if(kCode_Success){
  188. MOLogV(@"toGetRankOutcome: %@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  189. MORankBasedata *baseData = [MORankBasedata modelObjectWithDictionary:data[@"data"]];
  190. weakSelf.baseData = baseData;
  191. if (weakSelf.getTopBlock) {
  192. weakSelf.getTopBlock(baseData.newerTops);
  193. }
  194. weakSelf.dataArr = [baseData.ranklist mutableCopy];
  195. [weakSelf setTopView];
  196. [weakSelf.tableView reloadData];
  197. [weakSelf.bottomView setupContribute:baseData];
  198. [weakSelf checkTableViewcontentInset];
  199. [weakSelf setupNoDataView];
  200. }
  201. else{
  202. kShowNetError(data)
  203. }
  204. }];
  205. }
  206. /// 排行榜 - 贡献榜
  207. - (void)toGetRankOutcomeListWith:(NSDictionary *)dict{
  208. WEAKSELF
  209. [kHttpManager toGetRankOutcomeListWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  210. [weakSelf.tableView.mj_header endRefreshing];
  211. if(kCode_Success){
  212. MOLogV(@"toGetRankOutcomeList: %@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  213. MORankBasedata *baseData = [MORankBasedata modelObjectWithDictionary:data[@"data"]];
  214. weakSelf.baseData = baseData;
  215. if (weakSelf.getTopBlock) {
  216. weakSelf.getTopBlock(baseData.newerTops);
  217. }
  218. weakSelf.dataArr = [baseData.ranklist mutableCopy];
  219. [weakSelf setTopView];
  220. [weakSelf.tableView reloadData];
  221. weakSelf.isNeedUpdata = NO;
  222. [weakSelf checkTableViewcontentInset];
  223. [weakSelf setupNoDataView];
  224. }
  225. else{
  226. kShowNetError(data)
  227. }
  228. }];
  229. }
  230. /// 排行榜 - 收益榜
  231. - (void)toGetRankIncomeListWith:(NSDictionary *)dict{
  232. WEAKSELF
  233. [kHttpManager toGetRankIncomeListWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  234. [weakSelf.tableView.mj_header endRefreshing];
  235. if(kCode_Success){
  236. MOLogV(@"toGetRankIncomeList: %@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  237. MORankBasedata *baseData = [MORankBasedata modelObjectWithDictionary:data[@"data"]];
  238. weakSelf.baseData = baseData;
  239. if (weakSelf.getTopBlock) {
  240. weakSelf.getTopBlock(baseData.newerTops);
  241. }
  242. if (weakSelf.typeTime == 4) {//小时榜才回调出去
  243. if (weakSelf.getCurrentIndexBlock) {
  244. weakSelf.getCurrentIndexBlock(baseData.rankFooter);
  245. }
  246. }
  247. weakSelf.dataArr = [baseData.ranklist mutableCopy];
  248. [weakSelf checkIfNeedAddTimer];
  249. [weakSelf setTopView];
  250. weakSelf.topView.endTime = baseData.endTime;
  251. [weakSelf.tableView reloadData];
  252. weakSelf.isNeedUpdata = NO;
  253. [weakSelf.bottomView setupRevenue:baseData];
  254. [weakSelf checkTableViewcontentInset];
  255. [weakSelf setupNoDataView];
  256. }
  257. else{
  258. kShowNetError(data)
  259. }
  260. }];
  261. }
  262. - (void)checkIfNeedAddTimer {
  263. if(self.typeTime == 4 && self.typeNum == 3 && self.dataArr.count > 0) {
  264. self.needAddTimer = YES;
  265. if(!_liveTimer){
  266. [self.liveTimer fire];//打开定时器
  267. }
  268. }
  269. }
  270. - (void)checkTableViewcontentInset {
  271. if (self.outSideRoom) {
  272. self.bottomView.hidden = YES;
  273. self.tableView.contentInset = UIEdgeInsetsMake(0, 0, (kBottomSafeAreaInset > 0 ? kBottomSafeAreaInset : 20) , 0);
  274. return;
  275. }
  276. if (self.dataArr.count == 0) {
  277. self.bottomView.hidden = YES;
  278. //显示没有榜单,显示上榜
  279. return;
  280. }
  281. if (self.dataArr.count >= 6) {
  282. self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 86 + kBottomSafeAreaInset, 0);
  283. }
  284. }
  285. - (void)setTopView{
  286. if (self.isNewer) {
  287. if(self.typeTime == 4 && self.typeNum == 3){//直播间收益榜 && 小时榜
  288. self.topTwoView.endTime = self.baseData.endTime;
  289. return;
  290. }
  291. self.tableView.tableHeaderView = nil;
  292. return;
  293. }
  294. self.topView.hidden = (self.dataArr.count == 0);
  295. NSMutableArray *tempArr = [NSMutableArray array];
  296. int x = 0;
  297. for (MORanklist *model in self.dataArr) {
  298. if(x >= 3){
  299. break;
  300. }
  301. else{
  302. [tempArr addObject:model];
  303. }
  304. x++;
  305. }
  306. self.topView.typeNum = self.typeNum;
  307. self.topView.roomId = self.roomId;
  308. self.topView.dataArr = tempArr;
  309. }
  310. - (UIView *)listView{
  311. return self;
  312. }
  313. #pragma mark - UITableViewDelegate,UITableViewDataSource
  314. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  315. return 1;
  316. }
  317. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  318. if (self.isNewer) {
  319. return self.dataArr.count;
  320. }
  321. if(self.dataArr.count > 3){
  322. return self.dataArr.count - 3;
  323. }
  324. else{
  325. return 1;
  326. }
  327. }
  328. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  329. if (self.isNewer) {
  330. return 68.0;
  331. }
  332. if(self.dataArr.count > 3){
  333. return 68.0;
  334. }
  335. else
  336. {
  337. return 0.01;
  338. }
  339. }
  340. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  341. WEAKSELF
  342. if (self.isNewer) {
  343. MORanklist *model = self.dataArr[indexPath.row];
  344. MORankListCell *cell = [tableView dequeueReusableCellWithIdentifier:MORankLIstCell_ID];
  345. if (cell == nil){
  346. cell = [[MORankListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MORankLIstCell_ID];
  347. }
  348. NSInteger num = indexPath.row + 1;
  349. if (num <= 3) {
  350. cell.numLab.hidden = YES;
  351. cell.numImgView.hidden = NO;
  352. cell.numImgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"icon_rank_%zd", num]];
  353. } else {
  354. cell.numLab.hidden = NO;
  355. cell.numImgView.hidden = YES;
  356. cell.numLab.text = [NSString stringWithFormat:@"%zd",num];
  357. }
  358. cell.isShowLiving = YES;
  359. cell.typeNum = self.typeNum;
  360. cell.cellIndexPath = indexPath;
  361. cell.cellModel = model;
  362. cell.roomId = self.roomId;
  363. cell.followBtnBlock = ^(MORanklist * _Nonnull cellModel, NSIndexPath *cellIndexPath) {
  364. cellModel.userBase.follow = YES;
  365. for (MORanklist *tempModel in weakSelf.dataArr) {
  366. if([tempModel.userBase.userProfile.id isEqualToString:cellModel.userBase.userProfile.id]){
  367. tempModel.userBase.follow = YES;
  368. break;
  369. }
  370. }
  371. [weakSelf.tableView reloadRowsAtIndexPaths:@[cellIndexPath] withRowAnimation:UITableViewRowAnimationNone];
  372. };
  373. cell.headBtnBlock = ^(MORanklist * _Nonnull model) {
  374. weakSelf.headBtnBlock ? weakSelf.headBtnBlock(model.userBase) : nil;
  375. };
  376. return cell;
  377. }
  378. if(self.dataArr.count > 3){
  379. MORanklist *model = self.dataArr[indexPath.row + 3];
  380. MORankListCell *cell = [tableView dequeueReusableCellWithIdentifier:MORankLIstCell_ID];
  381. if (cell == nil){
  382. cell = [[MORankListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MORankLIstCell_ID];
  383. }
  384. NSInteger num = indexPath.row + 4;
  385. cell.numLab.text = [NSString stringWithFormat:@"%zd",num];
  386. cell.isShowLiving = YES;
  387. cell.typeNum = self.typeNum;
  388. cell.cellIndexPath = indexPath;
  389. cell.cellModel = model;
  390. cell.roomId = self.roomId;
  391. cell.followBtnBlock = ^(MORanklist * _Nonnull cellModel, NSIndexPath *cellIndexPath) {
  392. cellModel.userBase.follow = YES;
  393. for (MORanklist *tempModel in weakSelf.dataArr) {
  394. if([tempModel.userBase.userProfile.id isEqualToString:cellModel.userBase.userProfile.id]){
  395. tempModel.userBase.follow = YES;
  396. break;
  397. }
  398. }
  399. [weakSelf.tableView reloadRowsAtIndexPaths:@[cellIndexPath] withRowAnimation:UITableViewRowAnimationNone];
  400. };
  401. cell.headBtnBlock = ^(MORanklist * _Nonnull model) {
  402. weakSelf.headBtnBlock ? weakSelf.headBtnBlock(model.userBase) : nil;
  403. };
  404. return cell;
  405. }
  406. else {
  407. MORankNoDataCell *cell = [tableView dequeueReusableCellWithIdentifier:MORankNoDataCell_ID];
  408. cell.bgView.layer.cornerRadius = 16.0;
  409. cell.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
  410. cell.bgView.layer.masksToBounds = YES;
  411. cell.bgView.backgroundColor = [MOTools colorWithHexString:@"#FFFFFF" alpha:1.0];
  412. cell.titleLab.hidden = YES;
  413. return cell;
  414. }
  415. }
  416. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  417. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  418. // if (self.isNewer){
  419. // MORanklist *model = self.dataArr[indexPath.row];
  420. // self.headBtnBlock ? self.headBtnBlock(model.userBase) : nil;
  421. // }
  422. // else{
  423. // if(self.dataArr.count > 3){
  424. // MORanklist *model = self.dataArr[indexPath.row + 3];
  425. // self.headBtnBlock ? self.headBtnBlock(model.userBase) : nil;
  426. // }
  427. // }
  428. }
  429. #pragma mark - Lazy
  430. - (UITableView *)tableView{
  431. if (!_tableView)
  432. {
  433. _tableView= [[UITableView alloc] init];
  434. if (@available(iOS 11.0, *))
  435. {
  436. _tableView.estimatedRowHeight = 0;
  437. _tableView.estimatedSectionFooterHeight = 0;
  438. _tableView.estimatedSectionHeaderHeight = 0;
  439. _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  440. }
  441. //iOS15适配
  442. if (@available(iOS 15.0, *))
  443. {
  444. _tableView.sectionHeaderTopPadding = 0;
  445. }
  446. _tableView.backgroundColor = [UIColor clearColor];
  447. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  448. _tableView.dataSource = self;
  449. _tableView.delegate = self;
  450. _tableView.showsVerticalScrollIndicator = NO;
  451. _tableView.showsHorizontalScrollIndicator = NO;
  452. [_tableView registerClass:[MORankListCell class] forCellReuseIdentifier:MORankLIstCell_ID];
  453. [_tableView registerNib:[UINib nibWithNibName:@"MORankNoDataCell" bundle:nil] forCellReuseIdentifier:MORankNoDataCell_ID];
  454. CGFloat topViewHeigth = [MORankTopView theViewHeight];
  455. _tableView.tableHeaderView = self.topView;
  456. [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
  457. make.top.offset(0);
  458. make.left.offset(0.0);
  459. make.height.mas_equalTo(topViewHeigth);
  460. make.width.mas_equalTo(SCREENWIDTH);
  461. }];
  462. WEAKSELF
  463. MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  464. weakSelf.isNeedUpdata = YES;
  465. [weakSelf listWillAppear];
  466. }];
  467. header.lastUpdatedTimeLabel.hidden = YES;
  468. header.stateLabel.hidden = YES;
  469. _tableView.mj_header = header;
  470. }
  471. return _tableView;
  472. }
  473. - (MORankTopView *)topView{
  474. if (!_topView) {
  475. _topView = [MORankTopView moRankTopView];
  476. _topView.hidden = YES;
  477. CGFloat topViewHeigth = [MORankTopView theViewHeight];
  478. _topView.height = topViewHeigth;
  479. WEAKSELF
  480. _topView.followSomeOneBlock = ^(MORanklist * _Nonnull listModel) {
  481. for (MORanklist *model in weakSelf.dataArr) {
  482. if([model.userBase.userProfile.id isEqualToString:listModel.userBase.userProfile.id]){
  483. model.userBase.follow = YES;
  484. }
  485. }
  486. };
  487. _topView.headBtnClickBlock = ^(MOUserBase * _Nonnull userBase) {
  488. weakSelf.headBtnBlock ? weakSelf.headBtnBlock(userBase) : nil;
  489. };
  490. _topView.backgroundColor = [MOTools colorWithHexString:@"#FFFFFF"];
  491. _topView.timeEndBlock = ^{
  492. weakSelf.isNeedUpdata = YES;
  493. [weakSelf listWillAppear];
  494. };
  495. }
  496. return _topView;
  497. }
  498. - (MORankCountdownTopView *)topTwoView{
  499. if(!_topTwoView){
  500. WEAKSELF
  501. _topTwoView = [[MORankCountdownTopView alloc] init];
  502. _topTwoView.timeEndBlock = ^{
  503. weakSelf.isNeedUpdata = YES;
  504. [weakSelf listWillAppear];
  505. };
  506. }
  507. return _topTwoView;
  508. }
  509. - (NSMutableArray *)dataArr{
  510. if(!_dataArr){
  511. _dataArr = [NSMutableArray array];
  512. }
  513. return _dataArr;
  514. }
  515. - (MORankCurrentView *)bottomView {
  516. if (!_bottomView) {
  517. _bottomView = [[MORankCurrentView alloc] init];
  518. WEAKSELF
  519. _bottomView.hitBlock = ^(MORankHit * _Nonnull model) {
  520. if (weakSelf.hitBlock) {
  521. weakSelf.hitBlock(model);
  522. }
  523. };
  524. }
  525. return _bottomView;
  526. }
  527. - (void)dealloc{
  528. MOLogV(@"MORankListTableView dealloc");
  529. if(_liveTimer){
  530. [_liveTimer invalidate];
  531. _liveTimer = nil;
  532. }
  533. }
  534. - (YYTimer *)liveTimer{
  535. if(!_liveTimer){
  536. _liveTimer = [YYTimer timerWithTimeInterval:1 target:self selector:@selector(oneSecondPassed) repeats:YES];
  537. }
  538. return _liveTimer;
  539. }
  540. - (MORankNoDataView *)noDataView {
  541. if (!_noDataView) {
  542. _noDataView = [[MORankNoDataView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENWIDTH)];
  543. }
  544. return _noDataView;
  545. }
  546. - (void)oneSecondPassed{
  547. MOLogV(@"MORankListTableView tenSecondPassed");
  548. if(self.typeTime == 4 && self.typeNum == 3){//直播间收益榜 && 小时榜
  549. if(self.isNewer){
  550. [self.topTwoView oneSecondPassed];
  551. }
  552. else{
  553. [self.topView oneSecondPassed];
  554. }
  555. }
  556. }
  557. @end