红包逻辑
This commit is contained in:
@@ -70,7 +70,9 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
@end
|
||||
|
||||
@implementation XPRoomActivityContainerView
|
||||
|
||||
-(void)dealloc{
|
||||
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
||||
}
|
||||
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
@@ -92,8 +94,11 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
[self.stackView addArrangedSubview:self.redPacketView];
|
||||
[self.stackView addArrangedSubview:self.lookLoveImageView];
|
||||
[self.stackView addArrangedSubview:self.joinDatingView];
|
||||
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(openRedPacketResult) name:@"kOpenRedPacketResult" object:nil];
|
||||
}
|
||||
-(void)openRedPacketResult{
|
||||
self.redPacketView.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self);
|
||||
@@ -239,7 +244,15 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)setRedPacketModel:(XPRedPacketModel *)redPacketModel{
|
||||
_redPacketModel = redPacketModel;
|
||||
self.redPacketView.hidden = NO;
|
||||
self.redPacketView.redPacketModel = _redPacketModel;
|
||||
}
|
||||
-(void)setPi_redNum:(NSString *)pi_redNum{
|
||||
_pi_redNum = pi_redNum;
|
||||
self.redPacketView.pi_redNum = pi_redNum;
|
||||
}
|
||||
#pragma mark - RoomGuestDelegat
|
||||
- (void)onRoomUpdate {
|
||||
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||||
@@ -453,7 +466,30 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid];
|
||||
[self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil];
|
||||
}
|
||||
|
||||
-(void)openRedPacketAction{
|
||||
self.redPacketView.userInteractionEnabled = NO;
|
||||
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||||
[Api requestRedPacket:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
self.redPacketView.userInteractionEnabled = YES;
|
||||
if(code == 200){
|
||||
NSArray *array = [XPRedPacketModel modelsWithArray:data.data];
|
||||
for (XPRedPacketModel *model in array) {
|
||||
model.timestamp = data.timestamp;
|
||||
}
|
||||
if(array.count > 0){
|
||||
XPRedPacketModel *redModel = array.firstObject;
|
||||
if(redModel.state == 2 || redModel.state == 6){
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomActivityContainerView3")];
|
||||
self.redPacketView.hidden = YES;
|
||||
return;
|
||||
}
|
||||
if(self.openRedPacketHandle){
|
||||
self.openRedPacketHandle(self.redPacketModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
} uid:[NSString stringWithFormat:@"%ld",roomInfo.uid] isShowKind:@"1"];
|
||||
}
|
||||
#pragma mark - Getters And Setters
|
||||
- (SDCycleScrollView *)pi_cycleScrollView {
|
||||
if (!_pi_cycleScrollView) {
|
||||
@@ -484,7 +520,7 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
_stackView.axis = UILayoutConstraintAxisVertical;
|
||||
_stackView.distribution = UIStackViewDistributionFill;
|
||||
_stackView.alignment = UIStackViewAlignmentCenter;
|
||||
_stackView.spacing = 5;
|
||||
_stackView.spacing = 0;
|
||||
}
|
||||
return _stackView;
|
||||
}
|
||||
@@ -569,6 +605,9 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
- (PIRoomEnterRedPacketView *)redPacketView{
|
||||
if(!_redPacketView){
|
||||
_redPacketView = [[PIRoomEnterRedPacketView alloc]initWithFrame:CGRectZero];
|
||||
_redPacketView.hidden = YES;
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(openRedPacketAction)];
|
||||
[_redPacketView addGestureRecognizer:tap];
|
||||
}
|
||||
return _redPacketView;
|
||||
}
|
||||
|
Reference in New Issue
Block a user