123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // 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 "LDShopCarViewController.h"
- #import <AlibcTradeSDK/AlibcTradeSDK.h>
- #import <AlibabaAuthSDK/ALBBSession.h>
- #import <AlibabaAuthSDK/ALBBSDK.h>
- #import "LDTaobaoAuthorView.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 changeColor];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkUserJurisdiction) name:ChangeTaoBaoAuthor object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkUserJurisdiction) name:ChangeSex object:nil];
- }
- - (void)checkUserJurisdiction {
- //过审用
- // if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
- // [self initHeader];
- // self.authorView.hidden = YES;
- // return;
- // }
-
- if ([[ALBBSession sharedInstance] isLogin]){
- self.authorView.hidden = YES;
- [self initHeader];
- }else {
- self.titleView.hidden = YES;
- [self creatAuthorView];
- }
- [self.navigationBar setNavTitle:@"省钱购物车"];
- self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
-
- }
- - (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){
- }];
- [MobClick event:ImpowerShopping];
- };
- [self.view addSubview:self.authorView];
- }
- - (void)initHeader {
- [self.navigationBar removeAllSubviews];
- NSArray *titles = @[@"省钱购物车",@"淘宝购物车"];
- LDShopCarViewController *webShopCar = [[LDShopCarViewController 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.segScroll.scrollEnabled = NO;
- 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 clearColor];
- 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
|