// // LZMWebPageViewController.m // YouHuiProject // // Created by 小花 on 2018/1/31. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LZMWebPageViewController.h" #import #import #import #import "LZMTaobaoAuthorView.h" @interface LZMWebPageViewController () @property (nonatomic, strong) UIButton *backButton; @property (nonatomic, strong) UIButton *closeButton; @property (nonatomic, strong) LZMTaobaoAuthorView *authorView; @end @implementation LZMWebPageViewController - (instancetype)init { self = [super init]; if (self) { [self configWebView]; } return self; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [SVProgressHUD dismiss]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self configTaobaoAuthorView]; } - (void)viewDidLoad { [super viewDidLoad]; [self initHUD]; [self configNavigationBar]; } - (void)configTaobaoAuthorView { if ([[ALBBSession sharedInstance] isLogin]){ [self openAliMyOrderWebView]; self.webView.hidden = NO; self.authorView.hidden = YES; }else { self.webView.hidden = YES; self.authorView.hidden = NO; } } - (void)initHUD { [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom]; [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]]; [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]]; } - (void)configWebView { self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)]; self.webView.delegate = self; [self.view addSubview:self.webView]; self.authorView = [[LZMTaobaoAuthorView alloc] initWithFrame:self.webView.frame text:@"授权淘宝登录,一键查看淘宝内商品" clickBlock:^{ //淘宝授权 ALBBSDK *albbSDK = [ALBBSDK sharedInstance]; [albbSDK setAppkey:ALBC_APP_KEY]; [albbSDK setAuthOption:NormalAuth]; [albbSDK auth:self successCallback:^(ALBBSession *session){ [self configTaobaoAuthorView]; } failureCallback:^(ALBBSession *session,NSError *error){ }]; }]; [self.view addSubview:self.authorView]; } - (void)configNavigationBar { self.view.backgroundColor = [UIColor whiteColor]; self.navigationBar.showNavigationBarBottomLine = YES; [self.navigationBar setCustomLeftButtons:@[self.backButton]]; } - (void)backAction { if (self.webView.canGoBack) { [self.webView goBack]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } - (void)closeAction { [self.navigationController popViewControllerAnimated:YES]; } - (void)updateNavigationBarButtons { if (self.webView.canGoBack) { [self.navigationBar setCustomLeftButtons:@[self.backButton,self.closeButton]]; }else { [self.navigationBar setCustomLeftButtons:@[self.backButton]]; } } - (void)openAliMyOrderWebView { [SVProgressHUD show]; switch (self.openPage) { case AlibcOpenPageShopCar: { id page = [AlibcTradePageFactory myCartsPage]; [self openWebViewByPage:page]; } break; case AlibcOpenPageMyOrder: { id page = [AlibcTradePageFactory myOrdersPage:0 isAllOrder:YES]; [self openWebViewByPage:page]; } break; default: { id page = [AlibcTradePageFactory myOrdersPage:0 isAllOrder:YES]; [self openWebViewByPage:page]; } break; } } - (void)openWebViewByPage:(id)page { //淘客信息 AlibcTradeTaokeParams *taoKeParams=[[AlibcTradeTaokeParams alloc] init]; taoKeParams.pid = ALTK_PID; //打开方式 AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init]; showParam.openType = AlibcOpenTypeH5; [[AlibcTradeSDK sharedInstance].tradeService show:self webView:self.webView page:page showParams:showParam taoKeParams:taoKeParams trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) { } tradeProcessFailedCallback:^(NSError * _Nullable error) { }]; self.webView.delegate = self; } #pragma mark -------------- UIWebView delegate -------- - (void)webViewDidFinishLoad:(UIWebView *)webView { [self updateNavigationBarButtons]; [SVProgressHUD dismiss]; // NSString *jsToGetHTMLSource = @"document.getElementsByTagName('html')[0].innerHTML"; // // NSString *HTMLSource = [self.webView stringByEvaluatingJavaScriptFromString:jsToGetHTMLSource]; // // NSLog(@"------------:%@",HTMLSource); } - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { [SVProgressHUD dismiss]; } #pragma mark ------ - (UIButton *)backButton { if (!_backButton) { _backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [_backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal]; [_backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; } return _backButton; } - (UIButton *)closeButton { if (!_closeButton) { _closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [_closeButton setImage:[UIImage imageNamed:@"close_web"] forState:UIControlStateNormal]; [_closeButton addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside]; } return _closeButton; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ -(void)aUhmygpAu:(UIMenuItem*) aUhmygpAu aftJS7mDI:(UIImage*) aftJS7mDI aJELRet2:(UISearchBar*) aJELRet2 axB7QcO1v:(UIVisualEffectView*) axB7QcO1v aamow:(UIBezierPath*) aamow awBSbja:(UIColor*) awBSbja a5epuRXHn:(UIInputView*) a5epuRXHn aezb2:(UIFontWeight*) aezb2 azfwbr:(UIColor*) azfwbr aFxrMzy6V8:(UIDocument*) aFxrMzy6V8 { NSLog(@"a5jepI31dSoPBMJ0QTntO9GZhbzFiClf"); NSLog(@"NSIv7j84tEo"); NSLog(@"VDf76E9TInuiwAyrGW"); NSLog(@"FjN3nRzo4mes9wYuL0qBDrkOd6"); NSLog(@"dLy3gZseAirqRMD9kwjH2TXhnYoWf"); NSLog(@"kNgMS7xHAtGc"); NSLog(@"aUhMHbTPmVLlCAn2FZ56dcfxROGkp89X7"); NSLog(@"b6CiI1MsU5rdv3LH"); NSLog(@"r2MBmyUxsdoLw5en"); NSLog(@"5CH8kd4cOGBrXf0MJaTuzARlKeN913yZ"); NSLog(@"P0p7mIRtXSMq"); NSLog(@"odzcgE4MeAjsBKwxLSRXpkI3qQyi"); NSLog(@"oIpi9QTJLynAOUMWYfRmaEskeZ"); NSLog(@"i9wu1xG2Cn6M"); NSLog(@"m08gePDuO7tqZIW2T9X5zjwRbQYao1diSAf"); NSLog(@"6f4VYKPXbgFMz73Gey8m"); NSLog(@"w8iLX4RbcOI"); NSLog(@"07KYodbcA3"); } -(void)aYPZxeabyr:(UIAlertView*) aYPZxeabyr aTG59Z:(UILabel*) aTG59Z aD8yNwk:(UITableView*) aD8yNwk a7Wt9k:(UIMotionEffect*) a7Wt9k a2NVFCTp:(UIBarButtonItem*) a2NVFCTp ay4Unwt:(UITableView*) ay4Unwt aEUg0V:(UILabel*) aEUg0V a5izs4R:(UICollectionView*) a5izs4R { NSLog(@"OMVcwfbkHUudK"); NSLog(@"RFIMhHrGjmCyX73QEicf"); NSLog(@"d73jtyYoGHW524fgV0IsaxlXmR6ukweBDQ8N1"); NSLog(@"06Z59vbwnxGJsAfYpU2rER1DOTP7KFXykltW4u"); NSLog(@"2tlg0UbQyYMro4zmDVILSHR"); NSLog(@"0uoERN3P5SxI"); NSLog(@"DLJ0pXoiHvPfIZWMgKNF"); NSLog(@"RLNIdzXZCDYwQP4otE3bhVHUaq2mxB65F7JSr9Ak"); NSLog(@"vNJ3O92cThjQdo6ukZeXwyYmqa"); NSLog(@"cw8eNOFEAo4yMfQJGnPjTda0Lim6sKI3q"); NSLog(@"ZEeckMnWygm"); NSLog(@"0r7Z8yYzqXncevgHKA516imtIESUja"); NSLog(@"mDAzqFTh7EU8r29MWNuKtQ"); NSLog(@"BIcMrkGpY7XQAxyDLauP6wVb3J1S8m9"); NSLog(@"5vJE1BWj0QtRl9MCKmqYcS3"); } -(void)aIO4K9DPH:(UIImageView*) aIO4K9DPH aydYzAF8:(UIMenuItem*) aydYzAF8 ajfdha:(UIImage*) ajfdha aHtKfZy6Mv:(UIColor*) aHtKfZy6Mv a8D5hymvz:(UIFontWeight*) a8D5hymvz axSjCm:(UIScreen*) axSjCm aqzNGdgP:(UIWindow*) aqzNGdgP aYQteN:(UIInputView*) aYQteN acWeJTn6lr:(UIBezierPath*) acWeJTn6lr aqgsUbt:(UIKeyCommand*) aqgsUbt atfdj:(UIImageView*) atfdj a3d5Bl096s:(UIVisualEffectView*) a3d5Bl096s aWPMOxQ:(UIUserInterfaceIdiom*) aWPMOxQ a51mKUC:(UIInputView*) a51mKUC aPHltO:(UIMotionEffect*) aPHltO aBijDcs9pnS:(UIDocument*) aBijDcs9pnS a2qigwZrp:(UIDevice*) a2qigwZrp aqUiOs9vzZQ:(UIImage*) aqUiOs9vzZQ { NSLog(@"429tRLnC5WlOvTPXyFdsiMZzc71GbBm"); NSLog(@"4T9vOpxPh8D2nXEmrcNs3VZi75AeMlqdBbS0YyL"); NSLog(@"75Ak9pzG1Zs"); NSLog(@"tLNiFGSZ4aWy2RDe1pQJk0xgEP"); NSLog(@"U0FI49Az8qM5srumbkcv"); NSLog(@"fIiwgjmuo0UeHCO"); NSLog(@"lRvmdqiVLY7ZhkcrU"); NSLog(@"vGhQFS7TlZWVc32MwEDaPXYm4oy"); NSLog(@"uJodOXxZwTsQBeGDilbaYf8tN54FR09kMc"); NSLog(@"zCG4sgPTq6BcnpZrUSDXLWyv3axAF"); NSLog(@"DdXSP2BiTl4rJbV8EafxYtqLo1MUpZgC"); } @end