猎豆优选

KBUniteShopCarViewController.m 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // KBUniteShopCarViewController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/11/1.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBUniteShopCarViewController.h"
  9. #import "MLMSegmentHead.h"
  10. #import "MLMSegmentManager.h"
  11. #import "KBNativeShopCarViewController.h"
  12. #import "LDShopCarViewController.h"
  13. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  14. #import <AlibabaAuthSDK/ALBBSession.h>
  15. #import <AlibabaAuthSDK/ALBBSDK.h>
  16. #import "LDTaobaoAuthorView.h"
  17. #import "KBShopCarAuthorView.h"
  18. #import "PhoneLoginManager.h"
  19. @interface KBUniteShopCarViewController ()
  20. @property (nonatomic, strong) MLMSegmentHead *titleView;
  21. @property (nonatomic, strong) MLMSegmentScroll *segScroll;
  22. @property (nonatomic, strong) KBShopCarAuthorView *authorView ;
  23. @end
  24. @implementation KBUniteShopCarViewController
  25. - (void)viewDidAppear:(BOOL)animated {
  26. [super viewDidAppear:animated];
  27. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  28. }
  29. - (void)viewWillAppear:(BOOL)animated {
  30. [super viewWillAppear:animated];
  31. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  32. }
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35. [self addNotifationForChangeJurisdiction];
  36. [self checkUserJurisdiction];
  37. }
  38. //监听用户修改权限
  39. - (void)addNotifationForChangeJurisdiction {
  40. self.navigationBar.backgroundColor = [UIColor changeColor];
  41. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkUserJurisdiction) name:ChangeTaoBaoAuthor object:nil];
  42. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkUserJurisdiction) name:ChangeSex object:nil];
  43. }
  44. - (void)checkUserJurisdiction {
  45. //过审用
  46. // if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
  47. // [self initHeader];
  48. // self.authorView.hidden = YES;
  49. // return;
  50. // }
  51. if ([[ALBBSession sharedInstance] isLogin]){
  52. self.authorView.hidden = YES;
  53. [self initHeader];
  54. }else {
  55. self.titleView.hidden = YES;
  56. [self creatAuthorView];
  57. }
  58. [self.navigationBar setNavTitle:@"省钱购物车"];
  59. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  60. }
  61. - (void)creatAuthorView {
  62. __weak typeof(self) weakSelf = self;
  63. self.authorView = [[KBShopCarAuthorView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-TabbarHeight)];
  64. self.authorView.clickBlock = ^{
  65. //淘宝授权
  66. ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
  67. [albbSDK setAppkey:ALBC_APP_KEY];
  68. [albbSDK setAuthOption:NormalAuth];
  69. [albbSDK auth:weakSelf successCallback:^(ALBBSession *session){
  70. [weakSelf checkUserJurisdiction];
  71. } failureCallback:^(ALBBSession *session,NSError *error){
  72. }];
  73. [MobClick event:ImpowerShopping];
  74. };
  75. [self.view addSubview:self.authorView];
  76. }
  77. - (void)initHeader {
  78. [self.navigationBar removeAllSubviews];
  79. NSArray *titles = @[@"省钱购物车",@"淘宝购物车"];
  80. LDShopCarViewController *webShopCar = [[LDShopCarViewController alloc] init];
  81. KBNativeShopCarViewController *nativeShopaCar = [[KBNativeShopCarViewController alloc] init];
  82. NSArray *vcList = @[nativeShopaCar,webShopCar];
  83. self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) vcOrViews:vcList];
  84. self.segScroll.bounces = NO;
  85. self.segScroll.loadAll = YES;
  86. self.segScroll.scrollEnabled = NO;
  87. self.titleView = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0, NavBarHeight-45, SCREEN_WIDTH, 40) titles:titles headStyle:SegmentHeadStyleLine layoutStyle:MLMSegmentLayoutCenter];
  88. self.titleView.hidden = NO;
  89. self.titleView.headColor = [UIColor clearColor];
  90. self.titleView.bottomLineHeight = 0;
  91. self.titleView.bottomLineColor = [UIColor whiteColor];
  92. self.titleView.fontScale = 1.3f;
  93. self.titleView.fontSize = 14;
  94. self.titleView.equalSize = YES;
  95. self.titleView.showIndex = 0;
  96. self.titleView.lineColor = [UIColor whiteColor];
  97. self.titleView.lineScale = 0.6;
  98. self.titleView.lineHeight = 3;
  99. self.titleView.selectColor = [UIColor whiteColor];
  100. self.titleView.deSelectColor = [UIColor YHColorWithHex:0xFFCDD2];
  101. [MLMSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
  102. // [self.navigationBar addSubview:self.titleView];
  103. [self.view addSubview:self.segScroll];
  104. }];
  105. self.titleView.centerX = self.navigationBar.centerX;
  106. UIView *line = [self.titleView getLineView];
  107. line.layer.cornerRadius = 1.5f;
  108. }
  109. @end