|
@@ -98,6 +98,7 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
[self clearWeb];
|
|
[self clearWeb];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 监控网络状态变化
|
|
-(void)netReachChanged:(NSNotification *)notificaition{
|
|
-(void)netReachChanged:(NSNotification *)notificaition{
|
|
NSDictionary *userInfo = notificaition.userInfo;
|
|
NSDictionary *userInfo = notificaition.userInfo;
|
|
if ([userInfo[@"AFNetworkingReachabilityNotificationStatusItem"] intValue] == 0 || [userInfo[@"AFNetworkingReachabilityNotificationStatusItem"] intValue] == -1) {
|
|
if ([userInfo[@"AFNetworkingReachabilityNotificationStatusItem"] intValue] == 0 || [userInfo[@"AFNetworkingReachabilityNotificationStatusItem"] intValue] == -1) {
|
|
@@ -122,6 +123,7 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 首次加载web
|
|
-(void)webViewFirstRequest{
|
|
-(void)webViewFirstRequest{
|
|
NSString *url = [NSString stringWithFormat:@"%@%@", kHost, @"jyapp/free/login"];
|
|
NSString *url = [NSString stringWithFormat:@"%@%@", kHost, @"jyapp/free/login"];
|
|
NSString *token = [LXUserDefaults token];
|
|
NSString *token = [LXUserDefaults token];
|
|
@@ -179,13 +181,6 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
[self jsRemoveUserToken:nil];
|
|
[self jsRemoveUserToken:nil];
|
|
}
|
|
}
|
|
|
|
|
|
-- (IBAction)click:(id)sender {
|
|
|
|
-// [self jsLoginByWeixin:nil];
|
|
|
|
-// [self clearWeb];
|
|
|
|
- NewWebController *ctr = [[NewWebController alloc] init];
|
|
|
|
- ctr.url = @"http://www.baidu.com";
|
|
|
|
- [self presentViewController:ctr animated:NO completion:nil];
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
|
|
//捕获js中调用的方法
|
|
//捕获js中调用的方法
|
|
@@ -215,9 +210,9 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
if (!url) {
|
|
if (!url) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if ([url containsString:@"signOut"]) {
|
|
|
|
|
|
+ if ([url containsString:@"signOut"]) { // 收到退出消息后 跳转到登录页面
|
|
[self webViewFirstRequest];
|
|
[self webViewFirstRequest];
|
|
- }else if ([url containsString:@"/free/login"]){
|
|
|
|
|
|
+ }else if ([url containsString:@"/free/login"]){ // 如果通过接收消息 跳转到登录页面 展示消息内容
|
|
if (self.signOutContent && ![self.signOutContent isEqualToString:@"1"]) {
|
|
if (self.signOutContent && ![self.signOutContent isEqualToString:@"1"]) {
|
|
[[LXViewControllerManager shareViewControllerManager] showAlertViewWithTitle:@"提示" message:self.signOutContent actions:@[[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
[[LXViewControllerManager shareViewControllerManager] showAlertViewWithTitle:@"提示" message:self.signOutContent actions:@[[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
self.signOutContent = nil;
|
|
self.signOutContent = nil;
|
|
@@ -277,7 +272,7 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
// 微信登录
|
|
// 微信登录
|
|
-(NSString *)jsLoginByWeixin:(NSString *)str{
|
|
-(NSString *)jsLoginByWeixin:(NSString *)str{
|
|
|
|
|
|
- if ([LXUserDefaults isInstallWeiXin] != 1) {
|
|
|
|
|
|
+ if ([LXUserDefaults isInstallWeiXin] != 1) { // 没有安装微信 不走友盟
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"微信登录失败,没有安装微信" delay:1.5];
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"微信登录失败,没有安装微信" delay:1.5];
|
|
return nil;
|
|
return nil;
|
|
}
|
|
}
|
|
@@ -288,22 +283,6 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
|
|
|
|
UMSocialUserInfoResponse *resp = result;
|
|
UMSocialUserInfoResponse *resp = result;
|
|
|
|
|
|
- // 第三方登录数据(为空表示平台未提供)
|
|
|
|
- // 授权数据
|
|
|
|
- NSLog(@" uid: %@", resp.uid);
|
|
|
|
- NSLog(@" openid: %@", resp.openid);
|
|
|
|
- [LXUserDefaults saveOpenID:resp.openid];
|
|
|
|
- NSLog(@" accessToken: %@", resp.accessToken);
|
|
|
|
- NSLog(@" refreshToken: %@", resp.refreshToken);
|
|
|
|
- NSLog(@" expiration: %@", resp.expiration);
|
|
|
|
- // 用户数据
|
|
|
|
- NSLog(@" name: %@", resp.name);
|
|
|
|
- NSLog(@" iconurl: %@", resp.iconurl);
|
|
|
|
- NSLog(@" gender: %@", resp.unionGender);
|
|
|
|
-
|
|
|
|
- // 第三方平台SDK原始数据
|
|
|
|
- NSLog(@" originalResponse: %@", resp.originalResponse);
|
|
|
|
-
|
|
|
|
[self dealWXDic:(NSDictionary *)resp.originalResponse];
|
|
[self dealWXDic:(NSDictionary *)resp.originalResponse];
|
|
|
|
|
|
[[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
[[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
@@ -328,7 +307,7 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
double currDouble = [[NSDate date] timeIntervalSince1970];
|
|
double currDouble = [[NSDate date] timeIntervalSince1970];
|
|
[dic setObject:[NSNumber numberWithLong:(long)currDouble] forKey:@"createtime"];
|
|
[dic setObject:[NSNumber numberWithLong:(long)currDouble] forKey:@"createtime"];
|
|
|
|
|
|
-
|
|
|
|
|
|
+// 拼接标志位
|
|
NSString *sign = [NSString stringWithFormat:@"city=%@&country=%@&createtime=%@&headimgurl=%@&nickname=%@&openid=%@&province=%@&sex=%@&unionid=%@", dic[@"city"], dic[@"country"], dic[@"createtime"], dic[@"headimgurl"], dic[@"nickname"], dic[@"openid"], dic[@"province"],dic[@"sex"],dic[@"unionid"]];
|
|
NSString *sign = [NSString stringWithFormat:@"city=%@&country=%@&createtime=%@&headimgurl=%@&nickname=%@&openid=%@&province=%@&sex=%@&unionid=%@", dic[@"city"], dic[@"country"], dic[@"createtime"], dic[@"headimgurl"], dic[@"nickname"], dic[@"openid"], dic[@"province"],dic[@"sex"],dic[@"unionid"]];
|
|
sign = [LXMD5 md532BitLower:sign];
|
|
sign = [LXMD5 md532BitLower:sign];
|
|
[dic setObject:sign forKey:@"sign"];
|
|
[dic setObject:sign forKey:@"sign"];
|
|
@@ -349,11 +328,11 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
-(void)jsShare:(NSString *)type title:(NSString *)title content:(NSString *)content link:(NSString *)link{
|
|
-(void)jsShare:(NSString *)type title:(NSString *)title content:(NSString *)content link:(NSString *)link{
|
|
UMSocialPlatformType shareType;
|
|
UMSocialPlatformType shareType;
|
|
|
|
|
|
- if ([type intValue] == 1) {
|
|
|
|
|
|
+ if ([type intValue] == 1) { // 微信好友
|
|
shareType = UMSocialPlatformType_WechatSession;
|
|
shareType = UMSocialPlatformType_WechatSession;
|
|
- }else if ([type intValue] == 2){
|
|
|
|
|
|
+ }else if ([type intValue] == 2){ /// qq好友
|
|
shareType = UMSocialPlatformType_QQ;
|
|
shareType = UMSocialPlatformType_QQ;
|
|
- }else if ([type intValue] == 3){
|
|
|
|
|
|
+ }else if ([type intValue] == 3){ // 朋友圈
|
|
shareType = UMSocialPlatformType_WechatTimeLine;
|
|
shareType = UMSocialPlatformType_WechatTimeLine;
|
|
}else{
|
|
}else{
|
|
shareType = UMSocialPlatformType_WechatSession;
|
|
shareType = UMSocialPlatformType_WechatSession;
|
|
@@ -361,12 +340,14 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
|
|
|
|
kMainQueue(^{
|
|
kMainQueue(^{
|
|
|
|
|
|
|
|
+// 没有安装app 不走分享逻辑
|
|
if ([type intValue] == 1 || [type intValue] == 3) {
|
|
if ([type intValue] == 1 || [type intValue] == 3) {
|
|
if ([LXUserDefaults isInstallWeiXin] != 1) {
|
|
if ([LXUserDefaults isInstallWeiXin] != 1) {
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"没有安装微信" delay:1.5];
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"没有安装微信" delay:1.5];
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+// 没有安装app 不走分享逻辑
|
|
if ([type intValue] == 2) {
|
|
if ([type intValue] == 2) {
|
|
if (![[UMSocialManager defaultManager] isInstall:UMSocialPlatformType_QQ]) {
|
|
if (![[UMSocialManager defaultManager] isInstall:UMSocialPlatformType_QQ]) {
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"没有安装QQ" delay:1.5];
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"没有安装QQ" delay:1.5];
|
|
@@ -506,6 +487,7 @@ JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否
|
|
}
|
|
}
|
|
NewWebController *ctr = [[NewWebController alloc] init];
|
|
NewWebController *ctr = [[NewWebController alloc] init];
|
|
ctr.url = url;
|
|
ctr.url = url;
|
|
|
|
+// 有title的话 会显示自定义的导航栏 没有的话不显示导航栏 显示加载进度条
|
|
if (!title || [title isEqualToString:@""] || [title isEqualToString:@"undefined"]) {
|
|
if (!title || [title isEqualToString:@""] || [title isEqualToString:@"undefined"]) {
|
|
ctr.titleShow = nil;
|
|
ctr.titleShow = nil;
|
|
}else{
|
|
}else{
|