diff --git a/xplan-ios/Global/XPHtmlUrl.h b/xplan-ios/Global/XPHtmlUrl.h index 0c102029..b606cbe1 100644 --- a/xplan-ios/Global/XPHtmlUrl.h +++ b/xplan-ios/Global/XPHtmlUrl.h @@ -29,6 +29,8 @@ typedef NS_ENUM(NSUInteger, URLType) { kCandyTreeRecordURL, /// 糖果树玩法规则 kCandyTreeRuleURL, + ///房间魅力榜 + kRoomCharmRankUrl, }; NSString * const URLWithType(URLType type); diff --git a/xplan-ios/Global/XPHtmlUrl.m b/xplan-ios/Global/XPHtmlUrl.m index 4726740d..5a5e633f 100644 --- a/xplan-ios/Global/XPHtmlUrl.m +++ b/xplan-ios/Global/XPHtmlUrl.m @@ -25,6 +25,7 @@ NSString * const URLWithType(URLType type) { @(kCandyTreeURL) : @"activity/explore/index.html",///参加糖果树 @(kCandyTreeRuleURL) : @"modules/rank/index.html#/wishingWellRule",///糖果树规则 @(kCandyTreeRecordURL) : @"modules/rank/index.html#/wishingWellRecord",///糖果树记录 + @(kRoomCharmRankUrl) : @"modules/charm/index.html",//房间魅力榜 }; NSString * url = [dic objectForKey:@(type)]; diff --git a/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m b/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m index 73467ed6..69f433b7 100644 --- a/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m +++ b/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m @@ -13,7 +13,10 @@ #import "MicroGiftValueView.h" #import "NetImageView.h" +#import "XPHtmlUrl.h" #import "ThemeColor+Room.h" +#import "XCCurrentVCStackManager.h" +#import "XPWebViewController.h" #import "MicroQueueModel.h" #import "MicroStateModel.h" @@ -36,6 +39,12 @@ @property (nonatomic,strong) UILabel *leaveLabel; ///礼物值 @property (nonatomic,strong) MicroGiftValueView *giftValueView; +///麦序的信息 +@property (nonatomic,strong) MicroQueueModel *microModel; +///是否是离开模式 +@property (nonatomic,assign) BOOL isLeaveMode; +///房主的Uid +@property (nonatomic,copy) NSString *roomUid; @end @implementation MicroView @@ -49,6 +58,20 @@ return self; } +// 在view中重写以下方法,其中 self.longPreGetrueMaskView 就是那个希望被触发点击事件的按钮 +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { + UIView *view = [super hitTest:point withEvent:event]; + if (!view) { + // 转换坐标系 + CGPoint newPoint = [self.giftValueView convertPoint:point fromView:self]; + // 判断触摸点 + if (CGRectContainsPoint(self.giftValueView.bounds, newPoint)) { + view = self.giftValueView; + } + } + return view; +} + - (void)layoutSubviews { self.avatarImageView.layer.masksToBounds = YES; self.avatarImageView.layer.cornerRadius = self.frame.size.width / 2; @@ -115,6 +138,7 @@ } - (void)configMicroView:(MicroQueueModel *)model { + self.microModel = model; MicroStateModel * micStats = model.microState; UserInfoModel * userInfo = model.userInfo; [self configMicroState:micStats]; @@ -170,6 +194,21 @@ self.giftValueView.giftValue = 0; } +- (void)configRoomUid:(NSString *)roomUid { + self.roomUid = roomUid; +} + +#pragma mark - Event Response +- (void)tapGiftValueRecognizer { + if (self.giftValueView.hidden) return; + if (self.microModel.userInfo && self.microModel.userInfo.uid > 0) { + XPWebViewController * webVC = [[XPWebViewController alloc] init]; + webVC.roomUid = self.roomUid; + webVC.url = [NSString stringWithFormat:@"%@?uid=%ld", URLWithType(kRoomCharmRankUrl), self.microModel.userInfo.uid]; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; + } +} + #pragma mark - Getters And Setters - (NetImageView *)avatarImageView { if (!_avatarImageView) { @@ -250,6 +289,8 @@ if (!_giftValueView) { _giftValueView = [[MicroGiftValueView alloc] init]; _giftValueView.hidden = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGiftValueRecognizer)]; + [_giftValueView addGestureRecognizer:tap]; } return _giftValueView; } diff --git a/xplan-ios/Main/Room/View/StageView/MicroView/MicroViewProtocol.h b/xplan-ios/Main/Room/View/StageView/MicroView/MicroViewProtocol.h index 7c37d27c..47857356 100644 --- a/xplan-ios/Main/Room/View/StageView/MicroView/MicroViewProtocol.h +++ b/xplan-ios/Main/Room/View/StageView/MicroView/MicroViewProtocol.h @@ -55,6 +55,12 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)resetGiftValue; + +/** + * 房主的uid + */ +- (void)configRoomUid:(NSString *)roomUid; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/StageView/StageView.m b/xplan-ios/Main/Room/View/StageView/StageView.m index 5b625b16..f6d1833a 100644 --- a/xplan-ios/Main/Room/View/StageView/StageView.m +++ b/xplan-ios/Main/Room/View/StageView/StageView.m @@ -169,8 +169,9 @@ UIView * view = [self findMicroViewByIndex:i]; [view configMicroView:model]; + [view configRoomUid:[NSString stringWithFormat:@"%ld", roomInfo.uid]]; [view showLeaveMode:i == 0 && leaveMode]; - if (model.userInfo == nil) [view resetGiftValue]; + if (model.userInfo == nil || !roomInfo.showGiftValue) [view resetGiftValue]; [view showGiftValueMode:roomInfo.showGiftValue]; if (self.hostDelegate.getUserInfo.uid && model.userInfo.uid == self.hostDelegate.getUserInfo.uid) { selfNeedBroadcast = model.microState.micState == MicroMicStateType_Open; diff --git a/xplan-ios/Main/XPWebViewController.h b/xplan-ios/Main/XPWebViewController.h index 9d7ac335..3335da4b 100644 --- a/xplan-ios/Main/XPWebViewController.h +++ b/xplan-ios/Main/XPWebViewController.h @@ -12,6 +12,9 @@ NS_ASSUME_NONNULL_BEGIN @interface XPWebViewController : BaseViewController +//TODO: 先这样传进来 等修改了保存房间信息的manager 之后在修改 +@property (nonatomic,copy) NSString *roomUid; + @property (copy, nonatomic) NSString *url; /// URL加载完成回调,result:加载结果成功/失败,error:失败原因 diff --git a/xplan-ios/Main/XPWebViewController.m b/xplan-ios/Main/XPWebViewController.m index 9c6d1e6a..671cadcf 100644 --- a/xplan-ios/Main/XPWebViewController.m +++ b/xplan-ios/Main/XPWebViewController.m @@ -76,6 +76,7 @@ NSString * const kJSGetTicket = @"getTicket"; NSString * const kJSGetDeviceInfo = @"getDeviceInfo"; NSString * const kJSOpenFaceLiveness = @"openFaceLiveness"; NSString * const kJSInitNav = @"initNav"; +NSString * const kJSGetRoomUid = @"getRoomUid"; @implementation XPWebViewController @@ -191,6 +192,11 @@ NSString * const kJSInitNav = @"initNav"; #endif } else if([message.name isEqualToString:kJSInitNav]) { [self initNav:message.body]; + } else if([message.name isEqualToString:kJSGetRoomUid]) { + NSString *js = [NSString stringWithFormat:@"getMessage(\"roomUid\",\"%@\")",self.roomUid]; + [self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) { + NSLog(@"%@",error); + }]; } } }]; @@ -435,6 +441,8 @@ NSString * const kJSInitNav = @"initNav"; [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenFaceLiveness]; // 分享按钮 [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSInitNav]; + // 获取房间uid + [_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSGetRoomUid]; } return _userContentController;