Files
midi_ios/QXLive/活动/巡乐会/QXMeetActivityView.m
2025-10-04 18:31:00 +08:00

1046 lines
43 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// QXMeetActivityView.m
// QXLive
//
// Created by 启星 on 2025/8/29.
//
#import "QXMeetActivityView.h"
#import "QXMeetActivityRuleView.h"
#import "QXMeetActivityRecordView.h"
#import "QXMeetActivityRankView.h"
#import "QXMeetActivityPoolView.h"
#import "QXMeetActivityResultView.h"
#import "QXMeetLotteryView.h"
#import "QXDiamondViewController.h"
@interface QXMeetActivityView()<UIGestureRecognizerDelegate,QXMeetLotteryViewDelegate,QXMeetActivityViewDelegate>
@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UIImageView *bgImageView;
/// 奖池
@property (nonatomic,strong)UIButton *poolBtn;
/// 规则
@property (nonatomic,strong)UIButton *ruleBtn;
/// 记录
@property (nonatomic,strong)UIButton *recordBtn;
/// 榜单
@property (nonatomic,strong)UIButton *rankBtn;
//@property (nonatomic,strong)QXMeetTimeDownView *timeDownView;
///// 中间礼物
//@property (nonatomic,strong)UIImageView *centerGiftBgImageView;
//@property (nonatomic,strong)UIImageView *giftImageView;
//@property (nonatomic,strong)UIImageView *giftNameBgImageView;
//@property (nonatomic,strong)UILabel *giftNameLabel;
//@property (nonatomic,strong)UIButton *giftCoinBtn;
//@property (nonatomic,strong)UIImageView *giftHeartImageView;
//@property (nonatomic,strong)UILabel *heartLabel;
//
///// 右侧人
//@property (nonatomic,strong)UIImageView *userBgImageView;
//@property (nonatomic,strong)UIImageView *userHeader;
//@property (nonatomic,strong)UIImageView *userHeaderDress;
//@property (nonatomic,strong)UILabel *userNameLabel;
//
///// 左侧
//@property (nonatomic,strong)UIImageView *leftGiftBgImageView;
//@property (nonatomic,strong)UIImageView *leftGiftImageView;
//
//
@property (nonatomic,strong)QXMeetDrawBtn *oneBtn;
@property (nonatomic,strong)QXMeetDrawBtn *tenBtn;
@property (nonatomic,strong)QXMeetDrawBtn *hundredBtn;
@property (nonatomic,strong)UIImageView *leadToImageView1;
@property (nonatomic,strong)QXMeetUserView *roomOwenrView;
@property (nonatomic,strong)UIImageView *rightGiftBgImageView;
@property (nonatomic,strong)UIImageView *rightGiftImageView;
@property (nonatomic,strong)UIButton *rightGiftCoinBtn;
@property (nonatomic,strong)UILabel *rightGiftNameLabel;
@property (nonatomic,strong)QXMeetTimeDownView *timeDownView;
@property (nonatomic,strong)QXMeetUserView *roomLuckUserView;
@property (nonatomic,strong)QXMeetGiftView *topGiftView;
@property (nonatomic,strong)UIView *bottomGiftBgView;
@property (nonatomic,strong)UILabel *countLabel;
@property (nonatomic,strong)QXMeetGiftView *bottomGiftView;
@property (nonatomic,strong)UIImageView *lockImageView;
/// 金币
@property (nonatomic,strong)UIView* coinView;
@property (nonatomic,strong)UIButton* coinBtn;
@property (nonatomic,strong)UIButton* exchangeBtn;
/// 跳过动画
@property (nonatomic,strong)UIButton* jumpAnimateBtn;
@property (nonatomic,strong)QXMeetActivityRuleView* ruleView;
@property (nonatomic,strong)QXMeetActivityRecordView* recordView;
@property (nonatomic,strong)QXMeetActivityRankView* rankView;
@property (nonatomic,strong)QXMeetActivityPoolView* poolView;
@property (nonatomic,strong)QXActivityXLHModel* model;
@property (nonatomic,strong)QXMeetLotteryView *cycleScrollView;
@property (nonatomic,strong)UIImageView *drawGiftCenterBgImageView;
@property (nonatomic,assign)BOOL isDrawing;
@property (nonatomic,strong)NSArray *resultArray;
@property (nonatomic,assign)NSInteger cycleCount;
@property (nonatomic,strong)QXMeetActivityResultView *resultView;
@property (nonatomic,assign)double coin;
@end
@implementation QXMeetActivityView
- (instancetype)init
{
self = [super init];
if (self) {
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
[self initSubviews];
}
return self;
}
-(void)initSubviews{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
tap.delegate = self;
[self addGestureRecognizer:tap];
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663))];
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
[self addSubview:self.bgView];
// 添加拖拽手势
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc]
initWithTarget:self
action:@selector(handlePanGesture:)];
[self.bgView addGestureRecognizer:panGesture];
// NSString *path = [[NSBundle mainBundle] pathForResource:@"ac_meet_big_bg@2x" ofType:@"png"];
// UIImage *bgImage = [UIImage imageWithContentsOfFile:path];
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_big_bg"]];
self.bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663));
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
[self.bgView addSubview:self.bgImageView];
self.poolBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, ScaleWidth(61), ScaleWidth(48), ScaleWidth(24))];
[self.poolBtn setBackgroundImage:[UIImage imageNamed:@"sky_right_bg"] forState:(UIControlStateNormal)];
[self.poolBtn setTitle:@"奖池" forState:(UIControlStateNormal)];
[self.poolBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
self.poolBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.poolBtn addTarget:self action:@selector(poolAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:self.poolBtn];
self.rankBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.poolBtn.bottom+12, ScaleWidth(48), ScaleWidth(24))];
[self.rankBtn setBackgroundImage:[UIImage imageNamed:@"sky_right_bg"] forState:(UIControlStateNormal)];
[self.rankBtn setTitle:@"榜单" forState:(UIControlStateNormal)];
[self.rankBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
self.rankBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.rankBtn addTarget:self action:@selector(rankAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:self.rankBtn];
self.ruleBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-ScaleWidth(48), self.poolBtn.top, ScaleWidth(48), ScaleWidth(24))];
[self.ruleBtn setBackgroundImage:[UIImage imageNamed:@"sky_left_bg"] forState:(UIControlStateNormal)];
[self.ruleBtn setTitle:@"规则" forState:(UIControlStateNormal)];
[self.ruleBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
self.ruleBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.ruleBtn addTarget:self action:@selector(ruleAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:self.ruleBtn];
self.recordBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.ruleBtn.left, self.ruleBtn.bottom+12, ScaleWidth(48), ScaleWidth(24))];
[self.recordBtn setBackgroundImage:[UIImage imageNamed:@"sky_left_bg"] forState:(UIControlStateNormal)];
[self.recordBtn setTitle:@"记录" forState:(UIControlStateNormal)];
[self.recordBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
self.recordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.recordBtn addTarget:self action:@selector(recordAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:self.recordBtn];
self.leadToImageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_room_owner_lead"]];
self.leadToImageView1.frame = CGRectMake((self.width-90)/2, 108, 90, 12);
[self.bgView addSubview:self.leadToImageView1];
self.roomOwenrView = [[QXMeetUserView alloc] initWithFrame:CGRectMake(self.leadToImageView1.left-11-ScaleWidth(60), self.leadToImageView1.top-21, ScaleWidth(60), ScaleWidth(60)+23)];
self.roomOwenrView.isLuckUser = NO;
[self.bgView addSubview:self.roomOwenrView];
self.topGiftView = [[QXMeetGiftView alloc] initWithFrame:CGRectMake(self.leadToImageView1.right+5, self.roomOwenrView.top, ScaleWidth(48), ScaleWidth(60)+14+2)];
[self.bgView addSubview:self.topGiftView];
self.timeDownView = [[QXMeetTimeDownView alloc] initWithFrame:CGRectMake(self.roomOwenrView.right+10, self.leadToImageView1.bottom+10, ScaleWidth(88), ScaleWidth(88))];
self.timeDownView.delegate = self;
[self.bgView addSubview:self.timeDownView];
self.lockImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_lock_icon"]];
self.lockImageView.frame = CGRectMake(0, self.timeDownView.bottom, ScaleWidth(96), ScaleWidth(34));
self.lockImageView.centerX = self.bgView.centerX;
[self.bgView addSubview:self.lockImageView];
self.roomLuckUserView = [[QXMeetUserView alloc] initWithFrame:CGRectMake(self.leadToImageView1.left-11-60, self.roomOwenrView.bottom+21, ScaleWidth(94), ScaleWidth(94)+23)];
self.roomLuckUserView.isLuckUser = YES;
self.roomLuckUserView.centerX = self.roomOwenrView.centerX;
[self.bgView addSubview:self.roomLuckUserView];
self.bottomGiftBgView = [[UIView alloc] initWithFrame:CGRectMake(self.topGiftView.left-20, self.roomLuckUserView.bottom-14-ScaleWidth(118)-15, ScaleWidth(118), 14+ScaleWidth(118))];
self.bottomGiftBgView.bottom = self.roomLuckUserView.bottom;
[self.bgView addSubview:self.bottomGiftBgView];
self.bottomGiftView = [[QXMeetGiftView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(118), ScaleWidth(118)+14)];
self.bottomGiftView.isLockGift = YES;
[self.bottomGiftBgView addSubview:self.bottomGiftView];
self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 18, self.bottomGiftBgView.width, 40)];
self.countLabel.textColor = RGB16(0xF6D780);
self.countLabel.textAlignment = NSTextAlignmentRight;
self.countLabel.font = [UIFont fontWithName:@"DIN Condensed" size:35];
[self.bottomGiftBgView addSubview:self.countLabel];
CGFloat btnWidth = ScaleWidth(109);
CGFloat btnMargin = (SCREEN_WIDTH- ScaleWidth(109)*3)/4;
QXMeetDrawBtn *oneBtn = [[QXMeetDrawBtn alloc] initWithFrame:CGRectMake(btnMargin, self.bgView.height-ScaleWidth(34)-20, btnWidth, ScaleWidth(34))];
oneBtn.btnType = QXMeetDrawBtnTypeOne;
self.oneBtn = oneBtn;
self.oneBtn.hidden = YES;
[oneBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:oneBtn];
QXMeetDrawBtn *tenBtn = [[QXMeetDrawBtn alloc] initWithFrame:CGRectMake(self.oneBtn.right+btnMargin, self.oneBtn.top, btnWidth, ScaleWidth(34))];
tenBtn.btnType = QXMeetDrawBtnTypeTen;
self.tenBtn = tenBtn;
self.tenBtn.hidden = YES;
[tenBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:tenBtn];
QXMeetDrawBtn *hundredBtn = [[QXMeetDrawBtn alloc] initWithFrame:CGRectMake(tenBtn.right+btnMargin, self.oneBtn.top, btnWidth, ScaleWidth(34))];
hundredBtn.btnType = QXMeetDrawBtnTypeHundred;
self.hundredBtn = hundredBtn;
self.hundredBtn.hidden = YES;
[hundredBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:hundredBtn];
self.coinView = [[UIView alloc] initWithFrame:CGRectMake((self.bgView.width-100)/2,self.oneBtn.top-20-ScaleWidth(28), 100,ScaleWidth(28))];
[self.coinView addRoundedCornersWithRadius:ScaleWidth(14)];
self.coinView.backgroundColor = RGB16A(0x2d449f,0.5);
[self.bgView addSubview:self.coinView];
self.coinBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, self.coinView.height)];
[self.coinBtn setTitleColor:RGB16(0xF8E837) forState:(UIControlStateNormal)];
[self.coinBtn setTitle:@"-" forState:(UIControlStateNormal)];
[self.coinBtn setImage:[UIImage imageNamed:@"sky_item_coin"] forState:(UIControlStateNormal)];
self.coinBtn.titleLabel.font = [UIFont systemFontOfSize:10];
self.coinBtn.userInteractionEnabled = NO;
[self.coinView addSubview:self.coinBtn];
self.exchangeBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.coinView.width-50, 0, 50, self.coinView.height)];
[self.exchangeBtn setTitle:@"去兑换" forState:(UIControlStateNormal)];
[self.exchangeBtn setTitleColor:RGB16(0xF8E837) forState:(UIControlStateNormal)];
self.exchangeBtn.titleLabel.font = [UIFont systemFontOfSize:10];
self.exchangeBtn.userInteractionEnabled = YES;
[self.exchangeBtn addTarget:self action:@selector(exchangeAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.coinView addSubview:self.exchangeBtn];
self.jumpAnimateBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.bgView.width-109, 0, 109, ScaleWidth(28))];
[self.jumpAnimateBtn setImage:[UIImage imageNamed:@"login_agreement_nor"] forState:(UIControlStateNormal)];
[self.jumpAnimateBtn setImage:[UIImage imageNamed:@"login_agreement_sel"] forState:(UIControlStateSelected)];
[self.jumpAnimateBtn addTarget:self action:@selector(jumpAnimateAction:) forControlEvents:(UIControlEventTouchUpInside)];
[self.jumpAnimateBtn setTitle:@"跳过动画" forState:(UIControlStateNormal)];
self.jumpAnimateBtn.titleLabel.font = [UIFont systemFontOfSize:12];
[self.jumpAnimateBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
self.jumpAnimateBtn.centerY = self.coinView.centerY;
[self.bgView addSubview:self.jumpAnimateBtn];
[self.bgView addSubview:self.cycleScrollView];
self.drawGiftCenterBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_draw_gift_center_bg"]];
self.drawGiftCenterBgImageView.contentMode = UIViewContentModeScaleToFill;
self.drawGiftCenterBgImageView.hidden = YES;
self.drawGiftCenterBgImageView.frame = CGRectMake((self.bgView.width-ScaleWidth(105))/2, self.cycleScrollView.top+25, ScaleWidth(105), ScaleWidth(105));
[self.bgView addSubview:self.drawGiftCenterBgImageView];
}
- (void)handlePanGesture:(UIPanGestureRecognizer *)gesture {
static CGPoint originalCenter;
if (gesture.state == UIGestureRecognizerStateBegan) {
// 记录原始中心点
originalCenter = gesture.view.center;
}else if (gesture.state == UIGestureRecognizerStateChanged) {
// 获取拖拽位移
CGPoint translation = [gesture translationInView:self];
// 只允许向下拖拽
if (translation.y > 0) {
gesture.view.center = CGPointMake(originalCenter.x, originalCenter.y + translation.y);
// // 根据拖拽距离调整透明度
// CGFloat progress = translation.y / (self.view.bounds.size.height / 2);
// gesture.view.alpha = 1.0 - MIN(progress, 0.8);
}
}
else if (gesture.state == UIGestureRecognizerStateEnded ||
gesture.state == UIGestureRecognizerStateCancelled) {
CGPoint translation = [gesture translationInView:self];
CGPoint velocity = [gesture velocityInView:self];
// 判断是否应该消失:拖拽超过一半高度或速度足够快
BOOL shouldDismiss = translation.y > self.bgView.height/2.0 || velocity.y > 1000;
if (shouldDismiss) {
[self hide];
} else {
// 恢复原位置
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
}];
}
}
}
-(void)timeDownDidFinished{
[self hide];
}
//-(void)timeDownStopAnimation{
// [self.bottomGiftView stopAnimation];
//}
//-(void)timeDownStartAnimation{
// [self.bottomGiftView startAnimation];
//}
//-(void)timeDownUpdateAnimationWithTime:(NSInteger)time{
// NSInteger speed = 1 - (30 - time)*0.03;
// if (speed <= 0.3) {
// speed = 0.3;
// }
// [self.bottomGiftView updateAnimationSpeed:speed];
//}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
return touch.view == self;
}
-(void)exchangeAction{
QXDiamondViewController *vc = [[QXDiamondViewController alloc] init];
[self.viewController.navigationController pushViewController:vc animated:YES];
}
-(void)getMyWallet{
MJWeakSelf
[[QXRequset shareInstance] getWithUrl:QXWallet parameters:@{@"token":[QXGlobal shareGlobal].loginModel.token?[QXGlobal shareGlobal].loginModel.token:@""} needCache:NO success:^(id responseObject) {
double coin = [responseObject[@"data"][@"coin"] doubleValue];
NSString *coinStr = [NSString stringWithFormat:@"%.2f",coin];
[weakSelf.coinBtn setTitle:[NSString stringWithFormat:@" %@",coinStr] forState:(UIControlStateNormal)];
[weakSelf.coinBtn sizeToFit];
CGFloat allWidth = weakSelf.coinBtn.width + self.exchangeBtn.width+15;
weakSelf.coinView.width = allWidth;
weakSelf.coinView.x = (self.bgView.width-allWidth)/2;
weakSelf.coinBtn.frame = CGRectMake(10, 0, weakSelf.coinBtn.width, weakSelf.coinView.height);
weakSelf.exchangeBtn.frame = CGRectMake(allWidth-weakSelf.exchangeBtn.width, 0, weakSelf.exchangeBtn.width, weakSelf.coinView.height);
weakSelf.coin = coin;
[weakSelf configBtnStatus];
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
}];
}
-(void)getGiftList{
// if (self.model) {
// return;
// }
MJWeakSelf
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/xlh"] parameters:@{@"room_id":self.roomId?self.roomId:@""} needCache:NO success:^(id responseObject) {
QXActivityXLHModel *model = [QXActivityXLHModel yy_modelWithJSON:responseObject[@"data"]];
weakSelf.model = model;
[weakSelf configData];
[weakSelf.bottomGiftView stopAnimation];
[weakSelf.bottomGiftView startAnimation];
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
}];
}
-(void)configBtnStatus{
if (self.coin > 0 && self.model.box_price.integerValue > 0) {
if (self.coin>=self.model.box_price.integerValue) {
self.oneBtn.isDisable = NO;
}else{
self.oneBtn.isDisable = YES;
}
if (self.coin>=(self.model.box_price.integerValue*6)) {
self.tenBtn.isDisable = NO;
}else{
self.tenBtn.isDisable = YES;
}
if (self.coin>=(self.model.box_price.integerValue*9)) {
self.hundredBtn.isDisable = NO;
}else{
self.hundredBtn.isDisable = YES;
}
}else{
self.oneBtn.isDisable = YES;
self.tenBtn.isDisable = YES;
self.hundredBtn.isDisable = YES;
}
}
-(void)drawGiftWithNum:(NSString*)num{
if (self.isDrawing) {
// showToast(@"正在抽奖中");
return;
}
NSDictionary *parameters = @{
@"room_id":self.roomId,
@"num":num
};
self.drawGiftCenterBgImageView.hidden = YES;
self.drawGiftCenterBgImageView.alpha = 0;
self.isDrawing = YES;
self.resultView.times = num;
MJWeakSelf
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/xlh_draw_gift"] parameters:parameters needCache:NO success:^(id responseObject) {
weakSelf.resultArray = [NSArray yy_modelArrayWithClass:[QXDrawGiftModel class] json:responseObject[@"data"]];
[weakSelf getMyWallet];
if (weakSelf.jumpAnimateBtn.selected) {
weakSelf.resultView.resultArray = weakSelf.resultArray;
[weakSelf.resultView showInView:weakSelf];
weakSelf.isDrawing = NO;
}else{
NSInteger index = 0;
QXDrawGiftModel *md1 = weakSelf.resultArray.firstObject;
for (int j = 0; j < weakSelf.model.gift_list.count; j++) {
QXDrawGiftModel *md2 = weakSelf.model.gift_list[j];
if ([md1.gift_id isEqualToString:md2.gift_id]) {
index = j;
break;
}
}
weakSelf.cycleScrollView.finalPrizeIndex = index;
[weakSelf.cycleScrollView startLotteryAnimation];
}
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
weakSelf.isDrawing = NO;
showToast(msg);
}];
}
#pragma mark - LotteryWheelViewDelegate
- (void)lotteryWheelDidStopAtIndex:(NSInteger)index {
// NSString *prizeName = self.lotteryWheel.prizes[index];
// self.resultLabel.text = [NSString stringWithFormat:@"恭喜获得:%@", prizeName];
//
// // 显示获奖动画
// [UIView animateWithDuration:0.3 animations:^{
// self.resultLabel.transform = CGAffineTransformMakeScale(1.2, 1.2);
// } completion:^(BOOL finished) {
// [UIView animateWithDuration:0.3 animations:^{
// self.resultLabel.transform = CGAffineTransformIdentity;
// }];
// }];
self.drawGiftCenterBgImageView.hidden = NO;
MJWeakSelf
[UIView animateWithDuration:0.2 animations:^{
weakSelf.drawGiftCenterBgImageView.alpha = 1;
} completion:^(BOOL finished) {
weakSelf.resultView.resultArray = weakSelf.resultArray;
[weakSelf.resultView showInView:weakSelf];
weakSelf.isDrawing = NO;
}];
}
-(void)updateUserAndGiftInfoWithModel:(QXRoomChatListModel *)model{
if (self.model.xlh_user == nil) {
QXUserModel *xlh_user = [[QXUserModel alloc] init];
self.model.xlh_user = xlh_user;
}
self.model.xlh_user.nickname = model.FromUserInfo.nickname;
self.model.xlh_user.avatar = model.FromUserInfo.avatar;
self.model.locking_gift.gift_num = model.gift_num;
self.model.xlh_end_time = model.end_time;
[self configData];
}
-(void)configData{
[self.oneBtn.giftCoin setTitle:[NSString stringWithFormat:@"%@币一次",self.model.box_price] forState:(UIControlStateNormal)];
[self.tenBtn.giftCoin setTitle:[NSString stringWithFormat:@"%ld币一次",self.model.box_price.integerValue*10] forState:(UIControlStateNormal)];
[self.hundredBtn.giftCoin setTitle:[NSString stringWithFormat:@"%ld币一次",self.model.box_price.integerValue*100] forState:(UIControlStateNormal)];
self.oneBtn.hidden = NO;
self.tenBtn.hidden = NO;
self.hundredBtn.hidden = NO;
[self configBtnStatus];
if (self.model.xlh_user) {
self.roomLuckUserView.model = self.model.xlh_user;
}else{
[self.roomLuckUserView resetView];
}
if (self.model.homeowner_user) {
self.roomOwenrView.model = self.model.homeowner_user;
}else{
[self.roomOwenrView resetView];
}
if (self.model.locking_gift) {
self.bottomGiftView.model = self.model.locking_gift;
self.countLabel.text = self.model.locking_gift.gift_num?[NSString stringWithFormat:@"x%@",self.model.locking_gift.gift_num]:@"x0";
}
if (self.model.give_homeowner_gift) {
self.topGiftView.model = self.model.give_homeowner_gift;
}
self.cycleScrollView.prizes = self.model.gift_list;
self.timeDownView.endTime = self.model.xlh_end_time.longLongValue;
}
-(void)startAction:(QXMeetDrawBtn*)sender{
[self drawGiftWithNum:[NSString stringWithFormat:@"%ld",sender.btnType]];
}
-(void)jumpAnimateAction:(UIButton*)sender{
sender.selected = !sender.selected;
}
-(void)showInView:(UIView *)view{
[self getGiftList];
[self getMyWallet];
self.bgView.y = SCREEN_HEIGHT;
[view addSubview:self];
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
}];
}
-(void)hide{
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT;
} completion:^(BOOL finished) {
[self removeFromSuperview];
[self.bottomGiftView stopAnimation];
}];
}
-(void)poolAction{
self.poolView.roomId = self.roomId;
[self.poolView showInView:self];
}
-(void)ruleAction{
self.ruleView.rule = self.model.rule_url;
[self.ruleView showInView:self];
}
-(void)recordAction{
self.recordView.roomId = self.roomId;
[self.recordView showInView:self];
}
-(void)rankAction{
self.rankView.roomId = self.roomId;
[self.rankView showInView:self];
}
-(QXMeetActivityRuleView *)ruleView{
if (!_ruleView) {
_ruleView = [[QXMeetActivityRuleView alloc] init];
}
return _ruleView;
}
-(QXMeetActivityRankView *)rankView{
if (!_rankView) {
_rankView = [[QXMeetActivityRankView alloc] init];
}
return _rankView;
}
-(QXMeetActivityPoolView *)poolView{
if (!_poolView) {
_poolView = [[QXMeetActivityPoolView alloc] init];
}
return _poolView;
}
-(QXMeetActivityRecordView *)recordView{
if (!_recordView) {
_recordView = [[QXMeetActivityRecordView alloc] init];
}
return _recordView;
}
-(QXMeetActivityResultView *)resultView{
if (!_resultView) {
_resultView = [[QXMeetActivityResultView alloc] init];
MJWeakSelf
_resultView.againBlock = ^(NSString * _Nonnull times) {
// weakSelf.jumpAnimateBtn.selected = YES;
[weakSelf drawGiftWithNum:times];
};
}
return _resultView;
}
-(QXMeetLotteryView *)cycleScrollView{
if (!_cycleScrollView) {
_cycleScrollView = [[QXMeetLotteryView alloc] initWithFrame:CGRectMake(0, self.bottomGiftBgView.bottom+20, self.bgView.width, 220)];
_cycleScrollView.delegate = self;
}
return _cycleScrollView;
}
@end
@implementation QXMeetTimeDownView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)setEndTime:(long long)endTime{
_endTime = endTime;
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970];
// 将秒转换为毫秒
long long milliseconds = (long long)(timeInterval);
self.startTime = endTime - milliseconds;
if (self.startTime <= 0) {
//时间错误不进行倒计时
self.bigTimeLabel.hidden = NO;
self.timeLabel.hidden = YES;
self.titleLabel.hidden = YES;
self.bigTimeLabel.text = @"0";
return;
}
MJWeakSelf
[self stopTimer];
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.startTime--;
// NSInteger hour = self.startTime/60/60;
NSInteger min = (weakSelf.startTime % 3600) / 60;
NSInteger second = weakSelf.startTime % 60;
if (weakSelf.startTime<=30) {
weakSelf.bigTimeLabel.hidden = NO;
weakSelf.timeLabel.hidden = YES;
weakSelf.titleLabel.hidden = YES;
weakSelf.bigTimeLabel.text = [NSString stringWithFormat:@"%lld",weakSelf.startTime];
weakSelf.timeLabel.text = @"-";
if (weakSelf.startTime == 30) {
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(timeDownStartAnimation)]) {
[weakSelf.delegate timeDownStartAnimation];
}
}else{
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(timeDownUpdateAnimationWithTime:)]) {
[weakSelf.delegate timeDownUpdateAnimationWithTime:weakSelf.startTime];
}
}
// 弹性动画
[UIView animateWithDuration:0.6
delay:0
usingSpringWithDamping:0
initialSpringVelocity:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
weakSelf.bigTimeLabel.transform = CGAffineTransformMakeScale(1.5, 1.5);
} completion:^(BOOL finished) {
weakSelf.bigTimeLabel.transform = CGAffineTransformIdentity;
}];
}else{
weakSelf.bigTimeLabel.hidden = YES;
weakSelf.timeLabel.hidden = NO;
weakSelf.titleLabel.hidden = NO;
weakSelf.timeLabel.text = [NSString stringWithFormat:@"%02ld:%02ld",min,second];
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(timeDownStopAnimation)]) {
[weakSelf.delegate timeDownStopAnimation];
}
}
if (weakSelf.startTime<=0) {
[weakSelf stopTimer];
weakSelf.bigTimeLabel.hidden = NO;
weakSelf.timeLabel.hidden = YES;
weakSelf.titleLabel.hidden = YES;
weakSelf.bigTimeLabel.text = @"0";
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(timeDownDidFinished)]) {
[weakSelf.delegate timeDownDidFinished];
}
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(timeDownStopAnimation)]) {
[weakSelf.delegate timeDownStopAnimation];
}
}
});
}];
}
-(void)stopTimer{
if (_timer) {
[self->_timer invalidate];
self->_timer= nil;
}
}
-(void)initSubviews{
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_time_down_bg1"]];
[self addSubview:self.bgImageView];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.font = [UIFont systemFontOfSize:12];
self.titleLabel.textColor = RGB16(0xFFECA7);
self.titleLabel.text = @"倒计时";
self.titleLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self).offset(-ScaleWidth(24));
make.height.mas_equalTo(15);
make.centerX.equalTo(self);
}];
self.timeLabel = [[UILabel alloc] init];
self.timeLabel.font = [UIFont fontWithName:@"DIN Condensed" size:24];
self.timeLabel.textColor = RGB16(0xFFECA7);
self.timeLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.timeLabel];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.titleLabel.mas_top).offset(0);
make.height.mas_equalTo(25);
make.centerX.equalTo(self);
}];
self.bigTimeLabel = [[UILabel alloc] init];
self.bigTimeLabel.font = [UIFont fontWithName:@"DIN Condensed" size:32];
self.bigTimeLabel.text = @"-";
self.bigTimeLabel.textAlignment = NSTextAlignmentCenter;
self.bigTimeLabel.textColor = RGB16(0xFFECA7);
[self addSubview:self.bigTimeLabel];
[self.bigTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.centerY.equalTo(self);
}];
}
@end
@implementation QXMeetDrawBtn
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"meet_touch_bg"]];
self.bgImageView.frame = self.bounds;
[self addSubview:self.bgImageView];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.width, 16)];
self.titleLabel.font = [UIFont systemFontOfSize:12];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.textColor = RGB16(0xA18710);
[self addSubview:self.titleLabel];
self.giftCoin = [[UIButton alloc] initWithFrame:CGRectMake(0, self.titleLabel.bottom, self.width, 16)];
[self.giftCoin setTitleColor:RGB16(0xA18710) forState:(UIControlStateNormal)];
[self.giftCoin setImage:[UIImage imageNamed:@"sky_item_coin"] forState:(UIControlStateNormal)];
self.giftCoin.titleLabel.font = [UIFont systemFontOfSize:10];
self.giftCoin.userInteractionEnabled = NO;
[self addSubview:self.giftCoin];
}
-(void)setIsDisable:(BOOL)isDisable{
_isDisable = isDisable;
self.bgImageView.image = [UIImage imageNamed:isDisable?@"meet_touch_dis_bg":@"meet_touch_bg"];
}
-(void)setBtnType:(QXMeetDrawBtnType)btnType{
// /// 抽一次
// QXSkyDrawBtnTypeOne = 0,
// /// 抽10次
// QXSkyDrawBtnTypeTen ,
// /// 抽100次
// QXSkyDrawBtnTypeHundred ,
_btnType = btnType;
switch (btnType) {
case QXMeetDrawBtnTypeOne:
{
self.titleLabel.text = @"抽一次";
[self.giftCoin setTitle:@"10币一次" forState:(UIControlStateNormal)];
}
break;
case QXMeetDrawBtnTypeTen:
{
self.titleLabel.text = @"抽十次";
[self.giftCoin setTitle:@"100币一次" forState:(UIControlStateNormal)];
}
break;
case QXMeetDrawBtnTypeHundred:
{
self.titleLabel.text = @"抽百次";
[self.giftCoin setTitle:@"1000币一次" forState:(UIControlStateNormal)];
}
break;
default:
break;
}
}
@end
@implementation QXMeetUserView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.clipsToBounds = NO;
self.headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(9, 9, self.width-9*2, self.width-9*2)];
self.headerImageView.image = [UIImage imageNamed:@"user_header_placehoulder"];
self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
[self.headerImageView addRoundedCornersWithRadius:self.headerImageView.height/2];
[self addSubview:self.headerImageView];
self.dressImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.width)];
self.dressImageView.image = [UIImage imageNamed:@"ac_user_dress"];
[self addSubview:self.dressImageView];
self.tagLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.width-45)/2, self.headerImageView.bottom-8, 45, 16)];
self.tagLabel.textColor = RGB16(0xFFE554);
self.tagLabel.textAlignment = NSTextAlignmentCenter;
self.tagLabel.font = [UIFont systemFontOfSize:12];
[self.tagLabel addRoundedCornersWithRadius:8];
[self addSubview:self.tagLabel];
self.nameLabel = [[UILabel alloc] init] ;
self.nameLabel.textColor = RGB16(0xffffff);
self.nameLabel.font = [UIFont systemFontOfSize:12];
self.nameLabel.text = @"虚位以待";
[self addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.bottom.equalTo(self);
}];
}
-(void)setIsLuckUser:(BOOL)isLuckUser{
_isLuckUser = isLuckUser;
self.tagLabel.textColor = isLuckUser?RGB16(0xffffff):RGB16(0xFFE554);
self.tagLabel.backgroundColor = isLuckUser?RGB16(0x6C49E4):RGB16(0x8D6F28);
self.tagLabel.text = isLuckUser?@"幸运者":@"房主";
}
-(void)setModel:(QXUserModel *)model{
_model = model;
[self.headerImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar]];
self.nameLabel.text = model.nickname;
}
-(void)resetView{
self.headerImageView.image = [UIImage imageNamed:@"user_header_placehoulder"];
self.nameLabel.text = @"虚位以待";
}
@end
@implementation QXMeetGiftView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.giftNameLabel = [[UILabel alloc] init];
self.giftNameLabel.textColor = RGB16(0xffffff);
self.giftNameLabel.font = [UIFont systemFontOfSize:12];
self.giftNameLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.giftNameLabel];
[self.giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self);
make.centerX.equalTo(self);
make.height.mas_equalTo(15);
}];
self.giftPriceBgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_gift_name_bg"]];
[self addSubview:self.giftPriceBgView];
[self.giftPriceBgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.giftNameLabel.mas_top);
make.left.right.equalTo(self);
make.height.mas_equalTo(15);
}];
self.giftCoin = [[UIButton alloc] init];
[self.giftCoin setTitleColor:RGB16(0xC7BF62) forState:(UIControlStateNormal)];
[self.giftCoin setImage:[UIImage imageNamed:@"sky_item_coin"] forState:(UIControlStateNormal)];
self.giftCoin.titleLabel.font = [UIFont systemFontOfSize:10];
[self addSubview:self.giftCoin];
[self.giftCoin mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.centerY.equalTo(self.giftPriceBgView);
}];
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_left_gift_bg"]];
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
[self addSubview:self.bgImageView];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self);
make.bottom.equalTo(self).offset(-19);
}];
self.giftBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_lock_gift_light_bg"]];
self.giftBgImageView.hidden = YES;
self.giftBgImageView.contentMode = UIViewContentModeScaleToFill;
[self addSubview:self.giftBgImageView];
[self.giftBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self);
make.bottom.equalTo(self).offset(-19);
}];
self.giftImageView = [[UIImageView alloc] init];
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
[self addSubview:self.giftImageView];
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self).offset(6);
make.right.equalTo(self).offset(-6);
make.height.equalTo(self.giftImageView.mas_width);
}];
[self bringSubviewToFront:self.giftPriceBgView];
[self bringSubviewToFront:self.giftCoin];
}
-(void)setIsLockGift:(BOOL)isLockGift{
_isLockGift = isLockGift;
self.bgImageView.image = [UIImage imageNamed:isLockGift?@"ac_lock_gift_bg":@"ac_left_gift_bg"];
self.giftBgImageView.hidden = isLockGift?NO:YES;
if (isLockGift) {
[self.giftImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.centerY.equalTo(self.bgImageView);
make.height.width.mas_equalTo(ScaleWidth(62));
}];
}
//
}
-(void)setModel:(QXDrawGiftModel *)model{
_model = model;
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
self.giftNameLabel.text = model.gift_name;
[self.giftCoin setTitle:model.gift_price forState:(UIControlStateNormal)];
}
- (void)startAnimation {
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
//旋转角度
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI];
//每次旋转的时间(单位秒)
rotationAnimation.duration = 3;
rotationAnimation.cumulative = YES;
rotationAnimation.removedOnCompletion = NO;
//重复旋转的次数如果你想要无数次那么设置成MAXFLOAT
rotationAnimation.repeatCount = MAXFLOAT;
[self.giftImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
CABasicAnimation *rotationAnimation1 = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
//旋转角度
rotationAnimation1.toValue = [NSNumber numberWithFloat: -M_PI];
//每次旋转的时间(单位秒)
rotationAnimation1.duration = 3;
rotationAnimation1.cumulative = YES;
rotationAnimation1.removedOnCompletion = NO;
//重复旋转的次数如果你想要无数次那么设置成MAXFLOAT
rotationAnimation1.repeatCount = MAXFLOAT;
[self.giftBgImageView.layer addAnimation:rotationAnimation1 forKey:@"rotationAnimation1"];
}
-(void)resetAnimation{
[self.giftImageView.layer removeAllAnimations];
[self.giftBgImageView.layer removeAllAnimations];
}
-(void)stopAnimation{
[self.giftImageView.layer removeAllAnimations];
[self.giftBgImageView.layer removeAllAnimations];
}
@end
//@implementation QXMeetGiftCell
//
//- (instancetype)initWithFrame:(CGRect)frame {
// if (self = [super initWithFrame:frame]) {
// [self initSubViews];
// }
// return self;
//}
//-(void)setModel:(QXDrawGiftModel *)model{
// _model = model;
// [self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
// self.giftNameLabel.text = model.gift_name;
// [self.giftCoinBtn setTitle:[NSString stringWithFormat:@" %@",model.gift_price] forState:(UIControlStateNormal)];
//}
//-(void)initSubViews{
// self.giftBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_cycle_gift_bg"]];
// [self addSubview:self.giftBgImageView];
// [self.giftBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.edges.equalTo(self);
// }];
//
// self.giftImageView = [[UIImageView alloc] init];
// self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
// [self addSubview:self.giftImageView];
// [self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.mas_equalTo(35);
// make.width.mas_equalTo(ScaleWidth(80));
// make.height.mas_equalTo(ScaleWidth(80));
// make.centerX.equalTo(self);
// }];
//
//
// self.giftNameBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_gift_name_bg"]];
// self.giftNameBgImageView.contentMode = UIViewContentModeScaleToFill;
// [self addSubview:self.giftNameBgImageView];
// [self.giftNameBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.right.equalTo(self);
// make.bottom.mas_equalTo(-32);
// make.height.mas_equalTo(30);
// }];
//
// self.giftNameLabel = [[UILabel alloc] init];
// self.giftNameLabel.textColor = RGB16(0xffffff);
// self.giftNameLabel.font = [UIFont systemFontOfSize:12];
// self.giftNameLabel.textAlignment = NSTextAlignmentCenter;
// [self addSubview:self.giftNameLabel];
// [self.giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.top.left.right.equalTo(self.giftNameBgImageView);
// make.height.mas_equalTo(15);
// }];
//
// self.giftCoinBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.giftImageView.left, self.giftNameLabel.bottom, self.giftImageView.width, 15)];
// [self.giftCoinBtn setTitleColor:RGB16(0xC7BF62) forState:(UIControlStateNormal)];
// [self.giftCoinBtn setImage:[UIImage imageNamed:@"sky_item_coin"] forState:(UIControlStateNormal)];
// self.giftCoinBtn.titleLabel.font = [UIFont systemFontOfSize:10];
// [self addSubview:self.giftCoinBtn];
// [self.giftCoinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
// make.bottom.left.right.equalTo(self.giftNameBgImageView);
// make.height.mas_equalTo(15);
// }];
//}
//
//@end