123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- //
- // KBCollectionGoodsController.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/1/24.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "KBCollectionGoodsController.h"
- #import "KBDateHeaderView.h"
- #import "KBCollectionTicketCell.h"
- #import <AlibcTradeSDK/AlibcTradeSDK.h>
- #import <AlibabaAuthSDK/ALBBSession.h>
- #import <AlibabaAuthSDK/ALBBSDK.h>
- #import "KBTaobaoAuthorView.h"
- @interface KBCollectionGoodsController ()<UIWebViewDelegate>
- @property (nonatomic, strong) UIWebView *webView;
- @property (nonatomic, strong) KBTaobaoAuthorView *authorView;
- @end
- @implementation KBCollectionGoodsController
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self configTaobaoAuthorView];
- [self.view bringSubviewToFront:self.webView];
-
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
-
- [SVProgressHUD dismiss];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self configWebView];
-
- }
- - (void)initHUD {
- [SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];
- [SVProgressHUD setForegroundColor:[UIColor YHColorWithHex:0xff2420]];
- [SVProgressHUD setBackgroundColor:[UIColor YHColorWithHex:0xf5f4f4]];
-
- }
- - (void)configWebView {
-
- self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
- self.webView.delegate = self;
- [self.view addSubview:self.webView];
-
- self.authorView = [[KBTaobaoAuthorView 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)configTaobaoAuthorView {
- if ([[ALBBSession sharedInstance] isLogin]){
- [self openMyCollectionGoodsWebView];
- self.webView.hidden = NO;
- self.authorView.hidden = YES;
- }else {
- self.webView.hidden = YES;
- self.authorView.hidden = NO;
-
- }
- }
- - (void)openMyCollectionGoodsWebView {
-
- [SVProgressHUD show];
- id<AlibcTradePage> page = [AlibcTradePageFactory page:@"http://tbk.726p.com/api/users/token"];
- //淘客信息
- AlibcTradeTaokeParams *taoKeParams=[[AlibcTradeTaokeParams alloc] init];
- taoKeParams.pid= ALTK_PID;
- //打开方式
- AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
- showParam.openType = AlibcOpenTypeAuto;
- [[AlibcTradeSDK sharedInstance].tradeService show:self.parentViewController webView:self.webView page:page showParams:showParam taoKeParams:taoKeParams trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
- } tradeProcessFailedCallback:^(NSError * _Nullable error) {
-
- }];
- self.webView.delegate = self;
- }
- - (void)webViewDidStartLoad:(UIWebView *)webView {
- [SVProgressHUD dismiss];
- }
- - (void)webViewDidFinishLoad:(UIWebView *)webView {
-
-
- static NSString * const hiddenDiv =
- @"function hiddenDiv(){\
- var className = document.getElementsByClassName('icon-back');\
- className[0].style.display = 'none';\
- };";
- [self.webView stringByEvaluatingJavaScriptFromString:hiddenDiv];
- [self.webView stringByEvaluatingJavaScriptFromString:@"hiddenDiv()"];
- }
- - (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.
- }
- */
- @end
|