|
@@ -8,7 +8,7 @@
|
|
|
|
|
|
#import "JYSearchViewController.h"
|
|
|
#import "JYTabBarController.h"
|
|
|
-
|
|
|
+#import <CoreLocation/CoreLocation.h>
|
|
|
|
|
|
@protocol JYSearchViewControllerJSExport<JSExport>
|
|
|
|
|
@@ -41,14 +41,13 @@ JSExportAs(business, -(NSInteger)jsBusiness:(NSInteger)shooID shopType:(NSIntege
|
|
|
|
|
|
//新增
|
|
|
JSExportAs(hiddenBottom, -(void)jsHiddenBottom:(NSString*)hidden);
|
|
|
+//刷新其他页面
|
|
|
+JSExportAs(checkLab, -(void)jsCheckLab:(NSString*)str);
|
|
|
|
|
|
+//登录相关
|
|
|
JSExportAs(loginSuccess, -(void)jsLoginSuccess:(NSString*)status);
|
|
|
-
|
|
|
JSExportAs(backUrl, -(void)jsBackUrl:(NSString*)str);
|
|
|
-
|
|
|
-
|
|
|
//JSExportAs(redirectKeyset, -(void)jsRedirectKeyset:(NSString*)str);
|
|
|
-
|
|
|
JSExportAs(clearPushMessage, -(void)jsClearPushMessage:(NSString*)type);
|
|
|
|
|
|
|
|
@@ -65,18 +64,22 @@ JSExportAs(aliPay, -(void)jsAliPay:(NSString*)str);
|
|
|
JSExportAs(getOtherPushRid, -(NSString *)jsGetOtherPushRid:(NSString *)str);
|
|
|
JSExportAs(getPhoneBrand, -(NSString *)jsGetPhoneBrand:(NSString *)str);
|
|
|
|
|
|
+//返回省-市
|
|
|
+JSExportAs(getLocation, -(NSString *)jsGetLocation:(NSString *)str);
|
|
|
|
|
|
+//切换底部栏
|
|
|
+JSExportAs(chooseTab, -(void)jsChooseTab:(int)indexTab);
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
-@interface JYSearchViewController ()<UIWebViewDelegate, JYSearchViewControllerJSExport>
|
|
|
+@interface JYSearchViewController ()<UIWebViewDelegate, JYSearchViewControllerJSExport,CLLocationManagerDelegate>
|
|
|
{
|
|
|
CGPoint startTouch;
|
|
|
BOOL _isMoving;
|
|
|
|
|
|
- NSInteger pushIndex;
|
|
|
+ NSInteger pushIndex;//第几个模块过来的
|
|
|
|
|
|
NSInteger _timeTick;
|
|
|
NSInteger _time;
|
|
@@ -84,7 +87,7 @@ JSExportAs(getPhoneBrand, -(NSString *)jsGetPhoneBrand:(NSString *)str);
|
|
|
BOOL autologin;
|
|
|
BOOL notiFinish;
|
|
|
|
|
|
- BOOL expRefreshBool; //实验室 是否刷新
|
|
|
+ BOOL refreshTabBool; //实验室-百宝箱 是否刷新
|
|
|
}
|
|
|
|
|
|
|
|
@@ -103,6 +106,8 @@ JSExportAs(getPhoneBrand, -(NSString *)jsGetPhoneBrand:(NSString *)str);
|
|
|
@property (nonatomic, strong)NSMutableDictionary *notiDict;
|
|
|
@property (nonatomic,weak)NSTimer *timer;
|
|
|
|
|
|
+@property(nonatomic,strong)CLLocationManager *locaationManager;
|
|
|
+@property(nonatomic,strong)NSString *placeAdr;
|
|
|
@end
|
|
|
|
|
|
NSString *const kInitVector_0 = @"1389461544135476";
|
|
@@ -155,12 +160,6 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
|
|
|
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachChanged:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //前往登录通知-tabbar
|
|
|
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isLoginTabBar:) name:@"isLoginTabBar" object:nil];
|
|
|
-
|
|
|
UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(paningGestureReceive:)];
|
|
|
[recognizer delaysTouchesBegan];
|
|
|
[self.view addGestureRecognizer:recognizer];
|
|
@@ -175,14 +174,21 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //新增刷新通知
|
|
|
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshSS:) name:@"refreshSS" object:nil];
|
|
|
|
|
|
- //展示底部红的通知
|
|
|
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newsRedPoint:) name:JYNewsRedPoint object:nil];
|
|
|
|
|
|
|
|
|
+ //前往登录通知-tabbar
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isLoginTabBar:) name:LoginIndexTabBar object:nil];
|
|
|
+ //新增刷新通知
|
|
|
+// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshSS:) name:@"refreshSS" object:nil];
|
|
|
+ //展示底部红的通知
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newsRedPoint:) name:JYNewsRedPoint object:nil];
|
|
|
+ //接收全新通知
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshNonCurVC:) name:RefreshNonCurVC object:nil];
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshAllVC:) name:RefreshAllVC object:nil];
|
|
|
|
|
|
+ //初始化临时属性
|
|
|
+ self.placeAdr = [NSString new];
|
|
|
|
|
|
|
|
|
|
|
@@ -567,80 +573,69 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
|
|
|
|
|
|
}
|
|
|
|
|
|
+//刷新页面相关
|
|
|
+-(void)refreshNonCurVC:(NSNotification *)notificaition{
|
|
|
+ if(self.tabBarController.selectedIndex != 0) {
|
|
|
+ refreshTabBool = YES;
|
|
|
+ [self webViewFirstRequest];
|
|
|
+ }
|
|
|
+}
|
|
|
+-(void)refreshAllVC:(NSNotification *)notificaition{
|
|
|
+ [self webViewFirstRequest];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//前往登录页面
|
|
|
-(void)isLoginTabBar:(NSNotification *)notification
|
|
|
{
|
|
|
NSDictionary *dict = notification.userInfo;
|
|
|
- //
|
|
|
NSLog(@"我从第几个页面过来:%@",dict[@"item_index"]);
|
|
|
pushIndex = [dict[@"item_index"] integerValue];
|
|
|
-
|
|
|
- //
|
|
|
NSString *url = [NSString stringWithFormat:@"%@%@", kHost, @"jyapp/free/login"];
|
|
|
url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
|
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // NSString *index = [NSString stringWithFormat:@"%ld",pushIndex];
|
|
|
- // [[NSNotificationCenter defaultCenter] postNotificationName:@"isLoginTabBar" object:nil userInfo:@{@"item_index":index}];
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//js返回首页
|
|
|
-(void)jsBackUrl:(NSString*)str
|
|
|
{
|
|
|
- NSLog(@"search返回首页,search返回首页,search返回首页,search返回首页,search返回首页,search返回首页");
|
|
|
+ NSLog(@"search返回首页,search返回首页");
|
|
|
if([str isEqualToString:@"H"]) {
|
|
|
pushIndex = 0;
|
|
|
[self webViewFirstRequest];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//js方法登录成功
|
|
|
-(void)jsLoginSuccess:(NSString*)status
|
|
|
{
|
|
|
- NSLog(@"登录成功提示;%@当前下标:%ld",status,(long)pushIndex);
|
|
|
+ NSLog(@"首页登录成功提示");
|
|
|
[GlobalData shareInstance].isReLogin = YES;
|
|
|
if([status isEqualToString:@"S"]) {
|
|
|
if(pushIndex!=0) {
|
|
|
- NSLog(@"SSSSSS");
|
|
|
-
|
|
|
kMainQueue((^{
|
|
|
- NSString *index = [NSString stringWithFormat:@"%ld",(long)pushIndex];
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:@"changeItems" object:nil userInfo:@{@"item_index":index}];
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:RefreshAllVC object:nil userInfo:nil];
|
|
|
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
JYTabBarController *tab = (JYTabBarController *)delegate.window.rootViewController;
|
|
|
tab.selectedIndex = pushIndex;
|
|
|
pushIndex = 0;
|
|
|
}));
|
|
|
}else {
|
|
|
+ NSLog(@"刷新页面------当前页面");
|
|
|
[self webViewFirstRequest];
|
|
|
}
|
|
|
|
|
|
}else if ([status isEqualToString:@""]) {
|
|
|
- //不刷新订阅 首页,刷新其他
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshAllVC" object:nil userInfo:nil];
|
|
|
+ //不刷新订阅-首页,刷新其他
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:RefreshExpAndMine object:nil userInfo:nil];
|
|
|
}else {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
--(void)dealTabBar
|
|
|
-{
|
|
|
- NSLog(@"刷新第一个页面");
|
|
|
- kMainQueue(^{
|
|
|
- [self webViewFirstRequest];
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
- (void)hideTabBar {
|
|
|
NSLog(@"隐藏tabbar");
|
|
|
kMainQueue(^{
|
|
@@ -747,8 +742,8 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
|
|
|
notiFinish = YES;
|
|
|
}
|
|
|
|
|
|
- if(expRefreshBool) {
|
|
|
- expRefreshBool = NO;
|
|
|
+ if(refreshTabBool) {
|
|
|
+ refreshTabBool = NO;
|
|
|
}else {
|
|
|
//正常的网页加载
|
|
|
[self judgeIsHidden];//是否隐藏
|
|
@@ -1201,11 +1196,11 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
|
|
|
//}
|
|
|
|
|
|
//通知刷新页面
|
|
|
--(void)refreshSS:(NSNotification *)notificaition{
|
|
|
-
|
|
|
- expRefreshBool = YES;
|
|
|
- [self webViewFirstRequest];
|
|
|
-}
|
|
|
+//-(void)refreshSS:(NSNotification *)notificaition{
|
|
|
+//
|
|
|
+// refreshTabBool = YES;
|
|
|
+// [self webViewFirstRequest];
|
|
|
+//}
|
|
|
|
|
|
|
|
|
|
|
@@ -1301,7 +1296,7 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
|
|
|
-(NSString *)jsGetOtherPushRid:(NSString *)str
|
|
|
{
|
|
|
NSLog(@"取deviceToken:%@",[LXUserDefaults deviceToken]);
|
|
|
- return [LXUserDefaults deviceToken];;
|
|
|
+ return [LXUserDefaults deviceToken];
|
|
|
}
|
|
|
-(NSString *)jsGetPhoneBrand:(NSString *)str
|
|
|
{
|
|
@@ -1309,11 +1304,139 @@ NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
|
|
|
return device.platformString;
|
|
|
}
|
|
|
|
|
|
+-(void)jsChooseTab:(int)indexTab
|
|
|
+{
|
|
|
+ kMainQueue((^{
|
|
|
+ AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
+ JYTabBarController *tab = (JYTabBarController *)delegate.window.rootViewController;
|
|
|
+ tab.selectedIndex = indexTab;
|
|
|
+ pushIndex = indexTab;
|
|
|
+ }));
|
|
|
+}
|
|
|
+
|
|
|
+//刷新页面方法
|
|
|
+-(void)jsCheckLab:(NSString*)str
|
|
|
+{
|
|
|
+ [[NSNotificationCenter defaultCenter] postNotificationName:RefreshNonCurVC object:nil userInfo:nil];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+//获取定位相关
|
|
|
+-(NSString *)jsGetLocation:(NSString *)str
|
|
|
+{
|
|
|
+ NSLog(@"------开始调用获取位置");
|
|
|
+ // 1.检查定位服务是否开启
|
|
|
+ if ([self checkLocationServiceIsEnabled]) {
|
|
|
+ // 2.创建定位管理器:
|
|
|
+ [self createCLManager];
|
|
|
+ }else{
|
|
|
+ NSLog(@"定位不可用");
|
|
|
+ }
|
|
|
+ NSLog(@"即将返回城市信息-%@",self.placeAdr);
|
|
|
+ return self.placeAdr;
|
|
|
+}
|
|
|
+- (BOOL)checkLocationServiceIsEnabled{
|
|
|
+ // 该方法是类方法,和我们创建的管理器没有关系
|
|
|
+ if ([CLLocationManager locationServicesEnabled]) {
|
|
|
+ return YES;
|
|
|
+ }
|
|
|
+ return NO;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)createCLManager{
|
|
|
+ // 创建CoreLocation管理对象
|
|
|
+ self.locaationManager = [[CLLocationManager alloc]init];
|
|
|
+ // 设定定位精准度
|
|
|
+ [self.locaationManager setDesiredAccuracy:kCLLocationAccuracyBest];
|
|
|
+ // 设定DistanceFilter可以在用户移动指定距离之后触发更新事件(100米更新一次)
|
|
|
+ [self.locaationManager setDistanceFilter:100.f];
|
|
|
+ // 设置代理
|
|
|
+ self.locaationManager.delegate = self;
|
|
|
+ // 开始更新定位
|
|
|
+ [self.locaationManager startUpdatingLocation];
|
|
|
+}
|
|
|
+// 代理方法,更新位置
|
|
|
+- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
|
|
|
+ CLLocation * newLocation = [locations lastObject];
|
|
|
+ // 判空处理
|
|
|
+ if (newLocation.horizontalAccuracy < 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CLGeocoder *geocoder = [[CLGeocoder alloc] init];
|
|
|
+ [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) {
|
|
|
+ for (CLPlacemark *placeMark in placemarks) {
|
|
|
+ //NSLog(@"位置:%@", placeMark.name);
|
|
|
+ //NSLog(@"街道:%@", placeMark.thoroughfare);
|
|
|
+ //NSLog(@"子街道:%@", placeMark.subThoroughfare);
|
|
|
+ //NSLog(@"区\\县:%@", placeMark.subLocality);
|
|
|
+ //NSLog(@"市:%@", placeMark.locality);
|
|
|
+ //NSLog(@"行政区:%@", placeMark.administrativeArea);
|
|
|
+ //NSLog(@"国家:%@", placeMark.country);
|
|
|
+
|
|
|
+ self.placeAdr = [placeMark.administrativeArea stringByAppendingString:[NSString stringWithFormat:@"-%@",placeMark.locality]];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+
|
|
|
+// [self.locaationManager stopUpdatingLocation];
|
|
|
+// self.locaationManager.delegate=nil;
|
|
|
+ // //获取定位经纬度
|
|
|
+ // CLLocationCoordinate2D coor2D = newLocation.coordinate;
|
|
|
+ // NSLog(@"纬度为:%f, 经度为:%f", coor2D.latitude, coor2D.longitude);
|
|
|
+ //
|
|
|
+ // // 获取定位海拔高度
|
|
|
+ // CLLocationDistance altitude = newLocation.altitude;
|
|
|
+ // NSLog(@"高度为:%f", altitude);
|
|
|
+ //
|
|
|
+ // // 获取定位水平精确度, 垂直精确度
|
|
|
+ // CLLocationAccuracy horizontalAcc = newLocation.horizontalAccuracy;
|
|
|
+ // CLLocationAccuracy verticalAcc = newLocation.verticalAccuracy;
|
|
|
+ // NSLog(@"%f, %f", horizontalAcc, verticalAcc);
|
|
|
+}
|
|
|
+
|
|
|
+// 代理方法,定位权限检查
|
|
|
+-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
|
|
|
+ switch (status) {
|
|
|
+ case kCLAuthorizationStatusNotDetermined:{
|
|
|
+ NSLog(@"用户还未决定授权");
|
|
|
+ // 主动获得授权
|
|
|
+ [self.locaationManager requestWhenInUseAuthorization];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case kCLAuthorizationStatusRestricted:
|
|
|
+ {
|
|
|
+ NSLog(@"访问受限");
|
|
|
+ // 主动获得授权
|
|
|
+ [self.locaationManager requestWhenInUseAuthorization];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case kCLAuthorizationStatusDenied:{
|
|
|
+ // 此时使用主动获取方法也不能申请定位权限
|
|
|
+ // 类方法,判断是否开启定位服务
|
|
|
+ if ([CLLocationManager locationServicesEnabled]) {
|
|
|
+ NSLog(@"定位服务开启,被拒绝");
|
|
|
+ } else {
|
|
|
+ NSLog(@"定位服务关闭,不可用");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case kCLAuthorizationStatusAuthorizedAlways:{
|
|
|
+ NSLog(@"获得前后台授权");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case kCLAuthorizationStatusAuthorizedWhenInUse:{
|
|
|
+ NSLog(@"获得前台授权");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|