| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- //
- // MOGoldBeanViewController.m
- // MiMoLive
- //
- // Created by MiMo on 2025/8/25.
- //
- #import "MOGoldBeanViewController.h"
- #import "MOGoldBeanData.h"
- #import "MOGoldBeanItemView.h"
- #import "MOExhangeDiamondView.h"
- #import "MOExhangeCashView.h"
- #import "MOWebViewController.h"
- @interface MOGoldBeanViewController ()
- @property (nonatomic, strong) UIButton *goldBeanButton;
- @property (nonatomic, strong) MOGoldBeanItemView *diamondItemView;
- @property (nonatomic, strong) MOGoldBeanItemView *coinItemView;
- @property (nonatomic, strong) MOGoldBeanData *dataModel;
- @end
- @implementation MOGoldBeanViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setupUI];
- [self loadData];
- }
- - (void)loadData {
- WEAKSELF
- [kHttpManager getGoldBeanInfoWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if (kCode_Success) {
- MOLogV(@"getGoldBean: %@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- NSDictionary *baseDict = data[@"data"];
- MOGoldBeanData *goldBeanData = [MOGoldBeanData modelWithJSON:baseDict];
-
- weakSelf.dataModel = goldBeanData;
-
- [weakSelf.goldBeanButton setTitle:[NSString stringWithFormat:@"%zd", goldBeanData.amount] forState:UIControlStateNormal];
-
- self.coinItemView.hidden = YES;
- if (goldBeanData.convertCash) {
- self.coinItemView.hidden = NO;
- }
-
- self.diamondItemView.hidden = YES;
- if (goldBeanData.convertDiamond) {
- self.diamondItemView.hidden = NO;
- }
- }
- }];
- }
- - (void)setupUI {
- self.view.backgroundColor = [UIColor clearColor];
-
- [self.view addSubview:self.goldBeanButton];
- [self.goldBeanButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(20);
- make.height.mas_equalTo(37);
- make.left.mas_equalTo(10);
- make.right.mas_equalTo(-10);
- }];
-
- [self.view addSubview:self.diamondItemView];
- [self.diamondItemView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.goldBeanButton.mas_bottom).offset(20);
- make.left.mas_equalTo(12);
- make.right.mas_equalTo(-12);
- make.height.mas_equalTo(60);
- }];
-
- [self.view addSubview:self.coinItemView];
- [self.coinItemView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.diamondItemView.mas_bottom).offset(8);
- make.left.mas_equalTo(12);
- make.right.mas_equalTo(-12);
- make.height.mas_equalTo(60);
- }];
- }
- //兑换钻石
- - (void)diamondItemViewAction {
- MOExhangeDiamondView *exchangeDiamondView = [[MOExhangeDiamondView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT)];
- WEAKSELF
- exchangeDiamondView.exchangeSuccessBlock = ^{
- [weakSelf loadData];
- if (weakSelf.exchangeSuccessBlock) {
- weakSelf.exchangeSuccessBlock();
- }
- };
- exchangeDiamondView.dataModel = self.dataModel;
- [exchangeDiamondView show];
- }
- //收益改变
- - (void)coinItemViewAction {
- if (self.dataModel.needBindBankCard) {
- MOWebViewController *vc = [[MOWebViewController alloc] init];
- NSString *urlStr = [NSString stringWithFormat:@"%@/#/withdrawCenterIndex",kNetPath_Web_Base];
- vc.webUrl = [NSURL URLWithString:urlStr];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController mo_pushViewController:vc animated:YES];
- WEAKSELF
- vc.closeViewBlock = ^{
- [weakSelf loadData];
- };
-
- return;
- }
- MOExhangeCashView *exchangeCashView = [[MOExhangeCashView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT)];
- WEAKSELF
- exchangeCashView.exchangeSuccessBlock = ^{
- [weakSelf loadData];
- };
- exchangeCashView.dataModel = self.dataModel;
- [exchangeCashView show];
- }
- - (UIButton *)goldBeanButton {
- if (!_goldBeanButton) {
- _goldBeanButton = [[UIButton alloc] init];
- [_goldBeanButton setImage:[UIImage imageNamed:@"icon_gold_bean"] forState:UIControlStateNormal];
- _goldBeanButton.titleLabel.font = [MOTextTools poppinsSemiBoldFont:30];
- [_goldBeanButton setTitleColor:kBaseTextColor_1 forState:UIControlStateNormal];
- _goldBeanButton.userInteractionEnabled = NO;
- _goldBeanButton.titleLabel.adjustsFontSizeToFitWidth = YES;
- }
- return _goldBeanButton;
- }
- - (MOGoldBeanItemView *)diamondItemView {
- if (!_diamondItemView) {
- _diamondItemView = [[MOGoldBeanItemView alloc] initWithIconName:@"icon_gold_diamond" title:NSLocalString(@"A90002")];
- _diamondItemView.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(diamondItemViewAction)];
- [_diamondItemView addGestureRecognizer:tap];
- }
- return _diamondItemView;
- }
- - (MOGoldBeanItemView *)coinItemView {
- if (!_coinItemView) {
- _coinItemView = [[MOGoldBeanItemView alloc] initWithIconName:@"icon_gold_coin" title:NSLocalString(@"A90003")];
- _coinItemView.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(coinItemViewAction)];
- [_coinItemView addGestureRecognizer:tap];
- }
- return _coinItemView;
- }
- @end
|