修改了礼物面板请求失败的话可以重试
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
#import "XPGiftPresenter.h"
|
||||
#import "TTPopup.h"
|
||||
#import "ThemeColor+SendGift.h"
|
||||
#import "XCHUDTool.h"
|
||||
#import "StatisticsServiceHelper.h"
|
||||
///Model
|
||||
#import "GiftInfoModel.h"
|
||||
@@ -36,6 +35,10 @@
|
||||
#import "XPNobleCenterViewController.h"
|
||||
|
||||
@interface XPSendGiftView ()< XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate>
|
||||
///顶部的区域
|
||||
@property (nonatomic,strong) UIView * topView;
|
||||
///内容区域
|
||||
@property (nonatomic,strong) UIView *contentView;
|
||||
///
|
||||
@property (nonatomic,strong) UIStackView *stackView;
|
||||
///送礼物的人
|
||||
@@ -50,7 +53,10 @@
|
||||
@property (nonatomic,copy) NSString *roomUid;
|
||||
///使用的地方
|
||||
@property (nonatomic,assign) SendGiftType usingplaceType;
|
||||
|
||||
///普通礼物的重试次数
|
||||
@property (nonatomic,assign) int normalGiftRetryCount;
|
||||
///背包礼物的重试次数
|
||||
@property (nonatomic,assign) int packGiftRetryCount;
|
||||
@end
|
||||
|
||||
@implementation XPSendGiftView
|
||||
@@ -60,32 +66,42 @@
|
||||
|
||||
- (instancetype)initWithType:(SendGiftType)type uid:(NSString *)uid{
|
||||
if (self = [super init]) {
|
||||
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||||
self.roomUid = uid;
|
||||
self.usingplaceType = type;
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
[self initHttpRequest];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
[self initHttpRequest];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.backgroundColor = [ThemeColor giftBackGroundColor];
|
||||
[self addSubview:self.stackView];
|
||||
[self.view addSubview:self.topView];
|
||||
[self.view addSubview:self.contentView];
|
||||
[self.contentView addSubview:self.stackView];
|
||||
[self.stackView addArrangedSubview:self.userView];
|
||||
[self.stackView addArrangedSubview:self.giftInfoView];
|
||||
[self.stackView addArrangedSubview:self.giftBarView];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(KScreenWidth);
|
||||
make.bottom.mas_equalTo(self.stackView.mas_bottom);
|
||||
[self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.mas_equalTo(self.view);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_top);;
|
||||
}];
|
||||
|
||||
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.stackView.mas_top);
|
||||
make.left.right.bottom.mas_equalTo(self.view);
|
||||
}];
|
||||
|
||||
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.mas_equalTo(self);
|
||||
make.left.right.bottom.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -236,13 +252,13 @@
|
||||
RoomSendGiftType roomSendGiftType;
|
||||
if (self.userView.isSelectAll) {
|
||||
if (giftInfo.sourceType == GiftSourceType_Pack && giftCount.isTotal && giftInfo && uids.count > 1) {
|
||||
[XCHUDTool showErrorWithMessage:@"只能全部赠送给一人"];
|
||||
[self showErrorToast:@"只能全部赠送给一人"];
|
||||
return -1;
|
||||
}
|
||||
roomSendGiftType = RoomSendGiftType_AllMic;
|
||||
} else if(self.userView.selectUserArray.count > 1) {
|
||||
if (giftInfo.sourceType == GiftSourceType_Pack && giftCount.isTotal) {
|
||||
[XCHUDTool showErrorWithMessage:@"只能全部赠送给一人"];
|
||||
[self showErrorToast:@"只能全部赠送给一人"];
|
||||
return -1;
|
||||
}
|
||||
roomSendGiftType = RoomSendGiftType_MutableOnMic;
|
||||
@@ -283,7 +299,7 @@
|
||||
///发送消息
|
||||
[self.giftPresenter sendGift:uidString giftNum:giftNumber sendType:sendType giftId:giftId giftSource:sourceType giftType:giftInfo.giftType roomSendType:roomSendType roomUid:self.roomUid msg:@""];
|
||||
} else {
|
||||
[XCHUDTool showErrorWithMessage:@"请选择至少一个人"];
|
||||
[self showErrorToast:@"请选择至少一个人"];
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -292,20 +308,20 @@
|
||||
|
||||
///充值
|
||||
- (void)xPGiftBarViewDidClickRecharge:(XPGiftBarView *)view {
|
||||
[TTPopup dismiss];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
XPMineRechargeViewController * rechargeVC = [[XPMineRechargeViewController alloc] init];
|
||||
[self.delegate.getCurrentNav pushViewController:rechargeVC animated:YES];
|
||||
}
|
||||
|
||||
- (void)xPGiftBarViewDidClickFirstRecharge:(XPGiftBarView *)view {
|
||||
[TTPopup dismiss];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
XPFirstRechargeViewController * firstRechargeVC = [[XPFirstRechargeViewController alloc] initWithNavigation:self.delegate.getCurrentNav];
|
||||
[self.delegate.getCurrentNav presentViewController:firstRechargeVC animated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - XPGiftInfoViewDelegate
|
||||
- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickPlayRule:(NSString *)ruleUrl {
|
||||
[TTPopup dismiss];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
XPWebViewController * webVC = [[XPWebViewController alloc] init];
|
||||
webVC.url = ruleUrl;
|
||||
[self.delegate.getCurrentNav pushViewController:webVC animated:YES];
|
||||
@@ -316,7 +332,7 @@
|
||||
}
|
||||
|
||||
- (void)xPGiftInfoViewDidClickNobleEntrance:(XPGiftInfoView *)view {
|
||||
[TTPopup dismiss];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventvipEntranceGiftClick];
|
||||
XPNobleCenterViewController * nobleVC = [[XPNobleCenterViewController alloc] initWithRoomUid:self.delegate.getRoomInfo.uid];
|
||||
[self.delegate.getCurrentNav pushViewController:nobleVC animated:YES];
|
||||
@@ -331,11 +347,29 @@
|
||||
self.giftInfoView.packOriginArray = giftList;
|
||||
}
|
||||
|
||||
- (void)getPacketGiftListFail:(NSString *)message {
|
||||
self.packGiftRetryCount ++;
|
||||
if (self.packGiftRetryCount <= 10) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.giftPresenter getPackGiftList];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
///普通礼物 /幸运礼物
|
||||
- (void)getNormalGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
|
||||
self.giftInfoView.normalOriginArray = giftList;
|
||||
}
|
||||
|
||||
- (void)getNormalGiftListFail:(NSString *)message {
|
||||
self.normalGiftRetryCount ++;
|
||||
if (self.normalGiftRetryCount <= 10) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.giftPresenter getNormalGiftList:self.roomUid];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo originDic:(NSDictionary *)originDic uidCount:(NSInteger)uidCount{
|
||||
if (receiveInfo.sourceType == GiftSourceType_Pack) {
|
||||
///更新个数
|
||||
@@ -351,7 +385,6 @@
|
||||
if (code == 31005) {// 余额不足
|
||||
[self showNotSufficientFundsWithToast:msg];
|
||||
} else if (code == 8535) {//贵族等级未达到礼物等级
|
||||
[TTPopup dismiss];
|
||||
GiftInfoModel * giftInfo = self.giftInfoView.lastSelectGift;
|
||||
TTAlertConfig *config = [[TTAlertConfig alloc] init];
|
||||
config.actionStyle = TTAlertActionConfirmStyle;
|
||||
@@ -362,20 +395,24 @@
|
||||
|
||||
}];
|
||||
} else {
|
||||
[XCHUDTool showErrorWithMessage:msg];
|
||||
[self showErrorToast:msg];
|
||||
}
|
||||
}
|
||||
|
||||
/// 余额不足,是否弹首充弹窗
|
||||
- (void)showNotSufficientFundsWithToast:(NSString *)msg {
|
||||
if (self.delegate.getUserInfo.isFirstCharge) {
|
||||
[TTPopup dismiss];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
XPFirstRechargeViewController * firstRechargeVC = [[XPFirstRechargeViewController alloc] initWithNavigation:self.delegate.getCurrentNav];
|
||||
[self.delegate.getCurrentNav presentViewController:firstRechargeVC animated:YES completion:nil];
|
||||
} else {
|
||||
[XCHUDTool showErrorWithMessage:msg];
|
||||
[self showErrorToast:msg];
|
||||
}
|
||||
}
|
||||
#pragma mark - Event Response
|
||||
- (void)disMissViewRecognizer:(UITapGestureRecognizer *)tap {
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setDelegate:(id<RoomHostDelegate>)delegate {
|
||||
@@ -384,6 +421,25 @@
|
||||
self.giftInfoView.curUserNobleLevel = self.delegate.getUserInfo.userVipInfoVO.vipLevel;
|
||||
}
|
||||
|
||||
- (UIView *)topView {
|
||||
if (!_topView) {
|
||||
_topView = [[UIView alloc] init];
|
||||
_topView.backgroundColor = [UIColor clearColor];
|
||||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disMissViewRecognizer:)];
|
||||
[_topView addGestureRecognizer:tap];
|
||||
}
|
||||
return _topView;
|
||||
}
|
||||
|
||||
|
||||
- (UIView *)contentView {
|
||||
if (!_contentView) {
|
||||
_contentView = [[UIView alloc] init];
|
||||
_contentView.backgroundColor = [ThemeColor giftBackGroundColor];
|
||||
}
|
||||
return _contentView;
|
||||
}
|
||||
|
||||
- (XPGiftUsersView *)userView {
|
||||
if (!_userView) {
|
||||
_userView = [[XPGiftUsersView alloc] init];
|
||||
|
Reference in New Issue
Block a user