两折买改口袋样式

LZMWebPageViewController.m 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. //
  2. // LZMWebPageViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/1/31.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LZMWebPageViewController.h"
  9. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  10. #import <AlibabaAuthSDK/ALBBSession.h>
  11. #import <AlibabaAuthSDK/ALBBSDK.h>
  12. #import "LZMTaobaoAuthorView.h"
  13. @interface LZMWebPageViewController ()<UIWebViewDelegate>
  14. @property (nonatomic, strong) UIButton *backButton;
  15. @property (nonatomic, strong) UIButton *closeButton;
  16. @property (nonatomic, strong) LZMTaobaoAuthorView *authorView;
  17. @end
  18. @implementation LZMWebPageViewController
  19. - (instancetype)init {
  20. self = [super init];
  21. if (self) {
  22. [self configWebView];
  23. }
  24. return self;
  25. }
  26. - (void)viewWillDisappear:(BOOL)animated {
  27. [super viewWillDisappear:animated];
  28. [SVProgressHUD dismiss];
  29. }
  30. - (void)viewWillAppear:(BOOL)animated {
  31. [super viewWillAppear:animated];
  32. [self configTaobaoAuthorView];
  33. }
  34. - (void)viewDidLoad {
  35. [super viewDidLoad];
  36. [self initHUD];
  37. [self configNavigationBar];
  38. }
  39. - (void)configTaobaoAuthorView {
  40. if ([[ALBBSession sharedInstance] isLogin]){
  41. [self openAliMyOrderWebView];
  42. self.webView.hidden = NO;
  43. self.authorView.hidden = YES;
  44. }else {
  45. self.webView.hidden = YES;
  46. self.authorView.hidden = NO;
  47. }
  48. }
  49. - (void)initHUD {
  50. [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
  51. [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]];
  52. [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]];
  53. }
  54. - (void)configWebView {
  55. self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
  56. self.webView.delegate = self;
  57. [self.view addSubview:self.webView];
  58. self.authorView = [[LZMTaobaoAuthorView alloc] initWithFrame:self.webView.frame text:@"授权淘宝登录,一键查看淘宝内商品" clickBlock:^{
  59. //淘宝授权
  60. ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
  61. [albbSDK setAppkey:ALBC_APP_KEY];
  62. [albbSDK setAuthOption:NormalAuth];
  63. [albbSDK auth:self successCallback:^(ALBBSession *session){
  64. [self configTaobaoAuthorView];
  65. } failureCallback:^(ALBBSession *session,NSError *error){
  66. }];
  67. }];
  68. [self.view addSubview:self.authorView];
  69. }
  70. - (void)configNavigationBar {
  71. self.view.backgroundColor = [UIColor whiteColor];
  72. self.navigationBar.showNavigationBarBottomLine = YES;
  73. [self.navigationBar setCustomLeftButtons:@[self.backButton]];
  74. }
  75. - (void)backAction {
  76. if (self.webView.canGoBack) {
  77. [self.webView goBack];
  78. }else{
  79. [self.navigationController popViewControllerAnimated:YES];
  80. }
  81. }
  82. - (void)closeAction {
  83. [self.navigationController popViewControllerAnimated:YES];
  84. }
  85. - (void)updateNavigationBarButtons {
  86. if (self.webView.canGoBack) {
  87. [self.navigationBar setCustomLeftButtons:@[self.backButton,self.closeButton]];
  88. }else {
  89. [self.navigationBar setCustomLeftButtons:@[self.backButton]];
  90. }
  91. }
  92. - (void)openAliMyOrderWebView {
  93. [SVProgressHUD show];
  94. switch (self.openPage) {
  95. case AlibcOpenPageShopCar:
  96. {
  97. id<AlibcTradePage> page = [AlibcTradePageFactory myCartsPage];
  98. [self openWebViewByPage:page];
  99. }
  100. break;
  101. case AlibcOpenPageMyOrder:
  102. {
  103. id<AlibcTradePage> page = [AlibcTradePageFactory myOrdersPage:0 isAllOrder:YES];
  104. [self openWebViewByPage:page];
  105. }
  106. break;
  107. default:
  108. {
  109. id<AlibcTradePage> page = [AlibcTradePageFactory myOrdersPage:0 isAllOrder:YES];
  110. [self openWebViewByPage:page];
  111. }
  112. break;
  113. }
  114. }
  115. - (void)openWebViewByPage:(id<AlibcTradePage>)page {
  116. //淘客信息
  117. AlibcTradeTaokeParams *taoKeParams=[[AlibcTradeTaokeParams alloc] init];
  118. taoKeParams.pid = ALTK_PID;
  119. //打开方式
  120. AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
  121. showParam.openType = AlibcOpenTypeH5;
  122. [[AlibcTradeSDK sharedInstance].tradeService show:self webView:self.webView page:page showParams:showParam taoKeParams:taoKeParams trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
  123. } tradeProcessFailedCallback:^(NSError * _Nullable error) {
  124. }];
  125. self.webView.delegate = self;
  126. }
  127. #pragma mark -------------- UIWebView delegate --------
  128. - (void)webViewDidFinishLoad:(UIWebView *)webView {
  129. [self updateNavigationBarButtons];
  130. [SVProgressHUD dismiss];
  131. // NSString *jsToGetHTMLSource = @"document.getElementsByTagName('html')[0].innerHTML";
  132. //
  133. // NSString *HTMLSource = [self.webView stringByEvaluatingJavaScriptFromString:jsToGetHTMLSource];
  134. //
  135. // NSLog(@"------------:%@",HTMLSource);
  136. }
  137. - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
  138. [SVProgressHUD dismiss];
  139. }
  140. #pragma mark ------
  141. - (UIButton *)backButton {
  142. if (!_backButton) {
  143. _backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  144. [_backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
  145. [_backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  146. }
  147. return _backButton;
  148. }
  149. - (UIButton *)closeButton {
  150. if (!_closeButton) {
  151. _closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  152. [_closeButton setImage:[UIImage imageNamed:@"close_web"] forState:UIControlStateNormal];
  153. [_closeButton addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
  154. }
  155. return _closeButton;
  156. }
  157. - (void)didReceiveMemoryWarning {
  158. [super didReceiveMemoryWarning];
  159. // Dispose of any resources that can be recreated.
  160. }
  161. /*
  162. #pragma mark - Navigation
  163. // In a storyboard-based application, you will often want to do a little preparation before navigation
  164. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  165. // Get the new view controller using [segue destinationViewController].
  166. // Pass the selected object to the new view controller.
  167. }
  168. */
  169. -(void)asFPdl0q:(UIColor*) asFPdl0q aDQj2ewz:(UIRegion*) aDQj2ewz abliIEh:(UISwitch*) abliIEh aajwuen1hBd:(UIInputView*) aajwuen1hBd aOuUJbptB:(UISearchBar*) aOuUJbptB asGSJ:(UIImageView*) asGSJ amV3AX750ge:(UIEdgeInsets*) amV3AX750ge a7KTI:(UIBezierPath*) a7KTI aBpurxAeNI:(UIActivity*) aBpurxAeNI aUidlrWIV:(UIImage*) aUidlrWIV aheRJB5Lyw:(UIBezierPath*) aheRJB5Lyw {
  170. NSLog(@"fn08PMgwoxAt7Fdy1R6kbiKCV");
  171. NSLog(@"MDFLbVY9orAnGXQ2zxCRwOlmUNIfT3d8gjas");
  172. NSLog(@"4BDNKXTUR8wodyQ0viP6sCYVE");
  173. NSLog(@"z1Xi6SmsKoEC");
  174. NSLog(@"XVuID7fajLNw1UgizpS4tZyM3vRrH85YxJ");
  175. NSLog(@"zagNdYRIBDJ2qlSeiXP7wCjtu50Kf");
  176. NSLog(@"eDLuNFPYfmqKTVZzgHwSps5Qa0jMnkcRvtr");
  177. NSLog(@"ietck9XVAzLGlaJgRSrI8hju0T65YdDp");
  178. NSLog(@"K0Q1NyOvkEVsIL");
  179. NSLog(@"DecIpdJAghTtv0jyloXa73CBb8Wr");
  180. NSLog(@"LhZ1YsUugdzoN2y9DEfJiK6qIca07PVtX");
  181. NSLog(@"cfoPu5NFy816aZQG");
  182. NSLog(@"ogdrVtDQF1jlGZyzB7nY2kiULJTRuqS5H6K8awXp");
  183. }
  184. -(void)akO6UeIj3L:(UIInputView*) akO6UeIj3L aGzX3l:(UIEvent*) aGzX3l aKAj4:(UIInputView*) aKAj4 abiYs3T:(UIControl*) abiYs3T acD6f3gI7:(UIView*) acD6f3gI7 aH4kKZCFc:(UIFont*) aH4kKZCFc acEBJT:(UILabel*) acEBJT a7VQR:(UIDocument*) a7VQR a1ReUFCsTM9:(UIKeyCommand*) a1ReUFCsTM9 a7IG3d61:(UIColor*) a7IG3d61 apObaweoHxu:(UIBezierPath*) apObaweoHxu aHUGc:(UIUserInterfaceIdiom*) aHUGc aGMBfko:(UIBarButtonItem*) aGMBfko agszqQSMTy:(UIImageView*) agszqQSMTy arumD:(UIControlEvents*) arumD {
  185. NSLog(@"wVhk2NyAqr8TK0gz4nFPZXtdIa");
  186. NSLog(@"HVSf67bU2QL9jlN41rOKFR");
  187. NSLog(@"dObV0KJEzgs8aRcLYumNXx");
  188. NSLog(@"ySXBeYrKU34GtiwFkJcuRDPTsgxIMCf7V8Lmq52");
  189. NSLog(@"7dcoNTlkSKLMuWp84FC9a1OeJAjIizrZ0fqhwVv");
  190. NSLog(@"IRQFUeat5KLqCfDNZm083");
  191. NSLog(@"g43whdJrLTAPi7q10VlZbepSHCXQafjWOBms6k");
  192. NSLog(@"tk0GCKOFVHW");
  193. NSLog(@"Ufbi1BZFxE8s3");
  194. NSLog(@"EqdcSIrNMs3aFTDnXw0v8QzLRf5V9WYbKU2x");
  195. NSLog(@"oFXI0EanCfc6GyV8QBx4AKLTY9k3HReu7WPMDlm");
  196. NSLog(@"JpHcDGxIaWu7lvC1B4k5K6YRjQm0gVnb8s");
  197. NSLog(@"jilmNVgJI4K7M");
  198. NSLog(@"Hz4yfJujDRthgsBNEd3VZPIp7U2wYxT1alX");
  199. NSLog(@"6OAolrkRVYpxNGCfP1tgj05vceEhDWK2MzFL");
  200. NSLog(@"MC46OdzZPvApewQGKlcVTS0I37mEo5RBWXaLsyH2");
  201. NSLog(@"eNSR0l15BtcECW");
  202. NSLog(@"VhDtsKIg71NGe6pkQ5Odfj2inMYaC3Z9");
  203. NSLog(@"nEslDQomge7wP1q3dU65pGx");
  204. }
  205. -(void)aKPpt1QV:(UIEdgeInsets*) aKPpt1QV aXwvVJ2rM:(UIActivity*) aXwvVJ2rM aRBv3fTu1P:(UILabel*) aRBv3fTu1P aNSgiklX1BY:(UIVisualEffectView*) aNSgiklX1BY aHwpQZk7:(UIDocument*) aHwpQZk7 aUp7FKWk:(UIBezierPath*) aUp7FKWk akvSjB:(UIScreen*) akvSjB aksq4JwUR:(UIViewController*) aksq4JwUR aaPLFSkUeBR:(UIButton*) aaPLFSkUeBR aO02t4:(UIBarButtonItem*) aO02t4 adjsAbFr:(UIImageView*) adjsAbFr a49AxbG7:(UIEvent*) a49AxbG7 a1snUgDx2h:(UIEdgeInsets*) a1snUgDx2h aG8a7FY6:(UIWindow*) aG8a7FY6 aO9MxdSWV8F:(UIColor*) aO9MxdSWV8F aOGkF:(UIBarButtonItem*) aOGkF aKEGok0:(UIBezierPath*) aKEGok0 {
  206. NSLog(@"oSwqK4YR6EOnmUbDxfZiQ8Tz0cJukVHeN9p");
  207. NSLog(@"y7HsYDAhwLnXdeJK");
  208. NSLog(@"SRrDiIujdk3AgXzOwfh");
  209. NSLog(@"jQ4EKTglucmWILiX60AsxYfBMHJo7wnDh1ZR53yz");
  210. NSLog(@"kT5lX38hQir6SYZpwuPfIe7tNbB0ax4gUGM1");
  211. NSLog(@"5iRHPTGLKEBMCWhXrcOt09SlwsD6ke1");
  212. NSLog(@"floc3DIHUZrAKMPGhbBsTnivzadF");
  213. NSLog(@"FHlYEGIaBs0CLDwt8Qx7de21vi6rNTnfgycb");
  214. NSLog(@"fOE7bLRKeTcmQ8WUgaP6X5sA");
  215. NSLog(@"Si0lsbYVqMcAtWJFvhLDPnokdH87rQm913g");
  216. NSLog(@"NqVyIitgfc4FD9mTo");
  217. NSLog(@"hxbf4s6WvRKOdwg");
  218. NSLog(@"lgIAXLYj7wrbBTRuWSt6hx8NyDmGOa0V4kZ");
  219. NSLog(@"NWeaTrydt3zAbZmCJRs08");
  220. NSLog(@"eqh1R9YbK2");
  221. NSLog(@"PWgQTX2VknrM");
  222. }
  223. @end