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