h5跳转房间打开礼物面板

This commit is contained in:
chenguilong
2022-08-04 18:22:31 +08:00
parent 03fe19f47f
commit 0650dcdc01
11 changed files with 119 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 158 KiB

View File

@@ -128,13 +128,13 @@
#pragma mark - Event Response
- (void)sendButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPDressUpShopCardTableViewCellSendDress:dressId:)]) {
[self.delegate xPDressUpShopCardTableViewCellSendDress:self dressId:self.nobleCardModel.dressId];
[self.delegate xPDressUpShopCardTableViewCellSendDress:self dressId:self.nobleCardModel.dressUpId];
}
}
- (void)useButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPDressUpShopCardTableViewCellBuyDress:dressId:)]) {
[self.delegate xPDressUpShopCardTableViewCellBuyDress:self dressId:self.nobleCardModel.dressId];
[self.delegate xPDressUpShopCardTableViewCellBuyDress:self dressId:self.nobleCardModel.dressUpId];
}
}

View File

@@ -68,9 +68,10 @@
make.height.mas_equalTo(92);
make.left.top.right.mas_equalTo(0);
}];
CGFloat dressImageW = (KScreenWidth - 42) *0.5;
[self.dressUpImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(80, 45));
make.top.mas_equalTo(22);
make.size.mas_equalTo(CGSizeMake(dressImageW * 0.8, 70));
make.top.mas_equalTo(11);
make.centerX.mas_equalTo(self.userCardBackView);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -115,13 +116,13 @@
#pragma mark - Event Response
- (void)sendButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPDressUpShopCollectionViewCellSendDress:dressId:)]) {
[self.delegate xPDressUpShopCollectionViewCellSendDress:self dressId:self.dressUpModel.dressId];
[self.delegate xPDressUpShopCollectionViewCellSendDress:self dressId:self.dressUpModel.dressUpId];
}
}
- (void)useButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPDressUpShopCollectionViewCellBuyDress:dressId:)]) {
[self.delegate xPDressUpShopCollectionViewCellBuyDress:self dressId:self.dressUpModel.dressId];
[self.delegate xPDressUpShopCollectionViewCellBuyDress:self dressId:self.dressUpModel.dressUpId];
}
}

View File

@@ -52,6 +52,8 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) {
///当前用户贵族等级
@property (nonatomic, assign) NSInteger curUserNobleLevel;
@property (nonatomic, copy) NSString *defaultSelectGiftId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -69,6 +69,8 @@
@property (nonatomic,assign) GiftSegmentType segmentType;
///
@property (nonatomic,strong) GiftInfoModel *lastSelectGift;
@property (nonatomic, assign) NSInteger selectIndex;
@end
@implementation XPGiftInfoView
@@ -351,8 +353,17 @@
break;
}
if (self.datasource.count > 0) {
GiftInfoModel * gift = [self.datasource firstObject];
[self dealSelectGift:gift];
if (self.defaultSelectGiftId.length) {
for (GiftInfoModel * gift in self.datasource) {
if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
[self dealSelectGift:gift];
self.selectIndex = [self.datasource indexOfObject:gift];
}
}
} else {
GiftInfoModel * gift = [self.datasource firstObject];
[self dealSelectGift:gift];
}
} else {
self.playRuleButton.hidden = YES;
}
@@ -393,7 +404,34 @@
self.giftLuckyArray = luckyArray;
self.giftNobleArray = nobleArray;
self.giftWeekStarArray = weekStarArray;
self.segmentType = GiftSegmentType_Normal;
if (self.defaultSelectGiftId.length) {
for (GiftInfoModel *gift in self.normalOriginArray) {
if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
self.segmentType = GiftSegmentType_Normal;
break;
}
}
for (GiftInfoModel *gift in self.giftLuckyArray) {
if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
self.segmentType = GiftSegmentType_Lucky;
break;
}
}
for (GiftInfoModel *gift in self.giftNobleArray) {
if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
self.segmentType = GiftSegmentType_Noble;
break;
}
}
for (GiftInfoModel *gift in self.giftWeekStarArray) {
if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
self.segmentType = GiftSegmentType_WeekStar;
break;
}
}
} else {
self.segmentType = GiftSegmentType_Normal;
}
}
- (void)setPackOriginArray:(NSArray *)packOriginArray {
@@ -413,6 +451,10 @@
}
}
- (void)setDefaultSelectGiftId:(NSString *)defaultSelectGiftId {
_defaultSelectGiftId = defaultSelectGiftId;
}
- (UIStackView *)segmentStackView {
if (!_segmentStackView) {
_segmentStackView = [[UIStackView alloc] init];

View File

@@ -31,6 +31,9 @@ typedef NS_ENUM(NSInteger, SendGiftType) {
///完全封闭的一个组件
- (void)configGiftUsers:(NSArray<XPGiftUserInfoModel *> *)users;
///选中的礼物id
@property (nonatomic, copy) NSString *selectGiftId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -487,6 +487,11 @@
self.giftInfoView.usingplaceType = _usingplaceType;
}
- (void)setSelectGiftId:(NSString *)selectGiftId {
_selectGiftId = selectGiftId;
self.giftInfoView.defaultSelectGiftId = selectGiftId;
}
- (UIView *)topView {
if (!_topView) {
_topView = [[UIView alloc] init];

View File

@@ -70,6 +70,7 @@
self.delegate = delegate;
[self initSubViews];
[self initSubViewConstraints];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showGiftView:) name:@"kShowGiftView" object:nil];
}
return self;
}
@@ -173,6 +174,19 @@
}
}
#pragma mark - notification
- (void)showGiftView:(NSNotification *)noti {
NSDictionary *dict = noti.object;
NSString *giftId = dict[@"giftId"];
NSString * roomUid = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].uid];
XPSendGiftView * giftView = [[XPSendGiftView alloc] initWithType:SendGiftType_Room uid:roomUid];
giftView.delegate = self.delegate;
NSArray * giftUses = [self configGiftUsers:[self.delegate getMicroQueue]];
[giftView configGiftUsers:giftUses];
giftView.selectGiftId = giftId;
[self.delegate.getCurrentNav presentViewController:giftView animated:YES completion:nil];
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.scrollView];

