// // LZMClassifyViewController.m // YouHuiProject // // Created by 小花 on 2018/4/28. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LZMClassifyViewController.h" #import "LZMClassifyLeftView.h" #import "LZMClassifyRightView.h" #import "LZMCategoryModel.h" #import "LZMSecondCategoryModel.h" #import "LZMGoodListViewController.h" #import "LZMClassifyListController.h" #import "LZMFindNavBarStaticView.h" #import "PYSearchViewController.h" #import "LZMFindSearchResultViewController.h" #import "LZMFindRequestViewModel.h" #import "AdJumpManager.h" #import "TodayJumpManager.h" @interface LZMClassifyViewController () { } @property (nonatomic, strong) LZMClassifyLeftView *leftView; //类别 @property (nonatomic, strong) LZMClassifyRightView *rightView;//详单 @property (nonatomic, strong) NSMutableArray *dataArr; @property (nonatomic, strong) NSArray *secondDataArr; @property (nonatomic, strong) LZMFindNavBarStaticView *navBarStaticView; @property (nonatomic, strong) NSMutableArray *everyoneSearchArr; @property (nonatomic, strong) NSString *classifyName; @property (nonatomic, strong) NSString *firstCategoryId; @end @implementation LZMClassifyViewController - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; // [SVProgressHUD dismiss]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault]; } - (void)viewDidLoad { [super viewDidLoad]; [self creatNavBar]; [self createView]; [self requestData]; [self requestEveryoneSearch]; } - (void)creatNavBar { [self.navigationBar addSubview:self.navBarStaticView]; self.view.backgroundColor = [UIColor whiteColor]; self.navigationBar.navTitleLabel.textColor = [UIColor whiteColor]; self.navigationBar.backgroundColor = [UIColor changeColor]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeSex) name:ChangeSex object:nil]; } - (void)createView { [self createLeftView]; [self createRightView]; } - (void)changeSex { [self createLeftView]; [self createRightView]; [self refreshData]; } - (void)createLeftView{ self.leftView = [[LZMClassifyLeftView alloc]initWithFrame:CGRectMake(0, NavBarHeight, 92*SCREEN_MUTI, SCREEN_HEIGHT - NavBarHeight - TabbarHeight)]; __weak typeof(self) weakSelf = self; self.leftView.selectRowBlock = ^(NSInteger index) { LZMCategoryModel *model = weakSelf.dataArr[index]; weakSelf.secondDataArr = model.itemList; weakSelf.rightView.dataSource = model.itemList; weakSelf.rightView.model = model.adv; weakSelf.classifyName = model.name; weakSelf.firstCategoryId = model.Id; }; [self.view addSubview:self.leftView]; } - (void)createRightView{ self.rightView = [[LZMClassifyRightView alloc]initWithFrame:CGRectMake(92*SCREEN_MUTI, NavBarHeight, SCREEN_WIDTH - 92*SCREEN_MUTI, SCREEN_HEIGHT -NavBarHeight -TabbarHeight)]; __weak typeof(self) weakSelf = self; self.rightView.selectItemBlock = ^(NSInteger index) { LZMClassifyListController *list = [[LZMClassifyListController alloc] init]; LZMSecondCategoryModel *model = weakSelf.secondDataArr[index]; list.firstCategoryId = weakSelf.firstCategoryId; list.cate_id = model.Id; list.name = model.name; [weakSelf.navigationController pushViewController:list animated:YES]; NSString *tagStr = [NSString stringWithFormat:@"%@-%@",weakSelf.classifyName,model.name]; [MobClick event:Classify label:tagStr]; }; self.rightView.selectHeader = ^(AdPopModel *model) { [TodayJumpManager jumpToPageWithModel:model ParentViewControll:weakSelf]; }; [self.view addSubview:self.rightView]; } - (void)requestData { [SVProgressHUD show]; NSString *urlString = [NSString stringWithFormat:@"%@/api/v2/category/list", BaseURL]; [LZMCacheHttp get:urlString params:nil success:^(id json, BOOL isCache) { [self.dataArr removeAllObjects]; NSArray *arr = [NSArray yy_modelArrayWithClass:[LZMCategoryModel class] json:json[@"data"]]; [self.dataArr addObjectsFromArray:arr]; self.leftView.dataArray = arr; LZMCategoryModel *model = arr.firstObject; self.classifyName = model.name; self.secondDataArr = model.itemList; self.rightView.dataSource = model.itemList; // self.rightView.bannerImgUrl=model.adModel; self.rightView.model=model.adv; self.firstCategoryId = model.Id; [SVProgressHUD dismiss]; } failure:^(NSError *error) { [SVProgressHUD dismiss]; }]; } - (void)requestEveryoneSearch { [LZMFindRequestViewModel requestEveryoneSearchSuccess:^(NSArray *array) { if (array.count > 0) { for (NSDictionary *dict in array) { [self.everyoneSearchArr addObject:dict]; } } } failure:^(NSError *error) { }]; } - (void)refreshData { [self.dataArr removeAllObjects]; [self requestData]; } #pragma mark - navBarView - (void)yh_FindNavBarStaticViewClickSearch { [self createSearchViewControllerWith:nil]; } #pragma mark - -------------search ----------- - (void)createSearchViewControllerWith:(NSString *)text { PYSearchViewController *searchViewController = [PYSearchViewController searchViewControllerWithHotSearches:@[] searchBarPlaceholder:@"输入商品名或粘贴淘宝标题"]; searchViewController.searchHistoryStyle = PYSearchHistoryStyleARCBorderTag; searchViewController.hotSearchStyle = PYHotSearchStyleARCBorderTag; searchViewController.searchTextField.font = [UIFont systemFontOfSize:13]; searchViewController.delegate = self; searchViewController.searchBar.text = text; [self getHotSearchToSearchViewController:searchViewController]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchViewController]; [self presentViewController:nav animated:NO completion:^{ for (int i = 0; i < searchViewController.hotSearchTags.count; i++) { UILabel *tag = searchViewController.hotSearchTags[i]; NSDictionary *dic = self.everyoneSearchArr[i]; if ([dic[@"color"] boolValue]) { tag.layer.borderColor = [UIColor homeRedColor].CGColor; tag.textColor = [UIColor homeRedColor]; } } }]; searchViewController.didSearchBlock = ^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) { [MobClick event:search_count label:Search_Normal]; //处理搜索点击事件 LZMFindSearchResultViewController *resultVC = [[LZMFindSearchResultViewController alloc] init]; resultVC.searchBar = searchBar; resultVC.searchName = searchText; [nav pushViewController:resultVC animated:NO]; }; } /** 加载热搜词汇 */ - (void)getHotSearchToSearchViewController:(PYSearchViewController *)searchViewController { NSMutableArray *hotSearch = [NSMutableArray array]; for (NSDictionary *dic in self.everyoneSearchArr) { [hotSearch addObject:dic[@"name"]]; } searchViewController.hotSearches = hotSearch; } #pragma mark - PYSearchViewControllerDelegate /** 输入完成时触发 */ - (void)searchViewController:(PYSearchViewController *)searchViewController searchTextDidChange:(UISearchBar *)seachBar searchText:(NSString *)searchText { if (searchText.length) { [LZMHttp get:SearchAdvice params:@{@"name":searchText} success:^(id json) { NSArray *list = json[@"data"]; searchViewController.searchSuggestions = list; } failure:^(NSError *error) { }]; } } /** 点击建议 */ - (void)searchViewController:(PYSearchViewController *)searchViewController didSelectSearchSuggestionAtIndex:(NSInteger)index searchText:(NSString *)searchText { LZMFindSearchResultViewController *resultVC = [[LZMFindSearchResultViewController alloc] init]; resultVC.searchName = searchText; resultVC.searchBar = searchViewController.searchBar; [searchViewController.navigationController pushViewController:resultVC animated:NO]; } /** 点击热搜 */ - (void)searchViewController:(PYSearchViewController *)searchViewController didSelectHotSearchAtIndex:(NSInteger)index searchText:(NSString *)searchText { LZMFindSearchResultViewController *resultVC = [[LZMFindSearchResultViewController alloc] init]; resultVC.searchName = searchText; resultVC.searchBar = searchViewController.searchBar; [searchViewController.navigationController pushViewController:resultVC animated:NO]; [MobClick event:search_count label:Search_Hot_String]; } /** 点击历史 */ - (void)searchViewController:(PYSearchViewController *)searchViewController didSelectSearchHistoryAtIndex:(NSInteger)index searchText:(NSString *)searchText { LZMFindSearchResultViewController *resultVC = [[LZMFindSearchResultViewController alloc] init]; resultVC.searchName = searchText; resultVC.searchBar = searchViewController.searchBar; [searchViewController.navigationController pushViewController:resultVC animated:NO]; [MobClick event:search_count label:Search_History_String]; } #pragma mark ----- - (LZMFindNavBarStaticView *)navBarStaticView { if (!_navBarStaticView) { _navBarStaticView = [[LZMFindNavBarStaticView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, NavBarHeight)]; _navBarStaticView.backgroundColor = [UIColor whiteColor]; _navBarStaticView.delegate = self; } return _navBarStaticView; } - (NSMutableArray *)dataArr { if (!_dataArr) { _dataArr = [NSMutableArray array]; } return _dataArr; } - (NSMutableArray *)everyoneSearchArr { if (!_everyoneSearchArr) { _everyoneSearchArr = [NSMutableArray array]; } return _everyoneSearchArr; } - (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. } */ -(void)a8bcUgErQX:(UIColor*) a8bcUgErQX aHL73N:(UILabel*) aHL73N a4NvlL956:(UILabel*) a4NvlL956 aPcDYRQqxF:(UIDevice*) aPcDYRQqxF aXlK0GI:(UIMotionEffect*) aXlK0GI aAPT9kXL0Y:(UIControl*) aAPT9kXL0Y asdRmne:(UIBarButtonItem*) asdRmne axn2t5:(UIMenuItem*) axn2t5 aLHBUb:(UIButton*) aLHBUb aVSfn:(UIScreen*) aVSfn aj3yo:(UIControlEvents*) aj3yo atvQ3J:(UIImage*) atvQ3J akY06:(UIMenuItem*) akY06 a9sIlA2PWm6:(UIMenuItem*) a9sIlA2PWm6 asJkI2zu:(UIButton*) asJkI2zu aEwAfpN:(UIInputView*) aEwAfpN ahuN4FDp:(UIAlertView*) ahuN4FDp ap9f46HwW:(UISearchBar*) ap9f46HwW { NSLog(@"j0YPbc4rEFDRMUAeWVZsv"); NSLog(@"5HoQR6lWOAVUSFiBrC1ENs0b2DLezv"); NSLog(@"VJalEixZpKGfTLsgwyB8Q"); NSLog(@"AGIRVgxSdwX8HcTJCZYro4z2N"); NSLog(@"peCdUWPBTuF2M"); NSLog(@"CHmcB7sMGUxQRAe"); NSLog(@"3UwO8syMSAedrxPfhmGbJFKkEuzHY75Np0"); NSLog(@"Og10xizu2ePIMsfh"); NSLog(@"gewZOlD3s2N1bIQ5qMca"); NSLog(@"P04xBC7XwoULYRJiKzcuN1QlZFnM3htbjVT9"); NSLog(@"BDu3XgFzKSq25HGEe7"); NSLog(@"kTODxLpcjItF7bqmGEivCga3X5WZ"); NSLog(@"eq8oc7izZtLPBdFnar"); NSLog(@"jDV2QisGEpTA7JxZP80dN"); NSLog(@"FqJuCXd0iNjsIxKmeDGnZvO9h1ALPUplSw6"); NSLog(@"TCx2Vnjlp8XQdv4ED3rbSUKN0Bi7Jq1wOzoFetGA"); } -(void)a35dCMqTs:(UIActivity*) a35dCMqTs a3rhs:(UIEvent*) a3rhs ackID:(UICollectionView*) ackID a1UHh:(UIMenuItem*) a1UHh aZ3jBz5bIt:(UIScreen*) aZ3jBz5bIt aKn6s43YgSd:(UIControl*) aKn6s43YgSd aU61REri3na:(UIColor*) aU61REri3na anlXPUJ:(UIBarButtonItem*) anlXPUJ aTwXUCfi:(UILabel*) aTwXUCfi a6HgmX7L:(UIEdgeInsets*) a6HgmX7L aVM9tZ5xPD:(UIEvent*) aVM9tZ5xPD aWyqFmt:(UIDocument*) aWyqFmt aH5dLI0UWY:(UIEdgeInsets*) aH5dLI0UWY aLzERxbMnk:(UIMotionEffect*) aLzERxbMnk asbXBtyDkZU:(UIImageView*) asbXBtyDkZU aFTm8bJ:(UIImage*) aFTm8bJ atdMwCRU:(UIFontWeight*) atdMwCRU { NSLog(@"NFTUQrCilXHv34WR5wZG0a6qtz"); NSLog(@"v34MXmTpPZSGDlEIsxOtWq9"); NSLog(@"tbQxP8n7mz9"); NSLog(@"h9NcBt4V18EHI2lDpqaidLPYG6frxuSTnk7bgvAX"); NSLog(@"DJ5mpLCBzsZcSfnq49QbGluIi6Pae"); NSLog(@"CwdZa9O5qKYneGyr7ETzkscQFNUfhDAJPBl"); NSLog(@"y2QBTCtvmYMId1Kh58ulGZr3qJNW"); NSLog(@"CdksfwR2nTgmOS5B9IE"); NSLog(@"GXOv5YpAM84ziDK9cI"); NSLog(@"zY5aP17yIL0uU"); NSLog(@"8OdXZpM23xQBTwnAfGJKhbzmP"); NSLog(@"DpNvfjwFsyXL7u9QzbWxqZk1B540MR"); NSLog(@"OcmIv7xjsy"); NSLog(@"fvsjbNVhuZcSy"); } -(void)acAGlb2s:(UIApplication*) acAGlb2s aWMFlr:(UIUserInterfaceIdiom*) aWMFlr amGfjeOv:(UIControl*) amGfjeOv a52r40i8Tz:(UISearchBar*) a52r40i8Tz aj96T:(UIBezierPath*) aj96T aLoy1:(UIFont*) aLoy1 { NSLog(@"VBoGNSXIJTD4tRv8mWhen95sLyP1H"); NSLog(@"62UqMyXaApsCEuix10"); NSLog(@"Hfh91OcmJIVXb3Z6zMRdrxGsQWFYwv"); NSLog(@"hoLsq4mkRnv"); NSLog(@"nRQHg0U1ZN9KXC54Sc6uDYwvJW"); NSLog(@"DwGCrPpUhysuHnYdO7Z8"); NSLog(@"TfXy0Vc3IDZYdoEJqR46bxuUimrCw7Ftl8"); NSLog(@"l6kWrGvoAzKI5jmHfXeC"); NSLog(@"bNrKU8fc0jZnPR6E9OWsCpxL5DiqHw4kGah3e"); NSLog(@"OLCQuopB6lwtafHm4gMr"); NSLog(@"iYHRkKPvO4m8Jh2uraFMo7A1W"); NSLog(@"fFZOGLk3eqbshiCvEmYaK8XMl"); NSLog(@"LtFmEd9hqA8ICPT7gQiND0c3XWzOGR"); } -(void)aYK9Vh:(UIFontWeight*) aYK9Vh aXE4I:(UIInputView*) aXE4I anYujG:(UIControl*) anYujG aBUtPQHNy:(UIBarButtonItem*) aBUtPQHNy aYDwWG4UH1:(UIViewController*) aYDwWG4UH1 aRfrSZJsgt0:(UIViewController*) aRfrSZJsgt0 aEBqrKPiU:(UIVisualEffectView*) aEBqrKPiU ayqgi5E:(UIInputView*) ayqgi5E a9bvEHyZt:(UILabel*) a9bvEHyZt aRmQno:(UIImage*) aRmQno aVTzWqe:(UIControlEvents*) aVTzWqe aUxd2cOlpP:(UIAlertView*) aUxd2cOlpP aPlzxQscwO:(UIApplication*) aPlzxQscwO a8AGJdfb5vN:(UIBarButtonItem*) a8AGJdfb5vN aFUZwH:(UIRegion*) aFUZwH a4zPFxSQdtp:(UITableView*) a4zPFxSQdtp aeAIw3Zos:(UIView*) aeAIw3Zos { NSLog(@"S2wRZPl396qfIts"); NSLog(@"HeiZREq48cpuP6XgJK9NFVozaLrDWUT1d7Olym"); NSLog(@"tRCEk5fByredTxJ28pFNViao039"); NSLog(@"O7jeKf2mYtF"); NSLog(@"QTNEUgpsvq617nz0"); NSLog(@"xoSjD0iwX83FZlu1"); NSLog(@"DKgqJoiOh9xQ60lcXZ2tsmN3jbdpRMrWP4eFTL"); NSLog(@"KwdniSWsYh7LAI1"); NSLog(@"1Xh70lxzeFydkTtZCK93jq"); NSLog(@"ujiPgvRWVmtHfLlSM5s9oxhIBn1QpyGaqEJz4k3w"); NSLog(@"wx1tJKdCN5i3SR7VI"); NSLog(@"LcnXDd4qkWtBK3x2NUrash65u"); NSLog(@"i5T0JKgRwaDz27kZCXlHe9IdMmycEn8Qp3WVU"); NSLog(@"87ZmX5IhNSWMlkLxEHqy6f"); NSLog(@"pTUu14kG7ESJadf6Pyb5sZo3jLrtCeA8YFiMBxKO"); NSLog(@"ZTwOnVhgB4"); NSLog(@"YQWSBX5LZ8MO3yjnzxF"); NSLog(@"STli9Pj6O0sJdpLmHoqgRt2VNzX1ueEZ7DIxbCc"); NSLog(@"QYEnSqvgwBH3Ga"); NSLog(@"NleJSCaGZfkdhxD6WBjt1"); } -(void)aEvOcPe39V:(UIInputView*) aEvOcPe39V akCAc3YbsxX:(UILabel*) akCAc3YbsxX aRWT7k:(UIBezierPath*) aRWT7k a1mFG8fV5s9:(UIKeyCommand*) a1mFG8fV5s9 amyVH1Pj:(UIButton*) amyVH1Pj aQlcS9shWC:(UIButton*) aQlcS9shWC aHIWKNqRUO:(UILabel*) aHIWKNqRUO ayun5YFiwk:(UIAlertView*) ayun5YFiwk aqRsYo:(UIColor*) aqRsYo { NSLog(@"mCzpf62WANoPuy5JLc0VU3FS4EOYbrZhgjMDBQeG"); NSLog(@"lEB08DAkSeNLzXh4Jc5rQKxHtZ"); NSLog(@"Ch3auA8Oxbd41fD"); NSLog(@"YKATVHksLg1Nq"); NSLog(@"GfQbIpPr2HTyq4Cca8nxOUJvdkt0K3e9"); NSLog(@"Kuth0Ta1NeSMIwVl7HWZrCigxDmO3Qc8dp2A4o"); NSLog(@"4T0HWX92r5kuajmcBhs6DQnCdPR8pyvxgKloNS"); NSLog(@"RGANizqC0IWoHhb39Q1suE7VJS4dKj"); NSLog(@"4WmH1doVfbGc25LeBpjgCali"); NSLog(@"jAcKxqGsYHmRZdaVn5COtFi6ylM9wS37Lp0g"); } -(void)aKvm3x7do6:(UIInputView*) aKvm3x7do6 aeKoNPHXw:(UIEvent*) aeKoNPHXw ajcRtg3lx:(UITableView*) ajcRtg3lx aRCzl9Y:(UIUserInterfaceIdiom*) aRCzl9Y aOLTi8d3s:(UIMenuItem*) aOLTi8d3s { NSLog(@"QfGnhp0JBYFNCT9mtWHw8OZ7xs5lREUoyc3IV"); NSLog(@"KBlwv5qtFEr7e9ZO3hpG"); NSLog(@"Gij64PMElFtTnb2v3IachWUH8fs5KkV"); NSLog(@"goRLabFxDpQqPwnJG"); NSLog(@"QOhqW7lizD0LvB6b8RUFIXTVmJjsnaA3PN"); NSLog(@"V4iE178yDeJpIPAmjMcQ5ab2UHBKk9sW"); NSLog(@"tZicG3I6xLDu7Hb5WQ"); NSLog(@"NDfLxG9UwlukVe3"); NSLog(@"MBLRfkDnZv5t2jNsrPIA7lVU"); NSLog(@"umzJ0KrC7BEaHTe4nYIvdM8LiFPZOl9SUkNVwGQf"); NSLog(@"JIaG2yu8BANUd0nLbscYpwTHQk1jMqRhPzfW"); NSLog(@"sU0KF48kfgSDjbeHY2Xrp"); NSLog(@"eDBFn6MQPNtXjaUI3fwghOiJsZcp"); } -(void)a7cG2WzKJaI:(UIImageView*) a7cG2WzKJaI aURMj:(UIDocument*) aURMj aWntq:(UIImage*) aWntq ai38M:(UITableView*) ai38M axu2V63WoFn:(UIWindow*) axu2V63WoFn aY1ukgva:(UIBarButtonItem*) aY1ukgva aVna4jsK8e:(UITableView*) aVna4jsK8e aML7yOX:(UIVisualEffectView*) aML7yOX aYEXeqPp0m:(UIEdgeInsets*) aYEXeqPp0m aJazl5mCEk:(UIBezierPath*) aJazl5mCEk a5UDC:(UIEdgeInsets*) a5UDC aXeWKQZ:(UIMotionEffect*) aXeWKQZ a4Hcn0O7:(UITableView*) a4Hcn0O7 aum9nFtHD:(UIRegion*) aum9nFtHD aJVCEM:(UISearchBar*) aJVCEM aKgRT1j:(UISearchBar*) aKgRT1j apiYbwDK4O:(UIApplication*) apiYbwDK4O { NSLog(@"SHpaEy4X8WvKJhq1"); NSLog(@"CyAUIRxSrlgFOhDZ"); NSLog(@"ZteI3qWXrG0xBART4P1OmvsC92"); NSLog(@"7umfrxnSQ34kzFbGowi"); NSLog(@"d3a4mzjun9hXHxCiUVZPvy7JEg18"); NSLog(@"ABtoUxKYkCbp1GEicHQ"); NSLog(@"Qx1rk3hc7XZyfqB5CTjiHw"); NSLog(@"LXJZGigF1wNo2u0CMDhe8WUpqmbIytf"); NSLog(@"PnNksGHLKaOpfu"); NSLog(@"OA2BVJvNY6pKrRwLDQGXWqmPadsux3eobg"); NSLog(@"pA0WKEU8xRC7n4Hg"); NSLog(@"i7hPzu3XYeIkaRgxNEmfHsp"); NSLog(@"79GEduyjoPUBtwebvC"); NSLog(@"onjgaxHWwkT"); NSLog(@"VarlZqSNheuYf2dgxojEwQO"); } @end