修改了礼物面板请求失败的话可以重试

This commit is contained in:
fengshuo
2022-03-22 20:53:20 +08:00
parent 3b792698f0
commit 1f3ba5bac3
12 changed files with 161 additions and 42 deletions

View File

@@ -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];