View File

@@ -39,6 +39,12 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (BOOL)openRoom:(NSString*)roomUid mgId:(NSString *)mgId viewController:(UIViewController*)viewController;
/// h5进房并弹出礼物面板
/// @param roomUid 房主Uid
/// @param giftId 礼物id
/// @param viewController 启动方
+ (BOOL)openRoom:(NSString *)roomUid giftId:(NSString *)giftId viewController:(UIViewController *)viewController;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (id)copy NS_UNAVAILABLE;

View File

@@ -90,6 +90,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
@property (nonatomic,copy) NSString * roomUid;
///id
@property (nonatomic,copy) NSString *mgId;
///id
@property (nonatomic, copy) NSString *giftId;
///
@property (nonatomic,strong) UserInfoModel *userInfo;
///
@@ -158,6 +160,20 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
return YES;
}
/// h5
/// @param roomUid Uid
/// @param giftId id
/// @param viewController
+ (BOOL)openRoom:(NSString *)roomUid giftId:(NSString *)giftId viewController:(UIViewController *)viewController {
XPRoomViewController * roomVC = [[self alloc] init];
roomVC.roomUid = roomUid;
roomVC.giftId = giftId;
BaseNavigationController * baseNav = [[BaseNavigationController alloc] initWithRootViewController:roomVC];
baseNav.modalPresentationStyle = UIModalPresentationFullScreen;
[viewController presentViewController:baseNav animated:YES completion:nil];
return YES;
}
- (void)dealloc {
#warning to dox -
NSLog(@"房间销毁了");
@@ -737,6 +753,9 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
if (self.roomInfo != nil) {
[self.presenter reportUserInterRoom:[NSString stringWithFormat:@"%zd", self.roomInfo.uid]];
}
if (self.giftId.length) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"kShowGiftView" object:@{@"giftId": self.giftId}];
}
}
- (void)enterRoomFail:(NSInteger)code {

View File

@@ -24,6 +24,7 @@
#import "XPMineDressUpViewController.h"
#import "XPDressUpShopViewController.h"
#import "XPRoomViewController.h"
#import "RoomHostDelegate.h"
typedef NS_ENUM(NSUInteger, RightNavigationPushType){
///h5
@@ -294,6 +295,23 @@ NSString * const kJSOpenRoomForGiftId = @"openRoomForGiftId";
NSString *str = (NSString *)message.body;
bodyDict = [str toJSONObject];
}
// uid
NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"uid"]];
NSString *giftId = [NSString stringWithFormat:@"%@", bodyDict[@"giftId"]];
if (uid.length) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO];
XPRoomViewController<RoomHostDelegate> * rooomVC = obj;
[rooomVC exitRoom];
*stop = YES;
}
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XPRoomViewController openRoom:uid giftId:giftId viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
});
}
}
}
}];