新增h5跳转到聊天页

This commit is contained in:
liyuhua
2023-09-01 15:06:49 +08:00
parent 695662600e
commit 79076f549f
4 changed files with 134 additions and 118 deletions

View File

@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
///integer($int64)当 hallBtnStatus=6 时对应的申请记录Id,用户申请
@property (nonatomic,assign) BOOL isUser;
///是否需要关注用户
//@property(nonatomic,assign) BOOL
@property(nonatomic,assign) BOOL isAttention;
- (instancetype)initWithSession:(NIMSession *)session;
@property (nonatomic, assign) SessionListOpenType openType;
///置顶回话

View File

@@ -481,6 +481,9 @@
- (void)getFansLikeSuccess:(BOOL)isLike {
self.sessionNavView.isLike = isLike;
if(self.isAttention == YES && isLike == NO){
[self startAttention];
}
}
- (void)attentionUserSuccess:(NSString *)uid {

View File

@@ -102,6 +102,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
if([ClientConfig shareConfig].chatId != nil){
NIMSession * session = [NIMSession session:[ClientConfig shareConfig].chatId type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
sessionVC.isAttention = YES;
[self.navigationController pushViewController:sessionVC animated:YES];
[ClientConfig shareConfig].chatId = nil;
}
@@ -116,6 +117,7 @@ UIKIT_EXTERN NSString * const kOpenRoomNotification;
if (uid.length > 0) {
NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
sessionVC.isAttention = YES;
[self.navigationController pushViewController:sessionVC animated:YES];
[ClientConfig shareConfig].chatId = nil;
}

View File

@@ -101,7 +101,7 @@ NSString * const kJumpAppointPage = @"jumpAppointPage";
NSString * const kJSOpenRoom = @"openRoom";
NSString * const kJSOpenRoomForGiftId = @"openRoomForGiftId";
NSString * const kJSOpenChatPage = @"geToChatPage";
NSString * const kJSOpenAppConcernedChat = @"openAppConcernedChat";
@implementation XPWebViewController
@@ -248,123 +248,123 @@ NSString * const kJSOpenChatPage = @"geToChatPage";
#ifdef DEBUG
if (currentUrl != nil) {
#else
if (currentUrl != nil && [currentUrl containsString:API_HOST_URL]) {
if (currentUrl != nil && [currentUrl containsString:API_HOST_URL]) {
#endif
if ([message.name isEqualToString:kJSOpenSharePage]) {
if (message.body && message.body != [NSNull null]) {
NSDictionary *body;
//dic
if ([message.body isKindOfClass:[NSDictionary class]]) {
body = message.body;
} else if ([message.body isKindOfClass:[NSString class]]) {
body = [message.body toJSONObject];
}
self.shareDic = body[@"data"];
[self showSharePanel];
}
} else if ([message.name isEqualToString:kJSGetUid]) {
NSString *uid = [[AccountInfoStorage instance] getUid];
NSString *js = [NSString stringWithFormat:@"getMessage(\"uid\",%@)", uid];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetTicket]) {
NSString *ticket = [[AccountInfoStorage instance] getTicket];
NSString *js = [NSString stringWithFormat:@"getMessage(\"ticket\",\"%@\")",ticket];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetDeviceId]) {
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceId\",\"%@\")",[YYUtility deviceUniqueIdentification]];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetDeviceInfo]) {
NSDictionary *basicParmars = [HttpRequestHelper configBaseParmars:[[NSDictionary alloc] init]];
NSString *json = [basicParmars mj_JSONString];
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceInfo\",%@)", json];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable ohter, NSError * _Nullable error) {
NSLog(@"%@", error);
}];
} else if ([message.name isEqualToString:kJSOpenPurse]) {
}else if([message.name isEqualToString:kJSChargePayPage]){
NSString *money = [NSString stringWithFormat:@"%@",message.body] ;
}else if([message.name isEqualToString:kJSChargePayClickPage]){
if(message.body != nil && self.model.diamonds != nil){
NSString *type = [NSString stringWithFormat:@"%@",message.body];
}
}else if ([message.name isEqualToString:kJSOpenChargePage]) {
if(self.delegate && [self.delegate respondsToSelector:@selector(payHandler)]){
[self.delegate payHandler];
return;
}
[TTPopup dismiss];
if(self.isPush){
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
return;
}
UIViewController *controller = [XCCurrentVCStackManager shareManager].getCurrentVC;
if (controller.presentingViewController) {
[controller dismissViewControllerAnimated:NO completion:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
});
}else {
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
}
} else if ([message.name isEqualToString:kOpenPersonPage]) {
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.integerValue > 0) {
[TTPopup dismiss];
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = uid.integerValue;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:userInfoVC animated:YES];
}
} 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);
}];
} else if([message.name isEqualToString:kInitShowNav]) {
if (((NSNumber *)message.body).intValue == 0) {
if (self.InitShowNavBlock) {
self.InitShowNavBlock(YES);
return;
}
if (self.navigationController) {
[self.navigationController setNavigationBarHidden:YES];
}
}
} else if([message.name isEqualToString:kCloseWebView]) {
if (self.CloseWebViewBlock) {
self.CloseWebViewBlock(YES);
return;
}
if (self.navigationController) {
[self.navigationController popViewControllerAnimated:YES];
}
} else if ([message.name isEqualToString:kJumpAppointPage]) {
// h5
NSDictionary *bodyDict;
if ([message.body isKindOfClass:[NSDictionary class]]) {
bodyDict = message.body;
} else if ([message.body isKindOfClass:[NSString class]]) {
NSString *str = (NSString *)message.body;
bodyDict = [str toJSONObject];
}
NSInteger skyType = [bodyDict[@"routerType"] integerValue];
[self handleRouterType:skyType message:message];
if ([message.name isEqualToString:kJSOpenSharePage]) {
if (message.body && message.body != [NSNull null]) {
NSDictionary *body;
//dic
if ([message.body isKindOfClass:[NSDictionary class]]) {
body = message.body;
} else if ([message.body isKindOfClass:[NSString class]]) {
body = [message.body toJSONObject];
}
self.shareDic = body[@"data"];
[self showSharePanel];
}
} else if ([message.name isEqualToString:kJSGetUid]) {
NSString *uid = [[AccountInfoStorage instance] getUid];
NSString *js = [NSString stringWithFormat:@"getMessage(\"uid\",%@)", uid];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetTicket]) {
NSString *ticket = [[AccountInfoStorage instance] getTicket];
NSString *js = [NSString stringWithFormat:@"getMessage(\"ticket\",\"%@\")",ticket];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetDeviceId]) {
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceId\",\"%@\")",[YYUtility deviceUniqueIdentification]];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable other, NSError * _Nullable error) {
NSLog(@"%@",error);
}];
} else if ([message.name isEqualToString:kJSGetDeviceInfo]) {
NSDictionary *basicParmars = [HttpRequestHelper configBaseParmars:[[NSDictionary alloc] init]];
NSString *json = [basicParmars mj_JSONString];
NSString *js = [NSString stringWithFormat:@"getMessage(\"deviceInfo\",%@)", json];
[self.webview evaluateJavaScript:js completionHandler:^(id _Nullable ohter, NSError * _Nullable error) {
NSLog(@"%@", error);
}];
} else if ([message.name isEqualToString:kJSOpenPurse]) {
}else if([message.name isEqualToString:kJSChargePayPage]){
NSString *money = [NSString stringWithFormat:@"%@",message.body] ;
}else if([message.name isEqualToString:kJSChargePayClickPage]){
if(message.body != nil && self.model.diamonds != nil){
NSString *type = [NSString stringWithFormat:@"%@",message.body];
}
}else if ([message.name isEqualToString:kJSOpenChargePage]) {
if(self.delegate && [self.delegate respondsToSelector:@selector(payHandler)]){
[self.delegate payHandler];
return;
}
[TTPopup dismiss];
if(self.isPush){
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
return;
}
UIViewController *controller = [XCCurrentVCStackManager shareManager].getCurrentVC;
if (controller.presentingViewController) {
[controller dismissViewControllerAnimated:NO completion:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
});
}else {
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
}
} else if ([message.name isEqualToString:kOpenPersonPage]) {
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.integerValue > 0) {
[TTPopup dismiss];
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = uid.integerValue;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:userInfoVC animated:YES];
}
} 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);
}];
} else if([message.name isEqualToString:kInitShowNav]) {
if (((NSNumber *)message.body).intValue == 0) {
if (self.InitShowNavBlock) {
self.InitShowNavBlock(YES);
return;
}
if (self.navigationController) {
[self.navigationController setNavigationBarHidden:YES];
}
}
} else if([message.name isEqualToString:kCloseWebView]) {
if (self.CloseWebViewBlock) {
self.CloseWebViewBlock(YES);
return;
}
if (self.navigationController) {
[self.navigationController popViewControllerAnimated:YES];
}
} else if ([message.name isEqualToString:kJumpAppointPage]) {
// h5
NSDictionary *bodyDict;
if ([message.body isKindOfClass:[NSDictionary class]]) {
bodyDict = message.body;
} else if ([message.body isKindOfClass:[NSString class]]) {
NSString *str = (NSString *)message.body;
bodyDict = [str toJSONObject];
}
NSInteger skyType = [bodyDict[@"routerType"] integerValue];
[self handleRouterType:skyType message:message];
}else if ([message.name isEqualToString:kJSOpenChatPage]){
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
@@ -372,6 +372,14 @@ NSString * const kJSOpenChatPage = @"geToChatPage";
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:sessionVC animated:YES];
}
}else if([message.name isEqualToString:kJSOpenAppConcernedChat]){
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
sessionVC.isAttention = YES;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:sessionVC animated:YES];
}
}else if ([message.name isEqualToString:kJSOpenRoom]) {
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
@@ -719,6 +727,9 @@ NSString * const kJSOpenChatPage = @"geToChatPage";
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenRoomForGiftId];
///
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenChatPage];
///
[_pi_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenAppConcernedChat];
}
return _pi_userContentController;