|
@@ -15,9 +15,11 @@
|
|
#import <AFNetworking.h>
|
|
#import <AFNetworking.h>
|
|
#import "NoNetView.h"
|
|
#import "NoNetView.h"
|
|
//#import <WebKit/WebKit.h>
|
|
//#import <WebKit/WebKit.h>
|
|
|
|
+#import <CommonCrypto/CommonCryptor.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+#define LocalStr_None @""//空字符串
|
|
#define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
|
|
#define KIsiPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
|
|
|
|
|
|
@protocol ViewControllerMain<JSExport>
|
|
@protocol ViewControllerMain<JSExport>
|
|
@@ -27,6 +29,8 @@
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@protocol ViewControllerJSExport<JSExport>
|
|
@protocol ViewControllerJSExport<JSExport>
|
|
|
|
|
|
JSExportAs(loginByWeixin, -(NSString *)jsLoginByWeixin:(NSString *)str);// 微信登录 openid
|
|
JSExportAs(loginByWeixin, -(NSString *)jsLoginByWeixin:(NSString *)str);// 微信登录 openid
|
|
@@ -48,58 +52,71 @@ JSExportAs(openExternalLink, -(void)jsOpenExternalLink:(NSString *)url title:(NS
|
|
JSExportAs(getVersion, -(NSString *)jsGetVersion:(NSString *)str);// 获取当前版本号
|
|
JSExportAs(getVersion, -(NSString *)jsGetVersion:(NSString *)str);// 获取当前版本号
|
|
JSExportAs(alert, -(void)jsAlert:(NSString *)content);// 弹框
|
|
JSExportAs(alert, -(void)jsAlert:(NSString *)content);// 弹框
|
|
JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否安装微信
|
|
JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否安装微信
|
|
-
|
|
|
|
-
|
|
|
|
JSExportAs(changeMessageType, -(void)jsChangeMessageType:(NSString *)link);//已读操作处理
|
|
JSExportAs(changeMessageType, -(void)jsChangeMessageType:(NSString *)link);//已读操作处理
|
|
JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(NSString *)rectype openid:(NSString *)openid);
|
|
JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(NSString *)rectype openid:(NSString *)openid);
|
|
|
|
|
|
|
|
+JSExportAs(getCipherText, -(NSString *)jsGGetCipherText:(NSString *)phone);
|
|
|
|
+
|
|
|
|
+JSExportAs(business, -(NSInteger)jsBusiness:(NSInteger)shooID shopType:(NSInteger )shopType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-@end
|
|
|
|
|
|
|
|
|
|
+@end
|
|
|
|
|
|
|
|
|
|
@interface ViewController ()<UIWebViewDelegate, ViewControllerJSExport>
|
|
@interface ViewController ()<UIWebViewDelegate, ViewControllerJSExport>
|
|
{
|
|
{
|
|
CGPoint startTouch;
|
|
CGPoint startTouch;
|
|
BOOL _isMoving;
|
|
BOOL _isMoving;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ BOOL _isFirstLogin;
|
|
}
|
|
}
|
|
|
|
|
|
-@property (weak, nonatomic) IBOutlet UIWebView *webView;
|
|
|
|
-//@property(nonatomic, assign)BOOL ;
|
|
|
|
-@property(nonatomic, assign)BOOL updateNotify;
|
|
|
|
-@property(nonatomic, assign)BOOL afterOpenPushMessage;
|
|
|
|
-@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topC;
|
|
|
|
-//@property(nonatomic, strong)WKWebView *wkWebView;
|
|
|
|
-@property(nonatomic, strong)NoNetView *noNetView;
|
|
|
|
-@property(nonatomic, strong)NSURLRequest *errRequest;
|
|
|
|
-@property(nonatomic, strong)NSString *signOutContent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
+NSString *const kInitVector = @"1389461544135476";
|
|
|
|
+size_t const kKeySize = kCCKeySizeAES128;
|
|
|
|
+NSString *const AesKey = @"mGlAgnIBB8bx2nch";
|
|
|
|
+
|
|
@implementation ViewController
|
|
@implementation ViewController
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
|
+
|
|
|
|
+ NSLog(@"viewDidLoadviewDidLoad 初始化");
|
|
|
|
+
|
|
[LXDataBaseManager shareDataBaseManager];
|
|
[LXDataBaseManager shareDataBaseManager];
|
|
if ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0) {
|
|
if ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0) {
|
|
-// if(KIsiPhoneX) {
|
|
|
|
-// self.topC.constant = -44;
|
|
|
|
-// [self.webView updateConstraints];
|
|
|
|
-// }else {
|
|
|
|
-// self.topC.constant = -20;
|
|
|
|
-// [self.webView updateConstraints];
|
|
|
|
-// }
|
|
|
|
|
|
+ // if(KIsiPhoneX) {
|
|
|
|
+ // self.topC.constant = -44;
|
|
|
|
+ // [self.webView updateConstraints];
|
|
|
|
+ // }else {
|
|
|
|
+ // self.topC.constant = -20;
|
|
|
|
+ // [self.webView updateConstraints];
|
|
|
|
+ // }
|
|
self.topC.constant = -20;
|
|
self.topC.constant = -20;
|
|
[self.webView updateConstraints];
|
|
[self.webView updateConstraints];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ self.view.backgroundColor = [UIColor whiteColor];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT-TAB_BAR_HEIGHT+STATUS_BAR_HEIGHT)];
|
|
|
|
+ [self.view addSubview: self.webView];
|
|
self.webView.scrollView.bounces = NO;
|
|
self.webView.scrollView.bounces = NO;
|
|
|
|
+ self.webView.delegate = self;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
[[LXViewControllerManager shareViewControllerManager] showHudText:nil];
|
|
[[LXViewControllerManager shareViewControllerManager] showHudText:nil];
|
|
[self webViewFirstRequest];//请求页面数据
|
|
[self webViewFirstRequest];//请求页面数据
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(requestWebView:) name:kRequestWebViewWithUrl object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(requestWebView:) name:kRequestWebViewWithUrl object:nil];
|
|
@@ -112,13 +129,15 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachChanged:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachChanged:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
-// [self clearWeb];
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ [self clearWeb];
|
|
|
|
+
|
|
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(paningGestureReceive:)];
|
|
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(paningGestureReceive:)];
|
|
[recognizer delaysTouchesBegan];
|
|
[recognizer delaysTouchesBegan];
|
|
[self.view addGestureRecognizer:recognizer];
|
|
[self.view addGestureRecognizer:recognizer];
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
-(void)moveViewWithX:(float)x
|
|
-(void)moveViewWithX:(float)x
|
|
@@ -144,11 +163,11 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
|
|
|
|
NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
|
|
NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
|
|
NSLog(@"当前页面:%@",current_url);
|
|
NSLog(@"当前页面:%@",current_url);
|
|
-// NSString *current_url = self.webView.request.URL.absoluteString;
|
|
|
|
|
|
+ // NSString *current_url = self.webView.request.URL.absoluteString;
|
|
if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/free/me",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/wxkeyset/keyset/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
|
|
if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/free/me",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/wxkeyset/keyset/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//https://www.jianyu360.com/jyapp/free/me
|
|
//https://www.jianyu360.com/jyapp/free/me
|
|
//https://www.jianyu360.com/jyapp/jylab/index
|
|
//https://www.jianyu360.com/jyapp/jylab/index
|
|
//https://www.jianyu360.com/jyapp/wxkeyset/keyset/index
|
|
//https://www.jianyu360.com/jyapp/wxkeyset/keyset/index
|
|
@@ -211,7 +230,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
}else{
|
|
}else{
|
|
[self.webView reload];
|
|
[self.webView reload];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// 首次加载web
|
|
// 首次加载web
|
|
@@ -236,14 +255,14 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
-(void)requestWebTime:(NSDictionary *)infoDict
|
|
-(void)requestWebTime:(NSDictionary *)infoDict
|
|
{
|
|
{
|
|
NSString * urlStr = [NSString stringWithFormat:@"%@",infoDict[@"url"]];
|
|
NSString * urlStr = [NSString stringWithFormat:@"%@",infoDict[@"url"]];
|
|
-
|
|
|
|
|
|
+
|
|
if([infoDict[@"type"] isEqualToString:@"message"]) {
|
|
if([infoDict[@"type"] isEqualToString:@"message"]) {
|
|
NSString *url = [NSString stringWithFormat:@"%@",urlStr];
|
|
NSString *url = [NSString stringWithFormat:@"%@",urlStr];
|
|
NSArray * array = [url componentsSeparatedByString:@"=="];
|
|
NSArray * array = [url componentsSeparatedByString:@"=="];
|
|
url = [array.firstObject stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
url = [array.firstObject stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
|
|
-//
|
|
|
|
|
|
+ //
|
|
}else {
|
|
}else {
|
|
NSString *url = [NSString stringWithFormat:@"%@%@", kHost, urlStr];
|
|
NSString *url = [NSString stringWithFormat:@"%@%@", kHost, urlStr];
|
|
url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
@@ -260,28 +279,28 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
NSString * urlStr = [NSString stringWithFormat:@"%@",infoDict[@"url"]];
|
|
NSString * urlStr = [NSString stringWithFormat:@"%@",infoDict[@"url"]];
|
|
-
|
|
|
|
|
|
+
|
|
if (urlStr) {
|
|
if (urlStr) {
|
|
[[LXViewControllerManager shareViewControllerManager] showHudText:nil];
|
|
[[LXViewControllerManager shareViewControllerManager] showHudText:nil];
|
|
self.afterOpenPushMessage = YES;
|
|
self.afterOpenPushMessage = YES;
|
|
|
|
|
|
|
|
|
|
[self performSelector:@selector(requestWebTime:) withObject:infoDict afterDelay:1];
|
|
[self performSelector:@selector(requestWebTime:) withObject:infoDict afterDelay:1];
|
|
-// if([infoDict[@"type"] isEqualToString:@"message"]) {
|
|
|
|
-// NSString *url = [NSString stringWithFormat:@"%@",urlStr];
|
|
|
|
-// url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
|
|
-// [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
|
|
-// [[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
|
|
|
|
-// }else {
|
|
|
|
-// NSString *url = [NSString stringWithFormat:@"%@%@", kHost, urlStr];
|
|
|
|
-// url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
|
|
-// [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
|
|
-// [[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
|
|
|
|
-// }
|
|
|
|
|
|
+ // if([infoDict[@"type"] isEqualToString:@"message"]) {
|
|
|
|
+ // NSString *url = [NSString stringWithFormat:@"%@",urlStr];
|
|
|
|
+ // url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
|
|
+ // [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
|
|
+ // [[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
|
|
|
|
+ // }else {
|
|
|
|
+ // NSString *url = [NSString stringWithFormat:@"%@%@", kHost, urlStr];
|
|
|
|
+ // url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
|
|
+ // [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
|
|
+ // [[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -303,24 +322,92 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
}
|
|
}
|
|
NSString *url = [NSString stringWithFormat:@"%@%@?sign=%@", kHost, @"jyapp/free/signOut", [LXUserDefaults token]];
|
|
NSString *url = [NSString stringWithFormat:@"%@%@?sign=%@", kHost, @"jyapp/free/signOut", [LXUserDefaults token]];
|
|
url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
-
|
|
|
|
|
|
+
|
|
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
|
|
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
|
|
webView.delegate = self;
|
|
webView.delegate = self;
|
|
[self.view addSubview:webView];
|
|
[self.view addSubview:webView];
|
|
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
-
|
|
|
|
-// [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
|
|
|
|
+
|
|
|
|
+ // [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
[self jsRemoveUserToken:nil];
|
|
[self jsRemoveUserToken:nil];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+- (void)hideTabBar {
|
|
|
|
+
|
|
|
|
+ kMainQueue(^{
|
|
|
|
+ if (self.tabBarController.tabBar.hidden == YES) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ UIView *contentView;
|
|
|
|
+ if ( [[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
|
|
|
|
+ contentView = [self.tabBarController.view.subviews objectAtIndex:1];
|
|
|
|
+ else
|
|
|
|
+ contentView = [self.tabBarController.view.subviews objectAtIndex:0];
|
|
|
|
+ contentView.frame = CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y, contentView.bounds.size.width, contentView.bounds.size.height + self.tabBarController.tabBar.frame.size.height);
|
|
|
|
+ self.tabBarController.tabBar.hidden = YES;
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+- (void)showTabBar{
|
|
|
|
+ kMainQueue(^{
|
|
|
|
+ if (self.tabBarController.tabBar.hidden == NO)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ UIView *contentView;
|
|
|
|
+ if ([[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]])
|
|
|
|
+
|
|
|
|
+ contentView = [self.tabBarController.view.subviews objectAtIndex:1];
|
|
|
|
+
|
|
|
|
+ else
|
|
|
|
+
|
|
|
|
+ contentView = [self.tabBarController.view.subviews objectAtIndex:0];
|
|
|
|
+ contentView.frame = CGRectMake(contentView.bounds.origin.x, contentView.bounds.origin.y, contentView.bounds.size.width, contentView.bounds.size.height - self.tabBarController.tabBar.frame.size.height);
|
|
|
|
+ self.tabBarController.tabBar.hidden = NO;
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+-(void)jsHiddenBottom:(NSString *)hidden
|
|
|
|
+{
|
|
|
|
+ if([hidden integerValue]==0) {
|
|
|
|
+ [self hideTabBar];
|
|
|
|
+ self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT+STATUS_BAR_HEIGHT);
|
|
|
|
+ }else {
|
|
|
|
+ [self showTabBar];
|
|
|
|
+ self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT-TAB_BAR_HEIGHT+STATUS_BAR_HEIGHT);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+-(void)judgeIsHidden
|
|
|
|
+{
|
|
|
|
+ NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
|
|
|
|
+ // if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
|
|
|
|
+ // [self showTabBar];
|
|
|
|
+ // self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT-TAB_BAR_HEIGHT+STATUS_BAR_HEIGHT);
|
|
|
|
+ // }else {
|
|
|
|
+ // [self hideTabBar];
|
|
|
|
+ // self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT+STATUS_BAR_HEIGHT);
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/free/me",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/wxkeyset/keyset/index",kHost]]||[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
|
|
|
|
+ [self showTabBar];
|
|
|
|
+ self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT-TAB_BAR_HEIGHT+STATUS_BAR_HEIGHT);
|
|
|
|
+ }else {
|
|
|
|
+ [self hideTabBar];
|
|
|
|
+ self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT+STATUS_BAR_HEIGHT);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
|
|
#pragma mark 捕获js中调用的方法
|
|
#pragma mark 捕获js中调用的方法
|
|
|
|
|
|
//捕获js中调用的方法
|
|
//捕获js中调用的方法
|
|
- (void)webViewDidFinishLoad:(UIWebView *)webView{
|
|
- (void)webViewDidFinishLoad:(UIWebView *)webView{
|
|
|
|
+
|
|
|
|
+ [self judgeIsHidden];//是否隐藏
|
|
[self removeNoNetViews];
|
|
[self removeNoNetViews];
|
|
[[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
[[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
JSContext *context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
|
|
JSContext *context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
|
|
@@ -334,7 +421,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
[context evaluateScript:@"afterPageInit()"];
|
|
[context evaluateScript:@"afterPageInit()"];
|
|
if (self.afterOpenPushMessage) {
|
|
if (self.afterOpenPushMessage) {
|
|
self.afterOpenPushMessage = NO;
|
|
self.afterOpenPushMessage = NO;
|
|
-// [context evaluateScript:@"afterOpenPushMessage()"];
|
|
|
|
|
|
+ // [context evaluateScript:@"afterOpenPushMessage()"];
|
|
[context evaluateScript:[NSString stringWithFormat:@"afterOpenPushMessage('%d')", [self jsIsCanBack:nil]]];
|
|
[context evaluateScript:[NSString stringWithFormat:@"afterOpenPushMessage('%d')", [self jsIsCanBack:nil]]];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -347,7 +434,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if ([url containsString:@"signOut"]) { // 收到退出消息后 跳转到登录页面
|
|
if ([url containsString:@"signOut"]) { // 收到退出消息后 跳转到登录页面
|
|
-// [self webViewFirstRequest];
|
|
|
|
|
|
+ // [self webViewFirstRequest];
|
|
[self webViewRequestByMsg];
|
|
[self webViewRequestByMsg];
|
|
}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"]) {
|
|
@@ -362,7 +449,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
|
|
|
|
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
|
|
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
|
|
[[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
[[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
-
|
|
|
|
|
|
+
|
|
NSString *url = webView.request.URL.absoluteString;
|
|
NSString *url = webView.request.URL.absoluteString;
|
|
[self doSomeWithLoadUrl:url];
|
|
[self doSomeWithLoadUrl:url];
|
|
}
|
|
}
|
|
@@ -370,9 +457,9 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
|
|
|
|
|
|
|
|
-(void)webViewDidStartLoad:(UIWebView *)webView{
|
|
-(void)webViewDidStartLoad:(UIWebView *)webView{
|
|
-// if ([[UIDevice currentDevice].systemVersion floatValue] < 10) {
|
|
|
|
-// [[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
|
|
-// }
|
|
|
|
|
|
+ // if ([[UIDevice currentDevice].systemVersion floatValue] < 10) {
|
|
|
|
+ // [[LXViewControllerManager shareViewControllerManager] hideHud];
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -408,7 +495,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
#pragma mark JS 回调
|
|
#pragma mark JS 回调
|
|
// 微信登录
|
|
// 微信登录
|
|
-(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;
|
|
@@ -458,7 +545,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
|
|
JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
|
|
NSString * textJS1 = [NSString stringWithFormat:@"loginByWeixinCallBack('%@')", endStr];
|
|
NSString * textJS1 = [NSString stringWithFormat:@"loginByWeixinCallBack('%@')", endStr];
|
|
JSValue *value = [context evaluateScript:textJS1];
|
|
JSValue *value = [context evaluateScript:textJS1];
|
|
- LXLog(@"%@", value);
|
|
|
|
|
|
+ NSLog(@"%@", value);
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -468,7 +555,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
// js 调用分享
|
|
// js 调用分享
|
|
-(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){ /// qq好友
|
|
}else if ([type intValue] == 2){ /// qq好友
|
|
@@ -479,16 +566,16 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
shareType = UMSocialPlatformType_WechatSession;
|
|
shareType = UMSocialPlatformType_WechatSession;
|
|
}
|
|
}
|
|
|
|
|
|
- kMainQueue(^{
|
|
|
|
|
|
+ kMainQueue((^{
|
|
|
|
|
|
-// 没有安装app 不走分享逻辑
|
|
|
|
|
|
+ // 没有安装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 不走分享逻辑
|
|
|
|
|
|
+ // 没有安装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,28 +593,34 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
//调用分享接口
|
|
//调用分享接口
|
|
[[UMSocialManager defaultManager] shareToPlatform:shareType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
|
|
[[UMSocialManager defaultManager] shareToPlatform:shareType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
|
|
if (error) {
|
|
if (error) {
|
|
- UMSocialLogInfo(@"************Share fail with error %@*********",error);
|
|
|
|
- if (error.userInfo[@"message"] && [error.userInfo[@"message"] containsString:@"cancel"]) {
|
|
|
|
|
|
+ NSLog(@"22222222%@",error.userInfo);
|
|
|
|
+ if (error.userInfo[@"message"] && [error.userInfo[@"message"] containsString:@"Operation is cancel"]) {
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"取消分享" delay:1];
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"取消分享" delay:1];
|
|
}else{
|
|
}else{
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:error.userInfo[@"message"] delay:1];
|
|
[[LXViewControllerManager shareViewControllerManager] showHudOnlyText:error.userInfo[@"message"] delay:1];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ NSString *textJS = [NSString stringWithFormat:@"shareCallBack('%@','%@')",type,@"0"];
|
|
|
|
+ JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
|
|
|
|
+ [context evaluateScript:textJS];
|
|
|
|
+
|
|
}else{
|
|
}else{
|
|
if ([data isKindOfClass:[UMSocialShareResponse class]]) {
|
|
if ([data isKindOfClass:[UMSocialShareResponse class]]) {
|
|
UMSocialShareResponse *resp = data;
|
|
UMSocialShareResponse *resp = data;
|
|
- NSLog(@"%@",resp.message);
|
|
|
|
- NSLog(@"response originalResponse data is %@",resp.originalResponse);
|
|
|
|
- //分享结果消息
|
|
|
|
- UMSocialLogInfo(@"response message is %@",resp.message);
|
|
|
|
- //第三方原始返回的数据
|
|
|
|
- UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);
|
|
|
|
|
|
+ NSLog(@"33333%@",resp.message);
|
|
|
|
+ NSLog(@"44444%@",resp.originalResponse);
|
|
|
|
+
|
|
|
|
+ NSString *textJS = [NSString stringWithFormat:@"shareCallBack('%@','%@')",type,@"1"];
|
|
|
|
+ JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
|
|
|
|
+ [context evaluateScript:textJS];
|
|
|
|
|
|
}else{
|
|
}else{
|
|
UMSocialLogInfo(@"response data is %@",data);
|
|
UMSocialLogInfo(@"response data is %@",data);
|
|
|
|
+ NSLog(@"55555%@",data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}];
|
|
}];
|
|
- });
|
|
|
|
|
|
+ }));
|
|
}
|
|
}
|
|
|
|
|
|
// 登录时获取到令牌 并保存
|
|
// 登录时获取到令牌 并保存
|
|
@@ -544,7 +637,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
// 退出时 清空用户数据
|
|
// 退出时 清空用户数据
|
|
-(void)jsRemoveUserToken:(NSString *)str{
|
|
-(void)jsRemoveUserToken:(NSString *)str{
|
|
[LXUserDefaults clearAll];
|
|
[LXUserDefaults clearAll];
|
|
-// [[LXDataBaseManager shareDataBaseManager] clearAll];
|
|
|
|
|
|
+ // [[LXDataBaseManager shareDataBaseManager] clearAll];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -559,7 +652,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
-(void)jsOpenSystemNotification:(NSString *)str{
|
|
-(void)jsOpenSystemNotification:(NSString *)str{
|
|
self.updateNotify = YES;
|
|
self.updateNotify = YES;
|
|
kMainQueue(^{
|
|
kMainQueue(^{
|
|
- [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
|
|
|
|
|
+ [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -569,7 +662,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
self.updateNotify = NO;
|
|
self.updateNotify = NO;
|
|
JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
|
|
JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
|
|
NSString * textJS1 = [NSString stringWithFormat:@"updateNoticeSwitch()"];
|
|
NSString * textJS1 = [NSString stringWithFormat:@"updateNoticeSwitch()"];
|
|
- [context evaluateScript:textJS1];
|
|
|
|
|
|
+ [context evaluateScript:textJS1];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 获取推送id
|
|
// 获取推送id
|
|
@@ -583,7 +676,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
if (arr.count > 0) {
|
|
if (arr.count > 0) {
|
|
return [[LXViewControllerManager shareViewControllerManager] getJsonStr:arr];
|
|
return [[LXViewControllerManager shareViewControllerManager] getJsonStr:arr];
|
|
}
|
|
}
|
|
- return@"";
|
|
|
|
|
|
+ return @"";
|
|
}
|
|
}
|
|
|
|
|
|
// 更新消息状态
|
|
// 更新消息状态
|
|
@@ -603,7 +696,7 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
// 取未读消息总数
|
|
// 取未读消息总数
|
|
-(int)jsGetUnReadMessageCount:(NSString *)openid{
|
|
-(int)jsGetUnReadMessageCount:(NSString *)openid{
|
|
NSLog(@"openid=%@",openid);
|
|
NSLog(@"openid=%@",openid);
|
|
-// NSLog(@"%d",[[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid]);
|
|
|
|
|
|
+ // NSLog(@"%d",[[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid]);
|
|
|
|
|
|
return [[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid];
|
|
return [[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid];
|
|
}
|
|
}
|
|
@@ -624,17 +717,17 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
}
|
|
}
|
|
[[UIApplication sharedApplication] setStatusBarStyle:index];
|
|
[[UIApplication sharedApplication] setStatusBarStyle:index];
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
// 打开新页面 加载新web
|
|
// 打开新页面 加载新web
|
|
-(void)jsOpenExternalLink:(NSString *)url title:(NSString *)title{
|
|
-(void)jsOpenExternalLink:(NSString *)url title:(NSString *)title{
|
|
if (url) {
|
|
if (url) {
|
|
if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable || [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusUnknown) {
|
|
if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable || [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusUnknown) {
|
|
-// [self addNoNetViews];
|
|
|
|
|
|
+ // [self addNoNetViews];
|
|
}
|
|
}
|
|
NewWebController *ctr = [[NewWebController alloc] init];
|
|
NewWebController *ctr = [[NewWebController alloc] init];
|
|
ctr.url = url;
|
|
ctr.url = url;
|
|
-// 有title的话 会显示自定义的导航栏 没有的话不显示导航栏 显示加载进度条
|
|
|
|
|
|
+ // 有title的话 会显示自定义的导航栏 没有的话不显示导航栏 显示加载进度条
|
|
if (!title || [title isEqualToString:@""] || [title isEqualToString:@"undefined"]) {
|
|
if (!title || [title isEqualToString:@""] || [title isEqualToString:@"undefined"]) {
|
|
ctr.titleShow = nil;
|
|
ctr.titleShow = nil;
|
|
}else{
|
|
}else{
|
|
@@ -706,6 +799,69 @@ JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+-(NSString *)jsGGetCipherText:(NSString *)phone
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ NSDate *date=[NSDate date];
|
|
|
|
+ NSDateFormatter *format1=[[NSDateFormatter alloc] init];
|
|
|
|
+ [format1 setDateFormat:@"yyyyMMddhhmmss"];
|
|
|
|
+ NSString *dateStr;
|
|
|
|
+ dateStr=[format1 stringFromDate:date];
|
|
|
|
+ NSLog(@"%@",dateStr);
|
|
|
|
+
|
|
|
|
+ NSString *content = [[NSString stringWithFormat:@"%@_%@",phone,dateStr] stringByAppendingString:[NSString stringWithFormat:@"_%@",[LXMD5 md532BitLower:[NSString stringWithFormat:@"%@&%@",phone,dateStr]]]];
|
|
|
|
+ NSData *contentData = [content dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
+ NSUInteger dataLength = contentData.length;
|
|
|
|
+ // 为结束符'\\0' +1
|
|
|
|
+ char keyPtr[kKeySize + 1];
|
|
|
|
+ memset(keyPtr, 0, sizeof(keyPtr));
|
|
|
|
+ [AesKey getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
|
|
|
|
+ // 密文长度 <= 明文长度 + BlockSize
|
|
|
|
+ size_t encryptSize = dataLength + kCCBlockSizeAES128;
|
|
|
|
+ void *encryptedBytes = malloc(encryptSize);
|
|
|
|
+ size_t actualOutSize = 0;
|
|
|
|
+ NSData *initVector = [kInitVector dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
+ CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt,
|
|
|
|
+ kCCAlgorithmAES,
|
|
|
|
+ kCCOptionPKCS7Padding, // 系统默认使用 CBC,然后指明使用 PKCS7Padding
|
|
|
|
+ keyPtr,
|
|
|
|
+ kKeySize,
|
|
|
|
+ initVector.bytes,
|
|
|
|
+ contentData.bytes,
|
|
|
|
+ dataLength,
|
|
|
|
+ encryptedBytes,
|
|
|
|
+ encryptSize,
|
|
|
|
+ &actualOutSize);
|
|
|
|
+ if (cryptStatus == kCCSuccess) {
|
|
|
|
+ // 对加密后的数据进行 base64 编码
|
|
|
|
+ return [[NSData dataWithBytesNoCopy:encryptedBytes length:actualOutSize] base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
|
|
|
|
+ }
|
|
|
|
+ free(encryptedBytes);
|
|
|
|
+ return nil;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|