// // KBUniteShopCarViewController.m // YouHuiProject // // Created by 小花 on 2018/11/1. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBUniteShopCarViewController.h" #import "MLMSegmentHead.h" #import "MLMSegmentManager.h" #import "KBNativeShopCarViewController.h" #import "KBShopCarViewController.h" #import #import #import #import "KBTaobaoAuthorView.h" #import "KBShopCarAuthorView.h" #import "PhoneLoginManager.h" @interface KBUniteShopCarViewController () @property (nonatomic, strong) MLMSegmentHead *titleView; @property (nonatomic, strong) MLMSegmentScroll *segScroll; @property (nonatomic, strong) KBShopCarAuthorView *authorView ; @end @implementation KBUniteShopCarViewController - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } - (void)viewDidLoad { [super viewDidLoad]; [self addNotifationForChangeJurisdiction]; [self checkUserJurisdiction]; } //监听用户修改权限 - (void)addNotifationForChangeJurisdiction { self.navigationBar.backgroundColor = [UIColor homeRedColor]; [self.navigationBar setNavTitle:@"购物车"]; self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkUserJurisdiction) name:ChangeTaoBaoAuthor object:nil]; } - (void)checkUserJurisdiction { //过审用 if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) { [self initHeader]; self.authorView.hidden = YES; return; } if ([[ALBBSession sharedInstance] isLogin]){ [self initHeader]; self.authorView.hidden = YES; }else { self.titleView.hidden = YES; [self creatAuthorView]; } } - (void)creatAuthorView { __weak typeof(self) weakSelf = self; self.authorView = [[KBShopCarAuthorView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-TabbarHeight)]; self.authorView.clickBlock = ^{ //淘宝授权 ALBBSDK *albbSDK = [ALBBSDK sharedInstance]; [albbSDK setAppkey:ALBC_APP_KEY]; [albbSDK setAuthOption:NormalAuth]; [albbSDK auth:weakSelf successCallback:^(ALBBSession *session){ [weakSelf checkUserJurisdiction]; } failureCallback:^(ALBBSession *session,NSError *error){ }]; }; [self.view addSubview:self.authorView]; } - (void)initHeader { NSArray *titles = @[@"省钱购物车",@"淘宝购物车"]; KBShopCarViewController *webShopCar = [[KBShopCarViewController alloc] init]; KBNativeShopCarViewController *nativeShopaCar = [[KBNativeShopCarViewController alloc] init]; NSArray *vcList = @[nativeShopaCar,webShopCar]; self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) vcOrViews:vcList]; self.segScroll.bounces = NO; self.segScroll.loadAll = YES; self.titleView = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0, NavBarHeight-45, SCREEN_WIDTH, 40) titles:titles headStyle:SegmentHeadStyleLine layoutStyle:MLMSegmentLayoutCenter]; self.titleView.hidden = NO; self.titleView.headColor = [UIColor homeRedColor]; self.titleView.bottomLineHeight = 0; self.titleView.bottomLineColor = [UIColor whiteColor]; self.titleView.fontScale = 1.3f; self.titleView.fontSize = 14; self.titleView.equalSize = YES; self.titleView.showIndex = 0; self.titleView.lineColor = [UIColor whiteColor]; self.titleView.lineScale = 0.6; self.titleView.lineHeight = 3; self.titleView.selectColor = [UIColor whiteColor]; self.titleView.deSelectColor = [UIColor YHColorWithHex:0xFFCDD2]; [MLMSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{ [self.navigationBar addSubview:self.titleView]; [self.view addSubview:self.segScroll]; }]; self.titleView.centerX = self.navigationBar.centerX; UIView *line = [self.titleView getLineView]; line.layer.cornerRadius = 1.5f; } @end