JYSearchViewController.m 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  1. //
  2. // JYSearchViewController.m
  3. // JianYuIOS
  4. //
  5. // Created by apple on 2018/11/8.
  6. // Copyright © 2018年 lixianglan. All rights reserved.
  7. //
  8. #import "JYSearchViewController.h"
  9. #import "JYTabBarController.h"
  10. @protocol JYSearchViewControllerJSExport<JSExport>
  11. JSExportAs(loginByWeixin, -(NSString *)jsLoginByWeixin:(NSString *)str);// 微信登录 openid
  12. JSExportAs(share, -(void)jsShare:(NSString *)type title:(NSString *)title content:(NSString *)content link:(NSString *)link); // 调用分享
  13. JSExportAs(saveUserToken, -(void)jsSaveUserToken:(NSString *)token);// 登录时获取令牌 保存
  14. JSExportAs(getUserToken, -(NSString *)jsGetUserToken:(NSString *)str);// 取本地存的令牌
  15. JSExportAs(removeUserToken, -(void)jsRemoveUserToken:(NSString *)str); // 退出时清空数据
  16. JSExportAs(checkNoticePermission, -(int)jsCheckNoticePermission:(NSString *)str); // 查询手机通知是否打开
  17. JSExportAs(openSystemNotification, -(void)jsOpenSystemNotification:(NSString *)str);// 跳转到系统设置
  18. JSExportAs(getPushRid, -(NSString *)jsGetPushRid:(NSString *)str);// 返回极光id
  19. JSExportAs(getMessageList, -(NSString *)jsGetMessageList:(NSString *)openid);// 按通知接收时间倒排,取前100条
  20. JSExportAs(updateMessageState, -(void)jsUpdateMessageState:(NSString *)lxID state:(NSString *)state);// 更新状态
  21. JSExportAs(deleteMessageById, -(void)jsDeleteMessageById:(NSString *)lxID);// 删除一条消息
  22. JSExportAs(getMessage, -(NSString *)jsGetMessage:(NSString *)lxID);// 取单条数据
  23. JSExportAs(getUnReadMessageCount, -(int)jsGetUnReadMessageCount:(NSString *)openid);// 获取未读消息总数
  24. JSExportAs(updateAllUnReadMessage, -(void)jsUpdateAllUnReadMessage:(NSString *)openid);// 全部置为已读
  25. JSExportAs(lightStatusBar, -(void)jsLightStatusBar:(NSString *)status);// 导航栏文字颜色
  26. JSExportAs(openExternalLink, -(void)jsOpenExternalLink:(NSString *)url title:(NSString *)title);// 打开新控制器 加载新web
  27. JSExportAs(getVersion, -(NSString *)jsGetVersion:(NSString *)str);// 获取当前版本号
  28. JSExportAs(alert, -(void)jsAlert:(NSString *)content);// 弹框
  29. JSExportAs(isInstallWeixin, -(int)jsIsInstallWeixin:(NSString *)str);// 是否安装微信
  30. JSExportAs(changeMessageType, -(void)jsChangeMessageType:(NSString *)link);//已读操作处理
  31. JSExportAs(openActivityPage, -(void)jsOpenActivityPage:(NSString *)url rectype:(NSString *)rectype openid:(NSString *)openid);
  32. JSExportAs(getCipherText, -(NSString *)jsGGetCipherText:(NSString *)phone);
  33. JSExportAs(business, -(NSInteger)jsBusiness:(NSInteger)shooID shopType:(NSInteger )shopType);
  34. //新增
  35. JSExportAs(hiddenBottom, -(void)jsHiddenBottom:(NSString*)hidden);
  36. JSExportAs(loginSuccess, -(void)jsLoginSuccess:(NSString*)status);
  37. JSExportAs(backUrl, -(void)jsBackUrl:(NSString*)str);
  38. JSExportAs(redirectKeyset, -(void)jsRedirectKeyset:(NSString*)str);
  39. @end
  40. @interface JYSearchViewController ()<UIWebViewDelegate, JYSearchViewControllerJSExport>
  41. {
  42. CGPoint startTouch;
  43. BOOL _isMoving;
  44. NSInteger pushIndex;
  45. NSInteger _timeTick;
  46. NSInteger _time;
  47. BOOL autologin;
  48. BOOL notiFinish;
  49. BOOL expRefreshBool; //实验室 是否刷新
  50. }
  51. @property(nonatomic, strong)UIWebView *webView;
  52. //@property (weak, nonatomic) IBOutlet UIWebView *webView;
  53. @property(nonatomic, assign)BOOL updateNotify;
  54. @property(nonatomic, assign)BOOL afterOpenPushMessage;
  55. @property(nonatomic, strong)NoNetView *noNetView;
  56. @property(nonatomic, strong)NSURLRequest *errRequest;
  57. @property(nonatomic, strong)NSString *signOutContent;
  58. @property (nonatomic, strong)NSMutableDictionary *notiDict;
  59. @property (nonatomic,weak)NSTimer *timer;
  60. @end
  61. NSString *const kInitVector_0 = @"1389461544135476";
  62. size_t const kKeySize_0 = kCCKeySizeAES128;
  63. NSString *const AesKey_0 = @"mGlAgnIBB8bx2nch";
  64. @implementation JYSearchViewController
  65. -(void)viewWillAppear:(BOOL)animated
  66. {
  67. [super viewWillAppear:animated];
  68. [self.navigationController setNavigationBarHidden:YES animated:animated];
  69. }
  70. - (void)viewDidLoad {
  71. [super viewDidLoad];
  72. self.view.backgroundColor = [UIColor whiteColor];
  73. self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT-TAB_BAR_HEIGHT+STATUS_BAR_HEIGHT)];
  74. [self.view addSubview: self.webView];
  75. self.webView.scrollView.bounces = NO;
  76. self.webView.delegate = self;
  77. [[LXViewControllerManager shareViewControllerManager] showHudText:nil];
  78. [self webViewFirstRequest];//请求页面数据
  79. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(requestWebView:) name:kRequestWebViewWithUrl object:nil];
  80. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateNotifyState) name:kUpdateNotifyState object:nil];
  81. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(afterReceiveNewMsg) name:kAfterReceiveNewMsg object:nil];
  82. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadWebView) name:kReloadWebVIew object:nil];
  83. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginOut:) name:kLoginOut object:nil];
  84. [[AFNetworkReachabilityManager sharedManager] startMonitoring];
  85. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netReachChanged:) name:AFNetworkingReachabilityDidChangeNotification object:nil];
  86. //前往登录通知-tabbar
  87. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isLoginTabBar:) name:@"isLoginTabBar" object:nil];
  88. UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(paningGestureReceive:)];
  89. [recognizer delaysTouchesBegan];
  90. [self.view addGestureRecognizer:recognizer];
  91. //手势
  92. [self clearWeb];
  93. //新增监听
  94. self.notiDict = [[NSMutableDictionary alloc]initWithDictionary:[[NSUserDefaults standardUserDefaults] objectForKey:@"NotiDict"]];
  95. if(self.notiDict.count) {
  96. self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
  97. }
  98. //新增刷新通知
  99. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshSS:) name:@"refreshSS" object:nil];
  100. }
  101. //2.5.1
  102. -(void)timeFireMethod{
  103. _timeTick++;
  104. NSLog(@"定时器");
  105. if(self.webView&&notiFinish) {
  106. NSString * urlStr = [NSString stringWithFormat:@"%@",self.notiDict[@"url"]];
  107. if (urlStr) {
  108. [[LXViewControllerManager shareViewControllerManager] showHudText:nil];
  109. self.afterOpenPushMessage = YES;
  110. [self performSelector:@selector(requestWebTime:) withObject:self.notiDict afterDelay:1];
  111. [self.timer invalidate];
  112. self.timer = nil;
  113. _timeTick = 0;
  114. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"NotiDict"];
  115. }
  116. return;
  117. }
  118. if (_timeTick == 60) {
  119. [self.timer invalidate];
  120. self.timer = nil;
  121. _timeTick = 0;
  122. [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"NotiDict"];
  123. }
  124. }
  125. -(void)moveViewWithX:(float)x
  126. {
  127. CGRect rect = self.view.bounds;
  128. CGFloat width = CGRectGetWidth(rect);
  129. x = x>width?width:x;
  130. x = x<0?0:x;
  131. CGRect frame = self.webView.frame;
  132. frame.origin.x = x;
  133. self.webView.frame = frame;
  134. }
  135. #pragma mark – Gesture Recognizer –
  136. -(void)paningGestureReceive:(UIPanGestureRecognizer *)recoginzer
  137. {
  138. CGRect rect = self.view.bounds;
  139. CGFloat width = CGRectGetWidth(rect);
  140. if (![self.webView canGoBack]) {
  141. NSLog(@"不可返回");
  142. return;
  143. }
  144. NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
  145. NSLog(@"当前页面:%@",current_url);
  146. if([current_url containsString:@"jyapp/free/login"]) {
  147. return;
  148. }
  149. // NSString *current_url = self.webView.request.URL.absoluteString;
  150. 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]]){
  151. return;
  152. }
  153. //https://www.jianyu360.com/jyapp/free/me
  154. //https://www.jianyu360.com/jyapp/jylab/index
  155. //https://www.jianyu360.com/jyapp/wxkeyset/keyset/index
  156. //https://www.jianyu360.com/jyapp/jylab/mainSearch
  157. CGPoint touchPoint = [recoginzer locationInView:[UIApplication sharedApplication].keyWindow];
  158. if (recoginzer.state==UIGestureRecognizerStateBegan) {
  159. _isMoving = YES;
  160. startTouch = touchPoint;
  161. } else if (recoginzer.state==UIGestureRecognizerStateEnded){
  162. if (touchPoint.x - startTouch.x > width*0.125) {
  163. [UIView animateWithDuration:0.3 animations:^{
  164. [self moveViewWithX:width];
  165. [self.webView goBack];
  166. } completion:^(BOOL finished) {
  167. _isMoving = NO;
  168. [self moveViewWithX:0];
  169. }];
  170. } else {
  171. [UIView animateWithDuration:0.3 animations:^{
  172. [self moveViewWithX:0];
  173. } completion:^(BOOL finished) {
  174. _isMoving = NO;
  175. }];
  176. }
  177. return;
  178. } else if (recoginzer.state==UIGestureRecognizerStateCancelled){
  179. [UIView animateWithDuration:0.3 animations:^{
  180. [self moveViewWithX:0];
  181. } completion:^(BOOL finished) {
  182. _isMoving = NO;
  183. }];
  184. return;
  185. }
  186. if (_isMoving) {
  187. [self moveViewWithX:touchPoint.x - startTouch.x];
  188. }
  189. }
  190. // 监控网络状态变化
  191. -(void)netReachChanged:(NSNotification *)notificaition{
  192. NSDictionary *userInfo = notificaition.userInfo;
  193. if ([userInfo[@"AFNetworkingReachabilityNotificationStatusItem"] intValue] == 0 || [userInfo[@"AFNetworkingReachabilityNotificationStatusItem"] intValue] == -1) {
  194. [self addNoNetViews];
  195. }else{
  196. if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"firstLoad"] intValue] == 0) {
  197. [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"firstLoad"];
  198. [self removeNoNetViews];
  199. [self webViewFirstRequest];
  200. }
  201. }
  202. }
  203. // 再次加载页面
  204. -(void)reloadWebView{
  205. [[LXViewControllerManager shareViewControllerManager] showHudText:nil];
  206. if (!self.webView.canGoBack) {
  207. [self webViewFirstRequest];
  208. }else{
  209. [self.webView reload];
  210. }
  211. }
  212. // 首次加载web
  213. -(void)webViewFirstRequest{
  214. NSString *url = [NSString stringWithFormat:@"%@%@", kHost, @"jyapp/free/index"];
  215. NSString *token = [LXUserDefaults token];
  216. if (token) {
  217. url = [url stringByAppendingString:[NSString stringWithFormat:@"?sign=%@&url=/jyapp/jylab/mainSearch&from=restart", token]];
  218. }
  219. NSLog(@"111第一次加载%@",url);
  220. url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
  221. kMainQueue(^{
  222. [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
  223. })
  224. }
  225. //收到消息退出并重新加载web
  226. -(void)webViewRequestByMsg{
  227. // NSString *url = [NSString stringWithFormat:@"%@%@", kHost, @"jyapp/free/kicked"];
  228. NSString *url = [NSString stringWithFormat:@"%@%@", kHost, @"jyapp/free/login?back=index&isios=t"];
  229. url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
  230. [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
  231. }
  232. -(void)requestWebTime:(NSDictionary *)infoDict
  233. {
  234. NSString * urlStr = [NSString stringWithFormat:@"%@",infoDict[@"url"]];
  235. if([infoDict[@"type"] isEqualToString:@"message"]) {
  236. NSString *url = [NSString stringWithFormat:@"%@",urlStr];
  237. NSArray * array = [url componentsSeparatedByString:@"=="];
  238. url = [array.firstObject stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
  239. [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
  240. [[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
  241. //
  242. }else {
  243. NSString *url = [NSString stringWithFormat:@"%@%@", kHost, urlStr];
  244. url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
  245. [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
  246. [[NSNotificationCenter defaultCenter] postNotificationName:@"kNewWebControllerDismiss" object:nil];
  247. }
  248. }
  249. // 点击通知 跳转到通知内url
  250. -(void)requestWebView:(NSNotification *)notification{
  251. NSDictionary * infoDict = [notification object];
  252. if (!infoDict) {
  253. return;
  254. }
  255. NSString * urlStr = [NSString stringWithFormat:@"%@",infoDict[@"url"]];
  256. if (urlStr) {
  257. //当前控制器
  258. if(self.tabBarController.selectedIndex != 0) {
  259. return;
  260. }else {
  261. [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshMine" object:nil];;
  262. }
  263. [[LXViewControllerManager shareViewControllerManager] showHudText:nil];
  264. self.afterOpenPushMessage = YES;
  265. [self performSelector:@selector(requestWebTime:) withObject:infoDict afterDelay:1];
  266. }
  267. }
  268. // 收到通知消息
  269. -(void)afterReceiveNewMsg{
  270. NSLog(@"afterReceiveNewMsg");
  271. JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
  272. [context evaluateScript:@"afterReceiveNewMsg()"];
  273. }
  274. // 收到退出登录消息
  275. -(void)loginOut:(NSNotification *)notification{
  276. if([notification.userInfo[@"item_index"] integerValue]!=0) {
  277. return;
  278. }
  279. self.signOutContent = notification.object;
  280. if (!self.signOutContent) {
  281. self.signOutContent = @"1";
  282. }
  283. NSString *url = [NSString stringWithFormat:@"%@%@?sign=%@", kHost, @"jyapp/free/signOut", [LXUserDefaults token]];
  284. url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
  285. // UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
  286. // webView.delegate = self;
  287. // [self.view addSubview:webView];
  288. // [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
  289. [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
  290. [self jsRemoveUserToken:nil];
  291. }
  292. //前往登录页面
  293. -(void)isLoginTabBar:(NSNotification *)notification
  294. {
  295. NSDictionary *dict = notification.userInfo;
  296. //
  297. NSLog(@"我从第几个页面过来:%@",dict[@"item_index"]);
  298. pushIndex = [dict[@"item_index"] integerValue];
  299. //
  300. NSString *url = [NSString stringWithFormat:@"%@%@", kHost, @"jyapp/free/login"];
  301. url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
  302. [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
  303. // NSString *index = [NSString stringWithFormat:@"%ld",pushIndex];
  304. // [[NSNotificationCenter defaultCenter] postNotificationName:@"isLoginTabBar" object:nil userInfo:@{@"item_index":index}];
  305. }
  306. //js返回首页
  307. -(void)jsBackUrl:(NSString*)str
  308. {
  309. NSLog(@"search返回首页,search返回首页,search返回首页,search返回首页,search返回首页,search返回首页");
  310. if([str isEqualToString:@"H"]) {
  311. pushIndex = 0;
  312. [self webViewFirstRequest];
  313. }
  314. }
  315. //js方法登录成功
  316. -(void)jsLoginSuccess:(NSString*)status
  317. {
  318. NSLog(@"Search登录成功提示;;;%@当前下标:%ld",status,(long)pushIndex);
  319. //显示
  320. kMainQueue(^{
  321. [self.tabBarController.tabBar showBadgeOnItemIndex:3];
  322. });
  323. if([status isEqualToString:@"S"]) {
  324. if(pushIndex!=0) {
  325. NSLog(@"SSSSSS");
  326. kMainQueue((^{
  327. NSString *index = [NSString stringWithFormat:@"%ld",pushIndex];
  328. [[NSNotificationCenter defaultCenter] postNotificationName:@"changeItems" object:nil userInfo:@{@"item_index":index}];
  329. AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  330. JYTabBarController *tab = (JYTabBarController *)delegate.window.rootViewController;
  331. tab.selectedIndex = pushIndex;
  332. pushIndex = 0;
  333. }));
  334. }else {
  335. [self webViewFirstRequest];
  336. }
  337. }else if ([status isEqualToString:@""]) {
  338. //手动tabbar点击
  339. NSLog(@"statusstatusstatusstatusstatusstatusstatusstatusstatusstatus=======%@",status);
  340. // NSString *index = [NSString stringWithFormat:@"%ld",pushIndex];
  341. // [[NSNotificationCenter defaultCenter] postNotificationName:@"changeItems" object:nil userInfo:@{@"item_index":index}];
  342. // pushIndex = 0;
  343. //刷新 订阅 和 我的
  344. [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshAllVC" object:nil userInfo:nil];
  345. //首页跳转登录刷新 我们+订阅
  346. }else {
  347. }
  348. }
  349. -(void)dealTabBar
  350. {
  351. NSLog(@"刷新第一个页面");
  352. kMainQueue(^{
  353. // [self showTabBar];
  354. // self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT-TAB_BAR_HEIGHT+STATUS_BAR_HEIGHT);
  355. [self webViewFirstRequest];
  356. });
  357. }
  358. - (void)hideTabBar {
  359. NSLog(@"隐藏tabbar");
  360. kMainQueue(^{
  361. if (self.tabBarController.tabBar.hidden == YES) {
  362. return;
  363. }
  364. UIView *contentView;
  365. if ( [[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
  366. contentView = [self.tabBarController.view.subviews objectAtIndex:1];
  367. else
  368. contentView = [self.tabBarController.view.subviews objectAtIndex:0];
  369. 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);
  370. self.tabBarController.tabBar.hidden = YES;
  371. });
  372. }
  373. - (void)showTabBar{
  374. kMainQueue(^{
  375. if (self.tabBarController.tabBar.hidden == NO)
  376. {
  377. return;
  378. }
  379. UIView *contentView;
  380. if ([[self.tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]])
  381. contentView = [self.tabBarController.view.subviews objectAtIndex:1];
  382. else
  383. contentView = [self.tabBarController.view.subviews objectAtIndex:0];
  384. 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);
  385. self.tabBarController.tabBar.hidden = NO;
  386. });
  387. }
  388. -(void)jsHiddenBottom:(NSString *)hidden
  389. {
  390. NSLog(@"让我展示隐藏bottom==%@",hidden);
  391. if([hidden integerValue]==0) {
  392. [self hideTabBar];
  393. kMainQueue(^{
  394. self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT+STATUS_BAR_HEIGHT);
  395. });
  396. }else {
  397. [self showTabBar];
  398. kMainQueue(^{
  399. self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT-TAB_BAR_HEIGHT+STATUS_BAR_HEIGHT);
  400. });
  401. }
  402. }
  403. -(void)judgeIsHidden
  404. {
  405. NSString *current_url = [self.webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
  406. //[current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/free/index",kHost]]
  407. NSLog(@"%@",current_url);
  408. if([current_url isEqualToString:[NSString stringWithFormat:@"%@jyapp/jylab/mainSearch",kHost]]){
  409. NSLog(@"展示");
  410. [self showTabBar];
  411. self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT-TAB_BAR_HEIGHT+STATUS_BAR_HEIGHT);
  412. }else {
  413. NSLog(@"隐藏");
  414. [self hideTabBar];
  415. self.webView.frame = CGRectMake(0, -STATUS_BAR_HEIGHT, WIDTH, HEIGHT+STATUS_BAR_HEIGHT);
  416. }
  417. }
  418. #pragma mark 捕获js中调用的方法
  419. //捕获js中调用的方法
  420. - (void)webViewDidFinishLoad:(UIWebView *)webView{
  421. if(!notiFinish) {
  422. notiFinish = YES;
  423. }
  424. if(expRefreshBool) {
  425. expRefreshBool = NO;
  426. }else {
  427. //正常的网页加载
  428. [self judgeIsHidden];//是否隐藏
  429. }
  430. [self removeNoNetViews];
  431. [[LXViewControllerManager shareViewControllerManager] hideHud];
  432. JSContext *context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
  433. // Disable user selection
  434. [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
  435. // Disable callout
  436. [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
  437. context[@"JyObj"] = self;
  438. [context evaluateScript:@"afterPageInit()"];
  439. if (self.afterOpenPushMessage) {
  440. self.afterOpenPushMessage = NO;
  441. // [context evaluateScript:@"afterOpenPushMessage()"];
  442. [context evaluateScript:[NSString stringWithFormat:@"afterOpenPushMessage('%d')", [self jsIsCanBack:nil]]];
  443. }
  444. NSString *url = webView.request.URL.absoluteString;
  445. [self doSomeWithLoadUrl:url];
  446. //加载第一次成功的时候 调JS
  447. // if(!autologin&&[LXUserDefaults token]) {
  448. // autologin = YES;
  449. // NSString *textJS = [NSString stringWithFormat:@"refAutoLogin('%@')",@"S"];
  450. // JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
  451. // [context evaluateScript:textJS];
  452. // }
  453. if(!autologin) {
  454. //第一次加载页面成功
  455. if([LXUserDefaults token]) {
  456. //如果登录
  457. NSString *textJS = [NSString stringWithFormat:@"refAutoLogin('%@')",@"S"];
  458. JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
  459. [context evaluateScript:textJS];
  460. }
  461. autologin = YES;
  462. }
  463. }
  464. //15737190152
  465. -(void)doSomeWithLoadUrl:(NSString *)url{
  466. if (!url) {
  467. return;
  468. }
  469. if ([url containsString:@"signOut"]) { // 收到退出消息后 跳转到登录页面
  470. // [self webViewFirstRequest];
  471. [self webViewRequestByMsg];
  472. }else if ([url containsString:@"/free/login"]){ // 如果通过接收消息 跳转到登录页面 展示消息内容
  473. if (self.signOutContent && ![self.signOutContent isEqualToString:@"1"]) {
  474. [[LXViewControllerManager shareViewControllerManager] showAlertViewWithTitle:@"提示" message:self.signOutContent actions:@[[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  475. self.signOutContent = nil;
  476. }]]];
  477. }else{
  478. self.signOutContent = nil;
  479. }
  480. }
  481. }
  482. -(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
  483. [[LXViewControllerManager shareViewControllerManager] hideHud];
  484. NSString *url = webView.request.URL.absoluteString;
  485. [self doSomeWithLoadUrl:url];
  486. }
  487. -(void)webViewDidStartLoad:(UIWebView *)webView{
  488. // if ([[UIDevice currentDevice].systemVersion floatValue] < 10) {
  489. // [[LXViewControllerManager shareViewControllerManager] hideHud];
  490. // }
  491. }
  492. - (void)didReceiveMemoryWarning {
  493. [super didReceiveMemoryWarning];
  494. [self clearWeb];
  495. // Dispose of any resources that can be recreated.
  496. }
  497. -(void)clearWeb{
  498. NSURLCache * cache = [NSURLCache sharedURLCache];
  499. [cache removeAllCachedResponses];
  500. [cache setDiskCapacity:0];
  501. [cache setMemoryCapacity:0];
  502. }
  503. -(void)addNoNetViews{
  504. kMainQueue(^{
  505. [self removeNoNetViews];
  506. self.noNetView = [NoNetView shareView];
  507. [self.view addSubview:self.noNetView];
  508. });
  509. }
  510. -(void)removeNoNetViews{
  511. if (self.noNetView ) {
  512. [self.noNetView removeFromSuperview];
  513. self.noNetView = nil;
  514. }
  515. }
  516. #pragma mark JS 回调
  517. // 微信登录
  518. -(NSString *)jsLoginByWeixin:(NSString *)str{
  519. if ([LXUserDefaults isInstallWeiXin] != 1) { // 没有安装微信 不走友盟
  520. [[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"微信登录失败,没有安装微信" delay:1.5];
  521. return nil;
  522. }
  523. kMainQueue(^{
  524. [[UMSocialManager defaultManager] getUserInfoWithPlatform:UMSocialPlatformType_WechatSession currentViewController:self completion:^(id result, NSError *error) {
  525. UMSocialUserInfoResponse *resp = result;
  526. [self dealWXDic:(NSDictionary *)resp.originalResponse];
  527. [[LXViewControllerManager shareViewControllerManager] hideHud];
  528. }];
  529. });
  530. return nil;
  531. }
  532. // 处理微信登录获取到的数据
  533. -(void)dealWXDic:(NSDictionary *)dictionary{
  534. [[LXViewControllerManager shareViewControllerManager] showHudText:nil];
  535. //如果获取到用户信息,即用户点击了“登录”,则进行用户信息获取
  536. if (dictionary.count > 0) {
  537. NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:dictionary];
  538. if (dic) {
  539. [dic removeObjectForKey:@"privilege"];
  540. [dic removeObjectForKey:@"language"];
  541. double currDouble = [[NSDate date] timeIntervalSince1970];
  542. [dic setObject:[NSNumber numberWithLong:(long)currDouble] forKey:@"createtime"];
  543. // 拼接标志位
  544. 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"]];
  545. sign = [LXMD5 md532BitLower:sign];
  546. [dic setObject:sign forKey:@"sign"];
  547. NSString *endStr = [[LXViewControllerManager shareViewControllerManager] getJsonStr:dic];
  548. NSData *data = [endStr dataUsingEncoding:NSUTF8StringEncoding];
  549. endStr = [data base64EncodedStringWithOptions:0];
  550. JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
  551. NSString * textJS1 = [NSString stringWithFormat:@"loginByWeixinCallBack('%@')", endStr];
  552. JSValue *value = [context evaluateScript:textJS1];
  553. NSLog(@"%@", value);
  554. }
  555. }
  556. }
  557. // js 调用分享
  558. -(void)jsShare:(NSString *)type title:(NSString *)title content:(NSString *)content link:(NSString *)link{
  559. UMSocialPlatformType shareType;
  560. if ([type intValue] == 1) { // 微信好友
  561. shareType = UMSocialPlatformType_WechatSession;
  562. }else if ([type intValue] == 2){ /// qq好友
  563. shareType = UMSocialPlatformType_QQ;
  564. }else if ([type intValue] == 3){ // 朋友圈
  565. shareType = UMSocialPlatformType_WechatTimeLine;
  566. }else{
  567. shareType = UMSocialPlatformType_WechatSession;
  568. }
  569. kMainQueue((^{
  570. // 没有安装app 不走分享逻辑
  571. if ([type intValue] == 1 || [type intValue] == 3) {
  572. if ([LXUserDefaults isInstallWeiXin] != 1) {
  573. [[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"没有安装微信" delay:1.5];
  574. return;
  575. }
  576. }
  577. // 没有安装app 不走分享逻辑
  578. if ([type intValue] == 2) {
  579. if (![[UMSocialManager defaultManager] isInstall:UMSocialPlatformType_QQ]) {
  580. [[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"没有安装QQ" delay:1.5];
  581. return;
  582. }
  583. }
  584. //创建分享消息对象
  585. UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
  586. //创建网页内容对象
  587. UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:title descr:content thumImage:[UIImage imageNamed:@"logo"]];
  588. //设置网页地址
  589. shareObject.webpageUrl = link;
  590. messageObject.shareObject = shareObject;
  591. //调用分享接口
  592. [[UMSocialManager defaultManager] shareToPlatform:shareType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
  593. if (error) {
  594. NSLog(@"22222222%@",error.userInfo);
  595. if (error.userInfo[@"message"] && [error.userInfo[@"message"] containsString:@"Operation is cancel"]) {
  596. [[LXViewControllerManager shareViewControllerManager] showHudOnlyText:@"取消分享" delay:1];
  597. }else{
  598. [[LXViewControllerManager shareViewControllerManager] showHudOnlyText:error.userInfo[@"message"] delay:1];
  599. }
  600. NSString *textJS = [NSString stringWithFormat:@"shareCallBack('%@','%@')",type,@"0"];
  601. JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
  602. [context evaluateScript:textJS];
  603. }else{
  604. if ([data isKindOfClass:[UMSocialShareResponse class]]) {
  605. UMSocialShareResponse *resp = data;
  606. NSLog(@"33333%@",resp.message);
  607. NSLog(@"44444%@",resp.originalResponse);
  608. NSString *textJS = [NSString stringWithFormat:@"shareCallBack('%@','%@')",type,@"1"];
  609. JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
  610. [context evaluateScript:textJS];
  611. }else{
  612. UMSocialLogInfo(@"response data is %@",data);
  613. NSLog(@"55555%@",data);
  614. }
  615. }
  616. }];
  617. }));
  618. }
  619. // 登录时获取到令牌 并保存
  620. -(void)jsSaveUserToken:(NSString *)token{
  621. NSLog(@"登陆成功");
  622. [[LXViewControllerManager shareViewControllerManager] hideHud];
  623. [LXUserDefaults saveToken:token];
  624. }
  625. // 取本地的用户令牌
  626. -(NSString *)jsGetUserToken:(NSString *)str{
  627. NSLog(@"取用户token");
  628. return [LXUserDefaults token];
  629. }
  630. // 退出时 清空用户数据
  631. -(void)jsRemoveUserToken:(NSString *)str{
  632. NSLog(@"清除用户token");
  633. [LXUserDefaults clearAll];
  634. // [[LXDataBaseManager shareDataBaseManager] clearAll];
  635. }
  636. // 手机通知权限是否打开
  637. -(int)jsCheckNoticePermission:(NSString *)str{
  638. int a = [LXUserDefaults notifyState];
  639. return a;
  640. }
  641. // 跳转到系统设置
  642. -(void)jsOpenSystemNotification:(NSString *)str{
  643. self.updateNotify = YES;
  644. kMainQueue(^{
  645. [[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
  646. });
  647. }
  648. // 调用js方法 刷新推送权限状态
  649. -(void)updateNotifyState{
  650. if (self.updateNotify) {
  651. self.updateNotify = NO;
  652. JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
  653. NSString * textJS1 = [NSString stringWithFormat:@"updateNoticeSwitch()"];
  654. [context evaluateScript:textJS1];
  655. }
  656. }
  657. // 获取推送id
  658. -(NSString *)jsGetPushRid:(NSString *)str{
  659. return [LXUserDefaults registrationID];
  660. }
  661. // 按通知取数据
  662. -(NSString *)jsGetMessageList:(NSString *)openid{
  663. NSArray *arr = [[LXDataBaseManager shareDataBaseManager] getMessageWithKey:nil openid:openid fromTable:kNewsTable start:0 length:100];
  664. if (arr.count > 0) {
  665. return [[LXViewControllerManager shareViewControllerManager] getJsonStr:arr];
  666. }
  667. return @"";
  668. }
  669. // 更新消息状态
  670. -(void)jsUpdateMessageState:(NSNumber *)lxID state:(NSNumber *)state{
  671. [[LXDataBaseManager shareDataBaseManager] changeReadedWithID:lxID state:state];
  672. }
  673. // 删除一条数据
  674. -(void)jsDeleteMessageById:(NSNumber *)lxID{
  675. [[LXDataBaseManager shareDataBaseManager] deleteMessage:lxID fromTable:kNewsTable];
  676. }
  677. // 取单条数据
  678. -(NSString *)jsGetMessage:(NSString *)lxID{
  679. return [[LXViewControllerManager shareViewControllerManager] getJsonStr:[[LXDataBaseManager shareDataBaseManager] getMessageWithKey:lxID openid:nil fromTable:kNewsTable start:0 length:0]];
  680. }
  681. // 取未读消息总数
  682. -(int)jsGetUnReadMessageCount:(NSString *)openid{
  683. NSLog(@"openid=%@",openid);
  684. // NSLog(@"%d",[[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid]);
  685. if([[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid] ==0){
  686. //显示
  687. kMainQueue(^{
  688. [self.tabBarController.tabBar hideBadgeOnItemIndex:3];
  689. });
  690. }else {
  691. kMainQueue(^{
  692. [self.tabBarController.tabBar showBadgeOnItemIndex:3];
  693. });
  694. }
  695. return [[LXDataBaseManager shareDataBaseManager] getUnReadMessageCount:openid];
  696. }
  697. // 全部置为已读
  698. -(void)jsUpdateAllUnReadMessage:(NSString *)openid{
  699. [[LXDataBaseManager shareDataBaseManager] updateAllUnReadMessage:openid];
  700. }
  701. // 改变状态栏文字颜色
  702. -(void)jsLightStatusBar:(NSString *)status{
  703. kMainQueue(^{
  704. NSInteger index = 0;
  705. if ([status intValue] == 1) {
  706. index = 1;// hei
  707. }else{
  708. index = 0;// bai
  709. }
  710. [[UIApplication sharedApplication] setStatusBarStyle:index];
  711. });
  712. }
  713. // 打开新页面 加载新web
  714. -(void)jsOpenExternalLink:(NSString *)url title:(NSString *)title{
  715. if (url) {
  716. if ([AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusNotReachable || [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus == AFNetworkReachabilityStatusUnknown) {
  717. // [self addNoNetViews];
  718. }
  719. NewWebController *ctr = [[NewWebController alloc] init];
  720. ctr.url = url;
  721. // 有title的话 会显示自定义的导航栏 没有的话不显示导航栏 显示加载进度条
  722. if (!title || [title isEqualToString:@""] || [title isEqualToString:@"undefined"]) {
  723. ctr.titleShow = nil;
  724. }else{
  725. ctr.titleShow = title;
  726. }
  727. kMainQueue(^{
  728. [self presentViewController:ctr animated:NO completion:nil];
  729. });
  730. }
  731. }
  732. // 获取当前版本号
  733. -(NSString *)jsGetVersion:(NSString *)str{
  734. return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
  735. }
  736. // web是否可退回上页面
  737. -(int)jsIsCanBack:(NSString *)str{
  738. return self.webView.canGoBack ? 1:0;
  739. }
  740. // 弹框
  741. -(void)jsAlert:(NSString *)content{
  742. [[LXViewControllerManager shareViewControllerManager] showAlertViewWithMessage:content];
  743. }
  744. // 是否安装微信
  745. -(int)jsIsInstallWeixin:(NSString *)str{
  746. return [LXUserDefaults isInstallWeiXin];
  747. }
  748. -(void)jsChangeMessageType:(NSString *)link
  749. {
  750. //已读操作处理
  751. NSLog(@"已读操作处理-更改");
  752. [[LXDataBaseManager shareDataBaseManager] changeCatagoryTypeWithURL:link];
  753. }
  754. -(void)jsOpenActivityPage:(NSString *)url rectype:(NSString *)rectype openid:(NSString *)openid
  755. {
  756. NSDictionary * infoDic = @{@"url":url,
  757. @"rectype":rectype,
  758. @"openid":openid,
  759. };
  760. // NSString *textJS = [NSString stringWithFormat:@"messageAccept('%@','%@','%@')",infoDic[@"mid"],infoDic[@"rectype"],infoDic[@"openid"]];
  761. // JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
  762. // [context evaluateScript:textJS];
  763. //post请求
  764. NSLog(@"%@",[NSString stringWithFormat:@"%@jyapp/free/message/receive",kHost]);
  765. [[LXNetworkManager shareLXNetworkManager]postWithURLStr:[NSString stringWithFormat:@"%@jyapp/free/message/receive",kHost] parameters:infoDic progress:^(NSProgress *progress) {
  766. NSLog(@"成功:%@",progress);
  767. } success:^(id responseObject) {
  768. NSLog(@"responseObject=%@",responseObject);
  769. } failure:^(NSError *error) {
  770. NSLog(@"error=%@",error);
  771. }];
  772. }
  773. -(NSString *)jsGGetCipherText:(NSString *)phone
  774. {
  775. NSDate *date=[NSDate date];
  776. NSDateFormatter *format1=[[NSDateFormatter alloc] init];
  777. [format1 setDateFormat:@"yyyyMMddhhmmss"];
  778. NSString *dateStr;
  779. dateStr=[format1 stringFromDate:date];
  780. NSLog(@"%@",dateStr);
  781. NSString *content = [[NSString stringWithFormat:@"%@_%@",phone,dateStr] stringByAppendingString:[NSString stringWithFormat:@"_%@",[LXMD5 md532BitLower:[NSString stringWithFormat:@"%@&%@",phone,dateStr]]]];
  782. NSData *contentData = [content dataUsingEncoding:NSUTF8StringEncoding];
  783. NSUInteger dataLength = contentData.length;
  784. // 为结束符'\\0' +1
  785. char keyPtr[kKeySize_0 + 1];
  786. memset(keyPtr, 0, sizeof(keyPtr));
  787. [AesKey_0 getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
  788. // 密文长度 <= 明文长度 + BlockSize
  789. size_t encryptSize = dataLength + kCCBlockSizeAES128;
  790. void *encryptedBytes = malloc(encryptSize);
  791. size_t actualOutSize = 0;
  792. NSData *initVector = [kInitVector_0 dataUsingEncoding:NSUTF8StringEncoding];
  793. CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt,
  794. kCCAlgorithmAES,
  795. kCCOptionPKCS7Padding, // 系统默认使用 CBC,然后指明使用 PKCS7Padding
  796. keyPtr,
  797. kKeySize_0,
  798. initVector.bytes,
  799. contentData.bytes,
  800. dataLength,
  801. encryptedBytes,
  802. encryptSize,
  803. &actualOutSize);
  804. if (cryptStatus == kCCSuccess) {
  805. // 对加密后的数据进行 base64 编码
  806. return [[NSData dataWithBytesNoCopy:encryptedBytes length:actualOutSize] base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
  807. }
  808. free(encryptedBytes);
  809. return nil;
  810. }
  811. -(void)jsRedirectKeyset:(NSString*)str
  812. {
  813. [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshDY" object:nil userInfo:nil];
  814. [self performSelector:@selector(nextVC) withObject:nil afterDelay:0.5];
  815. }
  816. -(void)nextVC
  817. {
  818. AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  819. JYTabBarController *tab = (JYTabBarController *)delegate.window.rootViewController;
  820. tab.selectedIndex = 1;
  821. [self webViewFirstRequest];
  822. }
  823. //通知刷新页面
  824. -(void)refreshSS:(NSNotification *)notificaition{
  825. expRefreshBool = YES;
  826. [self webViewFirstRequest];
  827. }
  828. /*
  829. #pragma mark - Navigation
  830. // In a storyboard-based application, you will often want to do a little preparation before navigation
  831. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  832. // Get the new view controller using [segue destinationViewController].
  833. // Pass the selected object to the new view controller.
  834. }
  835. */
  836. @end