| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131 |
- //
- // MOGiftListView.m
- // MiMoLive
- //
- // Created by SuperC on 2023/11/23.
- //
- #import "MOGiftListView.h"
- #import "JXCategoryView.h"
- #import "MOGiftCollectionView.h"
- #import "MOGiftUserView.h"
- #import "MOStripeView.h"
- #import "MOGuideMaskView.h"
- #import "MOShowBubbleTool.h"
- #import "MOExpProgressView.h"//经验View
- #import "MOCustomGiftNumView.h"//自定义数量view
- #import "MOGiftListBagView.h"//背包view
- #import "MORemindAlertView.h"
- #import "MOBlindBoxTool.h"
- #import "MOBlindboxLottery.h"
- #import "MOShopList.h"
- #import "MOPropInfo.h"
- @interface MOGiftListView ()<MOGiftBottomMenuViewDelegate,
- MOGiftPanelsViewDelegate, MOGiftListViewModelDelegate,
- MOGiftComboViewDelegate>
- @property (strong, nonatomic) UIView *bgView;
- @property (strong, nonatomic) MASConstraint *bgViewHeight;
- @property (strong, nonatomic) UIView *bottomView;
- @property (strong, nonatomic) MASConstraint *bottomViewTop;
- @property (strong, nonatomic) UIImageView *bgImgView;
- @property (nonatomic, assign) NSInteger category;
- @property (nonatomic, strong) MOBaseLevelView *levelImgView;
- @property (nonatomic, strong) BigBtn *nextLevelBtn;
- @property (nonatomic, strong) BigBtn *vipBtn;
- @property (nonatomic, strong) BigBtn *zuanTagBtn;
- @property (nonatomic, strong) UILabel *expTipLab;
- @property (nonatomic, strong) MOGiftUserView *giftUserView;
- //震动反馈
- @property (nonatomic, strong) UIImpactFeedbackGenerator *generator;
- @property (nonatomic, strong) MOExpProgressView *expView;//经验View
- @property (nonatomic, strong) MOCustomGiftNumView *customNumView;//自定义礼物数量view
- @property (nonatomic, strong) MOGiftListBagView *bagView;//背包view
- @property (nonatomic, strong) UIImageView *susuImageView;
- @property (nonatomic, assign) MOBlindBoxRecordType blindBoxType;//盲盒礼物选中的处理方式
- @property (nonatomic, assign) BOOL showBlindBoxGiftAlert;//是否展示盲盒礼盒礼物选中的弹窗
- @property (nonatomic, strong) MOGiftListViewModel *listViewModel;
- @property (nonatomic, strong) MOGiftPanelsView* giftPanelsView;
- @property (nonatomic, strong) MOGiftBottomMenuView *bottomMenuView;
- @property (nonatomic, strong) MOGiftComboView *comboView;
- @property (nonatomic, strong) MOShopList *selectedProp;
- @end
- @implementation MOGiftListView
- - (instancetype)initWith:(MOGiftListViewModel *)listViewModel {
- self = [super init];
- if (self) {
- self.listViewModel = listViewModel;
- [self setupViews];
- [listViewModel addObserver:self];
- }
- return self;
- }
- - (void)setupViews {
- UIButton *dismiss = [UIButton new];
- [dismiss addTarget:self action:@selector(dismissBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:dismiss];
- [dismiss mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- }];
-
- self.bgView = [UIView new];
- [self addSubview:self.bgView];
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.trailing.equalTo(self);
- make.bottom.equalTo(self);
- make.height.equalTo(@(kScaleWidth(430.0)));
- }];
-
- self.bgImgView = [UIImageView new];
- [self.bgView addSubview:self.bgImgView];
- [self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.bgView);
- }];
-
- self.bottomView = [UIView new];
- [self.bgView addSubview:self.bottomView];
- [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.trailing.bottom.equalTo(self.bgView);
- self.bottomViewTop = make.top.equalTo(self.bgView).offset(56);
- }];
-
- self.viewType = MOGiftListViewTypeVideo;
-
- self.tag = TagLiveGiftListView;
-
- self.bgView.layer.cornerRadius = 16.0;
- self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
- // self.bgView.layer.masksToBounds = YES;
-
- NSArray *bgColorArr = @[[MOTools colorWithHexString:@"#12121F" alpha:1.0],[MOTools colorWithHexString:@"#12121F" alpha:1.0]];
- UIImage *bgImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, SCREENWIDTH, 400.0) Colors:bgColorArr GradientType:1];
- [self.bgImgView setImage:bgImage];
- self.bgImgView.layer.cornerRadius = 16.0;
- self.bgImgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
- self.bgImgView.hidden = YES;
-
- self.bottomView.backgroundColor = [MOTools colorWithHexString:@"#12121F" alpha:1.0];
-
- self.bottomView.layer.cornerRadius = 16.0;
- self.bottomView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
-
- CGFloat giftUserViewHeight = kScaleWidth(56.0);
- self.bottomViewTop.mas_equalTo(giftUserViewHeight);
-
- [self.bgView addSubview:self.giftUserView];
- [self.giftUserView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgView).offset(0.0);
- make.left.equalTo(self.bgView).offset(0.0);
- make.right.equalTo(self.bgView).offset(0.0);
- make.height.equalTo(@(kScaleWidth(56.0)));
- }];
- self.giftUserView.hidden = YES;
-
- MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
-
- CGFloat vipTopSpac = giftUserViewHeight + 9.0;
- [self.bgView addSubview:self.vipBtn];
- [self.vipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgView).offset(vipTopSpac);
- make.right.equalTo(self.bgView).offset(-12.0);
- make.height.equalTo(@24.0);
- make.width.equalTo(@24.0);
- }];
-
- UIImageView *tagOneImgView = [[UIImageView alloc] init];
- tagOneImgView.contentMode = UIViewContentModeScaleToFill;
- NSArray *tagOneImgColorArr = @[[MOTools colorWithHexString:@"#FFFFFF" alpha:0],[MOTools colorWithHexString:@"#FFFFFF" alpha:0.1],[MOTools colorWithHexString:@"#FFFFFF" alpha:0.1],[MOTools colorWithHexString:@"#FFFFFF" alpha:0]];
- UIImage *tagOneImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 26.0, 0.5) Colors:tagOneImgColorArr GradientType:1];
- [tagOneImgView setImage:tagOneImage];
- [self.bgView addSubview:tagOneImgView];
- [tagOneImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(@26.0);
- make.width.equalTo(@1);
- make.right.equalTo(self.vipBtn.mas_left).offset(-12.0);
- make.centerY.equalTo(self.vipBtn.mas_centerY);
- }];
-
- [self.bgView addSubview:self.zuanTagBtn];
- [self.zuanTagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(tagOneImgView.mas_left).offset(-12.0);
- make.height.equalTo(@24.0);
- make.width.equalTo(@24.0);
- make.centerY.equalTo(self.vipBtn.mas_centerY);
- }];
-
- UIImageView *tagTwoImgView = [[UIImageView alloc] init];
- tagTwoImgView.contentMode = UIViewContentModeScaleToFill;
- [tagTwoImgView setImage:tagOneImage];
- [self.bgView addSubview:tagTwoImgView];
- [tagTwoImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(@26.0);
- make.width.equalTo(@1);
- make.right.equalTo(self.zuanTagBtn.mas_left).offset(-12.0);
- make.centerY.equalTo(self.vipBtn.mas_centerY);
- }];
-
-
- [self.bgView addSubview:self.levelImgView];
- [self.levelImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(@(MOLevelNormalWidth));
- make.height.equalTo(@(MOLevelNormalHeight));
- make.centerY.equalTo(self.vipBtn.mas_centerY);
- make.left.equalTo(self.bgView).offset(12.0);
- }];
-
- self.levelImgView.levelNum = userInfoData.level;
- if(userInfoData.level >= 100){
- [self.levelImgView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(@(MOLevelMaxWidth));
- }];
- }
- else{
- [self.levelImgView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(@(MOLevelNormalWidth));
- }];
- }
-
- [self.bgView addSubview:self.expView];
- [self.expView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.levelImgView.mas_centerY).offset(-8.0);
- make.left.equalTo(self.levelImgView.mas_right).offset(10.0);
- make.width.equalTo(@190.0);
- make.height.equalTo(@10.0);
- }];
- if(userInfoData.nextExp != 0){
- self.expView.nextExp = userInfoData.nextExp;
- self.expView.currExp = userInfoData.currExp;
- [self.expView updateViewData];
- }
- else{
- self.expView.progress = 0.03;
- }
-
- [self.bgView addSubview:self.expTipLab];
- [self.expTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.levelImgView.mas_right).offset(10.0);
- make.top.equalTo(self.expView.mas_bottom).offset(2.0);
- make.right.equalTo(self.expView.mas_right);
- }];
- [self updateTheExpTipLab];
-
- [self.bgView addSubview:self.nextLevelBtn];
- [self.nextLevelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.vipBtn.mas_centerY);
- make.right.equalTo(tagTwoImgView.mas_left).offset(-12.0);
- make.height.width.equalTo(@12.0);
- }];
-
- CGFloat titleCategoryTop = giftUserViewHeight + 52.0;
- MOGiftPanelsView *panelsView = [[MOGiftPanelsView alloc] init:self.listViewModel];
- panelsView.delegate = self;
- [self.bgView addSubview:panelsView];
- [panelsView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgView).offset(titleCategoryTop);
- make.leading.trailing.equalTo(self.bgView);
- make.bottom.equalTo(self.bgView);
- }];
- self.giftPanelsView = panelsView;
-
- [self.bgView addSubview:self.susuImageView];
- [self.susuImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self.bgView);
- make.bottom.equalTo(self.bgView).offset(0);
- make.height.equalTo(@90.0);
- }];
-
- self.bottomMenuView = [[MOGiftBottomMenuView alloc] init];
- self.bottomMenuView.delegate = self;
- [self.bgView addSubview:self.bottomMenuView];
- [self.bottomMenuView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.trailing.equalTo(self.bgView);
- make.bottom.equalTo(self.bgView).offset(-kBottomSafeAreaInset);
- }];
-
- [self addSubview:self.customNumView];
- [self.customNumView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- }];
-
- [self setZuanNumBtnTitleWith:userInfoData.userWallet.diamond];
- }
- - (void)setZuanNumBtnTitleWith:(double)diamond{
- [self.bottomMenuView updateUserDiamond:diamond];
- }
- - (void)setIsSingleLinkMic:(BOOL)isSingleLinkMic{
- _isSingleLinkMic = isSingleLinkMic;
-
- self.giftUserView.isSingleLinkMic = isSingleLinkMic;
- }
- - (void)setMultiple:(BOOL)multiple{
- _multiple = multiple;
-
- if(multiple){
- self.giftUserView.hidden = NO;
- self.bottomView.layer.cornerRadius = 0;
- }
- else{
- self.giftUserView.hidden = YES;
- self.bottomView.layer.cornerRadius = 16;
- }
-
- [UIView animateWithDuration:0.3 animations:^{
- [self layoutIfNeeded];
- }];
- }
- - (void)setAnchorUser:(MOUserProfile *)anchorUser{
- _anchorUser = anchorUser;
- self.giftUserView.anchorUser = anchorUser;
- }
- - (void)setLinkMics:(NSArray *)linkMics{
- _linkMics = linkMics;
- self.giftUserView.linkMics = linkMics;
- }
- - (void)setSelectUserArr:(NSArray *)selectUserArr{
- _selectUserArr = selectUserArr;
- self.giftUserView.oldSelectUserArr = [selectUserArr copy];
- }
- - (void)toUpdateTheCurrentCollectionData{
- if(self.bagView.hidden == NO){
- [self.bagView toUpdataTheSelectIndexPathCell];
- } else{
- [self.giftPanelsView toUpdateTheCurrentCollectionData];
- }
- }
- - (void)updateStripViewWith:(MOStripe *)stripe OrSkins:(NSArray *)skins{
- [self.giftPanelsView updateStripViewWithSelected:self.chooseGiftModel stripe:stripe or:skins];
- }
- - (void)handleSelectGift:(MOGiftlist *)gift {
- self.selectedProp = nil;
- self.chooseGiftModel = gift;
- self.chooseGiftModel.giftInfo.selectSkin = nil;
- [self.comboView stopCombo];
- [self.bottomMenuView updateSelectItem:gift];
- [self.bottomMenuView selectGiftNum:1];
- self.expView.giftNum = 1;
- self.expView.moreExp = gift.basicExp + gift.additionExp;
- }
- - (void)handleSelectProp:(MOShopList *)prop {
- self.selectedProp = prop;
- self.chooseGiftModel = nil;
- self.chooseGiftModel.giftInfo.selectSkin = nil;
- [self.comboView stopCombo];
- [self.bottomMenuView updateSelectItem:prop];
- }
- - (void)toUpdateTheBaseCacheAndUse:(BOOL)isUsed {
- //道具分类\n * 1: 头饰\n * 2: 气泡\n * 3: 入场座驾(旧:进场条)\n * 4: 名片框\n * 5: 直播徽章\n * 6: 用户徽章\n * 7: 进场条(旧:进场飘屏)\n * 8: 打赏横幅\n * 9: 连麦边框\n * 10: 直播弹幕
- NSInteger type = (NSInteger)self.selectedProp.category;
-
- if(isUsed){
- //使用的时候, code必不为0
- NSInteger code = self.selectedProp.propInfo.storeInfo.code;
- if(code == 0){
- return;
- }
- }
-
- switch (type) {
- case 1:
- {
- //头饰 - 刷新房间自己的头饰
- if(isUsed){
- self.headDressChangeBlock ? self.headDressChangeBlock(self.selectedProp.propInfo.storeInfo) : nil;
- }
- else{
- self.headDressChangeBlock ? self.headDressChangeBlock(nil) : nil;
- }
-
- }
- break;
- case 2:
- {
- NSInteger bubbleCode;
- //进场条
- if(isUsed){
- bubbleCode = self.selectedProp.propInfo.storeInfo.code;
- }
- else{
- bubbleCode = 0;
- }
- [[NSUserDefaults standardUserDefaults] setObject:@(bubbleCode) forKey:kUserBubbleCode];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- break;
- case 3:
- {
- //入场特效
- NSInteger enterBar;
- //进场条
- if(isUsed){
- enterBar = self.selectedProp.propInfo.storeInfo.code;
- }
- else{
- enterBar = 0;
- }
- [[NSUserDefaults standardUserDefaults] setObject:@(enterBar) forKey:kUserEnterBar];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- break;
- case 4:
- {
- //名片框
- NSInteger cardFrame;
- //进场条
- if(isUsed){
- cardFrame = self.selectedProp.propInfo.storeInfo.code;
- }
- else{
- cardFrame = 0;
- }
- [[NSUserDefaults standardUserDefaults] setObject:@(cardFrame) forKey:kCardFrameCode];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- break;
- case 7:
- {
- NSInteger enterFloating;
- //进场条 - 进场飘屏
- if(isUsed){
- enterFloating = self.selectedProp.propInfo.storeInfo.code;
- }
- else{
- enterFloating = 0;
- }
- [[NSUserDefaults standardUserDefaults] setObject:@(enterFloating) forKey:kEnterFloatingCode];
- [[NSUserDefaults standardUserDefaults] synchronize];
-
- }
- break;
- case 8:
- {
- //打赏横幅
- NSInteger rewardBanner;
- if(isUsed){
- rewardBanner = self.selectedProp.propInfo.storeInfo.code;
- }
- else{
- rewardBanner = 0;
- }
- [[NSUserDefaults standardUserDefaults] setObject:@(rewardBanner) forKey:kRewardBannerCode];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- break;
- case 9:
- {
- //连麦边框
- NSInteger linkMicFrame;
- if(isUsed){
- linkMicFrame = self.selectedProp.propInfo.storeInfo.code;
- }
- else{
- linkMicFrame = 0;
- }
- [[NSUserDefaults standardUserDefaults] setObject:@(linkMicFrame) forKey:kLinkMicFrameCode];
- [[NSUserDefaults standardUserDefaults] synchronize];
-
- if(isUsed){
- self.linkMicPropChangeBlock ? self.linkMicPropChangeBlock(self.selectedProp.propInfo.storeInfo) : nil;
- }
- else{
- self.linkMicPropChangeBlock ? self.linkMicPropChangeBlock(nil) : nil;
- }
- }
- break;
- case 10:
- {
- //直播弹幕
- NSInteger liveBarrage;
- if(isUsed){
- liveBarrage = self.selectedProp.propInfo.storeInfo.code;
- }
- else{
- liveBarrage = 0;
- }
- [[NSUserDefaults standardUserDefaults] setObject:@(liveBarrage) forKey:kLiveBarrageCode];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- break;
-
- default:
- break;
- }
- }
- #pragma mark - My Mothed
- - (void)sendGiftAction{
- if(!self.chooseGiftModel){
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_room_living_send_gift")];
- return;
- }
-
- if(self.multiple && self.giftUserView.selectUserArr.count == 0){
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_voice_at_least_one")];
- return;
- }
-
- WEAKSELF
- // [self.generator impactOccurred];
-
- if (self.chooseGiftModel.giftInfo.blindBoxGift && !self.showBlindBoxGiftAlert) {
- BOOL canShow = [MOBlindBoxTool canShowRemindAlertView];
- MOBlindBoxRecordType recordType = [MOBlindBoxTool getRecordType];
- self.blindBoxType = recordType;
- if (!canShow) {
- self.showBlindBoxGiftAlert = YES;
- [self sendGiftAction];
- return;
- }
-
- WEAKSELF
- MORemindAlertView *view = [[MORemindAlertView alloc] init];
- [view hideRemindButton];
- view.leftButtonBlock = ^(BOOL notRemind) {
- weakSelf.blindBoxType = MOBlindBoxRecordTypeBag;
- if (notRemind) {//不再提醒
- [MOBlindBoxTool saveBlinBoxRecordType:MOBlindBoxRecordTypeBag];
- }
- [weakSelf sendGiftAction];
- };
- view.rightButtonBlock = ^(BOOL notRemind) {
- weakSelf.blindBoxType = MOBlindBoxRecordTypeSend;
- if (notRemind) {//不再提醒
- [MOBlindBoxTool saveBlinBoxRecordType:MOBlindBoxRecordTypeSend];
- }
- [weakSelf sendGiftAction];
- };
- [view show];
- self.showBlindBoxGiftAlert = YES;
- return;
- }
-
- if(self.multiple){
- if(self.chooseGiftModel.isBag){
- [self.listViewModel sendBagToUids:self.giftUserView.selectUserArr category:self.category gift:self.chooseGiftModel num:[self.bottomMenuView curGiftNum] completion:nil];
- }
- else{
- if (self.chooseGiftModel.giftInfo.blindBoxGift && self.blindBoxType == MOBlindBoxRecordTypeBag) {//盲盒礼物选中了放入背包,调用盲盒礼物抽奖
- [self drawBlindBox:self.chooseGiftModel];
- } else {
- [self.listViewModel sendGiftToUids:self.giftUserView.selectUserArr category:self.category gift:self.chooseGiftModel num:[self.bottomMenuView curGiftNum] completion:nil];
- }
- }
- }
- else{
- if(self.chooseGiftModel.isBag){
- [self.listViewModel sendBagToUid:self.targetUserId category:self.category gift:self.chooseGiftModel num:[self.bottomMenuView curGiftNum] completion:nil];
- }
- else{
- if (self.chooseGiftModel.giftInfo.blindBoxGift && self.blindBoxType == MOBlindBoxRecordTypeBag) {//盲盒礼物选中了放入背包,调用盲盒礼物抽奖
- [self drawBlindBox:self.chooseGiftModel];
- } else {
- [self.listViewModel sendGiftToUid:self.targetUserId category:self.category gift:self.chooseGiftModel num:[self.bottomMenuView curGiftNum] completion:nil];
- }
- }
- }
- }
- - (void)toUpdataTheViewExpViewDataWithLevel:(NSInteger)level AndCurrExp:(NSInteger)currExp AndNextExp:(NSInteger)nextExp{
-
- if(nextExp <= 0 || level <= 0){
- return;
- }
-
- //更新本地等级数据
- MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
- userInfoData.level = level;
- userInfoData.currExp = currExp;
- userInfoData.nextExp = nextExp;
-
- [[MODataCache sharedYYCache] setObject:userInfoData forKey:kMineUserInfo];
-
- NSInteger theLevel = GetUserLevel;//更新Rtm Level
- if(theLevel != level){
- [[NSUserDefaults standardUserDefaults] setObject:@(level) forKey:kUserLevel];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
-
- self.levelImgView.levelNum = level;
- if(userInfoData.level >= 100){
- [self.levelImgView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(@(MOLevelMaxWidth));
- }];
- }
- else{
- [self.levelImgView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(@(MOLevelNormalWidth));
- }];
- }
-
- self.expView.currExp = currExp;
- self.expView.nextExp = nextExp;
- [self.expView updateViewData];
- }
- - (void)toUseTheProps{
- MOShopList *curProp = self.selectedProp;
-
- if(!curProp || curProp.id.length == 0){
- return;
- }
- BOOL isUsed = !curProp.used;
-
- WEAKSELF
- NSDictionary *dict = @{@"id":curProp.id,
- @"use":@(isUsed)};
- [kHttpManager toUseThePropWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- //刷新当前界面
- curProp.used = isUsed;
- [weakSelf.bagView updatePropCollectionBy:weakSelf.selectedProp];
-
- //更新本地 缓存
- [weakSelf toUpdateTheBaseCacheAndUse:isUsed];
- if (weakSelf.selectedProp == curProp) {
- // 避免请求过程中选择了其他物品
- [weakSelf.bottomMenuView updateSelectItem:curProp];
- }
-
- if(isUsed){
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_2_bag_prop_equip_tip")];
- }
- else{
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_2_bag_prop_un_equip_tip")];
- }
- }
- else{
- kShowNetError(data)
- // weakSelf.theUseBtn.selected = !isUse;//报错 - 重置为原来
- // TODO: cwy
- }
- }];
- }
- - (void)drawBlindBox:(MOGiftlist *)giftModel {
- NSDictionary *dict = @{@"giftId": giftModel.giftInfo.id, @"roomId": self.listViewModel.curRoomId};
- [kHttpManager drawBlindBoxWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success) {
- MOLogV(@"drawBlindBox: %@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- } else {
- kShowNetError(data)
- }
- }];
- }
- - (void)toUpdataBagGiftWith:(MOGiftlist *)giftModel{
- [self.bagView toUpdataBagGiftWith:giftModel];
- }
- - (void)toDeleteBagGiftWith:(MOGiftlist *)giftModel Num:(NSInteger)num{
- [self.bagView toDeleteBagGiftWith:giftModel Num:num];
- }
- - (IBAction)dismissBtnClick:(id)sender {
- [self dismissGiftListView];
- }
- - (void)showGiftListView{
- [self setHidden:NO];
- self.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
-
- CGRect actionViewRect = self.bgView.frame;
- actionViewRect.origin.y = SCREENHEIGHT;
- self.bgView.frame = actionViewRect;
-
- CGFloat moveHeight = kScaleWidth(430.0);
- if(self.multiple){
- moveHeight = kScaleWidth(430.0);
- }
-
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^{
- CGRect actionViewRect = weakSelf.bgView.frame;
- actionViewRect.origin.y = SCREENHEIGHT - moveHeight;
- weakSelf.bgView.frame = actionViewRect;
- } completion:^(BOOL finished) {
- [weakSelf.listViewModel preloadGiftList];
- weakSelf.showUpBlock();
- }];
-
- [self.giftPanelsView toJudgeIsNeedChangeTheSelectTitle];//判断是否有滑动到特定分类的需求
-
- //不能滑动
- SendNotification(@"MOShowLivePagesVCCannotScroll")
-
- if([MOSvgaSourceManage shareManager].giftCategoryArr.count == 0){
- [[MOSvgaSourceManage shareManager] toGetGiftCategoryListDataAndNeedShowError:YES];
- }
-
- [self toJudgeNeedShowBagRed];//判断背包红点逻辑
- self.showBlindBoxGiftAlert = NO; // 重制盲盒弹窗开关
- }
- - (void)toJudgeNeedShowBagRed{
- [self.giftPanelsView enableBagRedDot:self.giftRedCount > 0 || self.propRedCount > 0];
- }
- - (void)dismissGiftListView{
- [MOSvgaSourceManage shareManager].hitGiftModel = nil;
-
- //完成下移动画
- WEAKSELF
- [UIView animateWithDuration:0.3 animations:^
- {
- CGRect actionSheetViewRect = weakSelf.bgView.frame;
- actionSheetViewRect.origin.y = SCREENHEIGHT;
- weakSelf.bgView.frame = actionSheetViewRect;
- } completion:^(BOOL finished)
- {
- [self setHidden:YES];
- }];
-
- self.dismissBlock ? self.dismissBlock() : nil;
-
- //可以滑动
- SendNotification(@"MOShowLivePagesVCCanScroll")
- }
- #pragma mark - MOGiftListViewModelDelegate
- - (void)onUserBalanceChangedBySendGiftWithCurrent:(NSInteger)current {
- [self setZuanNumBtnTitleWith:current];
- }
- - (void)onUserLevelChangedBySendGiftWithLevel:(NSInteger)level curExp:(NSInteger)curExp nextExp:(NSInteger)nextExp {
- [self toUpdataTheViewExpViewDataWithLevel:level AndCurrExp:curExp AndNextExp:nextExp];
- }
- - (void)onSendGiftSuccessWithCategory:(NSInteger)category num:(NSInteger)num gift:(MOGiftlist *)gift info:(MOGiftInfo *)info {
- self.sentGiftBlock(gift, num, category, info);
- }
- - (void)onSendBagSuccessWithCategory:(NSInteger)category num:(NSInteger)num
- gift:(MOGiftlist *)gift info:(MOGiftInfo *)info
- newItem:(MOGiftlist * _Nullable)newItem {
- if (newItem != nil) {
- [self toUpdataBagGiftWith:newItem];
- } else {
- [self toDeleteBagGiftWith:gift Num:num];
- }
-
- self.sentGiftBlock(gift, num, category, info);
- }
- #pragma mark - Lazy
- - (MOBaseLevelView *)levelImgView{
- if(!_levelImgView){
- _levelImgView = [[MOBaseLevelView alloc] init];
- }
- return _levelImgView;
- }
- - (BigBtn *)nextLevelBtn{
- if(!_nextLevelBtn){
- _nextLevelBtn = [BigBtn buttonWithType:UIButtonTypeCustom];
- [_nextLevelBtn setImage:[UIImage imageNamed:@"v_2_mine_white_right"] forState:UIControlStateNormal];
- [_nextLevelBtn setTitleColor:[MOTools colorWithHexString:@"#29FFD4" alpha:1.0] forState:UIControlStateNormal];
- _nextLevelBtn.titleLabel.font = [MOTextTools getTheFontWithSize:10.0 AndFontName:kNormalContentFontStr];
- [_nextLevelBtn addTarget:self action:@selector(nextLevelBtnClick) forControlEvents:UIControlEventTouchUpInside];
- }
- return _nextLevelBtn;
- }
- - (void)nextLevelBtnClick{
- self.levelBtnBlock ? self.levelBtnBlock() : nil;
- [self dismissGiftListView];
- }
- - (BigBtn *)vipBtn{
- if(!_vipBtn){
- _vipBtn = [BigBtn buttonWithType:UIButtonTypeCustom];
- [_vipBtn setImage:[UIImage imageNamed:@"icon_live_gift_vip"] forState:UIControlStateNormal];
- [_vipBtn addTarget:self action:@selector(vipBtnClick) forControlEvents:UIControlEventTouchUpInside];
- }
- return _vipBtn;
- }
- - (void)vipBtnClick{
- self.vipBtnBlock ? self.vipBtnBlock() : nil;
- [self dismissGiftListView];
- }
- - (BigBtn *)zuanTagBtn{
- if(!_zuanTagBtn){
- _zuanTagBtn = [BigBtn buttonWithType:UIButtonTypeCustom];
- [_zuanTagBtn setImage:[UIImage imageNamed:@"icon_gift_zuan_48"] forState:UIControlStateNormal];
- [_zuanTagBtn addTarget:self action:@selector(zuanBtnClick) forControlEvents:UIControlEventTouchUpInside];
- }
- return _zuanTagBtn;
- }
- - (void)zuanBtnClick{
- [self topUpBtnClick:nil];
- }
- - (IBAction)topUpBtnClick:(id)sender {
- self.topUpBtnBlock ? self.topUpBtnBlock() : nil;
- // [self dismissGiftListView];
- }
- - (MOGiftUserView *)giftUserView{
- if(!_giftUserView){
- _giftUserView = [MOGiftUserView moGiftUserView];
- }
- return _giftUserView;
- }
- - (UIImpactFeedbackGenerator *)generator{
- if (!_generator){
- _generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium];
- }
- return _generator;
- }
- - (MOExpProgressView *)expView{
- if(!_expView){
- _expView = [[MOExpProgressView alloc] initWithFrame:CGRectMake(0.0, 0.0, 190.0, 10.0)];
- WEAKSELF
- _expView.moreExpChangeBlock = ^{
- [weakSelf updateTheExpTipLab];
- };
- }
- return _expView;
- }
- - (UILabel *)expTipLab{
- if(!_expTipLab){
- _expTipLab = [[UILabel alloc] init];
- _expTipLab.font = [MOTextTools regularFont:10.0];
- _expTipLab.textColor = [MOTools colorWithHexString:@"#FFFFFF" alpha:0.5];
- _expTipLab.numberOfLines = 2;
- }
- return _expTipLab;
- }
- - (void)updateTheExpTipLab{
- CGFloat giftNum = self.expView.giftNum;
- if(giftNum == 0){
- giftNum = 1;
- }
-
- CGFloat moreExp = self.expView.moreExp * giftNum;
- CGFloat baseExp = 0.0;
- CGFloat xExp = 0.0;
-
- if(moreExp == 0){//基础经验 + 额外经验
- baseExp = 0.0;
- xExp = 0.0;
- }
- else{
- baseExp = self.chooseGiftModel.basicExp * giftNum;
- xExp = self.chooseGiftModel.additionExp * giftNum;
- }
-
- NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:@" "];
-
- if(baseExp > 0){
- NSString *expStr = [NSString stringWithFormat:@"+%.f",baseExp];
- NSString *contentStr = [NSString stringWithFormat:NSLocalString(@"mimo_send_gift_exp_1"),expStr];
- attri = [MOGiftListView base_colorfulStringWith:contentStr AndNameStr:expStr AndBaseColor:[MOTools colorWithHexString:@"#FFFFFF" alpha:0.5] AndNameColor:[MOTools colorWithHexString:@"#03FFB2" alpha:1.0]];
- [attri addAttribute:NSFontAttributeName value:[MOTextTools regularFont:10.0] range:NSMakeRange(0, attri.length)];
- }
-
- if(xExp > 0){
- NSString *moreStr = [NSString stringWithFormat:@"+%.f",xExp];
- NSString *contentStrTwo = [NSString stringWithFormat:NSLocalString(@"mimo_send_gift_exp_2"),moreStr];
- NSMutableAttributedString *attriTwo = [MOGiftListView base_colorfulStringWith:contentStrTwo AndNameStr:moreStr AndBaseColor:[MOTools colorWithHexString:@"#FFFFFF" alpha:0.5] AndNameColor:[MOTools colorWithHexString:@"#03FFB2" alpha:1.0]];
- [attriTwo addAttribute:NSFontAttributeName value:[MOTextTools regularFont:10.0] range:NSMakeRange(0, attriTwo.length)];
-
- [attri appendAttributedString:attriTwo];
- }
-
- if(self.expView.isLevelUp){
- NSString *tempStr = [NSString stringWithFormat:@" %@",NSLocalString(@"mimo_2_level_up")];
- NSMutableAttributedString *levelStr = [[NSMutableAttributedString alloc] initWithString:tempStr];
- [levelStr addAttribute:NSForegroundColorAttributeName value:[MOTools colorWithHexString:@"#03FFB2" alpha:1.0] range:NSMakeRange(0, levelStr.length)];
- [levelStr addAttribute:NSFontAttributeName value:[MOTextTools regularFont:10.0] range:NSMakeRange(0, levelStr.length)];
-
- [attri appendAttributedString:levelStr];
- }
-
- self.expTipLab.attributedText = attri;
- }
- + (NSMutableAttributedString *)base_colorfulStringWith:(NSString *)contentStr AndNameStr:(NSString *)nameStr AndBaseColor:(UIColor *)baseColor AndNameColor:(UIColor *)nameColor {
-
- // 创建属性字符串,整体颜色为白色
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:contentStr attributes:@{NSForegroundColorAttributeName:baseColor}];
-
- if(nameStr.length != 0){
- NSRange redRange = [contentStr rangeOfString:nameStr];
- if(redRange.location != NSNotFound){
- // 将最后三个字符的颜色设置为红色
- [attributedString addAttribute:NSForegroundColorAttributeName value:nameColor range:redRange];
- }
- }
- return attributedString;
- }
- - (MOCustomGiftNumView *)customNumView{
- if(!_customNumView){
- _customNumView = [[MOCustomGiftNumView alloc] initWithFrame:CGRectMake(0.0, 0.0, SCREENWIDTH, SCREENHEIGHT)];
- _customNumView.hidden = YES;
- WEAKSELF
- _customNumView.sureNumBlock = ^(NSInteger customNum) {
- if(customNum > weakSelf.chooseGiftModel.giftInfo.diyGiftNumberMax){
- customNum = weakSelf.chooseGiftModel.giftInfo.diyGiftNumberMax;
- NSString *tipStr = [NSString stringWithFormat:NSLocalString(@"mimo_2_live_custom_tip_2"),customNum];
- [MBProgressHUD showTipMessageInWindow:tipStr];
- return;
- }
-
- [weakSelf.customNumView.textField resignFirstResponder];//收回键盘
-
- [weakSelf.bottomMenuView updateCustomNum:customNum];
- weakSelf.expView.giftNum = customNum;
- [weakSelf toUpdateTheCurrentCollectionData];
- };
- }
- return _customNumView;
- }
- - (MOGiftListBagView *)bagView{
- if(!_bagView){
- WEAKSELF
- _bagView = [[MOGiftListBagView alloc] initWith:self.listViewModel];
- _bagView.frame =CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
-
- _bagView.selectGiftBlock = ^(MOGiftlist * _Nonnull selectGiftModel, NSInteger giftType) {
- weakSelf.category = giftType;
- [weakSelf handleSelectGift:selectGiftModel];
-
- [weakSelf updateStripViewWith:selectGiftModel.giftInfo.stripe OrSkins:selectGiftModel.giftInfo.skins];
- };
-
- //选中回调
- _bagView.selectCellBlock = ^(MOShopList * _Nonnull selectGiftModel) {
- [weakSelf handleSelectProp:selectGiftModel];
- };
-
- _bagView.theFirstGiftBlock = ^{
- weakSelf.chooseGiftModel = nil;
- weakSelf.expView.moreExp = 0;
- [weakSelf updateStripViewWith:nil OrSkins:nil];
- };
-
- _bagView.redChangeBlock = ^(NSInteger giftRedCount, NSInteger propRedCount, NSInteger propNearExpiryPropCount) {
- weakSelf.redChangeBlock ? weakSelf.redChangeBlock(giftRedCount,propRedCount,propNearExpiryPropCount) : nil;
- };
-
- _bagView.headDressChangeBlock = ^(MOStoreInfo * _Nonnull stroeInfo) {
- weakSelf.headDressChangeBlock ? weakSelf.headDressChangeBlock(stroeInfo) : nil;
- };
-
- _bagView.linkMicPropChangeBlock = ^(MOStoreInfo * _Nonnull stroeInfo) {
- weakSelf.linkMicPropChangeBlock ? weakSelf.linkMicPropChangeBlock(stroeInfo) : nil;
- };
-
- _bagView.toShopBlock = ^{
- weakSelf.toShopBlock ? weakSelf.toShopBlock() : nil;
- [weakSelf dismissGiftListView];
- };
-
- _bagView.dismissBlock = ^{
- [weakSelf.giftPanelsView handleResume];
- };
-
- _bagView.hidden = YES;
- }
- return _bagView;
- }
- - (void)oneSecondPassed{
- //时间戳逻辑
- if(!self.bagView.hidden){
- [self.bagView oneSecondPassed];
- }
- }
- - (UIImageView *)susuImageView{
- if(!_susuImageView){
- _susuImageView = [[UIImageView alloc] init];
- NSArray *colorArr = @[[MOTools colorWithHexString:@"#12121F" alpha:0.0],[MOTools colorWithHexString:@"#12121F" alpha:0.96],[MOTools colorWithHexString:@"#12121F" alpha:0.96],[MOTools colorWithHexString:@"#12121F" alpha:1.0]];
- UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, SCREENWIDTH, 50.0) Colors:colorArr GradientType:1];
- [_susuImageView setImage:image];
- _susuImageView.contentMode = UIViewContentModeScaleToFill;
- }
- return _susuImageView;
- }
- #pragma mark - MOGiftBottomMenuViewDelegate
- - (void)giftBottomMenuViewDidSelectNumWithView:(MOGiftBottomMenuView *)view num:(NSInteger)num isCustom:(BOOL)isCustom {
- if(isCustom && self.chooseGiftModel.giftInfo.diyGiftNumberMax == 0){
- [self.bottomMenuView selectGiftNum:1];
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_2_live_custom_tip")];
- return;
- }
- self.expView.giftNum = num;
- [self toUpdateTheCurrentCollectionData];
-
- SendObjNotification(@"kNotification_SelectSendGiftNumber", @(num));
- }
- - (void)giftBottomMenuViewClickSendGiftWithView:(MOGiftBottomMenuView *)view {
- if (self.comboView == nil) {
- self.comboView = [[MOGiftComboView alloc] init];
- self.comboView.delegate = self;
- [self.superview addSubview:self.comboView];
- [self.comboView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.trailing.equalTo(self.superview);
- make.bottom.equalTo(self.superview).offset(-kBottomSafeAreaInset);
- }];
- }
- [self.comboView setHidden:NO];
- [self.comboView startCombo];
- [self.bottomMenuView enableGiftSendView:NO];
-
- [self sendGiftAction];
- }
- - (void)giftBottomMenuViewClickCustomWithView:(MOGiftBottomMenuView *)view {
- if(self.chooseGiftModel.giftInfo.diyGiftNumberMax == 0){
- [self.bottomMenuView selectGiftNum:1];
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_2_live_custom_tip")];
- return;
- }
-
- self.customNumView.hidden = NO;
- self.customNumView.maxNum = self.chooseGiftModel.giftInfo.diyGiftNumberMax;
- [self.customNumView.textField becomeFirstResponder];
- }
- - (void)giftBottomMenuViewClickUseWithView:(MOGiftBottomMenuView *)view {
- [self toUseTheProps];
- }
- - (void)giftBottomMenuViewClickSendBagWithView:(MOGiftBottomMenuView *)view {
- [self sendGiftAction];
- }
- - (void)giftBottomMenuViewClickRechargeWithView:(MOGiftBottomMenuView *)view {
- [self topUpBtnClick:nil];
- }
- #pragma mark - MOGiftComboViewDelegate
- - (void)giftComboViewOnCountdownFinishedWithView:(MOGiftComboView *)view {
- [view setHidden:YES];
- [self.bottomMenuView enableGiftSendView:YES];
-
- if (view.needResumeGiftPanel) {
- [self showGiftListView];
- }
- }
- - (void)giftComboViewOnComboFiredWithView:(MOGiftComboView *)view combo:(NSInteger)combo {
- [self sendGiftAction];
- }
- - (void)giftComboViewRequireHideGiftPanelWithView:(MOGiftComboView *)view {
- [self dismissGiftListView];
- }
- #pragma mark - MOGiftPanelsViewDelegate
- - (void)onGiftPanelsViewSelectGiftWithView:(MOGiftPanelsView *)view category:(MOGiftCategoryList *)category
- giftMode:(MOGiftlist *)selectGiftMode giftType:(NSInteger)giftType {
- [self handleSelectGift:selectGiftMode];
-
- MOStripe *theStripe;
- NSString *stripetitle = selectGiftMode.giftInfo.stripe.title;
- if(stripetitle.length > 0){
- theStripe = selectGiftMode.giftInfo.stripe;
- } else{
- theStripe = category.stripe;
- }
- [self updateStripViewWith:theStripe OrSkins:selectGiftMode.giftInfo.skins];
-
- if (selectGiftMode.giftInfo.blindBoxGift) {
- [self.bottomMenuView enableGiftNum:NO];
- } else {
- [self.bottomMenuView enableGiftNum:YES];
- }
- }
- - (void)onGiftPanelsViewFirstGiftSelectedWithCategory:(MOGiftCategoryList *)category {
- self.chooseGiftModel = nil;
- [self.bottomMenuView updateViewType:GiftBottomMenuTypeGift];
- [self.bottomMenuView enableGiftSendView:NO];
- self.expView.moreExp = 0;
-
- if(category.stripe.title.length > 0){
- [self updateStripViewWith:category.stripe OrSkins:nil];
- }
- else{
- [self updateStripViewWith:nil OrSkins:nil];
- }
- }
- - (void)onGiftPanelsViewScripeClickWithScript:(MOStripe *)script {
- self.stripeClickBlock(script);
- }
- - (void)onGiftPanelsViewSkinClickWithSkin:(MOEffect *)skin {
- if(!skin.lock){
- self.chooseGiftModel.giftInfo.selectSkin = skin;
- }
- }
- - (void)onGiftPanelsViewClickBagButton {
- [self.bottomMenuView updateSelectItem:nil];
-
- if (self.bagView.superview == nil) {
- [self.bgView insertSubview:self.bagView belowSubview:self.susuImageView];
- [self.bagView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- }];
- }
- self.bagView.hidden = NO;
- self.bagView.multiple = self.multiple;
- self.bagView.giftRedCount = self.giftRedCount;
- self.bagView.propRedCount = self.propRedCount;
- [self.bagView showGiftListBagView];
- }
- @end
|