覆盖羽声
54
QXLive/活动/QXDrawGiftCenterView.h
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// QXDrawGiftCenterView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/27.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXGiftActivityModel.h"
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
/// 等待开始
|
||||
QXDrawGiftCenterTypeWait = 0,
|
||||
/// 即将开始
|
||||
QXDrawGiftCenterTypeWill = 2,
|
||||
/// 正式开始
|
||||
QXDrawGiftCenterTypeStart = 1 ,
|
||||
}QXDrawGiftCenterType;
|
||||
|
||||
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
/// 天空之境
|
||||
QXActivityTypeSky = 10,
|
||||
/// 岁月之城
|
||||
QXActivityTypeAge ,
|
||||
/// 时空之巅
|
||||
QXActivityTypeTime ,
|
||||
}QXActivityType;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXDrawGiftCenterProgressView : UIView
|
||||
@property (nonatomic, strong) UIColor *progressColor; // 进度条颜色
|
||||
@property (nonatomic, assign) double progress; // 进度 0.0 - 1.0
|
||||
@property (nonatomic,strong) UILabel *cycleLabel;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@interface QXDrawGiftCenterView : UIView
|
||||
@property (nonatomic, strong)QXDrawGiftCenterProgressView *progressView;
|
||||
@property (nonatomic, assign) double progress; // 进度 0.0 - 1.0
|
||||
@property (nonatomic,strong) UIImageView *bgImageView;
|
||||
@property (nonatomic,strong) UIButton *startBtn;
|
||||
|
||||
@property (nonatomic,strong) UIView *cycleBgView;
|
||||
|
||||
|
||||
@property (nonatomic,assign)QXDrawGiftCenterType type;
|
||||
@property (nonatomic,assign)QXActivityType activityType;
|
||||
@property (nonatomic,strong)QXGiftActivityModel *model;
|
||||
|
||||
@property (nonatomic,copy)void(^startBlock)(void);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
228
QXLive/活动/QXDrawGiftCenterView.m
Normal file
@@ -0,0 +1,228 @@
|
||||
//
|
||||
// QXDrawGiftCenterView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/27.
|
||||
//
|
||||
|
||||
#import "QXDrawGiftCenterView.h"
|
||||
static CGFloat lineWidth = 13;
|
||||
|
||||
@implementation QXDrawGiftCenterProgressView
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.progressColor = RGB16(0x32F6CB);
|
||||
self.backgroundColor = RGB16(0x70ADFA);
|
||||
self.cycleLabel = [[UILabel alloc] init];
|
||||
self.cycleLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
self.cycleLabel.textColor = RGB16(0xffffff);
|
||||
[self addSubview:self.cycleLabel];
|
||||
[self.cycleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.centerY.equalTo(self);
|
||||
}];
|
||||
[self bringSubviewToFront:self.cycleLabel];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)drawRect:(CGRect)rect{
|
||||
[super drawRect:rect];
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
CGContextSaveGState(context);
|
||||
|
||||
// 计算圆心和半径
|
||||
CGPoint center = CGPointMake(rect.size.width / 2, rect.size.height / 2);
|
||||
CGFloat radius = MIN(ScaleWidth(70), ScaleWidth(70)) / 2 - lineWidth / 2;
|
||||
|
||||
|
||||
// 绘制进度圆环
|
||||
[self drawProgressWithCenter:center radius:radius];
|
||||
|
||||
CGContextRestoreGState(context);
|
||||
}
|
||||
- (void)setProgress:(double)progress {
|
||||
_progress = MAX(0.0, MIN(1.0, progress)); // 限制在0-1之间
|
||||
[self setNeedsDisplay];
|
||||
self.cycleLabel.text = [NSString stringWithFormat:@"%d%%",(int)(progress*100)];
|
||||
[self bringSubviewToFront:self.cycleLabel];
|
||||
}
|
||||
|
||||
- (void)drawProgressWithCenter:(CGPoint)center radius:(CGFloat)radius {
|
||||
if (self.progress > 0) {
|
||||
// 计算结束角度(顺时针从顶部开始)
|
||||
CGFloat endAngle = -M_PI_2 + 2 * M_PI * self.progress;
|
||||
|
||||
UIBezierPath *progressPath = [UIBezierPath bezierPathWithArcCenter:center
|
||||
radius:radius
|
||||
startAngle:-M_PI_2 // 从顶部开始(-90度)
|
||||
endAngle:endAngle
|
||||
clockwise:YES];
|
||||
[self.progressColor setStroke];
|
||||
progressPath.lineWidth = lineWidth;
|
||||
progressPath.lineCapStyle = kCGLineCapRound;
|
||||
[progressPath stroke];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@implementation QXDrawGiftCenterView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setModel:(QXGiftActivityModel *)model{
|
||||
_model = model;
|
||||
if (model.is_xlh.intValue == 1) {
|
||||
self.hidden = NO;
|
||||
}else{
|
||||
self.hidden = YES;
|
||||
}
|
||||
double progress = (model.xlh_data.current_num.doubleValue/model.xlh_data.start_num.doubleValue);
|
||||
[self setProgress:progress];
|
||||
QXDrawGiftCenterType type = model.xlh_data.status.integerValue;
|
||||
[self setType:type];
|
||||
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_status_bg"]];
|
||||
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.right.equalTo(self);
|
||||
make.height.equalTo(self.bgImageView.mas_width);
|
||||
}];
|
||||
|
||||
self.cycleBgView = [[UIView alloc] init];
|
||||
self.cycleBgView.backgroundColor = RGB16(0x70ADFA);
|
||||
[self.cycleBgView addRoundedCornersWithRadius:ScaleWidth(35)];
|
||||
[self addSubview:self.cycleBgView];
|
||||
[self.cycleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(ScaleWidth(70));
|
||||
make.centerX.equalTo(self.bgImageView);
|
||||
make.centerY.equalTo(self.bgImageView).offset(10);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
self.startBtn = [[UIButton alloc] init];
|
||||
[self.startBtn addTarget:self action:@selector(startAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.startBtn];
|
||||
[self.startBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(ScaleWidth(92));
|
||||
make.height.mas_equalTo(ScaleWidth(54));
|
||||
make.centerX.equalTo(self);
|
||||
make.bottom.equalTo(self);
|
||||
}];
|
||||
self.progressView = [[QXDrawGiftCenterProgressView alloc] init];
|
||||
[self.progressView addRoundedCornersWithRadius:ScaleWidth(35)];
|
||||
[self addSubview:self.progressView];
|
||||
[self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(ScaleWidth(70));
|
||||
make.centerX.centerY.equalTo(self.cycleBgView);
|
||||
// make.centerY.equalTo(self.bgImageView).offset(10);
|
||||
}];
|
||||
// [self startHide];
|
||||
|
||||
}
|
||||
|
||||
-(void)startAction{
|
||||
switch (self.type) {
|
||||
case QXDrawGiftCenterTypeWait:{
|
||||
showToast(@"活动未开始");
|
||||
}
|
||||
break;
|
||||
case QXDrawGiftCenterTypeWill:{
|
||||
showToast(@"活动即将开始");
|
||||
}
|
||||
break;
|
||||
case QXDrawGiftCenterTypeStart:{
|
||||
if (self.startBlock) {
|
||||
self.startBlock();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)startHide{
|
||||
[UIView animateWithDuration:1 animations:^{
|
||||
// self.bgImageView.alpha = 0;
|
||||
self.alpha = 0;
|
||||
} completion:^(BOOL finished) {
|
||||
[self startShow];
|
||||
}];
|
||||
}
|
||||
-(void)startShow{
|
||||
[UIView animateWithDuration:1 animations:^{
|
||||
// self.bgImageView.alpha = 1;
|
||||
self.alpha = 1;
|
||||
} completion:^(BOOL finished) {
|
||||
[self startHide];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
- (void)setProgress:(CGFloat)progress {
|
||||
_progress = progress;
|
||||
self.progressView.progress = progress;
|
||||
}
|
||||
|
||||
-(void)setActivityType:(QXActivityType)activityType{
|
||||
_activityType = activityType;
|
||||
switch (_activityType) {
|
||||
case QXActivityTypeSky:{
|
||||
self.bgImageView.image = [UIImage imageNamed:@"sky_status_bg"];
|
||||
}
|
||||
break;
|
||||
case QXActivityTypeAge:{
|
||||
self.bgImageView.image = [UIImage imageNamed:@"age_status_bg"];
|
||||
}
|
||||
break;
|
||||
case QXActivityTypeTime:{
|
||||
self.bgImageView.image = [UIImage imageNamed:@"time_status_bg"];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setType:(QXDrawGiftCenterType)type{
|
||||
_type = type;
|
||||
switch (_type) {
|
||||
case QXDrawGiftCenterTypeWait:{
|
||||
[self.startBtn setBackgroundImage:[UIImage imageNamed:@"meet_status_wait"] forState:(UIControlStateNormal)];
|
||||
}
|
||||
break;
|
||||
case QXDrawGiftCenterTypeWill:{
|
||||
[self.startBtn setBackgroundImage:[UIImage imageNamed:@"meet_status_will"] forState:(UIControlStateNormal)];
|
||||
}
|
||||
break;
|
||||
case QXDrawGiftCenterTypeStart:{
|
||||
[self.startBtn setBackgroundImage:[UIImage imageNamed:@"meet_status_start"] forState:(UIControlStateNormal)];
|
||||
[self setProgress:1];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
||||
106
QXLive/活动/QXGiftActivityModel.h
Normal file
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// QXGiftActivityModel.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class QXXLHModel,QXDrawGiftModel;
|
||||
@interface QXGiftActivityModel : NSObject
|
||||
@property (nonatomic,strong)NSString *title;
|
||||
@property (nonatomic,strong)NSString *rule_url;
|
||||
/// 抽1次的价格
|
||||
@property (nonatomic,strong)NSString *box_price;
|
||||
///是否开启了巡乐会 0 未开启 1已开启
|
||||
@property (nonatomic,strong)NSString *is_xlh;
|
||||
/// 巡乐会数据
|
||||
@property (nonatomic,strong)QXXLHModel *xlh_data;
|
||||
|
||||
@property (nonatomic,strong)NSArray<QXDrawGiftModel*>* gift_list;
|
||||
@end
|
||||
|
||||
@interface QXXLHModel : NSObject
|
||||
///等待开始需要达到的次数
|
||||
@property (nonatomic,strong)NSString *waiting_start_num;
|
||||
///巡乐会开启需要达到的次数 【进度条 】
|
||||
@property (nonatomic,strong)NSString *start_num;
|
||||
///当前已抽奖次数 【进度条 】
|
||||
@property (nonatomic,strong)NSString *current_num;
|
||||
///状态 1:巡乐会开始 2:即将开始开始 0:等待开始
|
||||
@property (nonatomic,strong)NSString *status;
|
||||
|
||||
@property (nonatomic,assign)long end_time;
|
||||
@end
|
||||
|
||||
@interface QXDrawGiftModel : NSObject
|
||||
/// 编号
|
||||
@property (nonatomic,strong)NSString *number;
|
||||
/// giftid
|
||||
@property (nonatomic,strong)NSString *gift_id;
|
||||
/// 礼物名称
|
||||
@property (nonatomic,strong)NSString *gift_name;
|
||||
/// 礼物图标
|
||||
@property (nonatomic,strong)NSString *base_image;
|
||||
/// 礼物特效
|
||||
@property (nonatomic,strong)NSString *play_image;
|
||||
/// 礼物价格
|
||||
@property (nonatomic,strong)NSString *gift_price;
|
||||
|
||||
@property (nonatomic,strong)NSString *count;
|
||||
|
||||
/// 巡乐会number
|
||||
@property (nonatomic,strong)NSString *gift_num;
|
||||
@end
|
||||
|
||||
@interface QXDrawGiftResultModel : NSObject
|
||||
/// 抽奖结果标识
|
||||
@property (nonatomic,strong)NSString *blind_box_turntable_id;
|
||||
/// giftid 和 count
|
||||
@property (nonatomic,strong)NSArray <QXDrawGiftModel*> *reslut_list;
|
||||
@end
|
||||
|
||||
|
||||
@interface QXActivityRecordModel : NSObject
|
||||
/// giftid
|
||||
@property (nonatomic,strong)NSString *gift_id;
|
||||
///中奖礼物数量
|
||||
@property (nonatomic,strong)NSString *count;
|
||||
///接收礼物用户Id
|
||||
@property (nonatomic,strong)NSString *gift_user_id;
|
||||
/// 创建时间
|
||||
@property (nonatomic,strong)NSString *createtime;
|
||||
///用户昵称
|
||||
@property (nonatomic,strong)NSString *nickname;
|
||||
/// 礼物名称
|
||||
@property (nonatomic,strong)NSString *gift_name;
|
||||
///礼物特效
|
||||
@property (nonatomic,strong)NSString *play_image;
|
||||
/// 礼物图标
|
||||
@property (nonatomic,strong)NSString *base_image;
|
||||
|
||||
/// 期数
|
||||
@property (nonatomic,strong)NSString *periods;
|
||||
|
||||
@end
|
||||
|
||||
@interface QXActivityXLHModel : NSObject
|
||||
@property (nonatomic,strong)NSString *title;
|
||||
@property (nonatomic,strong)NSString* xlh_end_time;
|
||||
@property (nonatomic,strong)NSString *rule_url;
|
||||
@property (nonatomic,strong)NSString *box_price;
|
||||
@property (nonatomic,strong)QXDrawGiftModel* give_homeowner_gift;
|
||||
@property (nonatomic,strong)QXDrawGiftModel* locking_gift;
|
||||
|
||||
@property (nonatomic,strong)QXUserModel* xlh_user;
|
||||
@property (nonatomic,strong)QXUserModel* homeowner_user;
|
||||
|
||||
@property (nonatomic,strong)NSArray<QXDrawGiftModel*>* gift_list;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
61
QXLive/活动/QXGiftActivityModel.m
Normal file
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// QXGiftActivityModel.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import "QXGiftActivityModel.h"
|
||||
|
||||
@implementation QXGiftActivityModel
|
||||
+(NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
|
||||
return @{
|
||||
@"xlh_data" : @"QXXLHModel",
|
||||
@"gift_list":@"QXDrawGiftModel"
|
||||
};
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXXLHModel
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation QXDrawGiftModel
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXDrawGiftResultModel
|
||||
+(NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
|
||||
return @{
|
||||
@"reslut_list":@"QXDrawGiftModel"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation QXActivityRecordModel
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXActivityXLHModel
|
||||
+(NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
|
||||
return @{
|
||||
@"give_homeowner_gift" : @"QXDrawGiftModel",
|
||||
@"locking_gift":@"QXDrawGiftModel",
|
||||
@"xlh_user":@"QXUserModel",
|
||||
@"homeowner_user":@"QXUserModel",
|
||||
@"gift_list":@"QXDrawGiftModel"
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
BIN
QXLive/活动/Resource/a_gift_age_bg@2x.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
QXLive/活动/Resource/a_gift_age_bg@3x.png
Normal file
|
After Width: | Height: | Size: 170 KiB |
BIN
QXLive/活动/Resource/a_gift_age_icon@2x.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
QXLive/活动/Resource/a_gift_age_icon@3x.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
QXLive/活动/Resource/a_gift_sky_bg@2x.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
QXLive/活动/Resource/a_gift_sky_bg@3x.png
Normal file
|
After Width: | Height: | Size: 134 KiB |
BIN
QXLive/活动/Resource/a_gift_sky_icon@2x.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
QXLive/活动/Resource/a_gift_sky_icon@3x.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
QXLive/活动/Resource/a_gift_time_bg@2x.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
QXLive/活动/Resource/a_gift_time_bg@3x.png
Normal file
|
After Width: | Height: | Size: 198 KiB |
BIN
QXLive/活动/Resource/a_gift_time_icon@2x.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
QXLive/活动/Resource/a_gift_time_icon@3x.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
25
QXLive/活动/天空之境/QXSkyPraizePoolView.h
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// QXSkyPraizePoolView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/27.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXGiftActivityModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXSkyPraizePoolView : UIView
|
||||
@property (nonatomic,strong)QXGiftModel *giftModel;
|
||||
@property (nonatomic,strong)NSString *roomId;
|
||||
-(void)showInView:(UIView *)view;
|
||||
@end
|
||||
|
||||
@interface QXSkyPoolCell : UICollectionViewCell
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *nameLabel;
|
||||
@property (nonatomic,strong)UIButton *giftCoin;
|
||||
@property (nonatomic,strong)QXDrawGiftModel *model;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
177
QXLive/活动/天空之境/QXSkyPraizePoolView.m
Normal file
@@ -0,0 +1,177 @@
|
||||
//
|
||||
// QXSkyPraizePoolView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/27.
|
||||
//
|
||||
|
||||
#import "QXSkyPraizePoolView.h"
|
||||
@interface QXSkyPraizePoolView()<UIGestureRecognizerDelegate,UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
|
||||
@property(nonatomic,strong)UIView* bgView;
|
||||
@property(nonatomic,strong)UIImageView* ruleImageView;
|
||||
@property(nonatomic,strong)UIImageView* bgImageView;
|
||||
|
||||
@property(nonatomic,strong)UICollectionView* collectionView;
|
||||
@property(nonatomic,strong)QXGiftActivityModel* model;
|
||||
|
||||
@end
|
||||
@implementation QXSkyPraizePoolView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == 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];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_rule_bg"]];
|
||||
self.bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663));
|
||||
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self.bgView addSubview:self.bgImageView];
|
||||
|
||||
self.ruleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_pool_icon"]];
|
||||
self.ruleImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
self.ruleImageView.frame = CGRectMake((SCREEN_WIDTH-ScaleWidth(164))/2, 0, ScaleWidth(164), ScaleWidth(90));
|
||||
[self.bgView addSubview:self.ruleImageView];
|
||||
|
||||
[self.bgView addSubview:self.collectionView];
|
||||
}
|
||||
-(void)setGiftModel:(QXGiftModel *)giftModel{
|
||||
_giftModel = giftModel;
|
||||
[self getGiftList];
|
||||
}
|
||||
-(void)setRoomId:(NSString *)roomId{
|
||||
_roomId = roomId;
|
||||
}
|
||||
-(void)getGiftList{
|
||||
if (![self.giftModel.gift_bag isExist]) {
|
||||
return;
|
||||
}
|
||||
if (![self.roomId isExist]) {
|
||||
return;
|
||||
}
|
||||
if (self.model) {
|
||||
return;
|
||||
}
|
||||
MJWeakSelf
|
||||
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_gift_list"] parameters:@{@"gift_bag_id":self.giftModel.gift_bag?self.giftModel.gift_bag:@"",@"room_id":self.roomId?self.roomId:@""} needCache:NO success:^(id responseObject) {
|
||||
QXGiftActivityModel *model = [QXGiftActivityModel yy_modelWithJSON:responseObject[@"data"]];
|
||||
weakSelf.model = model;
|
||||
[self.collectionView reloadData];
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
|
||||
}];
|
||||
}
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.model.gift_list.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXSkyPoolCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSkyPoolCell" forIndexPath:indexPath];
|
||||
cell.model = self.model.gift_list[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(void)showInView:(UIView *)view{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
// [self stopSlowAnimate];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
-(UICollectionView *)collectionView{
|
||||
if (!_collectionView) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.minimumLineSpacing = 23;
|
||||
layout.minimumInteritemSpacing = 23;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 17, 0, 17);
|
||||
layout.itemSize = CGSizeMake((SCREEN_WIDTH-17*2-23*2-1)/3, ScaleWidth(128));
|
||||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.ruleImageView.bottom+10, SCREEN_WIDTH, self.bgView.height-self.ruleImageView.bottom) collectionViewLayout:layout];
|
||||
_collectionView.delegate = self;
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.showsHorizontalScrollIndicator = NO;
|
||||
_collectionView.showsVerticalScrollIndicator = NO;
|
||||
_collectionView.backgroundColor = [UIColor clearColor];
|
||||
[_collectionView registerClass:[QXSkyPoolCell class] forCellWithReuseIdentifier:@"QXSkyPoolCell"];
|
||||
// MJWeakSelf
|
||||
// _collectionView.mj_header = [m footerWithRefreshingBlock:^{
|
||||
// [weakSelf getGiftList];
|
||||
// }];
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXSkyPoolCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setModel:(QXDrawGiftModel *)model{
|
||||
_model = model;
|
||||
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
||||
self.nameLabel.text = model.gift_name;
|
||||
[self.giftCoin setTitle:[NSString stringWithFormat:@" %@",model.gift_price] forState:(UIControlStateNormal)];
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.giftImageView = [[UIImageView alloc] init];
|
||||
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.right.equalTo(self.contentView);
|
||||
make.height.equalTo(self.giftImageView.mas_width);
|
||||
}];
|
||||
|
||||
self.nameLabel = [[UILabel alloc] init];
|
||||
self.nameLabel.textColor = RGB16(0xffffff);
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.contentView addSubview:self.nameLabel];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.giftImageView.mas_bottom);
|
||||
make.centerX.equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
self.giftCoin = [[UIButton alloc] init];
|
||||
[self.giftCoin setTitleColor:RGB16(0xC7BF62) forState:(UIControlStateNormal)];
|
||||
self.giftCoin.titleLabel.font = [UIFont systemFontOfSize:10];
|
||||
[self.giftCoin setImage:[UIImage imageNamed:@"sky_item_coin"] forState:(UIControlStateNormal)];
|
||||
[self.contentView addSubview:self.giftCoin];
|
||||
[self.giftCoin mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.nameLabel.mas_bottom);
|
||||
make.centerX.equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
36
QXLive/活动/天空之境/QXSkyPraizeRecordView.h
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// QXSkyPraizeRecordView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXGiftActivityModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXSkyPraizeRecordView : UIView
|
||||
@property (nonatomic,strong)NSString *roomId;
|
||||
@property (nonatomic,strong)QXGiftModel *giftModel;
|
||||
-(void)showInView:(UIView *)view;
|
||||
@end
|
||||
|
||||
@interface QXSkyRecordCell : UICollectionViewCell
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *giftInfoLabel;
|
||||
@property (nonatomic,strong)UILabel *recieveInfoLabel;
|
||||
@property (nonatomic,strong)UILabel *timeLabel;
|
||||
@property (nonatomic,strong)QXActivityRecordModel *model;
|
||||
@end
|
||||
|
||||
@interface QXSkyAllRecordCell : UITableViewCell
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *giftInfoLabel;
|
||||
@property (nonatomic,strong)UILabel *recieveInfoLabel;
|
||||
@property (nonatomic,strong)UILabel *timeLabel;
|
||||
@property (nonatomic,strong)UIView *bottomLine;
|
||||
@property (nonatomic,strong)QXActivityRecordModel *model;
|
||||
+(instancetype)cellWithTableView:(UITableView*)tableView;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
416
QXLive/活动/天空之境/QXSkyPraizeRecordView.m
Normal file
@@ -0,0 +1,416 @@
|
||||
//
|
||||
// QXSkyPraizeRecordView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import "QXSkyPraizeRecordView.h"
|
||||
|
||||
|
||||
@interface QXSkyPraizeRecordView()<UIGestureRecognizerDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UITableViewDelegate,UITableViewDataSource>
|
||||
@property(nonatomic,strong)UIView* bgView;
|
||||
@property(nonatomic,strong)UIImageView* ruleImageView;
|
||||
@property(nonatomic,strong)UIImageView* bgImageView;
|
||||
|
||||
@property(nonatomic,strong)UIView* bgCoverView;
|
||||
|
||||
@property(nonatomic,strong)UIButton* myRecordBtn;
|
||||
@property(nonatomic,strong)UIButton* allRecordBtn;
|
||||
@property(nonatomic,strong)UICollectionView* collectionView;
|
||||
@property(nonatomic,strong)UITableView* tableView;
|
||||
@property(nonatomic,strong)NSMutableArray* myRecordArray;
|
||||
@property(nonatomic,strong)NSMutableArray* allRecordArray;
|
||||
@property(nonatomic,assign)NSInteger page;
|
||||
@end
|
||||
@implementation QXSkyPraizeRecordView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == 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];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_rule_bg"]];
|
||||
self.bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663));
|
||||
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self.bgView addSubview:self.bgImageView];
|
||||
|
||||
self.ruleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_record_icon"]];
|
||||
self.ruleImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
self.ruleImageView.frame = CGRectMake((SCREEN_WIDTH-ScaleWidth(164))/2, 0, ScaleWidth(164), ScaleWidth(90));
|
||||
[self.bgView addSubview:self.ruleImageView];
|
||||
|
||||
self.bgCoverView = [[UIView alloc] initWithFrame:CGRectMake(16, self.ruleImageView.bottom+12, self.bgView.width-32, self.bgView.height-self.ruleImageView.bottom-24)];
|
||||
self.bgCoverView.backgroundColor = RGB16A(0x000000, 0.5);
|
||||
[self.bgView addSubview:self.bgCoverView];
|
||||
|
||||
self.myRecordBtn = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 75, 40)];
|
||||
self.myRecordBtn.selected = YES;
|
||||
[self.myRecordBtn setTitle:@"我的记录" forState:(UIControlStateNormal)];
|
||||
[self.myRecordBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateSelected)];
|
||||
[self.myRecordBtn setTitleColor:RGB16(0x5B5B5B) forState:(UIControlStateNormal)];
|
||||
self.myRecordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
||||
[self.myRecordBtn addTarget:self action:@selector(recordAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgCoverView addSubview:self.myRecordBtn];
|
||||
|
||||
self.allRecordBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.myRecordBtn.right+5, 5, 75, 40)];
|
||||
[self.allRecordBtn setTitle:@"全服记录" forState:(UIControlStateNormal)];
|
||||
[self.allRecordBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateSelected)];
|
||||
[self.allRecordBtn setTitleColor:RGB16(0x5B5B5B) forState:(UIControlStateNormal)];
|
||||
self.allRecordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.allRecordBtn addTarget:self action:@selector(recordAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgCoverView addSubview:self.allRecordBtn];
|
||||
|
||||
|
||||
[self.bgCoverView addSubview:self.collectionView];
|
||||
[self.bgCoverView addSubview:self.tableView];
|
||||
}
|
||||
|
||||
-(void)recordAction:(UIButton*)sender{
|
||||
if (sender == self.myRecordBtn) {
|
||||
if (self.myRecordBtn.selected) {
|
||||
return;
|
||||
}else{
|
||||
self.myRecordBtn.selected = YES;
|
||||
self.allRecordBtn.selected = NO;
|
||||
self.myRecordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
||||
self.allRecordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
}
|
||||
}else{
|
||||
if (self.allRecordBtn.selected) {
|
||||
return;
|
||||
}else{
|
||||
self.allRecordBtn.selected = YES;
|
||||
self.myRecordBtn.selected = NO;
|
||||
self.allRecordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
||||
self.myRecordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
}
|
||||
}
|
||||
[self getRecordList];
|
||||
}
|
||||
-(void)setGiftModel:(QXGiftModel *)giftModel{
|
||||
_giftModel = giftModel;
|
||||
self.page = 1;
|
||||
[self getRecordList];
|
||||
}
|
||||
|
||||
-(void)getRecordList{
|
||||
if (![self.giftModel.gift_bag isExist]) {
|
||||
return;
|
||||
}
|
||||
if (![self.roomId isExist]) {
|
||||
return;
|
||||
}
|
||||
MJWeakSelf
|
||||
NSDictionary *parameters = @{
|
||||
@"gift_bag_id":self.giftModel.gift_bag,
|
||||
@"page":[NSNumber numberWithInteger:self.page]
|
||||
};
|
||||
NSString *url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_my_record"];
|
||||
if (self.myRecordBtn.selected) {
|
||||
url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_my_record"];
|
||||
}else{
|
||||
url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_all_record"];
|
||||
}
|
||||
[[QXRequset shareInstance] postWithUrl:url parameters:parameters needCache:NO success:^(id responseObject) {
|
||||
if (weakSelf.myRecordBtn.selected == YES) {
|
||||
weakSelf.collectionView.hidden = NO;
|
||||
weakSelf.tableView.hidden = YES;
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.myRecordArray removeAllObjects];
|
||||
}
|
||||
NSArray *arr = [NSArray yy_modelArrayWithClass:[QXActivityRecordModel class] json:responseObject[@"data"]];
|
||||
[weakSelf.myRecordArray addObjectsFromArray:arr];
|
||||
[weakSelf.collectionView reloadData];
|
||||
if (arr.count == 0) {
|
||||
weakSelf.collectionView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.collectionView.mj_footer endRefreshing];
|
||||
}
|
||||
[weakSelf.collectionView.mj_header endRefreshing];
|
||||
|
||||
}else{
|
||||
weakSelf.collectionView.hidden = YES;
|
||||
weakSelf.tableView.hidden = NO;
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.allRecordArray removeAllObjects];
|
||||
}
|
||||
NSArray *arr = [NSArray yy_modelArrayWithClass:[QXActivityRecordModel class] json:responseObject[@"data"]];
|
||||
[weakSelf.allRecordArray addObjectsFromArray:arr];
|
||||
[weakSelf.tableView reloadData];
|
||||
if (arr.count == 0) {
|
||||
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
}
|
||||
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
[weakSelf.collectionView.mj_footer endRefreshing];
|
||||
[weakSelf.collectionView.mj_header endRefreshing];
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)showInView:(UIView *)view{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
// [self stopSlowAnimate];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
// if (self.myRecordBtn.selected) {
|
||||
return self.myRecordArray.count;
|
||||
// }else{
|
||||
// return self.allRecordArray.count;
|
||||
// }
|
||||
|
||||
}
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXSkyRecordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSkyRecordCell" forIndexPath:indexPath];
|
||||
// if (self.myRecordBtn.selected) {
|
||||
cell.model = self.myRecordArray[indexPath.row];
|
||||
// }else{
|
||||
// cell.model = self.allRecordArray[indexPath.row];
|
||||
// }
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
return self.allRecordArray.count;
|
||||
}
|
||||
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXSkyAllRecordCell *cell = [QXSkyAllRecordCell cellWithTableView:tableView];
|
||||
cell.model = self.allRecordArray[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(UICollectionView *)collectionView{
|
||||
if (!_collectionView) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.minimumLineSpacing = 16;
|
||||
layout.minimumInteritemSpacing = 16;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 12, 0, 12);
|
||||
layout.itemSize = CGSizeMake((self.bgCoverView.width-12*2-16*2-1)/3, ScaleWidth(123));
|
||||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.myRecordBtn.bottom+10, self.bgCoverView.width, self.bgCoverView.height-self.myRecordBtn.bottom-5) collectionViewLayout:layout];
|
||||
_collectionView.delegate = self;
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.showsHorizontalScrollIndicator = NO;
|
||||
_collectionView.showsVerticalScrollIndicator = NO;
|
||||
_collectionView.backgroundColor = [UIColor clearColor];
|
||||
[_collectionView registerClass:[QXSkyRecordCell class] forCellWithReuseIdentifier:@"QXSkyRecordCell"];
|
||||
MJWeakSelf
|
||||
_collectionView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.page++;
|
||||
[weakSelf getRecordList];
|
||||
}];
|
||||
_collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getRecordList];
|
||||
}];
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
-(UITableView *)tableView{
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.myRecordBtn.bottom+10, self.bgCoverView.width, self.bgCoverView.height-self.myRecordBtn.bottom-5) style:(UITableViewStylePlain)];
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
_tableView.hidden = YES;
|
||||
_tableView.rowHeight = 70;
|
||||
_tableView.backgroundColor = [UIColor clearColor];
|
||||
MJWeakSelf
|
||||
_tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.page++;
|
||||
[weakSelf getRecordList];
|
||||
}];
|
||||
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getRecordList];
|
||||
}];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
-(NSMutableArray *)myRecordArray{
|
||||
if (!_myRecordArray) {
|
||||
_myRecordArray =[NSMutableArray array];
|
||||
}
|
||||
return _myRecordArray;
|
||||
}
|
||||
- (NSMutableArray *)allRecordArray{
|
||||
if (!_allRecordArray) {
|
||||
_allRecordArray = [NSMutableArray array];
|
||||
}
|
||||
return _allRecordArray;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXSkyRecordCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setModel:(QXActivityRecordModel *)model{
|
||||
_model = model;
|
||||
self.giftInfoLabel.text = [NSString stringWithFormat:@"%@x%@",model.gift_name,model.count];
|
||||
self.recieveInfoLabel.text = [NSString stringWithFormat:@"赠予%@",model.nickname];
|
||||
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
||||
self.timeLabel.text = model.createtime;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.giftImageView = [[UIImageView alloc] init];
|
||||
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.contentView);
|
||||
make.left.equalTo(self.contentView).offset(8);
|
||||
make.right.equalTo(self.contentView).offset(-8);
|
||||
make.height.equalTo(self.giftImageView.mas_width);
|
||||
}];
|
||||
|
||||
self.giftInfoLabel = [[UILabel alloc] init];
|
||||
self.giftInfoLabel.textColor = RGB16(0xffffff);
|
||||
self.giftInfoLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.contentView addSubview:self.giftInfoLabel];
|
||||
[self.giftInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.right.equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
self.recieveInfoLabel = [[UILabel alloc] init];
|
||||
self.recieveInfoLabel.textColor = RGB16(0xffffff);
|
||||
self.recieveInfoLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.contentView addSubview:self.recieveInfoLabel];
|
||||
[self.recieveInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.giftImageView.mas_bottom).offset(4);
|
||||
make.left.right.equalTo(self.contentView);
|
||||
make.height.mas_equalTo(21);
|
||||
}];
|
||||
|
||||
self.timeLabel = [[UILabel alloc] init];
|
||||
self.timeLabel.textColor = RGB16(0x5B5B5B);
|
||||
self.timeLabel.font = [UIFont systemFontOfSize:10];
|
||||
[self.contentView addSubview:self.timeLabel];
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.contentView);
|
||||
make.left.right.equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXSkyAllRecordCell
|
||||
|
||||
+(instancetype)cellWithTableView:(UITableView*)tableView{
|
||||
static NSString *cellId = @"QXSkyAllRecordCell";
|
||||
QXSkyAllRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
|
||||
if (!cell) {
|
||||
cell = [[QXSkyAllRecordCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId];
|
||||
cell.backgroundColor = [UIColor clearColor];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)setModel:(QXActivityRecordModel *)model{
|
||||
_model = model;
|
||||
self.giftInfoLabel.text = [NSString stringWithFormat:@"%@x%@",model.gift_name,model.count];
|
||||
self.recieveInfoLabel.text = [NSString stringWithFormat:@"%@",model.nickname];
|
||||
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
||||
self.timeLabel.text = model.createtime;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.contentView.backgroundColor = [UIColor clearColor];
|
||||
self.recieveInfoLabel = [[UILabel alloc] init];
|
||||
self.recieveInfoLabel.textColor = RGB16(0xffffff);
|
||||
self.recieveInfoLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.contentView addSubview:self.recieveInfoLabel];
|
||||
[self.recieveInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(12);
|
||||
make.left.mas_equalTo(12);
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
self.timeLabel = [[UILabel alloc] init];
|
||||
self.timeLabel.textColor = RGB16(0x5B5B5B);
|
||||
self.timeLabel.font = [UIFont systemFontOfSize:10];
|
||||
[self.contentView addSubview:self.timeLabel];
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.contentView).offset(-12);
|
||||
make.left.mas_equalTo(12);
|
||||
make.height.mas_equalTo(17);
|
||||
}];
|
||||
|
||||
self.giftImageView = [[UIImageView alloc] init];
|
||||
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.contentView).offset(-12);
|
||||
make.height.width.mas_equalTo(21);
|
||||
make.centerY.equalTo(self.recieveInfoLabel);
|
||||
}];
|
||||
|
||||
self.giftInfoLabel = [[UILabel alloc] init];
|
||||
self.giftInfoLabel.textColor = RGB16(0xffffff);
|
||||
self.giftInfoLabel.font = [UIFont systemFontOfSize:16];
|
||||
[self.contentView addSubview:self.giftInfoLabel];
|
||||
[self.giftInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.giftImageView.mas_left);
|
||||
make.centerY.equalTo(self.recieveInfoLabel);
|
||||
}];
|
||||
|
||||
self.bottomLine = [[UIView alloc] init];
|
||||
self.bottomLine.backgroundColor = RGB16(0xffffff);
|
||||
[self.contentView addSubview:self.bottomLine];
|
||||
[self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.contentView);
|
||||
make.left.mas_equalTo(12);
|
||||
make.right.mas_equalTo(-12);
|
||||
make.height.mas_equalTo(1);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
17
QXLive/活动/天空之境/QXSkyPraizeRuleView.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// QXSkyPraizeRuleView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXSkyPraizeRuleView : UIView
|
||||
@property (nonatomic,strong)NSString *rule;
|
||||
-(void)showInView:(UIView *)view;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
134
QXLive/活动/天空之境/QXSkyPraizeRuleView.m
Normal file
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// QXSkyPraizeRuleView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import "QXSkyPraizeRuleView.h"
|
||||
#import <WebKit/WebKit.h>
|
||||
static void *WKWebBrowserContext = &WKWebBrowserContext;
|
||||
|
||||
@interface QXSkyPraizeRuleView()<WKNavigationDelegate,WKUIDelegate,UIGestureRecognizerDelegate>
|
||||
@property(nonatomic,strong)WKWebView *contentWebView;
|
||||
@property(nonatomic,strong)UIView* bgView;
|
||||
@property(nonatomic,strong)UIImageView* ruleImageView;
|
||||
@property(nonatomic,strong)UIImageView* bgImageView;
|
||||
@end
|
||||
|
||||
@implementation QXSkyPraizeRuleView
|
||||
|
||||
- (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];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_rule_bg"]];
|
||||
self.bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663));
|
||||
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self.bgView addSubview:self.bgImageView];
|
||||
|
||||
self.ruleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_rule_icon"]];
|
||||
self.ruleImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
self.ruleImageView.frame = CGRectMake((SCREEN_WIDTH-ScaleWidth(164))/2, 0, ScaleWidth(164), ScaleWidth(90));
|
||||
[self.bgView addSubview:self.ruleImageView];
|
||||
|
||||
[self.bgView addSubview:self.contentWebView];
|
||||
|
||||
|
||||
|
||||
}
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == self;
|
||||
}
|
||||
|
||||
-(void)setRule:(NSString *)rule{
|
||||
_rule = rule;
|
||||
[self loadData];
|
||||
}
|
||||
- (void)loadData {
|
||||
NSURL* url=[NSURL URLWithString:self.rule];
|
||||
NSURLRequest *request =[NSURLRequest requestWithURL:url];
|
||||
[self.contentWebView loadRequest:request];
|
||||
}
|
||||
|
||||
|
||||
//进度条
|
||||
- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView {
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - getters and setters
|
||||
- (WKWebView *)contentWebView {
|
||||
if (!_contentWebView) {
|
||||
//设置网页的配置文件
|
||||
WKWebViewConfiguration * configuration = [[WKWebViewConfiguration alloc]init];
|
||||
// 允许可以与网页交互,选择视图
|
||||
configuration.selectionGranularity = YES;
|
||||
// web内容处理池pr
|
||||
configuration.processPool = [[WKProcessPool alloc] init];
|
||||
//自定义配置,一般用于 js调用oc方法(OC拦截URL中的数据做自定义操作)
|
||||
WKUserContentController * UserContentController = [[WKUserContentController alloc]init];
|
||||
// 是否支持记忆读取
|
||||
configuration.suppressesIncrementalRendering = NO;
|
||||
// 允许用户更改网页的设置
|
||||
configuration.preferences.javaScriptEnabled = YES;
|
||||
configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES;
|
||||
configuration.userContentController = UserContentController;
|
||||
// 此处一定要做判断,因为是iOS9之后才有的方法,否则在iOS8下会崩溃
|
||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0) {
|
||||
//允许视频播放
|
||||
configuration.allowsAirPlayForMediaPlayback = YES;
|
||||
// 允许在线播放
|
||||
configuration.allowsInlineMediaPlayback = YES;
|
||||
//开启手势触摸 默认设置就是NO。在ios8系统中会导致手势问题,程序崩溃
|
||||
_contentWebView.allowsBackForwardNavigationGestures = YES;
|
||||
}
|
||||
_contentWebView = [[WKWebView alloc] initWithFrame:CGRectMake(16, self.ruleImageView.bottom+12, self.width-16*2, self.bgView.height-self.ruleImageView.bottom-12) configuration:configuration];
|
||||
_contentWebView.backgroundColor = RGB16A(0x000000, 0.5);
|
||||
[_contentWebView addRoundedCornersWithRadius:6];
|
||||
_contentWebView.opaque = NO;
|
||||
//适应你设定的尺寸
|
||||
[_contentWebView sizeToFit];
|
||||
_contentWebView.scrollView.showsVerticalScrollIndicator = NO;
|
||||
_contentWebView.scrollView.backgroundColor = [UIColor clearColor];
|
||||
_contentWebView.scrollView.bounces = NO;
|
||||
// 设置代理
|
||||
_contentWebView.navigationDelegate = self;
|
||||
}
|
||||
return _contentWebView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)showInView:(UIView *)view{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
// [self stopSlowAnimate];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
67
QXLive/活动/天空之境/QXSkyPraizeView.h
Normal file
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// QXSkyPraizeView.h
|
||||
// QXLive 天空之镜
|
||||
//
|
||||
// Created by 启星 on 2025/8/16.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXGiftActivityModel.h"
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
/// 抽一次
|
||||
QXSkyDrawBtnTypeOne = 1,
|
||||
/// 抽10次
|
||||
QXSkyDrawBtnTypeTen = 6,
|
||||
/// 抽100次
|
||||
QXSkyDrawBtnTypeHundred = 9,
|
||||
}QXSkyDrawBtnType;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXSkyPraizeView : UIView
|
||||
@property (nonatomic,strong)NSString *roomId;
|
||||
@property (nonatomic,strong)QXGiftModel *giftModel;
|
||||
@property (nonatomic,strong)QXGiftActivityModel *model;
|
||||
@property (nonatomic,strong)NSString* userIds;
|
||||
@property (nonatomic,strong)NSString* heartId;
|
||||
@property (nonatomic,strong)NSString* auctionId;
|
||||
@property (nonatomic,copy)void(^startBlock)(void);
|
||||
-(void)showInView:(UIView *)view;
|
||||
-(void)hide;
|
||||
-(void)updateProgress:(QXXLHModel*)model;
|
||||
-(void)destroyViews;
|
||||
@end
|
||||
|
||||
|
||||
@interface QXSkyPraizeSubView :UIView
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
|
||||
@property (nonatomic,strong)UIView *resultView;
|
||||
@property (nonatomic,strong)UIImageView *resultBgImageView;
|
||||
@property (nonatomic,strong)UILabel *countLabel;
|
||||
|
||||
@property (nonatomic,strong)UIButton *giftCoin;
|
||||
@property (nonatomic,strong)QXDrawGiftModel *giftModel;
|
||||
@property (nonatomic,assign)BOOL isSelected;
|
||||
@property (nonatomic,strong)NSString *count;
|
||||
|
||||
- (void)startPulseAnimationWithLayer;
|
||||
// 停止动画
|
||||
- (void)stopPulseAnimationWithLayer;
|
||||
@end
|
||||
|
||||
@interface QXSkyDrawBtn : UIControl
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)UIButton *giftCoin;
|
||||
@property (nonatomic,assign)BOOL isDisable;
|
||||
@property (nonatomic,assign)QXSkyDrawBtnType btnType;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
910
QXLive/活动/天空之境/QXSkyPraizeView.m
Normal file
@@ -0,0 +1,910 @@
|
||||
//
|
||||
// QXSkyPraizeView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/16.
|
||||
//
|
||||
|
||||
#import "QXSkyPraizeView.h"
|
||||
#import "UIButton+QX.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import "QXSkyPraizeRuleView.h"
|
||||
#import "QXSkyPraizePoolView.h"
|
||||
#import "QXSkyPraizeRecordView.h"
|
||||
#import "QXDrawGiftCenterView.h"
|
||||
#import "QXDiamondViewController.h"
|
||||
|
||||
/// 共有12个礼物
|
||||
static NSInteger giftMaxCount = 12;
|
||||
/// 最少转2圈
|
||||
static NSInteger minRoundCount = 6;
|
||||
/// 距离4个的时候放慢
|
||||
static NSInteger toSlowCount = 4;
|
||||
|
||||
@interface QXSkyPraizeView()<UIGestureRecognizerDelegate>
|
||||
|
||||
|
||||
/// 目标下标
|
||||
@property (nonatomic,assign)NSInteger targetIndex;
|
||||
|
||||
@property (nonatomic,strong)NSMutableArray* targetArrayIndex;
|
||||
@property (nonatomic,strong)NSMutableArray* finishTargetArrayIndex;
|
||||
/// 当前转动到第几个下标
|
||||
@property (nonatomic,assign)NSInteger currentIndex;
|
||||
/// 转动了多少次
|
||||
@property (nonatomic,assign)NSInteger roundCount;
|
||||
/// 延时
|
||||
@property (nonatomic,assign)double delayTime;
|
||||
///// 22 抽一次 33 抽十次 44 抽 100次
|
||||
@property (nonatomic,assign)QXSkyDrawBtnType startType;
|
||||
|
||||
@property (nonatomic,strong)QXSkyPraizeSubView *currentGiftView;
|
||||
|
||||
@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 *soundBtn;
|
||||
/// 特效
|
||||
@property (nonatomic,strong)UIButton *specialBtn;
|
||||
|
||||
@property (nonatomic,strong)NSMutableArray *allViewsArray;
|
||||
|
||||
@property (nonatomic,strong)dispatch_source_t fastTimer;
|
||||
|
||||
@property (nonatomic,strong)AVPlayer* player;
|
||||
|
||||
/// 金币
|
||||
@property (nonatomic,strong)UIView* coinView;
|
||||
@property (nonatomic,strong)UIButton* coinBtn;
|
||||
@property (nonatomic,strong)UIButton* exchangeBtn;
|
||||
|
||||
@property (nonatomic,strong)QXSkyDrawBtn *oneBtn;
|
||||
@property (nonatomic,strong)QXSkyDrawBtn *tenBtn;
|
||||
@property (nonatomic,strong)QXSkyDrawBtn *hundredBtn;
|
||||
@property (nonatomic,strong)QXDrawGiftResultModel *drawResultModel;
|
||||
/// 是否正在抽奖
|
||||
@property (nonatomic,assign)BOOL isDrawing;
|
||||
/// 是否开启音效
|
||||
@property (nonatomic,assign)BOOL isOpenSound;
|
||||
/// 是否开启特效
|
||||
@property (nonatomic,assign)BOOL isOpenSpecial;
|
||||
/// 规则视图
|
||||
@property (nonatomic,strong)QXSkyPraizeRuleView *ruleView;
|
||||
/// 奖池视图
|
||||
@property (nonatomic,strong)QXSkyPraizePoolView *poolView;
|
||||
/// 记录
|
||||
@property (nonatomic,strong)QXSkyPraizeRecordView *recordView;
|
||||
|
||||
@property (nonatomic,strong)QXDrawGiftCenterView * centerView;
|
||||
|
||||
@property (nonatomic,assign)double coin;
|
||||
@end
|
||||
|
||||
@implementation QXSkyPraizeView
|
||||
|
||||
- (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];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"active_sky_raize_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(48), 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.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];
|
||||
|
||||
CGFloat topMargin = self.recordBtn.bottom+5;
|
||||
CGFloat margin = 11;
|
||||
CGFloat space = 8;
|
||||
CGFloat itemWidth = (SCREEN_WIDTH - margin*2 - space*3) / 4;
|
||||
CGFloat itemHeight = itemWidth/82*99;;
|
||||
for (int i = 0; i < giftMaxCount; i++) {
|
||||
QXSkyPraizeSubView *giftView;
|
||||
if (i < 4) {
|
||||
/// 第一行4个
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+space)*i, topMargin, itemWidth, itemHeight)];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",i];
|
||||
[self.allViewsArray replaceObjectAtIndex:i withObject:giftView];
|
||||
}else if (i > 3 && i < 6){
|
||||
/// 第二行两个
|
||||
if (i == 4) {
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin, topMargin+itemHeight+space, itemWidth, itemHeight)];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",11];
|
||||
[self.allViewsArray replaceObjectAtIndex:11 withObject:giftView];
|
||||
}else{
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+space)*3, topMargin+itemHeight+space, itemWidth, itemHeight)];
|
||||
[self.allViewsArray replaceObjectAtIndex:4 withObject:giftView];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",4];
|
||||
}
|
||||
}else if (i > 5 && i < 8){
|
||||
/// 第三行两个
|
||||
if (i == 6) {
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin, topMargin+(itemHeight+space)*2, itemWidth, itemHeight)];
|
||||
[self.allViewsArray replaceObjectAtIndex:10 withObject:giftView];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",10];
|
||||
}else{
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+space)*3, topMargin+(itemHeight+space)*2, itemWidth, itemHeight)];
|
||||
[self.allViewsArray replaceObjectAtIndex:5 withObject:giftView];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",5];
|
||||
}
|
||||
}else{
|
||||
giftView = [[QXSkyPraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+space)*(i%4), topMargin+(itemHeight+space)*3, itemWidth, itemHeight)];
|
||||
[self.allViewsArray replaceObjectAtIndex:11-(i-6) withObject:giftView];
|
||||
giftView.titleLabel.text = [NSString stringWithFormat:@"%d",11-(i-6)];
|
||||
}
|
||||
|
||||
[self.bgView addSubview:giftView];
|
||||
}
|
||||
[self resetViews];
|
||||
|
||||
CGFloat btnWidth = ScaleWidth(109);
|
||||
CGFloat btnMargin = (SCREEN_WIDTH- ScaleWidth(109)*3)/4;
|
||||
QXSkyDrawBtn *oneBtn = [[QXSkyDrawBtn alloc] initWithFrame:CGRectMake(btnMargin, self.bgView.height-ScaleWidth(34)-20, btnWidth, ScaleWidth(34))];
|
||||
oneBtn.btnType = QXSkyDrawBtnTypeOne;
|
||||
oneBtn.isDisable = YES;
|
||||
self.oneBtn = oneBtn;
|
||||
self.oneBtn.hidden = YES;
|
||||
[oneBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:oneBtn];
|
||||
|
||||
QXSkyDrawBtn *tenBtn = [[QXSkyDrawBtn alloc] initWithFrame:CGRectMake(self.oneBtn.right+btnMargin, self.oneBtn.top, btnWidth, ScaleWidth(34))];
|
||||
tenBtn.btnType = QXSkyDrawBtnTypeTen;
|
||||
tenBtn.isDisable = YES;
|
||||
self.tenBtn = tenBtn;
|
||||
self.tenBtn.hidden = YES;
|
||||
[tenBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:tenBtn];
|
||||
|
||||
QXSkyDrawBtn *hundredBtn = [[QXSkyDrawBtn alloc] initWithFrame:CGRectMake(tenBtn.right+btnMargin, self.oneBtn.top, btnWidth, ScaleWidth(34))];
|
||||
hundredBtn.btnType = QXSkyDrawBtnTypeHundred;
|
||||
hundredBtn.isDisable = YES;
|
||||
self.hundredBtn = hundredBtn;
|
||||
self.hundredBtn.hidden = YES;
|
||||
[hundredBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:hundredBtn];
|
||||
|
||||
self.soundBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2-75-15, self.oneBtn.top-20-20, 75, 20)];
|
||||
[self.soundBtn addTarget:self action:@selector(soundAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.soundBtn setTitle:@"音效" forState:(UIControlStateNormal)];
|
||||
[self.soundBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
|
||||
self.soundBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.soundBtn setImage:[UIImage imageNamed:@"sky_switch_off"] forState:(UIControlStateNormal)];
|
||||
[self.soundBtn setImage:[UIImage imageNamed:@"sky_switch_on"] forState:(UIControlStateSelected)];
|
||||
self.soundBtn.selected = YES;
|
||||
[self.bgView addSubview:self.soundBtn];
|
||||
|
||||
|
||||
self.specialBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2+15, self.oneBtn.top-20-20, 75, 20)];
|
||||
[self.specialBtn addTarget:self action:@selector(specialAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.specialBtn setTitle:@"特效" forState:(UIControlStateNormal)];
|
||||
[self.specialBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
|
||||
self.specialBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.specialBtn setImage:[UIImage imageNamed:@"sky_switch_off"] forState:(UIControlStateNormal)];
|
||||
[self.specialBtn setImage:[UIImage imageNamed:@"sky_switch_on"] forState:(UIControlStateSelected)];
|
||||
self.specialBtn.selected = YES;
|
||||
[self.bgView addSubview:self.specialBtn];
|
||||
|
||||
[self.soundBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:2];
|
||||
[self.specialBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:2];
|
||||
self.isOpenSound = YES;
|
||||
self.isOpenSpecial = YES;
|
||||
|
||||
|
||||
self.coinView = [[UIView alloc] initWithFrame:CGRectMake((self.bgView.width-100)/2, topMargin+(itemHeight+space)*3-ScaleWidth(28)-6, 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 addTarget:self action:@selector(exchangeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.coinView addSubview:self.exchangeBtn];
|
||||
|
||||
MJWeakSelf
|
||||
self.centerView = [[QXDrawGiftCenterView alloc] initWithFrame:CGRectMake((self.bgView.width-ScaleWidth(148))/2, topMargin+itemHeight, ScaleWidth(148), ScaleWidth(180))];
|
||||
self.centerView.hidden = YES;
|
||||
self.centerView.startBlock = ^{
|
||||
if (weakSelf.startBlock) {
|
||||
weakSelf.startBlock();
|
||||
}
|
||||
};
|
||||
self.centerView.type = QXDrawGiftCenterTypeWait;
|
||||
self.centerView.activityType = QXActivityTypeSky;
|
||||
[self.bgView addSubview:self.centerView];
|
||||
}
|
||||
- (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)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 conifgBtnStatus];
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
|
||||
}];
|
||||
}
|
||||
-(void)setGiftModel:(QXGiftModel *)giftModel{
|
||||
_giftModel = giftModel;
|
||||
[self getGiftList];
|
||||
[self getMyWallet];
|
||||
}
|
||||
-(void)updateProgress:(QXXLHModel*)model{
|
||||
if (self.model) {
|
||||
self.model.xlh_data = model;
|
||||
self.centerView.model = self.model;
|
||||
}
|
||||
}
|
||||
-(void)getGiftList{
|
||||
if (![self.giftModel.gift_bag isExist]) {
|
||||
return;
|
||||
}
|
||||
if (![self.roomId isExist]) {
|
||||
return;
|
||||
}
|
||||
// if (self.model) {
|
||||
// return;
|
||||
// }
|
||||
MJWeakSelf
|
||||
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_gift_list"] parameters:@{@"gift_bag_id":self.giftModel.gift_bag?self.giftModel.gift_bag:@"",@"room_id":self.roomId?self.roomId:@""} needCache:NO success:^(id responseObject) {
|
||||
QXGiftActivityModel *model = [QXGiftActivityModel yy_modelWithJSON:responseObject[@"data"]];
|
||||
weakSelf.model = model;
|
||||
weakSelf.centerView.model = model;
|
||||
for (int i = 0; i < model.gift_list.count; i++) {
|
||||
QXSkyPraizeSubView* subview = weakSelf.allViewsArray[i];
|
||||
subview.giftModel = model.gift_list[i];
|
||||
}
|
||||
[weakSelf.oneBtn.giftCoin setTitle:[NSString stringWithFormat:@"%@币一次",model.box_price] forState:(UIControlStateNormal)];
|
||||
[weakSelf.tenBtn.giftCoin setTitle:[NSString stringWithFormat:@"%ld币一次",model.box_price.integerValue*6] forState:(UIControlStateNormal)];
|
||||
[weakSelf.hundredBtn.giftCoin setTitle:[NSString stringWithFormat:@"%ld币一次",model.box_price.integerValue*9] forState:(UIControlStateNormal)];
|
||||
weakSelf.oneBtn.hidden = NO;
|
||||
weakSelf.tenBtn.hidden = NO;
|
||||
weakSelf.hundredBtn.hidden = NO;
|
||||
[weakSelf conifgBtnStatus];
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
|
||||
}];
|
||||
}
|
||||
-(void)conifgBtnStatus{
|
||||
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)setHeartId:(NSString *)heartId{
|
||||
_heartId = heartId;
|
||||
}
|
||||
-(void)drawGiftWithNum:(NSString*)num{
|
||||
|
||||
NSDictionary *parameters = @{
|
||||
@"gift_bag_id":self.giftModel.gift_bag,
|
||||
@"gift_user_ids":self.userIds,
|
||||
@"room_id":self.roomId,
|
||||
@"num":num,
|
||||
@"heart_id":[self.heartId isExist]?self.heartId:@"",
|
||||
@"auction_id":[self.auctionId isExist]?self.auctionId:@""
|
||||
};
|
||||
self.isDrawing = YES;
|
||||
MJWeakSelf
|
||||
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/draw_gift"] parameters:parameters needCache:NO success:^(id responseObject) {
|
||||
QXDrawGiftResultModel *model = [QXDrawGiftResultModel yy_modelWithJSON:responseObject[@"data"]];
|
||||
weakSelf.drawResultModel = model;
|
||||
[weakSelf.targetArrayIndex removeAllObjects];
|
||||
[weakSelf getMyWallet];
|
||||
for (int i = 0; i < model.reslut_list.count; i++) {
|
||||
QXDrawGiftModel *md = model.reslut_list[i];
|
||||
for (int j = 0; j < weakSelf.model.gift_list.count; j++) {
|
||||
QXDrawGiftModel*gift = weakSelf.model.gift_list[j];
|
||||
if ([md.gift_id isEqualToString:gift.gift_id]) {
|
||||
[weakSelf.targetArrayIndex addObject:[NSNumber numberWithInt:j]];
|
||||
if (j < 12) {
|
||||
QXSkyPraizeSubView *subView = weakSelf.allViewsArray[j];
|
||||
subView.count = md.count;
|
||||
if (!weakSelf.isOpenSpecial) {
|
||||
subView.resultView.hidden = NO;
|
||||
subView.isSelected = YES;
|
||||
weakSelf.isDrawing = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (weakSelf.isOpenSound) {
|
||||
[weakSelf.player seekToTime:CMTimeMake(0, 1)];
|
||||
[weakSelf.player play];
|
||||
}
|
||||
if (weakSelf.isOpenSpecial) {
|
||||
[weakSelf startFastAnimate];
|
||||
}else{
|
||||
[weakSelf animateFinishedSendGift];
|
||||
}
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
weakSelf.isDrawing = NO;
|
||||
showToast(msg);
|
||||
}];
|
||||
}
|
||||
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == self;
|
||||
}
|
||||
-(void)specialAction:(UIButton*)sender{
|
||||
sender.selected = !sender.selected;
|
||||
self.isOpenSpecial = sender.selected;
|
||||
if (self.isOpenSpecial) {
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}else{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"no_animate_draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}
|
||||
}
|
||||
-(void)soundAction:(UIButton*)sender{
|
||||
sender.selected = !sender.selected;
|
||||
self.isOpenSound = sender.selected;
|
||||
if (self.isOpenSpecial) {
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}else{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"no_animate_draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}
|
||||
}
|
||||
-(void)startAction:(QXSkyDrawBtn*)sender{
|
||||
if (sender.isDisable) {
|
||||
showToast(@"金币不足");
|
||||
return;
|
||||
}
|
||||
if (self.isDrawing) {
|
||||
// showToast(@"正在抽奖中");
|
||||
return;
|
||||
}
|
||||
[self resetViews];
|
||||
[self drawGiftWithNum:[NSString stringWithFormat:@"%ld",sender.btnType]];
|
||||
|
||||
/// 获取目标礼物
|
||||
|
||||
// [self getTargetGift];
|
||||
// [self startFastAnimate];
|
||||
}
|
||||
|
||||
-(void)exchangeAction{
|
||||
QXDiamondViewController *vc = [[QXDiamondViewController alloc] init];
|
||||
[self.viewController.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
-(void)resetViews{
|
||||
|
||||
self.isDrawing = NO;
|
||||
self.targetIndex = -1;
|
||||
self.currentIndex = -1;
|
||||
self.roundCount = 0;
|
||||
self.delayTime = 0.2;
|
||||
[self.targetArrayIndex removeAllObjects];
|
||||
[self.finishTargetArrayIndex removeAllObjects];
|
||||
if (self.currentGiftView != nil) {
|
||||
self.currentGiftView.isSelected = NO;
|
||||
[self.currentGiftView stopPulseAnimationWithLayer];
|
||||
}
|
||||
for (QXSkyPraizeSubView *giftView in self.allViewsArray) {
|
||||
giftView.isSelected = NO;
|
||||
giftView.count = @"0";
|
||||
giftView.resultView.hidden = YES;
|
||||
[giftView stopPulseAnimationWithLayer];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)startFastAnimate{
|
||||
self.currentGiftView = self.allViewsArray.firstObject;
|
||||
self.currentGiftView.isSelected = YES;
|
||||
[self stopFastAnimate];
|
||||
if (_fastTimer == nil) {
|
||||
_fastTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
|
||||
}
|
||||
// dispatch_source_set_timer(_fastTimer,
|
||||
// dispatch_time(DISPATCH_TIME_NOW, 0),
|
||||
// NSEC_PER_SEC * 0.06, // 间隔0.1秒
|
||||
// NSEC_PER_SEC * 0.01); // 允许误差0.01秒
|
||||
|
||||
dispatch_source_set_timer(_fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER, // 使用一次性模式
|
||||
0.01 * NSEC_PER_SEC);
|
||||
if (self.isOpenSound) {
|
||||
[self.player seekToTime:CMTimeMake(0, 1)];
|
||||
[self.player play];
|
||||
}
|
||||
__weak typeof(self) weakSelf = self;
|
||||
dispatch_source_set_event_handler(_fastTimer, ^{
|
||||
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||
if (!strongSelf) return;
|
||||
// 如果需要更新UI,切换到主线程
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
strongSelf.roundCount++;
|
||||
if ((strongSelf.roundCount / giftMaxCount == minRoundCount) && strongSelf.startType != QXSkyDrawBtnTypeOne) {
|
||||
BOOL has = NO;
|
||||
for (NSNumber *index in self.finishTargetArrayIndex) {
|
||||
if (index.integerValue == self.currentIndex) {
|
||||
has = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.currentGiftView.isSelected = NO;
|
||||
if (has) {
|
||||
QXSkyPraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = YES;
|
||||
}else{
|
||||
QXSkyPraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = NO;
|
||||
}
|
||||
}else{
|
||||
/// 把上一个选中状态置为未选中
|
||||
strongSelf.currentGiftView.isSelected = NO;
|
||||
}
|
||||
/// 计算当前下标
|
||||
strongSelf.currentIndex = strongSelf.roundCount%giftMaxCount;
|
||||
/// 获取当前选中的view 并设置为选中状态
|
||||
QXSkyPraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = YES;
|
||||
|
||||
/// 重新赋值给选中view
|
||||
strongSelf.currentGiftView = giftView;
|
||||
|
||||
if (strongSelf.roundCount / giftMaxCount == minRoundCount) {
|
||||
for (NSNumber *index in strongSelf.targetArrayIndex) {
|
||||
if (strongSelf.currentIndex == index.integerValue) {
|
||||
QXSkyPraizeSubView *giftView = strongSelf.allViewsArray[index.integerValue];
|
||||
giftView.isSelected = YES;
|
||||
giftView.resultView.hidden = NO;
|
||||
[giftView startPulseAnimationWithLayer];
|
||||
[strongSelf.targetArrayIndex removeObject:index];
|
||||
[strongSelf.finishTargetArrayIndex addObject:index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
dispatch_source_set_timer(strongSelf.fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, 0.03 * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.01 * NSEC_PER_SEC);
|
||||
if (strongSelf.targetArrayIndex.count == 0) {
|
||||
strongSelf.isDrawing = NO;
|
||||
[strongSelf stopFastAnimate];
|
||||
[strongSelf animateFinishedSendGift];
|
||||
}
|
||||
// }
|
||||
}else{
|
||||
strongSelf.delayTime = strongSelf.delayTime-0.02;
|
||||
if (strongSelf.delayTime <= 0.03) {
|
||||
strongSelf.delayTime = 0.03;
|
||||
}
|
||||
dispatch_source_set_timer(strongSelf.fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, strongSelf.delayTime * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.01 * NSEC_PER_SEC);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
dispatch_resume(_fastTimer);
|
||||
}
|
||||
-(void)animateFinishedSendGift{
|
||||
NSDictionary *parameters = @{
|
||||
@"send_id":self.drawResultModel.blind_box_turntable_id?self.drawResultModel.blind_box_turntable_id:@""
|
||||
};
|
||||
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/gift_send"] parameters:parameters needCache:NO success:^(id responseObject) {
|
||||
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
|
||||
showToast(msg);
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)stopFastAnimate{
|
||||
if (_fastTimer != nil) {
|
||||
dispatch_source_cancel(_fastTimer);
|
||||
_fastTimer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pauseGCDTimer {
|
||||
if (_fastTimer) {
|
||||
dispatch_suspend(_fastTimer);
|
||||
NSLog(@"GCD定时器已暂停");
|
||||
}
|
||||
}
|
||||
- (void)resumeGCDTimer {
|
||||
if (_fastTimer) {
|
||||
dispatch_resume(_fastTimer);
|
||||
NSLog(@"GCD定时器已恢复");
|
||||
}
|
||||
}
|
||||
-(void)ruleAction{
|
||||
self.ruleView.rule = self.model.rule_url;
|
||||
[self.ruleView showInView:self];
|
||||
}
|
||||
|
||||
-(void)poolAction{
|
||||
self.poolView.roomId = self.roomId;
|
||||
self.poolView.giftModel = self.giftModel;
|
||||
|
||||
[self.poolView showInView:self];
|
||||
}
|
||||
|
||||
-(void)recordAction{
|
||||
self.recordView.roomId = self.roomId;
|
||||
self.recordView.giftModel = self.giftModel;
|
||||
|
||||
[self.recordView showInView:self];
|
||||
}
|
||||
-(NSMutableArray *)allViewsArray{
|
||||
if (!_allViewsArray) {
|
||||
_allViewsArray = [NSMutableArray arrayWithArray:@[@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@""]];
|
||||
}
|
||||
return _allViewsArray;
|
||||
}
|
||||
|
||||
-(NSMutableArray *)targetArrayIndex{
|
||||
if (!_targetArrayIndex) {
|
||||
_targetArrayIndex = [NSMutableArray array];
|
||||
}
|
||||
return _targetArrayIndex;
|
||||
}
|
||||
|
||||
|
||||
-(AVPlayer *)player{
|
||||
if (!_player) {
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}
|
||||
return _player;
|
||||
}
|
||||
|
||||
|
||||
-(NSMutableArray *)finishTargetArrayIndex{
|
||||
if (!_finishTargetArrayIndex) {
|
||||
_finishTargetArrayIndex = [NSMutableArray array];
|
||||
}
|
||||
return _finishTargetArrayIndex;
|
||||
}
|
||||
-(QXSkyPraizeRuleView *)ruleView{
|
||||
if (!_ruleView) {
|
||||
_ruleView = [[QXSkyPraizeRuleView alloc] init];
|
||||
}
|
||||
return _ruleView;
|
||||
}
|
||||
-(QXSkyPraizePoolView *)poolView{
|
||||
if (!_poolView) {
|
||||
_poolView = [[QXSkyPraizePoolView alloc] init];
|
||||
}
|
||||
return _poolView;
|
||||
}
|
||||
-(QXSkyPraizeRecordView *)recordView{
|
||||
if (!_recordView) {
|
||||
_recordView = [[QXSkyPraizeRecordView alloc] init];
|
||||
}
|
||||
return _recordView;
|
||||
}
|
||||
-(void)showInView:(UIView *)view{
|
||||
[self getGiftList];
|
||||
[self resetViews];
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
[self stopFastAnimate];
|
||||
// [self stopSlowAnimate];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
-(void)destroyViews{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXSkyPraizeSubView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_item_nor"]];
|
||||
[self addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
|
||||
self.giftImageView = [[UIImageView alloc] init];
|
||||
[self addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(7);
|
||||
make.width.height.mas_equalTo(ScaleWidth(50));
|
||||
make.centerX.equalTo(self);
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:12];
|
||||
self.titleLabel.textColor = RGB16(0xffffff);
|
||||
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.giftImageView.mas_bottom).offset(4);
|
||||
make.height.mas_equalTo(ScaleWidth(14));
|
||||
make.centerX.equalTo(self);
|
||||
}];
|
||||
|
||||
self.giftCoin = [[UIButton alloc] init];
|
||||
self.giftCoin.userInteractionEnabled = NO;
|
||||
[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.equalTo(self);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom);
|
||||
}];
|
||||
|
||||
self.resultView = [[UIView alloc] init];
|
||||
self.resultView.hidden = YES;;
|
||||
[self addSubview:self.resultView];
|
||||
[self.resultView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.equalTo(self);
|
||||
make.height.mas_equalTo(54);
|
||||
}];
|
||||
self.resultBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_item_top_bg"]];
|
||||
[self.resultView addSubview:self.resultBgImageView];
|
||||
[self.resultBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.resultView);
|
||||
}];
|
||||
|
||||
self.countLabel = [[UILabel alloc] init];
|
||||
self.countLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:18];
|
||||
self.countLabel.textColor = RGB16(0x024AA7);
|
||||
self.countLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self.resultView addSubview:self.countLabel];
|
||||
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(12);
|
||||
make.height.mas_equalTo(ScaleWidth(20));
|
||||
make.centerX.equalTo(self.resultView);
|
||||
}];
|
||||
}
|
||||
-(void)setCount:(NSString *)count{
|
||||
_count = count;
|
||||
if (count.integerValue > 0) {
|
||||
// self.resultView.hidden = YES;
|
||||
// }else{
|
||||
// self.resultView.hidden = NO;
|
||||
self.countLabel.text = [NSString stringWithFormat:@"X%@",count];
|
||||
}
|
||||
}
|
||||
-(void)setGiftModel:(QXDrawGiftModel *)giftModel{
|
||||
_giftModel = giftModel;
|
||||
self.titleLabel.text = giftModel.gift_name;
|
||||
[self.giftCoin setTitle:giftModel.gift_price forState:(UIControlStateNormal)];
|
||||
NSString *encodedQuery = [giftModel.base_image stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
||||
NSURL *imageUrl = [NSURL URLWithString:encodedQuery];
|
||||
[self.giftImageView sd_setImageWithURL:imageUrl];
|
||||
}
|
||||
-(void)setIsSelected:(BOOL)isSelected{
|
||||
_isSelected = isSelected;
|
||||
self.bgImageView.image = [UIImage imageNamed:isSelected?@"sky_item_sel":@"sky_item_nor"];
|
||||
}
|
||||
- (void)startPulseAnimationWithLayer {
|
||||
CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
|
||||
pulseAnimation.duration = 0.5;
|
||||
pulseAnimation.fromValue = @0.9;
|
||||
pulseAnimation.toValue = @1.1;
|
||||
pulseAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
||||
pulseAnimation.autoreverses = YES;
|
||||
pulseAnimation.repeatCount = HUGE_VALF; // 无限循环
|
||||
|
||||
[self.layer addAnimation:pulseAnimation forKey:@"pulse"];
|
||||
|
||||
}
|
||||
|
||||
// 停止动画
|
||||
- (void)stopPulseAnimationWithLayer {
|
||||
[self.layer removeAnimationForKey:@"pulse"];
|
||||
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXSkyDrawBtn
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sky_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?@"sky_touch_dis_bg":@"sky_touch_bg"];
|
||||
}
|
||||
-(void)setBtnType:(QXSkyDrawBtnType)btnType{
|
||||
// /// 抽一次
|
||||
// QXSkyDrawBtnTypeOne = 0,
|
||||
// /// 抽10次
|
||||
// QXSkyDrawBtnTypeTen ,
|
||||
// /// 抽100次
|
||||
// QXSkyDrawBtnTypeHundred ,
|
||||
_btnType = btnType;
|
||||
switch (btnType) {
|
||||
case QXSkyDrawBtnTypeOne:
|
||||
{
|
||||
self.titleLabel.text = @"抽一次";
|
||||
[self.giftCoin setTitle:@"10币一次" forState:(UIControlStateNormal)];
|
||||
}
|
||||
break;
|
||||
case QXSkyDrawBtnTypeTen:
|
||||
{
|
||||
self.titleLabel.text = @"抽六次";
|
||||
[self.giftCoin setTitle:@"100币一次" forState:(UIControlStateNormal)];
|
||||
}
|
||||
break;
|
||||
case QXSkyDrawBtnTypeHundred:
|
||||
{
|
||||
self.titleLabel.text = @"抽九次";
|
||||
[self.giftCoin setTitle:@"1000币一次" forState:(UIControlStateNormal)];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@end
|
||||
BIN
QXLive/活动/天空之境/Resource/active_sky_raize_bg@2x.png
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
QXLive/活动/天空之境/Resource/active_sky_raize_bg@3x.png
Normal file
|
After Width: | Height: | Size: 2.4 MiB |
BIN
QXLive/活动/天空之境/Resource/draw_music.mp3
Normal file
BIN
QXLive/活动/天空之境/Resource/no_animate_draw_music.mp3
Normal file
BIN
QXLive/活动/天空之境/Resource/sky_item_coin@2x.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_item_coin@3x.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_item_nor@2x.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_item_nor@3x.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_item_sel@2x.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_item_sel@3x.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_item_top_bg@2x.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_item_top_bg@3x.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_left_bg@2x.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_left_bg@3x.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_pool_icon@2x.png
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_pool_icon@3x.png
Normal file
|
After Width: | Height: | Size: 174 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_record_icon@2x.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_record_icon@3x.png
Normal file
|
After Width: | Height: | Size: 223 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_right_bg@2x.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_right_bg@3x.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_rule_bg@2x.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
QXLive/活动/天空之境/Resource/sky_rule_bg@3x.png
Normal file
|
After Width: | Height: | Size: 2.0 MiB |
BIN
QXLive/活动/天空之境/Resource/sky_rule_icon@2x.png
Normal file
|
After Width: | Height: | Size: 101 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_rule_icon@3x.png
Normal file
|
After Width: | Height: | Size: 213 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_status_bg@2x.png
Normal file
|
After Width: | Height: | Size: 104 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_status_bg@3x.png
Normal file
|
After Width: | Height: | Size: 213 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_switch_off@2x.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_switch_off@3x.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_switch_on@2x.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_switch_on@3x.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_touch_bg@2x.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_touch_bg@3x.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_touch_dis_bg@2x.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
QXLive/活动/天空之境/Resource/sky_touch_dis_bg@3x.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
25
QXLive/活动/岁月之城/QXAgePraizePoolView.h
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// QXAgePraizePoolView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/27.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXGiftActivityModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXAgePraizePoolView : UIView
|
||||
@property (nonatomic,strong)QXGiftModel *giftModel;
|
||||
@property (nonatomic,strong)NSString *roomId;
|
||||
-(void)showInView:(UIView *)view;
|
||||
@end
|
||||
|
||||
@interface QXAgePoolCell : UICollectionViewCell
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *nameLabel;
|
||||
@property (nonatomic,strong)UIButton *giftCoin;
|
||||
@property (nonatomic,strong)QXDrawGiftModel *model;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
177
QXLive/活动/岁月之城/QXAgePraizePoolView.m
Normal file
@@ -0,0 +1,177 @@
|
||||
//
|
||||
// QXAgePraizePoolView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/27.
|
||||
//
|
||||
|
||||
#import "QXAgePraizePoolView.h"
|
||||
@interface QXAgePraizePoolView()<UIGestureRecognizerDelegate,UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
|
||||
@property(nonatomic,strong)UIView* bgView;
|
||||
@property(nonatomic,strong)UIImageView* ruleImageView;
|
||||
@property(nonatomic,strong)UIImageView* bgImageView;
|
||||
|
||||
@property(nonatomic,strong)UICollectionView* collectionView;
|
||||
@property(nonatomic,strong)QXGiftActivityModel* model;
|
||||
|
||||
@end
|
||||
@implementation QXAgePraizePoolView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == 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];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_rule_bg"]];
|
||||
self.bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663));
|
||||
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self.bgView addSubview:self.bgImageView];
|
||||
|
||||
self.ruleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_pool_icon"]];
|
||||
self.ruleImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
self.ruleImageView.frame = CGRectMake((SCREEN_WIDTH-ScaleWidth(164))/2, 0, ScaleWidth(164), ScaleWidth(90));
|
||||
[self.bgView addSubview:self.ruleImageView];
|
||||
|
||||
[self.bgView addSubview:self.collectionView];
|
||||
}
|
||||
-(void)setGiftModel:(QXGiftModel *)giftModel{
|
||||
_giftModel = giftModel;
|
||||
[self getGiftList];
|
||||
}
|
||||
-(void)setRoomId:(NSString *)roomId{
|
||||
_roomId = roomId;
|
||||
}
|
||||
-(void)getGiftList{
|
||||
if (![self.giftModel.gift_bag isExist]) {
|
||||
return;
|
||||
}
|
||||
if (![self.roomId isExist]) {
|
||||
return;
|
||||
}
|
||||
if (self.model) {
|
||||
return;
|
||||
}
|
||||
MJWeakSelf
|
||||
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_gift_list"] parameters:@{@"gift_bag_id":self.giftModel.gift_bag?self.giftModel.gift_bag:@"",@"room_id":self.roomId?self.roomId:@""} needCache:NO success:^(id responseObject) {
|
||||
QXGiftActivityModel *model = [QXGiftActivityModel yy_modelWithJSON:responseObject[@"data"]];
|
||||
weakSelf.model = model;
|
||||
[self.collectionView reloadData];
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
|
||||
}];
|
||||
}
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.model.gift_list.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXAgePoolCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXAgePoolCell" forIndexPath:indexPath];
|
||||
cell.model = self.model.gift_list[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(void)showInView:(UIView *)view{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
// [self stopSlowAnimate];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
-(UICollectionView *)collectionView{
|
||||
if (!_collectionView) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.minimumLineSpacing = 23;
|
||||
layout.minimumInteritemSpacing = 23;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 17, 0, 17);
|
||||
layout.itemSize = CGSizeMake((SCREEN_WIDTH-17*2-23*2-1)/3, ScaleWidth(128));
|
||||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.ruleImageView.bottom+10, SCREEN_WIDTH, self.bgView.height-self.ruleImageView.bottom) collectionViewLayout:layout];
|
||||
_collectionView.delegate = self;
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.showsHorizontalScrollIndicator = NO;
|
||||
_collectionView.showsVerticalScrollIndicator = NO;
|
||||
_collectionView.backgroundColor = [UIColor clearColor];
|
||||
[_collectionView registerClass:[QXAgePoolCell class] forCellWithReuseIdentifier:@"QXAgePoolCell"];
|
||||
// MJWeakSelf
|
||||
// _collectionView.mj_header = [m footerWithRefreshingBlock:^{
|
||||
// [weakSelf getGiftList];
|
||||
// }];
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXAgePoolCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setModel:(QXDrawGiftModel *)model{
|
||||
_model = model;
|
||||
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
||||
self.nameLabel.text = model.gift_name;
|
||||
[self.giftCoin setTitle:[NSString stringWithFormat:@" %@",model.gift_price] forState:(UIControlStateNormal)];
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.giftImageView = [[UIImageView alloc] init];
|
||||
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.right.equalTo(self.contentView);
|
||||
make.height.equalTo(self.giftImageView.mas_width);
|
||||
}];
|
||||
|
||||
self.nameLabel = [[UILabel alloc] init];
|
||||
self.nameLabel.textColor = RGB16(0xffffff);
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.contentView addSubview:self.nameLabel];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.giftImageView.mas_bottom);
|
||||
make.centerX.equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
self.giftCoin = [[UIButton alloc] init];
|
||||
[self.giftCoin setTitleColor:RGB16(0xC7BF62) forState:(UIControlStateNormal)];
|
||||
self.giftCoin.titleLabel.font = [UIFont systemFontOfSize:10];
|
||||
[self.giftCoin setImage:[UIImage imageNamed:@"age_item_coin"] forState:(UIControlStateNormal)];
|
||||
[self.contentView addSubview:self.giftCoin];
|
||||
[self.giftCoin mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.nameLabel.mas_bottom);
|
||||
make.centerX.equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
36
QXLive/活动/岁月之城/QXAgePraizeRecordView.h
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// QXAgePraizeRecordView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXGiftActivityModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXAgePraizeRecordView : UIView
|
||||
@property (nonatomic,strong)NSString *roomId;
|
||||
@property (nonatomic,strong)QXGiftModel *giftModel;
|
||||
-(void)showInView:(UIView *)view;
|
||||
@end
|
||||
|
||||
@interface QXAgeRecordCell : UICollectionViewCell
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *giftInfoLabel;
|
||||
@property (nonatomic,strong)UILabel *recieveInfoLabel;
|
||||
@property (nonatomic,strong)UILabel *timeLabel;
|
||||
@property (nonatomic,strong)QXActivityRecordModel *model;
|
||||
@end
|
||||
|
||||
@interface QXAgeAllRecordCell : UITableViewCell
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *giftInfoLabel;
|
||||
@property (nonatomic,strong)UILabel *recieveInfoLabel;
|
||||
@property (nonatomic,strong)UILabel *timeLabel;
|
||||
@property (nonatomic,strong)UIView *bottomLine;
|
||||
@property (nonatomic,strong)QXActivityRecordModel *model;
|
||||
+(instancetype)cellWithTableView:(UITableView*)tableView;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
416
QXLive/活动/岁月之城/QXAgePraizeRecordView.m
Normal file
@@ -0,0 +1,416 @@
|
||||
//
|
||||
// QXAgePraizeRecordView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import "QXAgePraizeRecordView.h"
|
||||
|
||||
|
||||
@interface QXAgePraizeRecordView()<UIGestureRecognizerDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UITableViewDelegate,UITableViewDataSource>
|
||||
@property(nonatomic,strong)UIView* bgView;
|
||||
@property(nonatomic,strong)UIImageView* ruleImageView;
|
||||
@property(nonatomic,strong)UIImageView* bgImageView;
|
||||
|
||||
@property(nonatomic,strong)UIView* bgCoverView;
|
||||
|
||||
@property(nonatomic,strong)UIButton* myRecordBtn;
|
||||
@property(nonatomic,strong)UIButton* allRecordBtn;
|
||||
@property(nonatomic,strong)UICollectionView* collectionView;
|
||||
@property(nonatomic,strong)UITableView* tableView;
|
||||
@property(nonatomic,strong)NSMutableArray* myRecordArray;
|
||||
@property(nonatomic,strong)NSMutableArray* allRecordArray;
|
||||
@property(nonatomic,assign)NSInteger page;
|
||||
@end
|
||||
@implementation QXAgePraizeRecordView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == 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];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_rule_bg"]];
|
||||
self.bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663));
|
||||
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self.bgView addSubview:self.bgImageView];
|
||||
|
||||
self.ruleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_record_icon"]];
|
||||
self.ruleImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
self.ruleImageView.frame = CGRectMake((SCREEN_WIDTH-ScaleWidth(164))/2, 0, ScaleWidth(164), ScaleWidth(90));
|
||||
[self.bgView addSubview:self.ruleImageView];
|
||||
|
||||
self.bgCoverView = [[UIView alloc] initWithFrame:CGRectMake(16, self.ruleImageView.bottom+12, self.bgView.width-32, self.bgView.height-self.ruleImageView.bottom-24)];
|
||||
self.bgCoverView.backgroundColor = RGB16A(0x000000, 0.5);
|
||||
[self.bgView addSubview:self.bgCoverView];
|
||||
|
||||
self.myRecordBtn = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 75, 40)];
|
||||
self.myRecordBtn.selected = YES;
|
||||
[self.myRecordBtn setTitle:@"我的记录" forState:(UIControlStateNormal)];
|
||||
[self.myRecordBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateSelected)];
|
||||
[self.myRecordBtn setTitleColor:RGB16(0x5B5B5B) forState:(UIControlStateNormal)];
|
||||
self.myRecordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
||||
[self.myRecordBtn addTarget:self action:@selector(recordAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgCoverView addSubview:self.myRecordBtn];
|
||||
|
||||
self.allRecordBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.myRecordBtn.right+5, 5, 75, 40)];
|
||||
[self.allRecordBtn setTitle:@"全服记录" forState:(UIControlStateNormal)];
|
||||
[self.allRecordBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateSelected)];
|
||||
[self.allRecordBtn setTitleColor:RGB16(0x5B5B5B) forState:(UIControlStateNormal)];
|
||||
self.allRecordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.allRecordBtn addTarget:self action:@selector(recordAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgCoverView addSubview:self.allRecordBtn];
|
||||
|
||||
|
||||
[self.bgCoverView addSubview:self.collectionView];
|
||||
[self.bgCoverView addSubview:self.tableView];
|
||||
}
|
||||
|
||||
-(void)recordAction:(UIButton*)sender{
|
||||
if (sender == self.myRecordBtn) {
|
||||
if (self.myRecordBtn.selected) {
|
||||
return;
|
||||
}else{
|
||||
self.myRecordBtn.selected = YES;
|
||||
self.allRecordBtn.selected = NO;
|
||||
self.myRecordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
||||
self.allRecordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
}
|
||||
}else{
|
||||
if (self.allRecordBtn.selected) {
|
||||
return;
|
||||
}else{
|
||||
self.allRecordBtn.selected = YES;
|
||||
self.myRecordBtn.selected = NO;
|
||||
self.allRecordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
||||
self.myRecordBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
}
|
||||
}
|
||||
[self getRecordList];
|
||||
}
|
||||
-(void)setGiftModel:(QXGiftModel *)giftModel{
|
||||
_giftModel = giftModel;
|
||||
self.page = 1;
|
||||
[self getRecordList];
|
||||
}
|
||||
|
||||
-(void)getRecordList{
|
||||
if (![self.giftModel.gift_bag isExist]) {
|
||||
return;
|
||||
}
|
||||
if (![self.roomId isExist]) {
|
||||
return;
|
||||
}
|
||||
MJWeakSelf
|
||||
NSDictionary *parameters = @{
|
||||
@"gift_bag_id":self.giftModel.gift_bag,
|
||||
@"page":[NSNumber numberWithInteger:self.page]
|
||||
};
|
||||
NSString *url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_my_record"];
|
||||
if (self.myRecordBtn.selected) {
|
||||
url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_my_record"];
|
||||
}else{
|
||||
url = [NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_all_record"];
|
||||
}
|
||||
[[QXRequset shareInstance] postWithUrl:url parameters:parameters needCache:NO success:^(id responseObject) {
|
||||
if (weakSelf.myRecordBtn.selected == YES) {
|
||||
weakSelf.collectionView.hidden = NO;
|
||||
weakSelf.tableView.hidden = YES;
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.myRecordArray removeAllObjects];
|
||||
}
|
||||
NSArray *arr = [NSArray yy_modelArrayWithClass:[QXActivityRecordModel class] json:responseObject[@"data"]];
|
||||
[weakSelf.myRecordArray addObjectsFromArray:arr];
|
||||
[weakSelf.collectionView reloadData];
|
||||
if (arr.count == 0) {
|
||||
weakSelf.collectionView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.collectionView.mj_footer endRefreshing];
|
||||
}
|
||||
[weakSelf.collectionView.mj_header endRefreshing];
|
||||
|
||||
}else{
|
||||
weakSelf.collectionView.hidden = YES;
|
||||
weakSelf.tableView.hidden = NO;
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.allRecordArray removeAllObjects];
|
||||
}
|
||||
NSArray *arr = [NSArray yy_modelArrayWithClass:[QXActivityRecordModel class] json:responseObject[@"data"]];
|
||||
[weakSelf.allRecordArray addObjectsFromArray:arr];
|
||||
[weakSelf.tableView reloadData];
|
||||
if (arr.count == 0) {
|
||||
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
}
|
||||
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
[weakSelf.collectionView.mj_footer endRefreshing];
|
||||
[weakSelf.collectionView.mj_header endRefreshing];
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)showInView:(UIView *)view{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
// [self stopSlowAnimate];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
// if (self.myRecordBtn.selected) {
|
||||
return self.myRecordArray.count;
|
||||
// }else{
|
||||
// return self.allRecordArray.count;
|
||||
// }
|
||||
|
||||
}
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXAgeRecordCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXAgeRecordCell" forIndexPath:indexPath];
|
||||
// if (self.myRecordBtn.selected) {
|
||||
cell.model = self.myRecordArray[indexPath.row];
|
||||
// }else{
|
||||
// cell.model = self.allRecordArray[indexPath.row];
|
||||
// }
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
return self.allRecordArray.count;
|
||||
}
|
||||
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXAgeAllRecordCell *cell = [QXAgeAllRecordCell cellWithTableView:tableView];
|
||||
cell.model = self.allRecordArray[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(UICollectionView *)collectionView{
|
||||
if (!_collectionView) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.minimumLineSpacing = 16;
|
||||
layout.minimumInteritemSpacing = 16;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 12, 0, 12);
|
||||
layout.itemSize = CGSizeMake((self.bgCoverView.width-12*2-16*2-1)/3, ScaleWidth(123));
|
||||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.myRecordBtn.bottom+10, self.bgCoverView.width, self.bgCoverView.height-self.myRecordBtn.bottom-5) collectionViewLayout:layout];
|
||||
_collectionView.delegate = self;
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.showsHorizontalScrollIndicator = NO;
|
||||
_collectionView.showsVerticalScrollIndicator = NO;
|
||||
_collectionView.backgroundColor = [UIColor clearColor];
|
||||
[_collectionView registerClass:[QXAgeRecordCell class] forCellWithReuseIdentifier:@"QXAgeRecordCell"];
|
||||
MJWeakSelf
|
||||
_collectionView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.page++;
|
||||
[weakSelf getRecordList];
|
||||
}];
|
||||
_collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getRecordList];
|
||||
}];
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
-(UITableView *)tableView{
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.myRecordBtn.bottom+10, self.bgCoverView.width, self.bgCoverView.height-self.myRecordBtn.bottom-5) style:(UITableViewStylePlain)];
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
_tableView.hidden = YES;
|
||||
_tableView.rowHeight = 70;
|
||||
_tableView.backgroundColor = [UIColor clearColor];
|
||||
MJWeakSelf
|
||||
_tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.page++;
|
||||
[weakSelf getRecordList];
|
||||
}];
|
||||
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getRecordList];
|
||||
}];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
-(NSMutableArray *)myRecordArray{
|
||||
if (!_myRecordArray) {
|
||||
_myRecordArray =[NSMutableArray array];
|
||||
}
|
||||
return _myRecordArray;
|
||||
}
|
||||
- (NSMutableArray *)allRecordArray{
|
||||
if (!_allRecordArray) {
|
||||
_allRecordArray = [NSMutableArray array];
|
||||
}
|
||||
return _allRecordArray;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXAgeRecordCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setModel:(QXActivityRecordModel *)model{
|
||||
_model = model;
|
||||
self.giftInfoLabel.text = [NSString stringWithFormat:@"%@x%@",model.gift_name,model.count];
|
||||
self.recieveInfoLabel.text = [NSString stringWithFormat:@"赠予%@",model.nickname];
|
||||
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
||||
self.timeLabel.text = model.createtime;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.giftImageView = [[UIImageView alloc] init];
|
||||
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.contentView);
|
||||
make.left.equalTo(self.contentView).offset(8);
|
||||
make.right.equalTo(self.contentView).offset(-8);
|
||||
make.height.equalTo(self.giftImageView.mas_width);
|
||||
}];
|
||||
|
||||
self.giftInfoLabel = [[UILabel alloc] init];
|
||||
self.giftInfoLabel.textColor = RGB16(0xffffff);
|
||||
self.giftInfoLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.contentView addSubview:self.giftInfoLabel];
|
||||
[self.giftInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.right.equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
self.recieveInfoLabel = [[UILabel alloc] init];
|
||||
self.recieveInfoLabel.textColor = RGB16(0xffffff);
|
||||
self.recieveInfoLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.contentView addSubview:self.recieveInfoLabel];
|
||||
[self.recieveInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.giftImageView.mas_bottom).offset(4);
|
||||
make.left.right.equalTo(self.contentView);
|
||||
make.height.mas_equalTo(21);
|
||||
}];
|
||||
|
||||
self.timeLabel = [[UILabel alloc] init];
|
||||
self.timeLabel.textColor = RGB16(0x5B5B5B);
|
||||
self.timeLabel.font = [UIFont systemFontOfSize:10];
|
||||
[self.contentView addSubview:self.timeLabel];
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.contentView);
|
||||
make.left.right.equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXAgeAllRecordCell
|
||||
|
||||
+(instancetype)cellWithTableView:(UITableView*)tableView{
|
||||
static NSString *cellId = @"QXAgeAllRecordCell";
|
||||
QXAgeAllRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
|
||||
if (!cell) {
|
||||
cell = [[QXAgeAllRecordCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId];
|
||||
cell.backgroundColor = [UIColor clearColor];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)setModel:(QXActivityRecordModel *)model{
|
||||
_model = model;
|
||||
self.giftInfoLabel.text = [NSString stringWithFormat:@"%@x%@",model.gift_name,model.count];
|
||||
self.recieveInfoLabel.text = [NSString stringWithFormat:@"%@",model.nickname];
|
||||
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
||||
self.timeLabel.text = model.createtime;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.contentView.backgroundColor = [UIColor clearColor];
|
||||
self.recieveInfoLabel = [[UILabel alloc] init];
|
||||
self.recieveInfoLabel.textColor = RGB16(0xffffff);
|
||||
self.recieveInfoLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.contentView addSubview:self.recieveInfoLabel];
|
||||
[self.recieveInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(12);
|
||||
make.left.mas_equalTo(12);
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
self.timeLabel = [[UILabel alloc] init];
|
||||
self.timeLabel.textColor = RGB16(0x5B5B5B);
|
||||
self.timeLabel.font = [UIFont systemFontOfSize:10];
|
||||
[self.contentView addSubview:self.timeLabel];
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.contentView).offset(-12);
|
||||
make.left.mas_equalTo(12);
|
||||
make.height.mas_equalTo(17);
|
||||
}];
|
||||
|
||||
self.giftImageView = [[UIImageView alloc] init];
|
||||
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.contentView).offset(-12);
|
||||
make.height.width.mas_equalTo(21);
|
||||
make.centerY.equalTo(self.recieveInfoLabel);
|
||||
}];
|
||||
|
||||
self.giftInfoLabel = [[UILabel alloc] init];
|
||||
self.giftInfoLabel.textColor = RGB16(0xffffff);
|
||||
self.giftInfoLabel.font = [UIFont systemFontOfSize:16];
|
||||
[self.contentView addSubview:self.giftInfoLabel];
|
||||
[self.giftInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.giftImageView.mas_left);
|
||||
make.centerY.equalTo(self.recieveInfoLabel);
|
||||
}];
|
||||
|
||||
self.bottomLine = [[UIView alloc] init];
|
||||
self.bottomLine.backgroundColor = RGB16(0xffffff);
|
||||
[self.contentView addSubview:self.bottomLine];
|
||||
[self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.contentView);
|
||||
make.left.mas_equalTo(12);
|
||||
make.right.mas_equalTo(-12);
|
||||
make.height.mas_equalTo(1);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
17
QXLive/活动/岁月之城/QXAgePraizeRuleView.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// QXAgePraizeRuleView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXAgePraizeRuleView : UIView
|
||||
@property (nonatomic,strong)NSString *rule;
|
||||
-(void)showInView:(UIView *)view;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
134
QXLive/活动/岁月之城/QXAgePraizeRuleView.m
Normal file
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// QXAgePraizeRuleView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/26.
|
||||
//
|
||||
|
||||
#import "QXAgePraizeRuleView.h"
|
||||
#import <WebKit/WebKit.h>
|
||||
static void *WKWebBrowserContext = &WKWebBrowserContext;
|
||||
|
||||
@interface QXAgePraizeRuleView()<WKNavigationDelegate,WKUIDelegate,UIGestureRecognizerDelegate>
|
||||
@property(nonatomic,strong)WKWebView *contentWebView;
|
||||
@property(nonatomic,strong)UIView* bgView;
|
||||
@property(nonatomic,strong)UIImageView* ruleImageView;
|
||||
@property(nonatomic,strong)UIImageView* bgImageView;
|
||||
@end
|
||||
|
||||
@implementation QXAgePraizeRuleView
|
||||
|
||||
- (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];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_rule_bg"]];
|
||||
self.bgImageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(663));
|
||||
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self.bgView addSubview:self.bgImageView];
|
||||
|
||||
self.ruleImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_rule_icon"]];
|
||||
self.ruleImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
self.ruleImageView.frame = CGRectMake((SCREEN_WIDTH-ScaleWidth(164))/2, 0, ScaleWidth(164), ScaleWidth(90));
|
||||
[self.bgView addSubview:self.ruleImageView];
|
||||
|
||||
[self.bgView addSubview:self.contentWebView];
|
||||
|
||||
|
||||
|
||||
}
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == self;
|
||||
}
|
||||
|
||||
-(void)setRule:(NSString *)rule{
|
||||
_rule = rule;
|
||||
[self loadData];
|
||||
}
|
||||
- (void)loadData {
|
||||
NSURL* url=[NSURL URLWithString:self.rule];
|
||||
NSURLRequest *request =[NSURLRequest requestWithURL:url];
|
||||
[self.contentWebView loadRequest:request];
|
||||
}
|
||||
|
||||
|
||||
//进度条
|
||||
- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView {
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - getters and setters
|
||||
- (WKWebView *)contentWebView {
|
||||
if (!_contentWebView) {
|
||||
//设置网页的配置文件
|
||||
WKWebViewConfiguration * configuration = [[WKWebViewConfiguration alloc]init];
|
||||
// 允许可以与网页交互,选择视图
|
||||
configuration.selectionGranularity = YES;
|
||||
// web内容处理池pr
|
||||
configuration.processPool = [[WKProcessPool alloc] init];
|
||||
//自定义配置,一般用于 js调用oc方法(OC拦截URL中的数据做自定义操作)
|
||||
WKUserContentController * UserContentController = [[WKUserContentController alloc]init];
|
||||
// 是否支持记忆读取
|
||||
configuration.suppressesIncrementalRendering = NO;
|
||||
// 允许用户更改网页的设置
|
||||
configuration.preferences.javaScriptEnabled = YES;
|
||||
configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES;
|
||||
configuration.userContentController = UserContentController;
|
||||
// 此处一定要做判断,因为是iOS9之后才有的方法,否则在iOS8下会崩溃
|
||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0) {
|
||||
//允许视频播放
|
||||
configuration.allowsAirPlayForMediaPlayback = YES;
|
||||
// 允许在线播放
|
||||
configuration.allowsInlineMediaPlayback = YES;
|
||||
//开启手势触摸 默认设置就是NO。在ios8系统中会导致手势问题,程序崩溃
|
||||
_contentWebView.allowsBackForwardNavigationGestures = YES;
|
||||
}
|
||||
_contentWebView = [[WKWebView alloc] initWithFrame:CGRectMake(16, self.ruleImageView.bottom+12, self.width-16*2, self.bgView.height-self.ruleImageView.bottom-12) configuration:configuration];
|
||||
_contentWebView.backgroundColor = RGB16A(0x000000, 0.5);
|
||||
[_contentWebView addRoundedCornersWithRadius:6];
|
||||
_contentWebView.opaque = NO;
|
||||
//适应你设定的尺寸
|
||||
[_contentWebView sizeToFit];
|
||||
_contentWebView.scrollView.showsVerticalScrollIndicator = NO;
|
||||
_contentWebView.scrollView.backgroundColor = [UIColor clearColor];
|
||||
_contentWebView.scrollView.bounces = NO;
|
||||
// 设置代理
|
||||
_contentWebView.navigationDelegate = self;
|
||||
}
|
||||
return _contentWebView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)showInView:(UIView *)view{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
// [self stopSlowAnimate];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
67
QXLive/活动/岁月之城/QXAgePraizeView.h
Normal file
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// QXAgePraizeView.h
|
||||
// QXLive 天空之镜
|
||||
//
|
||||
// Created by 启星 on 2025/8/16.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXGiftActivityModel.h"
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
/// 抽一次
|
||||
QXAgeDrawBtnTypeOne = 1,
|
||||
/// 抽10次
|
||||
QXAgeDrawBtnTypeTen = 6,
|
||||
/// 抽100次
|
||||
QXAgeDrawBtnTypeHundred = 9,
|
||||
}QXAgeDrawBtnType;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXAgePraizeView : UIView
|
||||
@property (nonatomic,strong)NSString *roomId;
|
||||
@property (nonatomic,strong)QXGiftModel *giftModel;
|
||||
@property (nonatomic,strong)QXGiftActivityModel *model;
|
||||
@property (nonatomic,strong)NSString* userIds;
|
||||
@property (nonatomic,strong)NSString* heartId;
|
||||
@property (nonatomic,strong)NSString* auctionId;
|
||||
@property (nonatomic,copy)void(^startBlock)(void);
|
||||
-(void)showInView:(UIView *)view;
|
||||
-(void)hide;
|
||||
-(void)updateProgress:(QXXLHModel*)model;
|
||||
-(void)destroyViews;
|
||||
@end
|
||||
|
||||
|
||||
@interface QXAgePraizeSubView :UIView
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)UIImageView *giftImageView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
|
||||
@property (nonatomic,strong)UIView *resultView;
|
||||
@property (nonatomic,strong)UIImageView *resultBgImageView;
|
||||
@property (nonatomic,strong)UILabel *countLabel;
|
||||
|
||||
@property (nonatomic,strong)UIButton *giftCoin;
|
||||
@property (nonatomic,strong)QXDrawGiftModel *giftModel;
|
||||
@property (nonatomic,assign)BOOL isSelected;
|
||||
@property (nonatomic,strong)NSString *count;
|
||||
|
||||
- (void)startPulseAnimationWithLayer;
|
||||
// 停止动画
|
||||
- (void)stopPulseAnimationWithLayer;
|
||||
@end
|
||||
|
||||
@interface QXAgeDrawBtn : UIControl
|
||||
@property (nonatomic,strong)UIImageView *bgImageView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)UIButton *giftCoin;
|
||||
@property (nonatomic,assign)BOOL isDisable;
|
||||
@property (nonatomic,assign)QXAgeDrawBtnType btnType;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
942
QXLive/活动/岁月之城/QXAgePraizeView.m
Normal file
@@ -0,0 +1,942 @@
|
||||
//
|
||||
// QXAgePraizeView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/8/16.
|
||||
//
|
||||
|
||||
#import "QXAgePraizeView.h"
|
||||
#import "UIButton+QX.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import "QXAgePraizeRuleView.h"
|
||||
#import "QXAgePraizePoolView.h"
|
||||
#import "QXAgePraizeRecordView.h"
|
||||
#import "QXDrawGiftCenterView.h"
|
||||
#import "QXDiamondViewController.h"
|
||||
|
||||
/// 共有12个礼物
|
||||
static NSInteger giftMaxCount = 10;
|
||||
/// 最少转2圈
|
||||
static NSInteger minRoundCount = 7;
|
||||
/// 距离4个的时候放慢
|
||||
static NSInteger toSlowCount = 4;
|
||||
|
||||
|
||||
@interface QXAgePraizeView()<UIGestureRecognizerDelegate>
|
||||
|
||||
|
||||
/// 目标下标
|
||||
@property (nonatomic,assign)NSInteger targetIndex;
|
||||
|
||||
@property (nonatomic,strong)NSMutableArray* targetArrayIndex;
|
||||
@property (nonatomic,strong)NSMutableArray* finishTargetArrayIndex;
|
||||
/// 当前转动到第几个下标
|
||||
@property (nonatomic,assign)NSInteger currentIndex;
|
||||
/// 转动了多少次
|
||||
@property (nonatomic,assign)NSInteger roundCount;
|
||||
/// 延时
|
||||
@property (nonatomic,assign)double delayTime;
|
||||
///// 22 抽一次 33 抽十次 44 抽 100次
|
||||
@property (nonatomic,assign)QXAgeDrawBtnType startType;
|
||||
|
||||
@property (nonatomic,strong)QXAgePraizeSubView *currentGiftView;
|
||||
|
||||
@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 *soundBtn;
|
||||
/// 特效
|
||||
@property (nonatomic,strong)UIButton *specialBtn;
|
||||
|
||||
@property (nonatomic,strong)NSMutableArray *allViewsArray;
|
||||
|
||||
@property (nonatomic,strong)dispatch_source_t fastTimer;
|
||||
|
||||
@property (nonatomic,strong)AVPlayer* player;
|
||||
|
||||
/// 金币
|
||||
@property (nonatomic,strong)UIView* coinView;
|
||||
@property (nonatomic,strong)UIButton* coinBtn;
|
||||
@property (nonatomic,strong)UIButton* exchangeBtn;
|
||||
|
||||
@property (nonatomic,strong)QXAgeDrawBtn *oneBtn;
|
||||
@property (nonatomic,strong)QXAgeDrawBtn *tenBtn;
|
||||
@property (nonatomic,strong)QXAgeDrawBtn *hundredBtn;
|
||||
@property (nonatomic,strong)QXDrawGiftResultModel *drawResultModel;
|
||||
/// 是否正在抽奖
|
||||
@property (nonatomic,assign)BOOL isDrawing;
|
||||
/// 是否开启音效
|
||||
@property (nonatomic,assign)BOOL isOpenSound;
|
||||
/// 是否开启特效
|
||||
@property (nonatomic,assign)BOOL isOpenSpecial;
|
||||
/// 规则视图
|
||||
@property (nonatomic,strong)QXAgePraizeRuleView *ruleView;
|
||||
/// 奖池视图
|
||||
@property (nonatomic,strong)QXAgePraizePoolView *poolView;
|
||||
/// 记录
|
||||
@property (nonatomic,strong)QXAgePraizeRecordView *recordView;
|
||||
|
||||
@property (nonatomic,strong)QXDrawGiftCenterView * centerView;
|
||||
|
||||
@property (nonatomic,assign)double coin;
|
||||
@end
|
||||
|
||||
@implementation QXAgePraizeView
|
||||
|
||||
- (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];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"active_age_castle_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(48), ScaleWidth(48), ScaleWidth(24))];
|
||||
[self.poolBtn setBackgroundImage:[UIImage imageNamed:@"age_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.ruleBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-ScaleWidth(48), self.poolBtn.top, ScaleWidth(48), ScaleWidth(24))];
|
||||
[self.ruleBtn setBackgroundImage:[UIImage imageNamed:@"age_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:@"age_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.allViewsArray removeAllObjects];
|
||||
CGFloat topMargin = self.recordBtn.bottom+5;
|
||||
CGFloat margin = 34;
|
||||
CGFloat space = 8;
|
||||
CGFloat leftSpace = 30;
|
||||
CGFloat itemWidth = (SCREEN_WIDTH - margin*2 - leftSpace*2) / 3;
|
||||
CGFloat itemHeight = itemWidth/82*99;;
|
||||
// for (int i = 0; i < giftMaxCount; i++) {
|
||||
// QXAgePraizeSubView *giftView;
|
||||
// if (i < 3) {
|
||||
// /// 第一行3个
|
||||
// giftView = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+leftSpace)*i, topMargin, itemWidth, itemHeight)];
|
||||
// giftView.titleLabel.text = [NSString stringWithFormat:@"%d",i];
|
||||
// [self.allViewsArray replaceObjectAtIndex:i withObject:giftView];
|
||||
// }else if (i > 2 && i < 5){
|
||||
// /// 第二行两个
|
||||
// if (i == 3) {
|
||||
// giftView = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(margin, topMargin+itemHeight+space, itemWidth, itemHeight)];
|
||||
// giftView.titleLabel.text = [NSString stringWithFormat:@"%d",9];
|
||||
// [self.allViewsArray replaceObjectAtIndex:9 withObject:giftView];
|
||||
// }else{
|
||||
// giftView = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+leftSpace)*2, topMargin+itemHeight+space, itemWidth, itemHeight)];
|
||||
// [self.allViewsArray replaceObjectAtIndex:3 withObject:giftView];
|
||||
// giftView.titleLabel.text = [NSString stringWithFormat:@"%d",3];
|
||||
// }
|
||||
// }else if (i > 4 && i < 7){
|
||||
// /// 第三行两个
|
||||
// if (i == 5) {
|
||||
// giftView = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(margin, topMargin+(itemHeight+space)*2, itemWidth, itemHeight)];
|
||||
// [self.allViewsArray replaceObjectAtIndex:8 withObject:giftView];
|
||||
// giftView.titleLabel.text = [NSString stringWithFormat:@"%d",8];
|
||||
// }else{
|
||||
// giftView = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+leftSpace)*2, topMargin+(itemHeight+space)*2, itemWidth, itemHeight)];
|
||||
// [self.allViewsArray replaceObjectAtIndex:4 withObject:giftView];
|
||||
// giftView.titleLabel.text = [NSString stringWithFormat:@"%d",4];
|
||||
// }
|
||||
// }else{
|
||||
// giftView = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(margin+(itemWidth+leftSpace)*(i%3), topMargin+(itemHeight+space)*3, itemWidth, itemHeight)];
|
||||
// [self.allViewsArray replaceObjectAtIndex:9-(i-4) withObject:giftView];
|
||||
// giftView.titleLabel.text = [NSString stringWithFormat:@"%d",9-(i-4)];
|
||||
// }
|
||||
//
|
||||
// [self.bgView addSubview:giftView];
|
||||
// }
|
||||
QXAgePraizeSubView*giftView1 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(margin, topMargin, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView1];
|
||||
[self.bgView addSubview:giftView1];
|
||||
QXAgePraizeSubView*giftView2 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(giftView1.right+leftSpace, topMargin, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView2];
|
||||
[self.bgView addSubview:giftView2];
|
||||
QXAgePraizeSubView*giftView3 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(giftView2.right+leftSpace, topMargin, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView3];
|
||||
[self.bgView addSubview:giftView3];
|
||||
QXAgePraizeSubView*giftView4 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(giftView3.left, giftView3.bottom+space, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView4];
|
||||
[self.bgView addSubview:giftView4];
|
||||
QXAgePraizeSubView*giftView5 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(giftView3.left, giftView4.bottom+space, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView5];
|
||||
[self.bgView addSubview:giftView5];
|
||||
QXAgePraizeSubView*giftView6 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(giftView3.left, giftView5.bottom+space, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView6];
|
||||
[self.bgView addSubview:giftView6];
|
||||
QXAgePraizeSubView*giftView7 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(giftView2.left, giftView6.top, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView7];
|
||||
[self.bgView addSubview:giftView7];
|
||||
QXAgePraizeSubView*giftView8 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(giftView1.left, giftView6.top, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView8];
|
||||
[self.bgView addSubview:giftView8];
|
||||
QXAgePraizeSubView*giftView9 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(giftView1.left, giftView5.top, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView9];
|
||||
[self.bgView addSubview:giftView9];
|
||||
QXAgePraizeSubView*giftView10 = [[QXAgePraizeSubView alloc] initWithFrame:CGRectMake(giftView1.left, giftView4.top, itemWidth, itemHeight)];
|
||||
[self.allViewsArray addObject:giftView10];
|
||||
[self.bgView addSubview:giftView10];
|
||||
[self resetViews];
|
||||
|
||||
CGFloat btnWidth = ScaleWidth(109);
|
||||
CGFloat btnMargin = (SCREEN_WIDTH- ScaleWidth(109)*3)/4;
|
||||
QXAgeDrawBtn *oneBtn = [[QXAgeDrawBtn alloc] initWithFrame:CGRectMake(btnMargin, self.bgView.height-ScaleWidth(34)-20, btnWidth, ScaleWidth(34))];
|
||||
oneBtn.btnType = QXAgeDrawBtnTypeOne;
|
||||
oneBtn.isDisable = YES;
|
||||
self.oneBtn = oneBtn;
|
||||
self.oneBtn.hidden = YES;
|
||||
[oneBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:oneBtn];
|
||||
|
||||
QXAgeDrawBtn *tenBtn = [[QXAgeDrawBtn alloc] initWithFrame:CGRectMake(self.oneBtn.right+btnMargin, self.oneBtn.top, btnWidth, ScaleWidth(34))];
|
||||
tenBtn.btnType = QXAgeDrawBtnTypeTen;
|
||||
tenBtn.isDisable = YES;
|
||||
self.tenBtn = tenBtn;
|
||||
self.tenBtn.hidden = YES;
|
||||
[tenBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:tenBtn];
|
||||
|
||||
QXAgeDrawBtn *hundredBtn = [[QXAgeDrawBtn alloc] initWithFrame:CGRectMake(tenBtn.right+btnMargin, self.oneBtn.top, btnWidth, ScaleWidth(34))];
|
||||
hundredBtn.btnType = QXAgeDrawBtnTypeHundred;
|
||||
hundredBtn.isDisable = YES;
|
||||
self.hundredBtn = hundredBtn;
|
||||
self.hundredBtn.hidden = YES;
|
||||
[hundredBtn addTarget:self action:@selector(startAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:hundredBtn];
|
||||
|
||||
self.soundBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2-75-15, self.oneBtn.top-20-20, 75, 20)];
|
||||
[self.soundBtn addTarget:self action:@selector(soundAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.soundBtn setTitle:@"音效" forState:(UIControlStateNormal)];
|
||||
[self.soundBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
|
||||
self.soundBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.soundBtn setImage:[UIImage imageNamed:@"age_switch_off"] forState:(UIControlStateNormal)];
|
||||
[self.soundBtn setImage:[UIImage imageNamed:@"age_switch_on"] forState:(UIControlStateSelected)];
|
||||
self.soundBtn.selected = YES;
|
||||
[self.bgView addSubview:self.soundBtn];
|
||||
|
||||
|
||||
self.specialBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2+15, self.oneBtn.top-20-20, 75, 20)];
|
||||
[self.specialBtn addTarget:self action:@selector(specialAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.specialBtn setTitle:@"特效" forState:(UIControlStateNormal)];
|
||||
[self.specialBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
|
||||
self.specialBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.specialBtn setImage:[UIImage imageNamed:@"age_switch_off"] forState:(UIControlStateNormal)];
|
||||
[self.specialBtn setImage:[UIImage imageNamed:@"age_switch_on"] forState:(UIControlStateSelected)];
|
||||
self.specialBtn.selected = YES;
|
||||
[self.bgView addSubview:self.specialBtn];
|
||||
|
||||
[self.soundBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:2];
|
||||
[self.specialBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:2];
|
||||
self.isOpenSound = YES;
|
||||
self.isOpenSpecial = YES;
|
||||
|
||||
|
||||
self.coinView = [[UIView alloc] initWithFrame:CGRectMake((self.bgView.width-100)/2, topMargin+(itemHeight+space)*3-ScaleWidth(28)-6, 100,ScaleWidth(28))];
|
||||
[self.coinView addRoundedCornersWithRadius:ScaleWidth(14)];
|
||||
self.coinView.backgroundColor = RGB16A(0x926D37,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:@"age_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 addTarget:self action:@selector(exchangeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.coinView addSubview:self.exchangeBtn];
|
||||
|
||||
MJWeakSelf
|
||||
self.centerView = [[QXDrawGiftCenterView alloc] initWithFrame:CGRectMake((self.bgView.width-ScaleWidth(148))/2, topMargin+itemHeight, ScaleWidth(148), ScaleWidth(180))];
|
||||
self.centerView.hidden = YES;
|
||||
self.centerView.startBlock = ^{
|
||||
if (weakSelf.startBlock) {
|
||||
weakSelf.startBlock();
|
||||
}
|
||||
};
|
||||
self.centerView.type = QXDrawGiftCenterTypeWait;
|
||||
self.centerView.activityType = QXActivityTypeAge;
|
||||
[self.bgView addSubview:self.centerView];
|
||||
|
||||
}
|
||||
- (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)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)setGiftModel:(QXGiftModel *)giftModel{
|
||||
_giftModel = giftModel;
|
||||
[self getGiftList];
|
||||
[self getMyWallet];
|
||||
}
|
||||
-(void)updateProgress:(QXXLHModel*)model{
|
||||
if (self.model) {
|
||||
self.model.xlh_data = model;
|
||||
self.centerView.model = self.model;
|
||||
}
|
||||
}
|
||||
-(void)getGiftList{
|
||||
if (![self.giftModel.gift_bag isExist]) {
|
||||
return;
|
||||
}
|
||||
if (![self.roomId isExist]) {
|
||||
return;
|
||||
}
|
||||
// if (self.model) {
|
||||
// return;
|
||||
// }
|
||||
MJWeakSelf
|
||||
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/get_gift_list"] parameters:@{@"gift_bag_id":self.giftModel.gift_bag?self.giftModel.gift_bag:@"",@"room_id":self.roomId?self.roomId:@""} needCache:NO success:^(id responseObject) {
|
||||
QXGiftActivityModel *model = [QXGiftActivityModel yy_modelWithJSON:responseObject[@"data"]];
|
||||
weakSelf.model = model;
|
||||
weakSelf.centerView.model = model;
|
||||
for (int i = 0; i < model.gift_list.count; i++) {
|
||||
QXAgePraizeSubView* subview = weakSelf.allViewsArray[i];
|
||||
subview.giftModel = model.gift_list[i];
|
||||
}
|
||||
[weakSelf.oneBtn.giftCoin setTitle:[NSString stringWithFormat:@"%@币一次",model.box_price] forState:(UIControlStateNormal)];
|
||||
[weakSelf.tenBtn.giftCoin setTitle:[NSString stringWithFormat:@"%ld币一次",model.box_price.integerValue*6] forState:(UIControlStateNormal)];
|
||||
[weakSelf.hundredBtn.giftCoin setTitle:[NSString stringWithFormat:@"%ld币一次",model.box_price.integerValue*9] forState:(UIControlStateNormal)];
|
||||
weakSelf.oneBtn.hidden = NO;
|
||||
weakSelf.tenBtn.hidden = NO;
|
||||
weakSelf.hundredBtn.hidden = NO;
|
||||
[weakSelf configBtnStatus];
|
||||
} 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)setHeartId:(NSString *)heartId{
|
||||
_heartId = heartId;
|
||||
}
|
||||
-(void)drawGiftWithNum:(NSString*)num{
|
||||
NSDictionary *parameters = @{
|
||||
@"gift_bag_id":self.giftModel.gift_bag,
|
||||
@"gift_user_ids":self.userIds,
|
||||
@"room_id":self.roomId,
|
||||
@"num":num,
|
||||
@"heart_id":[self.heartId isExist]?self.heartId:@"",
|
||||
@"auction_id":[self.auctionId isExist]?self.auctionId:@""
|
||||
};
|
||||
self.isDrawing = YES;
|
||||
MJWeakSelf
|
||||
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/draw_gift"] parameters:parameters needCache:NO success:^(id responseObject) {
|
||||
QXDrawGiftResultModel *model = [QXDrawGiftResultModel yy_modelWithJSON:responseObject[@"data"]];
|
||||
weakSelf.drawResultModel = model;
|
||||
[weakSelf.targetArrayIndex removeAllObjects];
|
||||
[weakSelf getMyWallet];
|
||||
for (int i = 0; i < model.reslut_list.count; i++) {
|
||||
QXDrawGiftModel *md = model.reslut_list[i];
|
||||
for (int j = 0; j < weakSelf.model.gift_list.count; j++) {
|
||||
QXDrawGiftModel*gift = weakSelf.model.gift_list[j];
|
||||
if ([md.gift_id isEqualToString:gift.gift_id]) {
|
||||
[weakSelf.targetArrayIndex addObject:[NSNumber numberWithInt:j]];
|
||||
if (j < 12) {
|
||||
QXAgePraizeSubView *subView = weakSelf.allViewsArray[j];
|
||||
subView.count = md.count;
|
||||
if (!weakSelf.isOpenSpecial) {
|
||||
subView.resultView.hidden = NO;
|
||||
subView.isSelected = YES;
|
||||
weakSelf.isDrawing = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (weakSelf.isOpenSound) {
|
||||
[weakSelf.player seekToTime:CMTimeMake(0, 1)];
|
||||
[weakSelf.player play];
|
||||
}
|
||||
if (weakSelf.isOpenSpecial) {
|
||||
[weakSelf startFastAnimate];
|
||||
}else{
|
||||
[weakSelf animateFinishedSendGift];
|
||||
}
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
weakSelf.isDrawing = NO;
|
||||
showToast(msg);
|
||||
}];
|
||||
}
|
||||
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == self;
|
||||
}
|
||||
-(void)specialAction:(UIButton*)sender{
|
||||
sender.selected = !sender.selected;
|
||||
self.isOpenSpecial = sender.selected;
|
||||
if (self.isOpenSpecial) {
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}else{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"no_animate_draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}
|
||||
}
|
||||
-(void)soundAction:(UIButton*)sender{
|
||||
sender.selected = !sender.selected;
|
||||
self.isOpenSound = sender.selected;
|
||||
if (self.isOpenSpecial) {
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}else{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"no_animate_draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}
|
||||
}
|
||||
-(void)startAction:(QXAgeDrawBtn*)sender{
|
||||
if (sender.isDisable) {
|
||||
showToast(@"金币不足");
|
||||
return;
|
||||
}
|
||||
if (self.isDrawing) {
|
||||
// showToast(@"正在抽奖中");
|
||||
return;
|
||||
}
|
||||
[self resetViews];
|
||||
[self drawGiftWithNum:[NSString stringWithFormat:@"%ld",sender.btnType]];
|
||||
|
||||
/// 获取目标礼物
|
||||
|
||||
// [self getTargetGift];
|
||||
// [self startFastAnimate];
|
||||
}
|
||||
-(void)exchangeAction{
|
||||
QXDiamondViewController *vc = [[QXDiamondViewController alloc] init];
|
||||
[self.viewController.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
|
||||
-(void)resetViews{
|
||||
|
||||
self.isDrawing = NO;
|
||||
self.targetIndex = -1;
|
||||
self.currentIndex = -1;
|
||||
self.roundCount = 0;
|
||||
self.delayTime = 0.2;
|
||||
[self.targetArrayIndex removeAllObjects];
|
||||
[self.finishTargetArrayIndex removeAllObjects];
|
||||
if (self.currentGiftView != nil) {
|
||||
self.currentGiftView.isSelected = NO;
|
||||
[self.currentGiftView stopPulseAnimationWithLayer];
|
||||
}
|
||||
for (QXAgePraizeSubView *giftView in self.allViewsArray) {
|
||||
giftView.isSelected = NO;
|
||||
giftView.count = @"0";
|
||||
giftView.resultView.hidden = YES;
|
||||
[giftView stopPulseAnimationWithLayer];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)startFastAnimate{
|
||||
self.currentGiftView = self.allViewsArray.firstObject;
|
||||
self.currentGiftView.isSelected = YES;
|
||||
[self stopFastAnimate];
|
||||
if (_fastTimer == nil) {
|
||||
_fastTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
|
||||
}
|
||||
// dispatch_source_set_timer(_fastTimer,
|
||||
// dispatch_time(DISPATCH_TIME_NOW, 0),
|
||||
// NSEC_PER_SEC * 0.06, // 间隔0.1秒
|
||||
// NSEC_PER_SEC * 0.01); // 允许误差0.01秒
|
||||
|
||||
dispatch_source_set_timer(_fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER, // 使用一次性模式
|
||||
0.01 * NSEC_PER_SEC);
|
||||
if (self.isOpenSound) {
|
||||
[self.player seekToTime:CMTimeMake(0, 1)];
|
||||
[self.player play];
|
||||
}
|
||||
__weak typeof(self) weakSelf = self;
|
||||
dispatch_source_set_event_handler(_fastTimer, ^{
|
||||
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||
if (!strongSelf) return;
|
||||
// 如果需要更新UI,切换到主线程
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
strongSelf.roundCount++;
|
||||
if ((strongSelf.roundCount / giftMaxCount == minRoundCount) && strongSelf.startType != QXAgeDrawBtnTypeOne) {
|
||||
BOOL has = NO;
|
||||
for (NSNumber *index in strongSelf.finishTargetArrayIndex) {
|
||||
if (index.integerValue == strongSelf.currentIndex) {
|
||||
has = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.currentGiftView.isSelected = NO;
|
||||
if (has) {
|
||||
QXAgePraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = YES;
|
||||
}else{
|
||||
QXAgePraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = NO;
|
||||
}
|
||||
}else{
|
||||
/// 把上一个选中状态置为未选中
|
||||
strongSelf.currentGiftView.isSelected = NO;
|
||||
}
|
||||
/// 计算当前下标
|
||||
strongSelf.currentIndex = strongSelf.roundCount%giftMaxCount;
|
||||
/// 获取当前选中的view 并设置为选中状态
|
||||
QXAgePraizeSubView *giftView = strongSelf.allViewsArray[strongSelf.currentIndex];
|
||||
giftView.isSelected = YES;
|
||||
|
||||
/// 重新赋值给选中view
|
||||
strongSelf.currentGiftView = giftView;
|
||||
|
||||
if (strongSelf.roundCount / giftMaxCount == minRoundCount) {
|
||||
for (NSNumber *index in strongSelf.targetArrayIndex) {
|
||||
if (strongSelf.currentIndex == index.integerValue) {
|
||||
QXAgePraizeSubView *giftView = strongSelf.allViewsArray[index.integerValue];
|
||||
giftView.isSelected = YES;
|
||||
giftView.resultView.hidden = NO;
|
||||
[giftView startPulseAnimationWithLayer];
|
||||
[strongSelf.targetArrayIndex removeObject:index];
|
||||
[strongSelf.finishTargetArrayIndex addObject:index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
dispatch_source_set_timer(strongSelf.fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, 0.03 * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.01 * NSEC_PER_SEC);
|
||||
if (strongSelf.targetArrayIndex.count == 0) {
|
||||
strongSelf.isDrawing = NO;
|
||||
[strongSelf stopFastAnimate];
|
||||
[strongSelf animateFinishedSendGift];
|
||||
}
|
||||
// }
|
||||
}else{
|
||||
strongSelf.delayTime = strongSelf.delayTime-0.02;
|
||||
if (strongSelf.delayTime <= 0.03) {
|
||||
strongSelf.delayTime = 0.03;
|
||||
}
|
||||
dispatch_source_set_timer(strongSelf.fastTimer,
|
||||
dispatch_time(DISPATCH_TIME_NOW, strongSelf.delayTime * NSEC_PER_SEC),
|
||||
DISPATCH_TIME_FOREVER,
|
||||
0.01 * NSEC_PER_SEC);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
dispatch_resume(_fastTimer);
|
||||
}
|
||||
-(void)animateFinishedSendGift{
|
||||
NSDictionary *parameters = @{
|
||||
@"send_id":self.drawResultModel.blind_box_turntable_id?self.drawResultModel.blind_box_turntable_id:@""
|
||||
};
|
||||
[[QXRequset shareInstance] postWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,@"api/BlindBoxTurntable/gift_send"] parameters:parameters needCache:NO success:^(id responseObject) {
|
||||
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
|
||||
showToast(msg);
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)stopFastAnimate{
|
||||
if (_fastTimer != nil) {
|
||||
dispatch_source_cancel(_fastTimer);
|
||||
_fastTimer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pauseGCDTimer {
|
||||
if (_fastTimer) {
|
||||
dispatch_suspend(_fastTimer);
|
||||
NSLog(@"GCD定时器已暂停");
|
||||
}
|
||||
}
|
||||
- (void)resumeGCDTimer {
|
||||
if (_fastTimer) {
|
||||
dispatch_resume(_fastTimer);
|
||||
NSLog(@"GCD定时器已恢复");
|
||||
}
|
||||
}
|
||||
-(void)ruleAction{
|
||||
self.ruleView.rule = self.model.rule_url;
|
||||
[self.ruleView showInView:self];
|
||||
}
|
||||
|
||||
-(void)poolAction{
|
||||
self.poolView.roomId = self.roomId;
|
||||
self.poolView.giftModel = self.giftModel;
|
||||
|
||||
[self.poolView showInView:self];
|
||||
}
|
||||
|
||||
-(void)recordAction{
|
||||
self.recordView.roomId = self.roomId;
|
||||
self.recordView.giftModel = self.giftModel;
|
||||
|
||||
[self.recordView showInView:self];
|
||||
}
|
||||
-(NSMutableArray *)allViewsArray{
|
||||
if (!_allViewsArray) {
|
||||
_allViewsArray = [NSMutableArray array];
|
||||
}
|
||||
return _allViewsArray;
|
||||
}
|
||||
|
||||
-(NSMutableArray *)targetArrayIndex{
|
||||
if (!_targetArrayIndex) {
|
||||
_targetArrayIndex = [NSMutableArray array];
|
||||
}
|
||||
return _targetArrayIndex;
|
||||
}
|
||||
|
||||
|
||||
-(AVPlayer *)player{
|
||||
if (!_player) {
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"draw_music" ofType:@"mp3"];
|
||||
_player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:path]];
|
||||
}
|
||||
return _player;
|
||||
}
|
||||
|
||||
|
||||
-(NSMutableArray *)finishTargetArrayIndex{
|
||||
if (!_finishTargetArrayIndex) {
|
||||
_finishTargetArrayIndex = [NSMutableArray array];
|
||||
}
|
||||
return _finishTargetArrayIndex;
|
||||
}
|
||||
-(QXAgePraizeRuleView *)ruleView{
|
||||
if (!_ruleView) {
|
||||
_ruleView = [[QXAgePraizeRuleView alloc] init];
|
||||
}
|
||||
return _ruleView;
|
||||
}
|
||||
-(QXAgePraizePoolView *)poolView{
|
||||
if (!_poolView) {
|
||||
_poolView = [[QXAgePraizePoolView alloc] init];
|
||||
}
|
||||
return _poolView;
|
||||
}
|
||||
-(QXAgePraizeRecordView *)recordView{
|
||||
if (!_recordView) {
|
||||
_recordView = [[QXAgePraizeRecordView alloc] init];
|
||||
}
|
||||
return _recordView;
|
||||
}
|
||||
-(void)showInView:(UIView *)view{
|
||||
[self getGiftList];
|
||||
[self resetViews];
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(663);
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
[self stopFastAnimate];
|
||||
// [self stopSlowAnimate];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
-(void)destroyViews{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXAgePraizeSubView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_item_nor"]];
|
||||
[self addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
|
||||
self.giftImageView = [[UIImageView alloc] init];
|
||||
[self addSubview:self.giftImageView];
|
||||
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(7);
|
||||
make.width.height.mas_equalTo(ScaleWidth(50));
|
||||
make.centerX.equalTo(self);
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:12];
|
||||
self.titleLabel.textColor = RGB16(0xffffff);
|
||||
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.giftImageView.mas_bottom).offset(4);
|
||||
make.height.mas_equalTo(ScaleWidth(14));
|
||||
make.centerX.equalTo(self);
|
||||
}];
|
||||
|
||||
self.giftCoin = [[UIButton alloc] init];
|
||||
self.giftCoin.userInteractionEnabled = NO;
|
||||
[self.giftCoin setTitleColor:RGB16(0xC7BF62) forState:(UIControlStateNormal)];
|
||||
[self.giftCoin setImage:[UIImage imageNamed:@"age_item_coin"] forState:(UIControlStateNormal)];
|
||||
self.giftCoin.titleLabel.font = [UIFont systemFontOfSize:10];
|
||||
[self addSubview:self.giftCoin];
|
||||
[self.giftCoin mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(self);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom);
|
||||
}];
|
||||
|
||||
self.resultView = [[UIView alloc] init];
|
||||
self.resultView.hidden = YES;;
|
||||
[self addSubview:self.resultView];
|
||||
[self.resultView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.equalTo(self);
|
||||
make.height.mas_equalTo(54);
|
||||
}];
|
||||
self.resultBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_item_top_bg"]];
|
||||
[self.resultView addSubview:self.resultBgImageView];
|
||||
[self.resultBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.resultView);
|
||||
}];
|
||||
|
||||
self.countLabel = [[UILabel alloc] init];
|
||||
self.countLabel.font = [UIFont fontWithName:@"YouSheBiaoTiHei" size:18];
|
||||
self.countLabel.textColor = RGB16(0xE3732D);
|
||||
self.countLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self.resultView addSubview:self.countLabel];
|
||||
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(12);
|
||||
make.height.mas_equalTo(ScaleWidth(20));
|
||||
make.centerX.equalTo(self.resultView);
|
||||
}];
|
||||
}
|
||||
-(void)setCount:(NSString *)count{
|
||||
_count = count;
|
||||
if (count.integerValue > 0) {
|
||||
// self.resultView.hidden = YES;
|
||||
// }else{
|
||||
// self.resultView.hidden = NO;
|
||||
self.countLabel.text = [NSString stringWithFormat:@"X%@",count];
|
||||
}
|
||||
}
|
||||
-(void)setGiftModel:(QXDrawGiftModel *)giftModel{
|
||||
_giftModel = giftModel;
|
||||
self.titleLabel.text = giftModel.gift_name;
|
||||
[self.giftCoin setTitle:giftModel.gift_price forState:(UIControlStateNormal)];
|
||||
NSString *encodedQuery = [giftModel.base_image stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
||||
NSURL *imageUrl = [NSURL URLWithString:encodedQuery];
|
||||
[self.giftImageView sd_setImageWithURL:imageUrl];
|
||||
}
|
||||
-(void)setIsSelected:(BOOL)isSelected{
|
||||
_isSelected = isSelected;
|
||||
self.bgImageView.image = [UIImage imageNamed:isSelected?@"age_item_sel":@"age_item_nor"];
|
||||
}
|
||||
- (void)startPulseAnimationWithLayer {
|
||||
CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
|
||||
pulseAnimation.duration = 0.5;
|
||||
pulseAnimation.fromValue = @0.9;
|
||||
pulseAnimation.toValue = @1.1;
|
||||
pulseAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
||||
pulseAnimation.autoreverses = YES;
|
||||
pulseAnimation.repeatCount = HUGE_VALF; // 无限循环
|
||||
|
||||
[self.layer addAnimation:pulseAnimation forKey:@"pulse"];
|
||||
|
||||
}
|
||||
|
||||
// 停止动画
|
||||
- (void)stopPulseAnimationWithLayer {
|
||||
[self.layer removeAnimationForKey:@"pulse"];
|
||||
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXAgeDrawBtn
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"age_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:@"age_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?@"age_touch_dis_bg":@"age_touch_bg"];
|
||||
}
|
||||
-(void)setBtnType:(QXAgeDrawBtnType)btnType{
|
||||
// /// 抽一次
|
||||
// QXAgeDrawBtnTypeOne = 0,
|
||||
// /// 抽10次
|
||||
// QXAgeDrawBtnTypeTen ,
|
||||
// /// 抽100次
|
||||
// QXAgeDrawBtnTypeHundred ,
|
||||
_btnType = btnType;
|
||||
switch (btnType) {
|
||||
case QXAgeDrawBtnTypeOne:
|
||||
{
|
||||
self.titleLabel.text = @"抽一次";
|
||||
[self.giftCoin setTitle:@"10币一次" forState:(UIControlStateNormal)];
|
||||
}
|
||||
break;
|
||||
case QXAgeDrawBtnTypeTen:
|
||||
{
|
||||
self.titleLabel.text = @"抽六次";
|
||||
[self.giftCoin setTitle:@"100币一次" forState:(UIControlStateNormal)];
|
||||
}
|
||||
break;
|
||||
case QXAgeDrawBtnTypeHundred:
|
||||
{
|
||||
self.titleLabel.text = @"抽九次";
|
||||
[self.giftCoin setTitle:@"1000币一次" forState:(UIControlStateNormal)];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@end
|
||||
BIN
QXLive/活动/岁月之城/Resource/active_age_castle_bg@2x.png
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
QXLive/活动/岁月之城/Resource/active_age_castle_bg@3x.png
Normal file
|
After Width: | Height: | Size: 3.5 MiB |
BIN
QXLive/活动/岁月之城/Resource/age_item_coin@2x.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_item_coin@3x.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_item_nor@2x.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_item_nor@3x.png
Normal file
|
After Width: | Height: | Size: 65 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_item_sel@2x.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_item_sel@3x.png
Normal file
|
After Width: | Height: | Size: 62 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_item_top_bg@2x.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_item_top_bg@3x.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_left_bg@2x.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_left_bg@3x.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_pool_icon@2x.png
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_pool_icon@3x.png
Normal file
|
After Width: | Height: | Size: 174 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_record_icon@2x.png
Normal file
|
After Width: | Height: | Size: 107 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_record_icon@3x.png
Normal file
|
After Width: | Height: | Size: 224 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_right_bg@2x.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_right_bg@3x.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_rule_bg@2x.png
Normal file
|
After Width: | Height: | Size: 1.6 MiB |
BIN
QXLive/活动/岁月之城/Resource/age_rule_bg@3x.png
Normal file
|
After Width: | Height: | Size: 3.1 MiB |
BIN
QXLive/活动/岁月之城/Resource/age_rule_icon@2x.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_rule_icon@3x.png
Normal file
|
After Width: | Height: | Size: 223 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_status_bg@2x.png
Normal file
|
After Width: | Height: | Size: 105 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_status_bg@3x.png
Normal file
|
After Width: | Height: | Size: 215 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_switch_off@2x.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_switch_off@3x.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_switch_on@2x.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_switch_on@3x.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_touch_bg@2x.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_touch_bg@3x.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_touch_dis_bg@2x.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
QXLive/活动/岁月之城/Resource/age_touch_dis_bg@3x.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
18
QXLive/活动/巡乐会/QXActivityTagView.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// QXActivityTagView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/9/24.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXActivityTagView : UIView
|
||||
@property (nonatomic,copy)void(^startBlock)(void);
|
||||
@property (nonatomic,assign)long end_time;
|
||||
-(void)stopTimer;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
108
QXLive/活动/巡乐会/QXActivityTagView.m
Normal file
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// QXActivityTagView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/9/24.
|
||||
//
|
||||
|
||||
#import "QXActivityTagView.h"
|
||||
#import "QXTimer.h"
|
||||
@interface QXActivityTagView()
|
||||
@property (nonatomic,strong)UIImageView *imageView;
|
||||
@property (nonatomic,strong)UILabel *timeLabel;
|
||||
@property (nonatomic,strong)QXTimer *timer;
|
||||
@property (nonatomic,assign)NSInteger startTime;
|
||||
@property (nonatomic,strong)UIButton *btn;
|
||||
@end
|
||||
@implementation QXActivityTagView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(SCREEN_WIDTH-80, SCREEN_HEIGHT-250, 80, 100);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)initSubviews{
|
||||
|
||||
|
||||
self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ac_tag_icon"]];
|
||||
self.imageView.frame = CGRectMake(0, 0, 80, 80);
|
||||
[self addSubview:self.imageView];
|
||||
|
||||
self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.imageView.bottom, self.width, 20)];
|
||||
self.timeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.timeLabel.font = [UIFont systemFontOfSize:12];
|
||||
self.timeLabel.textColor = RGB16(0xFFEBBD);
|
||||
[self addSubview:self.timeLabel];
|
||||
self.btn = [[UIButton alloc] initWithFrame:self.bounds];
|
||||
[self.btn addTarget:self action:@selector(btnClick) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.btn];
|
||||
|
||||
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
|
||||
[self addGestureRecognizer:panRecognizer];
|
||||
}
|
||||
-(void)btnClick{
|
||||
if (self.startBlock) {
|
||||
self.startBlock();
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setEnd_time:(long)end_time{
|
||||
_end_time = end_time;
|
||||
if (end_time == 0) {
|
||||
return;
|
||||
}
|
||||
NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970];
|
||||
// 将秒转换为毫秒
|
||||
long long milliseconds = (long long)(timeInterval);
|
||||
self.startTime = end_time - milliseconds;
|
||||
|
||||
if (self.startTime <= 0) {
|
||||
//时间错误不进行倒计时
|
||||
self.timeLabel.text = @"倒计时 00:00";
|
||||
[self removeFromSuperview];
|
||||
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 min = (self.startTime % 3600) / 60;
|
||||
NSInteger second = self.startTime % 60;
|
||||
weakSelf.timeLabel.text = [NSString stringWithFormat:@"倒计时 %02ld:%02ld",min,second];
|
||||
if (weakSelf.startTime<=0) {
|
||||
[weakSelf stopTimer];
|
||||
weakSelf.timeLabel.text = @"倒计时 00:00";
|
||||
[weakSelf removeFromSuperview];
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
-(void)stopTimer{
|
||||
if (_timer) {
|
||||
[self->_timer invalidate];
|
||||
self->_timer= nil;
|
||||
}
|
||||
}
|
||||
-(void)handlePan:(UIPanGestureRecognizer*)recognizer{
|
||||
if (recognizer.state == UIGestureRecognizerStateEnded) {
|
||||
NSLog(@"拖动结束");
|
||||
}
|
||||
CGPoint translation = [recognizer translationInView:self.viewController.view];
|
||||
CGPoint panCenter = CGPointMake(recognizer.view.center.x + translation.x,
|
||||
recognizer.view.center.y + translation.y);
|
||||
if (panCenter.y < kSafeAreaTop || panCenter.y> SCREEN_HEIGHT-kSafeAreaBottom) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
recognizer.view.center = CGPointMake(SCREEN_WIDTH-ScaleWidth(80)/2,
|
||||
recognizer.view.center.y + translation.y);
|
||||
[recognizer setTranslation:CGPointZero inView:self.viewController.view];
|
||||
}
|
||||
@end
|
||||