// // MOSendRedPacketView.m // MiMoLive // // Created by SuperC on 2024/6/12. // #import "MOSendRedPacketView.h" #import "MOSendRedPackeCell.h" #import "MOOpenCountdownView.h" #import "MORedPacketRuleView.h" #import "MORedPacketHistoryView.h" #import "MOTopUpVC.h" #import "MORedCellShowView.h" #import "MORedPackeQuantityView.h" #import "MORedPacketCustomView.h" #define kBgViewHeight kScaleWidth(583) @interface MOSendRedPacketView () @property (nonatomic, strong) UIView *backgroundView; @property (nonatomic, strong) UIView *contentView; @property (nonatomic, strong) UIImageView *bgImgView; @property (nonatomic, strong) UIButton *ruleButton; @property (nonatomic, strong) UIButton *historyButton; @property (nonatomic, strong) UILabel *tipTagLab; @property (nonatomic, strong) UIButton *sendBtn; @property (nonatomic, strong) NSArray *dataArr; @property (nonatomic, strong) MORedPacketRuleView *ruleView; @property (nonatomic, strong) MORedPacketHistoryView *historyView; @property (nonatomic, strong) MORedConfigData *configData; @property (nonatomic, strong) MOOpenCountdownView *bottomView; @property (nonatomic, assign) BOOL isKeyboardVisible; @property (nonatomic, assign) BOOL isAlreadySend; @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;//区分普通红包 / 全服红包 @property (nonatomic, strong) UIImageView *centerContainerView; @property (nonatomic, strong) UILabel *amountLabel; @property (nonatomic, strong) MORedCellShowView *collectionShowView; @property (nonatomic, strong) UILabel *quantityLabel; @property (nonatomic, strong) MORedPackeQuantityView *quantityView; @property (nonatomic, strong) UILabel *timeLabel; @property (nonatomic, strong) NSMutableArray *scope1Array;//普通红包 @property (nonatomic, strong) NSMutableArray *scope2Array;;//全服红包 @property (nonatomic, strong) UIView *bottomContentView; @property (nonatomic, strong) UIImageView *diamondIconView; @property (nonatomic, strong) UILabel *diamondLabel; @property (nonatomic, strong) UILabel *rechargeLab; @property (nonatomic, strong) UIImageView *arrowImageView; @property (nonatomic, strong) MORedSendConfigs *currentSelectedConfig;//当前选中的红包金额配置 @property (nonatomic, assign) NSInteger selectedQuantityIdx;//当前选中红包数量位置 @property (nonatomic, assign) CGFloat bottomSpacing;//底部显示间距差,全面屏和非全面屏的值不一样 //请求参数 /** 当前范围 1 普通 2全服 */ @property (nonatomic, assign) NSInteger currentScope; /** 1默认 2自定义 */ @property (nonatomic, assign) NSInteger type; /** 倒计时 分钟 */ @property (nonatomic, assign) NSInteger countdownNum; /** 红包数量 */ @property (nonatomic, assign) NSInteger quantityNum; /** 钻石数量 */ @property (nonatomic, assign) NSInteger zuanNum; /** 红包编号 */ @property (nonatomic, assign) double redCode; @end @implementation MOSendRedPacketView + (instancetype)moSendRedPacketView{ MOSendRedPacketView *view = [[MOSendRedPacketView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT)]; return view; } - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { [self initData]; [self setupUI]; } return self; } - (void)initData { self.currentScope = 1; self.type = 1; self.zuanNum = 0; self.quantityNum = 0; self.countdownNum = 0; self.isKeyboardVisible = NO; self.isAlreadySend = NO; self.bottomSpacing = kBottomSafeAreaInset > 0 ? 15.0 : 50.0; } - (void)setupUI { [self addSubview:self.backgroundView]; [self.backgroundView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(0); }]; [self addSubview:self.contentView]; [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(0); make.top.mas_equalTo(SCREENHEIGHT); make.height.mas_equalTo(kScaleWidth(583)); }]; [self.contentView addSubview:self.bgImgView]; [self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(0); }]; [self.contentView addSubview:self.ruleButton]; [self.ruleButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(kScaleWidth(74)); make.left.mas_equalTo(15); make.size.mas_equalTo(CGSizeMake(21, 21)); }]; [self.contentView addSubview:self.historyButton]; [self.historyButton mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.ruleButton); make.right.mas_equalTo(-15); make.size.mas_equalTo(CGSizeMake(21, 21)); }]; self.titleCategoryView.titles = @[NSLocalString(@"mimo_red_packet_normal_title"),NSLocalString(@"mimo_red_packet_all_title")]; CGFloat totalItemWidth = 283.0; self.titleCategoryView.layer.cornerRadius = 30.0 / 2.0; self.titleCategoryView.layer.masksToBounds = YES; self.titleCategoryView.cellSpacing = 0; self.titleCategoryView.cellWidth = totalItemWidth / self.titleCategoryView.titles.count; self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#FFFFFF" alpha:1.0]; self.titleCategoryView.titleSelectedColor = [MOTools colorWithHexString:@"#6B2800" alpha:1.0]; self.titleCategoryView.titleFont = [MOTextTools getTheFontWithSize:13.0 AndFontName:kNormalContentFontStr]; self.titleCategoryView.titleSelectedFont = [MOTextTools getTheFontWithSize:13.0 AndFontName:kNormalContentBlodFontStr]; self.titleCategoryView.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.2]; self.titleCategoryView.layer.borderColor = [MOTools colorWithHexString:@"#FFBB95"].CGColor; self.titleCategoryView.layer.borderWidth = 1; JXCategoryIndicatorBackgroundView *backgroundTwoView = [[JXCategoryIndicatorBackgroundView alloc] init]; backgroundTwoView.indicatorHeight = 30.0; backgroundTwoView.indicatorWidthIncrement = 0; backgroundTwoView.indicatorColor = [MOTools colorWithHexString:@"#FFEC85" alpha:1.0]; NSArray *colorTwoArr = @[[MOTools colorWithHexString:@"#FAEFA7"],[MOTools colorWithHexString:@"#FFB54C"]]; UIImage *imageTwo = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 142.0, 30.0) Colors:colorTwoArr GradientType:0]; UIImageView *imgTwoBgView = [[UIImageView alloc] init]; imgTwoBgView.contentMode = UIViewContentModeScaleToFill; [imgTwoBgView setImage:imageTwo]; [backgroundTwoView addSubview:imgTwoBgView]; [imgTwoBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(backgroundTwoView); }]; imgTwoBgView.layer.cornerRadius = 15; imgTwoBgView.layer.masksToBounds = YES; imgTwoBgView.layer.borderColor = [MOTools colorWithHexString:@"#FFBB95"].CGColor; imgTwoBgView.layer.borderWidth = 1; self.titleCategoryView.indicators = @[backgroundTwoView]; [self.contentView addSubview:self.titleCategoryView]; [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(kScaleWidth(114)); make.width.mas_equalTo(283); make.centerX.mas_equalTo(0); make.height.mas_equalTo(30); }]; [self.contentView addSubview:self.centerContainerView]; [self.centerContainerView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.titleCategoryView.mas_bottom).offset(kScaleWidth(15)); make.centerX.mas_equalTo(0); make.width.mas_equalTo(kScaleWidth(345)); make.height.mas_equalTo(kScaleWidth(320)); }]; [self.centerContainerView addSubview:self.amountLabel]; [self.amountLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.mas_equalTo(kScaleWidth(15)); }]; [self.centerContainerView addSubview:self.collectionShowView]; [self.collectionShowView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.amountLabel.mas_bottom).offset(kScaleWidth(10)); make.left.right.mas_equalTo(0); make.height.mas_equalTo(kScaleWidth(80)); }]; [self.centerContainerView addSubview:self.quantityLabel]; [self.quantityLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.collectionShowView.mas_bottom).offset(kScaleWidth(15)); make.left.mas_equalTo(kScaleWidth(15)); }]; [self.centerContainerView addSubview:self.quantityView]; [self.quantityView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.quantityLabel.mas_bottom).offset(kScaleWidth(10)); make.left.right.mas_equalTo(0); make.height.mas_equalTo(kScaleWidth(32)); }]; [self.centerContainerView addSubview:self.timeLabel]; [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.quantityView.mas_bottom).offset(kScaleWidth(15)); make.left.mas_equalTo(kScaleWidth(15)); }]; [self.centerContainerView addSubview:self.bottomView]; [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.timeLabel.mas_bottom).offset(kScaleWidth(10)); make.left.right.mas_equalTo(0); make.height.mas_equalTo(kScaleWidth(32)); }]; [self.centerContainerView addSubview:self.tipTagLab]; [self.tipTagLab mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(0); make.bottom.mas_equalTo(-35); }]; [self.contentView addSubview:self.sendBtn]; [self.sendBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(0); make.centerY.equalTo(self.centerContainerView.mas_bottom); make.size.mas_equalTo(CGSizeMake(kScaleWidth(244), kScaleWidth(59))); }]; [self.contentView addSubview:self.bottomContentView]; [self.bottomContentView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.sendBtn.mas_bottom).offset(5); make.left.right.bottom.mas_equalTo(0); }]; [self.bottomContentView addSubview:self.diamondIconView]; [self.diamondIconView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(10); make.left.mas_equalTo(15); make.size.mas_equalTo(CGSizeMake(16, 12)); }]; [self.bottomContentView addSubview:self.diamondLabel]; [self.diamondLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.diamondIconView.mas_right).offset(5); make.centerY.equalTo(self.diamondIconView); }]; [self.bottomContentView addSubview:self.arrowImageView]; [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.diamondIconView); make.right.mas_equalTo(-15); make.size.mas_equalTo(CGSizeMake(6, 11)); }]; [self.bottomContentView addSubview:self.rechargeLab]; [self.rechargeLab mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.diamondIconView); make.right.equalTo(self.arrowImageView.mas_left).offset(-5); }]; } - (void)ruleBtnClick { [self addSubview:self.ruleView]; [self.ruleView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self).offset(0); make.width.mas_equalTo(@(SCREENWIDTH)); make.height.mas_equalTo(kBgViewHeight - self.bottomSpacing); make.top.equalTo(self.mas_bottom); }]; [self setNeedsLayout]; [self layoutIfNeeded]; [self.ruleView showRedPacketRuleView]; } - (void)historyBtnClick { [self addSubview:self.historyView]; [self.historyView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self).offset(0); make.width.mas_equalTo(SCREENWIDTH); make.height.mas_equalTo(kBgViewHeight - self.bottomSpacing); make.top.equalTo(self.mas_bottom); }]; [self setNeedsLayout]; [self layoutIfNeeded]; [self.historyView showRedPacketHistoryView]; } - (void)rechargeClick { WEAKSELF UIViewController *currentVC = [MOTools currentViewController]; MOTopUpVC *vc = [[MOTopUpVC alloc] init]; vc.topUpSuccesssBlock = ^(MOMeDataInfo * _Nonnull model) { weakSelf.diamondLabel.text = [NSString stringWithFormat:@"%.f",model.userWallet.diamond]; }; [currentVC.navigationController pushViewController:vc animated:YES]; } //发红包 - (void)sendRedPackedBtnClick { if(self.dataArr.count == 0){ return; } if(self.type == 2){ MORedSendConfigs *model = self.dataArr.firstObject; if(self.quantityNum < model.minNum){ [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_red_packet_min_red_num_tip")]; return; } if(self.quantityNum > model.maxNum){ [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_red_packet_max_red_num_tip")]; return; } if(self.zuanNum < model.minAmount){ [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_red_packet_min_red_diamond_num_tip")]; return; } } if(self.roomId.length == 0){ return; } if(self.isAlreadySend == YES){ return; } self.isAlreadySend = YES; WEAKSELF NSDictionary *dict = @{@"roomId":self.roomId, @"configCode":@(self.redCode), @"num":@(self.quantityNum), @"amount":@(self.zuanNum), @"delayMinutes":@(self.countdownNum)}; [kHttpManager toSendTheRedEnvelopeConfigWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) { if(kCode_Success){ // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]); [weakSelf dismissSendRedPacketView]; NSDictionary *backDict = data[@"data"]; NSInteger currentDiamond = [[MODataManager objectOrNilForKey:@"walletDiamonds" fromDictionary:backDict] integerValue]; weakSelf.diamondLabel.text = [NSString stringWithFormat:@"%zd",currentDiamond]; MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo]; userInfoData.userWallet.diamond = currentDiamond; [[MODataCache sharedYYCache] setObject:userInfoData forKey:kMineUserInfo]; } else{ self.isAlreadySend = NO; MOLogV(@"toSendTheRedEnvelopeConfigWithParams 接口报错了"); NSInteger code = [data[@"code"] integerValue]; if(code != 30001){ //没钱, 提示充值 kShowNetError(data) } } }]; } - (void)showSendRedPacketView{ [UIView animateWithDuration:0.3 animations:^ { self.contentView.transform = CGAffineTransformMakeTranslation(0, -kBgViewHeight + self.bottomSpacing); }]; //不能滑动 SendNotification(@"MOShowLivePagesVCCannotScroll") [self toGetTheRedPacketConfig]; } - (void)dismissSendRedPacketView{ //完成下移动画 [UIView animateWithDuration:0.3 animations:^ { self.contentView.transform = CGAffineTransformIdentity; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; //可以滑动 SendNotification(@"MOShowLivePagesVCCanScroll") if (self.dismissBlock) { self.dismissBlock(); } } - (void)toGetTheRedPacketConfig{ WEAKSELF [kHttpManager toGetTheRedEnvelopeConfigWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) { if(kCode_Success){ MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]); weakSelf.configData = [MORedConfigData modelObjectWithDictionary:data[@"data"]]; [weakSelf handleData]; } else{ MOLogV(@"toGetTheRedPacketConfig 接口报错了"); kShowNetError(data) } }]; } - (void)handleData { [self.configData.redSendConfigs enumerateObjectsUsingBlock:^(MORedSendConfigs *_Nonnull object, NSUInteger idx, BOOL * _Nonnull stop) { if (object.scope == 1) {//普通红包 [self.scope1Array addObject:object]; } else if (object.scope == 2) {//全服红包 [self.scope2Array addObject:object]; } }]; [self updataAllUIWithProperty]; } - (void)updataAllUIWithProperty{ NSMutableArray *tempArr = [NSMutableArray array]; self.currentSelectedConfig.customAmountValue = 0; self.currentSelectedConfig.customQuantityValue = 0; if(self.currentScope == 1){//普通红包 //普通红包 [self.scope1Array enumerateObjectsUsingBlock:^(MORedSendConfigs * _Nonnull object, NSUInteger idx, BOOL * _Nonnull stop) { object.isSelect = NO; if (object.type == 1) {//默认红包 object.iconName = [NSString stringWithFormat:@"icon_diamone_%zd", idx]; } else {//自定义 object.isCustom = YES; object.customAmountValue = 0; object.iconName = @"icon_red_packet_edit_big"; } [tempArr addObject:object]; }]; } else {//全服红包 [self.scope2Array enumerateObjectsUsingBlock:^(MORedSendConfigs * _Nonnull object, NSUInteger idx, BOOL * _Nonnull stop) { object.isSelect = NO; if (object.type == 1) {//默认红包 object.iconName = [NSString stringWithFormat:@"icon_diamone_%zd", idx]; } else {//自定义 object.isCustom = YES; object.iconName = @"icon_red_packet_edit_big"; } [tempArr addObject:object]; }]; } self.tipTagLab.text = [NSString stringWithFormat:NSLocalString(@"mimo_red_packet_tip_tag_title"),self.configData.refundMinutes]; if(tempArr.count > 0){ MORedSendConfigs *firstObject = tempArr.firstObject; firstObject.isSelect = YES; self.currentSelectedConfig = firstObject; self.redCode = firstObject.code; NSArray *optionNumArray = (NSArray *)firstObject.optionalNum; self.quantityNum = [optionNumArray.firstObject integerValue]; self.zuanNum = firstObject.minAmount; if(self.type == 2){ self.quantityNum = 0; self.zuanNum = 0; } self.quantityView.configModel = firstObject; } self.bottomView.startDelayMinutes = self.configData.startDelayMinutes; if(self.configData.startDelayMinutes.count > 0){ NSNumber *object = self.configData.startDelayMinutes.firstObject; NSInteger num = [object integerValue]; self.countdownNum = num; } self.dataArr = [tempArr copy]; self.collectionShowView.dataArr = [tempArr copy]; } // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。 - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{ MOLogV(@"变换了"); if(categoryView == self.titleCategoryView){ if(index == 0){ self.currentScope = 1; } else{ self.currentScope = 2; } } if(self.configData){ [self updataAllUIWithProperty]; } } #pragma mark - Lazy - (UIView *)backgroundView { if (!_backgroundView) { _backgroundView = [[UIView alloc] init]; _backgroundView.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.5]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissSendRedPacketView)]; [_backgroundView addGestureRecognizer:tap]; } return _backgroundView; } - (UIView *)contentView { if (!_contentView) { _contentView = [[UIView alloc] init]; } return _contentView; } - (UIImageView *)bgImgView { if (!_bgImgView) { _bgImgView = [[UIImageView alloc] init]; _bgImgView.image = [UIImage imageNamed:@"icon_red_envelope_bg"]; } return _bgImgView; } - (UIButton *)ruleButton { if (!_ruleButton) { _ruleButton = [[UIButton alloc] init]; [_ruleButton addTarget:self action:@selector(ruleBtnClick) forControlEvents:UIControlEventTouchUpInside]; [_ruleButton setImage:[UIImage imageNamed:@"icon_rule_yellow"] forState:UIControlStateNormal]; } return _ruleButton; } - (UIButton *)historyButton { if (!_historyButton) { _historyButton = [[UIButton alloc] init]; [_historyButton addTarget:self action:@selector(historyBtnClick) forControlEvents:UIControlEventTouchUpInside]; [_historyButton setImage:[UIImage imageNamed:@"icon_history_yellow"] forState:UIControlStateNormal]; } return _historyButton; } - (MORedPacketRuleView *)ruleView{ if(!_ruleView){ _ruleView = [MORedPacketRuleView moRedPacketRuleView]; } return _ruleView; } - (MORedPacketHistoryView *)historyView{ if(!_historyView){ _historyView = [MORedPacketHistoryView moRedPacketHistoryView]; } return _historyView; } - (MOOpenCountdownView *)bottomView{ if(!_bottomView){ _bottomView = [MOOpenCountdownView moOpenCountdownView]; WEAKSELF _bottomView.countdownClickBlock = ^(NSInteger mins) { weakSelf.countdownNum = mins; }; } return _bottomView; } - (JXCategoryTitleView *)titleCategoryView{ if(!_titleCategoryView){ _titleCategoryView = [[JXCategoryTitleView alloc] init]; _titleCategoryView.delegate = self; } return _titleCategoryView; } - (UIImageView *)centerContainerView { if (!_centerContainerView) { _centerContainerView = [[UIImageView alloc] init]; NSArray *colorArr = @[[MOTools colorWithHexString:@"#FFFFFF"],[MOTools colorWithHexString:@"#FFF1E7"]]; UIImage *bgImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, kScaleWidth(345), kScaleWidth(331)) Colors:colorArr GradientType:1]; _centerContainerView.image = bgImage; _centerContainerView.layer.masksToBounds = YES; _centerContainerView.layer.cornerRadius = 16; _centerContainerView.layer.borderColor = [MOTools colorWithHexString:@"#FFFFFF"].CGColor; _centerContainerView.layer.borderWidth = 2; _centerContainerView.userInteractionEnabled = YES; } return _centerContainerView; } - (UILabel *)amountLabel { if (!_amountLabel) { _amountLabel = [[UILabel alloc] init]; _amountLabel.textColor = [MOTools colorWithHexString:@"#75360E"]; _amountLabel.font = [MOTextTools getTheFontWithSize:13.0 AndFontName:kNormalContentBlodFontStr]; _amountLabel.text = NSLocalString(@"mimo_send_red_envelope_amount_title"); } return _amountLabel; } - (MORedCellShowView *)collectionShowView{ if(!_collectionShowView){ _collectionShowView = [[MORedCellShowView alloc] initTheView]; WEAKSELF _collectionShowView.didSelectItemAtIndexPath = ^(MORedSendConfigs * _Nonnull cellModel) { if (self.currentSelectedConfig == cellModel && !cellModel.isCustom) {//选中的不是自定义选项并且和之前是同一个,不做处理 return; } //刷新数量UI // weakSelf.quantityView.configModel.customQuantityValue = 0; // weakSelf.quantityView.configModel = cellModel; // weakSelf.quantityNum = cellModel.minNum; if (cellModel.isCustom) {//自定义红包金额 MORedPacketCustomView *customView = [[MORedPacketCustomView alloc] init]; customView.confirmBlock = ^(NSInteger result) { cellModel.iconName = @"icon_diamone_2"; cellModel.customAmountValue = result; cellModel.isSelect = YES; weakSelf.currentSelectedConfig = cellModel; [weakSelf.collectionShowView reloadView]; weakSelf.zuanNum = result; weakSelf.redCode = cellModel.code; }; customView.cancelBlock = ^{ cellModel.isSelect = NO; weakSelf.currentSelectedConfig.isSelect = YES; [weakSelf.collectionShowView reloadView]; }; customView.type = CustomRedPacketTypeAmount; customView.config = cellModel; [customView show]; } else {//选中默认的红包金额 weakSelf.currentSelectedConfig = cellModel; weakSelf.redCode = cellModel.code; weakSelf.zuanNum = cellModel.minAmount; } }; } return _collectionShowView; } - (UILabel *)quantityLabel { if (!_quantityLabel) { _quantityLabel = [[UILabel alloc] init]; _quantityLabel.textColor = [MOTools colorWithHexString:@"#75360E"]; _quantityLabel.font = [MOTextTools getTheFontWithSize:13.0 AndFontName:kNormalContentBlodFontStr]; _quantityLabel.text = NSLocalString(@"mimo_send_red_envelope_quantity_title"); } return _quantityLabel; } - (MORedPackeQuantityView *)quantityView { if (!_quantityView) { _quantityView = [[MORedPackeQuantityView alloc] init]; WEAKSELF _quantityView.didSelectItemAtIndexPath = ^(NSInteger quantity, NSInteger index) { if (quantity == -1) {//自定义数量 MORedPacketCustomView *customView = [[MORedPacketCustomView alloc] init]; customView.type = CustomRedPacketTypeQuantity; customView.config = weakSelf.currentSelectedConfig; customView.confirmBlock = ^(NSInteger result) { weakSelf.quantityNum = result; weakSelf.quantityView.configModel.customQuantityValue = result; [weakSelf.quantityView reloadView]; }; customView.cancelBlock = ^{ weakSelf.quantityView.selectedIdx = weakSelf.selectedQuantityIdx; [weakSelf.quantityView reloadView]; }; [customView show]; } else { weakSelf.quantityNum = quantity; weakSelf.selectedQuantityIdx = index; } }; } return _quantityView; } - (UILabel *)timeLabel { if (!_timeLabel) { _timeLabel = [[UILabel alloc] init]; _timeLabel.textColor = [MOTools colorWithHexString:@"#75360E"]; _timeLabel.font = [MOTextTools getTheFontWithSize:13.0 AndFontName:kNormalContentBlodFontStr]; _timeLabel.text = NSLocalString(@"mimo_send_red_envelope_open_title"); } return _timeLabel; } - (NSMutableArray *)scope1Array { if (!_scope1Array) { _scope1Array = [NSMutableArray array]; } return _scope1Array; } - (NSMutableArray *)scope2Array { if (!_scope2Array) { _scope2Array = [NSMutableArray array]; } return _scope2Array; } - (UILabel *)tipTagLab { if (!_tipTagLab) { _tipTagLab = [[UILabel alloc] init]; [_tipTagLab setFont:[MOTextTools getTheFontWithSize:11.0 AndFontName:kNormalContentFontStr]]; _tipTagLab.textColor = [MOTools colorWithHexString:@"#75360E"]; } return _tipTagLab; } - (UIButton *)sendBtn { if (!_sendBtn) { _sendBtn = [[UIButton alloc] init]; [_sendBtn setFont:[MOTextTools getTheFontWithSize:15.0 AndFontName:kNormalContentBlodFontStr]]; [_sendBtn setTitleColor:[MOTools colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal]; [_sendBtn setBackgroundImage:[UIImage imageNamed:@"icon_send_red_packet_bg"] forState:UIControlStateNormal]; [_sendBtn setTitle:NSLocalString(@"mimo_red_packet_send_btn_title") forState:UIControlStateNormal]; [_sendBtn addTarget:self action:@selector(sendRedPackedBtnClick) forControlEvents:UIControlEventTouchUpInside]; } return _sendBtn; } - (UIView *)bottomContentView { if (!_bottomContentView) { _bottomContentView = [[UIView alloc] init]; _bottomContentView.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.3]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(rechargeClick)]; [_bottomContentView addGestureRecognizer:tap]; } return _bottomContentView; } - (UIImageView *)diamondIconView { if (!_diamondIconView) { _diamondIconView = [[UIImageView alloc] init]; _diamondIconView.image = [UIImage imageNamed:@"icon_red_list_diamond"]; } return _diamondIconView; } - (UILabel *)diamondLabel { if (!_diamondLabel) { _diamondLabel = [[UILabel alloc] init]; _diamondLabel.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr]; _diamondLabel.textColor = [MOTools colorWithHexString:@"#FFCC00"]; MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo]; _diamondLabel.text = [MOTextTools formatNumberDecimalValue:userInfoData.userWallet.diamond]; } return _diamondLabel; } - (UILabel *)rechargeLab { if (!_rechargeLab) { _rechargeLab = [[UILabel alloc] init]; _rechargeLab.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr]; _rechargeLab.textColor = [MOTools colorWithHexString:@"#FFCC00"]; _rechargeLab.text = NSLocalString(@"mimo_red_packet_rechange_title"); } return _rechargeLab; } - (UIImageView *)arrowImageView { if (!_arrowImageView) { _arrowImageView = [[UIImageView alloc] init]; _arrowImageView.image = [UIImage imageNamed:@"icon_arrow_yellow"]; } return _arrowImageView; } @end