口袋优选

KBUniteShopCarViewController.m 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 "KBShopCarViewController.h"
  13. #import <AlibcTradeSDK/AlibcTradeSDK.h>
  14. #import <AlibabaAuthSDK/ALBBSession.h>
  15. #import <AlibabaAuthSDK/ALBBSDK.h>
  16. #import "KBTaobaoAuthorView.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 homeRedColor];
  41. [self.navigationBar setNavTitle:@"购物车"];
  42. self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor];
  43. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkUserJurisdiction) name:ChangeTaoBaoAuthor object:nil];
  44. }
  45. - (void)checkUserJurisdiction {
  46. //过审用
  47. if ([[PhoneLoginManager shareManager].showPhoneBtn boolValue]) {
  48. [self initHeader];
  49. self.authorView.hidden = YES;
  50. return;
  51. }
  52. if ([[ALBBSession sharedInstance] isLogin]){
  53. [self initHeader];
  54. self.authorView.hidden = YES;
  55. }else {
  56. self.titleView.hidden = YES;
  57. [self creatAuthorView];
  58. }
  59. }
  60. - (void)creatAuthorView {
  61. __weak typeof(self) weakSelf = self;
  62. self.authorView = [[KBShopCarAuthorView alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight-TabbarHeight)];
  63. self.authorView.clickBlock = ^{
  64. //淘宝授权
  65. ALBBSDK *albbSDK = [ALBBSDK sharedInstance];
  66. [albbSDK setAppkey:ALBC_APP_KEY];
  67. [albbSDK setAuthOption:NormalAuth];
  68. [albbSDK auth:weakSelf successCallback:^(ALBBSession *session){
  69. [weakSelf checkUserJurisdiction];
  70. } failureCallback:^(ALBBSession *session,NSError *error){
  71. }];
  72. };
  73. [self.view addSubview:self.authorView];
  74. }
  75. - (void)initHeader {
  76. NSArray *titles = @[@"省钱购物车",@"淘宝购物车"];
  77. KBShopCarViewController *webShopCar = [[KBShopCarViewController alloc] init];
  78. KBNativeShopCarViewController *nativeShopaCar = [[KBNativeShopCarViewController alloc] init];
  79. NSArray *vcList = @[nativeShopaCar,webShopCar];
  80. self.segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight) vcOrViews:vcList];
  81. self.segScroll.bounces = NO;
  82. self.segScroll.loadAll = YES;
  83. self.titleView = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(0, NavBarHeight-45, SCREEN_WIDTH, 40) titles:titles headStyle:SegmentHeadStyleLine layoutStyle:MLMSegmentLayoutCenter];
  84. self.titleView.hidden = NO;
  85. self.titleView.headColor = [UIColor homeRedColor];
  86. self.titleView.bottomLineHeight = 0;
  87. self.titleView.bottomLineColor = [UIColor whiteColor];
  88. self.titleView.fontScale = 1.3f;
  89. self.titleView.fontSize = 14;
  90. self.titleView.equalSize = YES;
  91. self.titleView.showIndex = 0;
  92. self.titleView.lineColor = [UIColor whiteColor];
  93. self.titleView.lineScale = 0.6;
  94. self.titleView.lineHeight = 3;
  95. self.titleView.selectColor = [UIColor whiteColor];
  96. self.titleView.deSelectColor = [UIColor YHColorWithHex:0xFFCDD2];
  97. [MLMSegmentManager associateHead:self.titleView withScroll:self.segScroll completion:^{
  98. [self.navigationBar addSubview:self.titleView];
  99. [self.view addSubview:self.segScroll];
  100. }];
  101. self.titleView.centerX = self.navigationBar.centerX;
  102. UIView *line = [self.titleView getLineView];
  103. line.layer.cornerRadius = 1.5f;
  104. }
  105. @end