Files
midi_ios/QXLive/活动/巡乐会/QXMeetActivityView.m
2025-09-15 18:20:22 +08:00

873 lines
38 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>
@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)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.timeDownView = [[QXMeetTimeDownView alloc] initWithFrame:CGRectMake((self.bgView.width-ScaleWidth(122))/2, self.rankBtn.top-4, ScaleWidth(122), ScaleWidth(29))];
[self.bgView addSubview:self.timeDownView];
self.giftImageView = [[UIImageView alloc] initWithFrame:CGRectMake((self.bgView.width-ScaleWidth(118))/2, self.timeDownView.bottom+11, ScaleWidth(118), ScaleWidth(118))];
[self.bgView addSubview:self.giftImageView];
self.giftNameBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_gift_name_bg"]];
self.giftNameBgImageView.contentMode = UIViewContentModeScaleToFill;
self.giftNameBgImageView.frame = CGRectMake(self.giftImageView.left, self.giftImageView.bottom-30, self.giftImageView.width, 30);
[self.bgView addSubview:self.giftNameBgImageView];
self.giftNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.giftImageView.left, self.giftImageView.bottom-30, self.giftImageView.width, 15)];
self.giftNameLabel.textColor = RGB16(0xffffff);
self.giftNameLabel.font = [UIFont systemFontOfSize:12];
self.giftNameLabel.textAlignment = NSTextAlignmentCenter;
[self.bgView addSubview:self.giftNameLabel];
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.bgView addSubview:self.giftCoinBtn];
self.giftHeartImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_gift_heart"]];
self.giftHeartImageView.frame = CGRectMake((self.bgView.width-ScaleWidth(46))/2, self.giftCoinBtn.bottom, ScaleWidth(46), ScaleWidth(46));
[self.bgView addSubview:self.giftHeartImageView];
self.heartLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.bgView.width, 14)];
self.heartLabel.textAlignment = NSTextAlignmentCenter;
self.heartLabel.font = [UIFont boldSystemFontOfSize:14];
self.heartLabel.text = @"-";
self.heartLabel.centerY = self.giftHeartImageView.centerY;
[self.bgView addSubview:self.heartLabel];
self.centerGiftBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_center_gift_bg"]];
self.centerGiftBgImageView.frame = CGRectMake((self.bgView.width-ScaleWidth(320))/2, self.giftImageView.top, ScaleWidth(320), ScaleWidth(195));
[self.bgView insertSubview:self.centerGiftBgImageView belowSubview:self.giftImageView];
self.userBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_user_bg"]];
self.userBgImageView.contentMode = UIViewContentModeScaleToFill;
self.userBgImageView.frame = CGRectMake(self.bgView.width-25-ScaleWidth(56), 0, ScaleWidth(56), ScaleWidth(73));
self.userBgImageView.centerY = self.centerGiftBgImageView.centerY;
[self.bgView addSubview:self.userBgImageView];
self.userHeader = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.userBgImageView.top, ScaleWidth(36), ScaleWidth(36))];
self.userHeader.contentMode = UIViewContentModeScaleAspectFill;
self.userHeader.centerX = self.userBgImageView.centerX;
[self.userHeader addRoundedCornersWithRadius:ScaleWidth(18)];
[self.bgView addSubview:self.userHeader];
self.userHeaderDress = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(52), ScaleWidth(52))];
UIImage *dressImage = [UIImage imageNamed:@"ac_user_dress"];
self.userHeaderDress.image = dressImage;
self.userHeaderDress.hidden = YES;
self.userHeaderDress.contentMode = UIViewContentModeScaleAspectFill;
self.userHeaderDress.centerX = self.userHeader.centerX;
self.userHeaderDress.centerY = self.userHeader.centerY;
[self.bgView addSubview:self.userHeaderDress];
// @2x
self.userNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.userBgImageView.left, self.userBgImageView.bottom-7-14, self.userBgImageView.width, 14)];
self.userNameLabel.textColor = RGB16(0xffffff);
self.userNameLabel.font = [UIFont systemFontOfSize:12];
self.userNameLabel.text = @"虚位以待";
self.userNameLabel.textAlignment = NSTextAlignmentCenter;
[self.bgView addSubview:self.userNameLabel];
self.leftGiftBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_left_gift_bg"]];
self.leftGiftBgImageView.frame = CGRectMake(25, 0, ScaleWidth(94), ScaleWidth(105));
self.leftGiftBgImageView.centerY = self.centerGiftBgImageView.centerY;
[self.bgView addSubview:self.leftGiftBgImageView];
self.leftGiftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.leftGiftBgImageView.top+ScaleWidth(13), ScaleWidth(54), ScaleWidth(52))];
self.leftGiftImageView.centerX = self.leftGiftBgImageView.centerX;
// self.leftGiftImageView.backgroundColor = UIColor.redColor;
[self.bgView addSubview:self.leftGiftImageView];
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);
}];
}
}
}
-(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];
} 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*10)) {
self.tenBtn.isDisable = NO;
}else{
self.tenBtn.isDisable = YES;
}
if (self.coin>(self.model.box_price.integerValue*100)) {
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.userHeader sd_setImageWithURL:[NSURL URLWithString:self.model.xlh_user.avatar]];
self.userHeader.hidden = NO;
self.userNameLabel.text = self.model.xlh_user.nickname?self.model.xlh_user.nickname:@"虚位以待";
self.userHeaderDress.hidden = NO;
}else{
self.userHeaderDress.hidden = YES;
self.userHeader.hidden = YES;
self.userNameLabel.text = self.model.xlh_user.nickname?self.model.xlh_user.nickname:@"虚位以待";
}
if (self.model.locking_gift) {
NSString *encodedQuery = [self.model.locking_gift.base_image stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSURL *imageUrl = [NSURL URLWithString:encodedQuery];
[self.giftImageView sd_setImageWithURL:imageUrl];
self.giftNameLabel.text = self.model.locking_gift.gift_name;
[self.giftCoinBtn setTitle:[NSString stringWithFormat:@" %@",self.model.locking_gift.gift_price] forState:(UIControlStateNormal)];
self.heartLabel.text = self.model.locking_gift.gift_num?self.model.locking_gift.gift_num:@"0";
}
if (self.model.give_homeowner_gift) {
[self.leftGiftImageView sd_setImageWithURL:[NSURL URLWithString:self.model.give_homeowner_gift.base_image]];
}
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];
}];
}
-(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 drawGiftWithNum:times];
};
}
return _resultView;
}
-(QXMeetLotteryView *)cycleScrollView{
if (!_cycleScrollView) {
_cycleScrollView = [[QXMeetLotteryView alloc] initWithFrame:CGRectMake(0, self.giftHeartImageView.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.timeLabel1.text = @"0";
self.timeLabel2.text = @"0";
self.timeLabel3.text = @"0";
self.timeLabel4.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 = (self.startTime % 3600) / 60;
NSInteger second = self.startTime % 60;
NSString *time = [NSString stringWithFormat:@"%02ld%02ld",min,second];
if (time.length == 4) {
self.timeLabel1.text = [time substringWithRange:NSMakeRange(0, 1)];
self.timeLabel2.text = [time substringWithRange:NSMakeRange(1, 1)];
self.timeLabel3.text = [time substringWithRange:NSMakeRange(2, 1)];
self.timeLabel4.text = [time substringWithRange:NSMakeRange(3, 1)];
}
if (weakSelf.startTime<=0) {
[weakSelf stopTimer];
weakSelf.timeLabel1.text = @"0";
weakSelf.timeLabel2.text = @"0";
weakSelf.timeLabel3.text = @"0";
weakSelf.timeLabel4.text = @"0";
}
});
}];
}
-(void)stopTimer{
if (_timer) {
[self->_timer invalidate];
self->_timer= nil;
}
}
-(void)initSubviews{
self.timeBgView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_time_down_bg"]];
[self addSubview:self.timeBgView1];
[self.timeBgView1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(ScaleWidth(19));
make.height.mas_equalTo(ScaleWidth(29));
make.left.equalTo(self);
make.centerY.equalTo(self);
}];
self.timeLabel1 = [[UILabel alloc] init];
self.timeLabel1.font = [UIFont fontWithName:@"Didot" size:16];
self.timeLabel1.textColor = RGB16(0x00F3D3);
self.timeLabel1.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.timeLabel1];
[self.timeLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.timeBgView1);
}];
self.timeBgView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_time_down_bg"]];
[self addSubview:self.timeBgView2];
[self.timeBgView2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(ScaleWidth(19));
make.height.mas_equalTo(ScaleWidth(29));
make.left.equalTo(self.timeBgView1.mas_right).offset(6);
make.centerY.equalTo(self);
}];
self.timeLabel2 = [[UILabel alloc] init];
self.timeLabel2.font = [UIFont fontWithName:@"Didot" size:16];
self.timeLabel2.textColor = RGB16(0x00F3D3);
self.timeLabel2.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.timeLabel2];
[self.timeLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.timeBgView2);
}];
self.centerLabel = [[UILabel alloc] init];
self.centerLabel.font = [UIFont fontWithName:@"Didot" size:16];
self.centerLabel.text = @":";
self.centerLabel.textAlignment = NSTextAlignmentCenter;
self.centerLabel.textColor = RGB16(0x00F3D3);
[self addSubview:self.centerLabel];
[self.centerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.centerY.equalTo(self);
}];
self.timeBgView4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_time_down_bg"]];
[self addSubview:self.timeBgView4];
[self.timeBgView4 mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(ScaleWidth(19));
make.height.mas_equalTo(ScaleWidth(29));
make.right.equalTo(self);
make.centerY.equalTo(self);
}];
self.timeLabel4 = [[UILabel alloc] init];
self.timeLabel4.font = [UIFont fontWithName:@"Didot" size:16];
self.timeLabel4.textColor = RGB16(0x00F3D3);
self.timeLabel4.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.timeLabel4];
[self.timeLabel4 mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.timeBgView4);
}];
self.timeBgView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_meet_time_down_bg"]];
[self addSubview:self.timeBgView3];
[self.timeBgView3 mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(ScaleWidth(19));
make.height.mas_equalTo(ScaleWidth(29));
make.right.equalTo(self.timeBgView4.mas_left).offset(-6);
make.centerY.equalTo(self);
}];
self.timeLabel3 = [[UILabel alloc] init];
self.timeLabel3.textColor = RGB16(0x00F3D3);
self.timeLabel3.textAlignment = NSTextAlignmentCenter;
self.timeLabel3.font = [UIFont fontWithName:@"Didot" size:16];
[self addSubview:self.timeLabel3];
[self.timeLabel3 mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.timeBgView3);
}];
self.timeLabel1.text = @"0";
self.timeLabel2.text = @"0";
self.timeLabel3.text = @"0";
self.timeLabel4.text = @"0";
}
@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 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