| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- //
- // MOExploreMenuView.m
- // MiMoLive
- //
- // Created by SuperC on 2023/11/15.
- //
- #import "MOExploreMenuView.h"
- #import "MOTopsBasedata.h"
- #import "MOThemeManager.h"
- #import "MORankTopThreeView.h"
- @interface MOExploreMenuView ()
- @property (nonatomic, strong) MORankTopThreeView *revenueView;//收入
- @property (nonatomic, strong) MORankTopThreeView *wealthView;//财富
- @property (nonatomic, strong) MORankTopThreeView *pkView;//pk
- //@property (nonatomic, strong) UIImageView *wealthView;//财富
- @property (nonatomic, strong) MOTopsBasedata *baseModel;
- @end
- @implementation MOExploreMenuView
- - (instancetype)init {
- if (self = [super init]) {
- [self setupUI];
- }
- return self;
- }
- - (void)setupUI {
-
- CGFloat spacing = 8;
- CGFloat margin = 12;
- CGFloat totalHeight = kScaleWidth(132);
- CGFloat itemWidth = (SCREENWIDTH - margin * 2 - spacing * 2) / 3.0; // 三列
- // CGFloat halfHeight = (totalHeight - spacing) / 2.0; // 卡片3、4高度
-
- UIView *containerView = [[UIView alloc] init];
- [self addSubview:containerView];
- [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self).insets(UIEdgeInsetsMake(0, margin, 0, margin));
- make.top.mas_equalTo(0);
- make.height.mas_equalTo(totalHeight);
- }];
- //收入
- [containerView addSubview:self.revenueView];
- [self.revenueView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.equalTo(containerView);
- make.width.mas_equalTo(itemWidth);
- make.height.mas_equalTo(totalHeight);
- }];
- //财富
- [containerView addSubview:self.wealthView];
- [self.wealthView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(containerView);
- make.left.equalTo(self.revenueView.mas_right).offset(spacing);
- make.width.mas_equalTo(itemWidth);
- make.height.mas_equalTo(totalHeight);
- }];
- //pk
- [containerView addSubview:self.pkView];
- [self.pkView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(containerView);
- make.left.equalTo(self.wealthView.mas_right).offset(spacing);
- make.width.mas_equalTo(itemWidth);
- make.height.mas_equalTo(totalHeight);
- }];
- }
- - (void)toGetTheHttpData{
- WEAKSELF
- [kHttpManager toGetTheRankTopsWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"toGetTheRank: %@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- weakSelf.baseModel = [MOTopsBasedata modelObjectWithDictionary:data[@"data"]];
- [weakSelf refreshAllTopsView];
- }
- else{
- MOLogV(@"toGetTheHttpData 接口报错了");
- kShowNetError(data)
- }
- }];
- }
- - (void)refreshAllTopsView {
- self.revenueView.data = self.baseModel.incomeData;
- self.wealthView.data = self.baseModel.outcomeData;
- self.pkView.data = self.baseModel.pksData;
- }
- - (void)revenueBtnClick {
- self.revenueBlock ? self.revenueBlock() : nil;
- }
- - (void)pkBtnClick {
- self.pkBlock ? self.pkBlock() : nil;
- }
- - (void)wealthBtnClick {
- self.wealthBlock ? self.wealthBlock() : nil;
- }
- - (MORankTopThreeView *)revenueView {
- if (!_revenueView) {
- _revenueView = [[MORankTopThreeView alloc] init];
- _revenueView.layer.cornerRadius = 16;
- _revenueView.layer.masksToBounds = YES;
- _revenueView.viewType = MORankTopViewTypeRevenue;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(revenueBtnClick)];
- [_revenueView addGestureRecognizer:tap];
- }
- return _revenueView;
- }
- - (MORankTopThreeView *)wealthView {
- if (!_wealthView) {
- _wealthView = [[MORankTopThreeView alloc] init];
- _wealthView.layer.cornerRadius = 16;
- _wealthView.layer.masksToBounds = YES;
- _wealthView.viewType = MORankTopViewTypeWealth;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(wealthBtnClick)];
- [_wealthView addGestureRecognizer:tap];
- }
- return _wealthView;
- }
- - (MORankTopThreeView *)pkView {
- if (!_pkView) {
- _pkView = [[MORankTopThreeView alloc] init];
- _pkView.layer.cornerRadius = 16;
- _pkView.layer.masksToBounds = YES;
- _pkView.viewType = MORankTopViewTypePk;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pkBtnClick)];
- [_pkView addGestureRecognizer:tap];
- }
- return _pkView;
- }
- @end
|