MOExploreMenuView.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // MOExploreMenuView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/11/15.
  6. //
  7. #import "MOExploreMenuView.h"
  8. #import "MOTopsBasedata.h"
  9. #import "MOThemeManager.h"
  10. #import "MORankTopThreeView.h"
  11. @interface MOExploreMenuView ()
  12. @property (nonatomic, strong) MORankTopThreeView *revenueView;//收入
  13. @property (nonatomic, strong) MORankTopThreeView *wealthView;//财富
  14. @property (nonatomic, strong) MORankTopThreeView *pkView;//pk
  15. //@property (nonatomic, strong) UIImageView *wealthView;//财富
  16. @property (nonatomic, strong) MOTopsBasedata *baseModel;
  17. @end
  18. @implementation MOExploreMenuView
  19. - (instancetype)init {
  20. if (self = [super init]) {
  21. [self setupUI];
  22. }
  23. return self;
  24. }
  25. - (void)setupUI {
  26. CGFloat spacing = 8;
  27. CGFloat margin = 12;
  28. CGFloat totalHeight = kScaleWidth(132);
  29. CGFloat itemWidth = (SCREENWIDTH - margin * 2 - spacing * 2) / 3.0; // 三列
  30. // CGFloat halfHeight = (totalHeight - spacing) / 2.0; // 卡片3、4高度
  31. UIView *containerView = [[UIView alloc] init];
  32. [self addSubview:containerView];
  33. [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.right.equalTo(self).insets(UIEdgeInsetsMake(0, margin, 0, margin));
  35. make.top.mas_equalTo(0);
  36. make.height.mas_equalTo(totalHeight);
  37. }];
  38. //收入
  39. [containerView addSubview:self.revenueView];
  40. [self.revenueView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.left.equalTo(containerView);
  42. make.width.mas_equalTo(itemWidth);
  43. make.height.mas_equalTo(totalHeight);
  44. }];
  45. //财富
  46. [containerView addSubview:self.wealthView];
  47. [self.wealthView mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.top.equalTo(containerView);
  49. make.left.equalTo(self.revenueView.mas_right).offset(spacing);
  50. make.width.mas_equalTo(itemWidth);
  51. make.height.mas_equalTo(totalHeight);
  52. }];
  53. //pk
  54. [containerView addSubview:self.pkView];
  55. [self.pkView mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.equalTo(containerView);
  57. make.left.equalTo(self.wealthView.mas_right).offset(spacing);
  58. make.width.mas_equalTo(itemWidth);
  59. make.height.mas_equalTo(totalHeight);
  60. }];
  61. }
  62. - (void)toGetTheHttpData{
  63. WEAKSELF
  64. [kHttpManager toGetTheRankTopsWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  65. if(kCode_Success){
  66. MOLogV(@"toGetTheRank: %@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  67. weakSelf.baseModel = [MOTopsBasedata modelObjectWithDictionary:data[@"data"]];
  68. [weakSelf refreshAllTopsView];
  69. }
  70. else{
  71. MOLogV(@"toGetTheHttpData 接口报错了");
  72. kShowNetError(data)
  73. }
  74. }];
  75. }
  76. - (void)refreshAllTopsView {
  77. self.revenueView.data = self.baseModel.incomeData;
  78. self.wealthView.data = self.baseModel.outcomeData;
  79. self.pkView.data = self.baseModel.pksData;
  80. }
  81. - (void)revenueBtnClick {
  82. self.revenueBlock ? self.revenueBlock() : nil;
  83. }
  84. - (void)pkBtnClick {
  85. self.pkBlock ? self.pkBlock() : nil;
  86. }
  87. - (void)wealthBtnClick {
  88. self.wealthBlock ? self.wealthBlock() : nil;
  89. }
  90. - (MORankTopThreeView *)revenueView {
  91. if (!_revenueView) {
  92. _revenueView = [[MORankTopThreeView alloc] init];
  93. _revenueView.layer.cornerRadius = 16;
  94. _revenueView.layer.masksToBounds = YES;
  95. _revenueView.viewType = MORankTopViewTypeRevenue;
  96. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(revenueBtnClick)];
  97. [_revenueView addGestureRecognizer:tap];
  98. }
  99. return _revenueView;
  100. }
  101. - (MORankTopThreeView *)wealthView {
  102. if (!_wealthView) {
  103. _wealthView = [[MORankTopThreeView alloc] init];
  104. _wealthView.layer.cornerRadius = 16;
  105. _wealthView.layer.masksToBounds = YES;
  106. _wealthView.viewType = MORankTopViewTypeWealth;
  107. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(wealthBtnClick)];
  108. [_wealthView addGestureRecognizer:tap];
  109. }
  110. return _wealthView;
  111. }
  112. - (MORankTopThreeView *)pkView {
  113. if (!_pkView) {
  114. _pkView = [[MORankTopThreeView alloc] init];
  115. _pkView.layer.cornerRadius = 16;
  116. _pkView.layer.masksToBounds = YES;
  117. _pkView.viewType = MORankTopViewTypePk;
  118. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pkBtnClick)];
  119. [_pkView addGestureRecognizer:tap];
  120. }
  121. return _pkView;
  122. }
  123. @end