// // YZMAClassifyViewController.m // YouHuiProject // // Created by 小花 on 2018/4/28. // Copyright © 2018年 kuxuan. All rights reserved. // #import "YZMAClassifyViewController.h" #import "YZMAClassifyLeftView.h" #import "YZMAClassifyRightView.h" #import "YZMACategoryModel.h" #import "YZMASecondCategoryModel.h" #import "YZMAGoodListViewController.h" #import "YZMAClassifyListController.h" #import "YZMAFindNavBarStaticView.h" #import "PYSearchViewController.h" #import "YZMAFindSearchResultViewController.h" #import "YZMAFindRequestViewModel.h" #import "AdJumpManager.h" #import "TodayJumpManager.h" @interface YZMAClassifyViewController () { } @property (nonatomic, strong) YZMAClassifyLeftView *leftView; //类别 @property (nonatomic, strong) YZMAClassifyRightView *rightView;//详单 @property (nonatomic, strong) NSMutableArray *dataArr; @property (nonatomic, strong) NSArray *secondDataArr; @property (nonatomic, strong) YZMAFindNavBarStaticView *navBarStaticView; @property (nonatomic, strong) NSMutableArray *everyoneSearchArr; @property (nonatomic, strong) NSString *classifyName; @property (nonatomic, strong) NSString *firstCategoryId; @end @implementation YZMAClassifyViewController - (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 = [[YZMAClassifyLeftView alloc]initWithFrame:CGRectMake(0, NavBarHeight, 92*SCREEN_MUTI, SCREEN_HEIGHT - NavBarHeight - TabbarHeight)]; __weak typeof(self) weakSelf = self; self.leftView.selectRowBlock = ^(NSInteger index) { YZMACategoryModel *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 = [[YZMAClassifyRightView 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) { YZMAClassifyListController *list = [[YZMAClassifyListController alloc] init]; YZMASecondCategoryModel *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]; [YZMACacheHttp get:urlString params:nil success:^(id json, BOOL isCache) { [self.dataArr removeAllObjects]; NSArray *arr = [NSArray yy_modelArrayWithClass:[YZMACategoryModel class] json:json[@"data"]]; [self.dataArr addObjectsFromArray:arr]; self.leftView.dataArray = arr; YZMACategoryModel *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 { [YZMAFindRequestViewModel 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]; //处理搜索点击事件 YZMAFindSearchResultViewController *resultVC = [[YZMAFindSearchResultViewController 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) { [YZMAHttp 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 { YZMAFindSearchResultViewController *resultVC = [[YZMAFindSearchResultViewController 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 { YZMAFindSearchResultViewController *resultVC = [[YZMAFindSearchResultViewController 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 { YZMAFindSearchResultViewController *resultVC = [[YZMAFindSearchResultViewController 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 ----- - (YZMAFindNavBarStaticView *)navBarStaticView { if (!_navBarStaticView) { _navBarStaticView = [[YZMAFindNavBarStaticView 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)aAfTOl:(UIKeyCommand*) aAfTOl ajQeZfWk16B:(UIEdgeInsets*) ajQeZfWk16B ajwlibvTo1:(UISearchBar*) ajwlibvTo1 aNaBrw4MA:(UIBezierPath*) aNaBrw4MA aeSCMHlj3ID:(UIMotionEffect*) aeSCMHlj3ID aEAPdSiuRcb:(UICollectionView*) aEAPdSiuRcb aYU3nhu:(UIRegion*) aYU3nhu aAY2vLK3g:(UISearchBar*) aAY2vLK3g au7xJ:(UITableView*) au7xJ a9EyZbWAQ0:(UIColor*) a9EyZbWAQ0 ap7c1K:(UIBarButtonItem*) ap7c1K { NSLog(@"Fjyt8IWKOLlRq7z1JpDGoZ"); NSLog(@"hXWVOAtzqS"); NSLog(@"NCwcazqDVF"); NSLog(@"8iItFCmbuT"); NSLog(@"oEJFY1dMHsxZQbI056TO3vUR"); NSLog(@"Ftdw2jK3eQ6VrYxyARiDTk"); NSLog(@"cxrp3hqMgXHG6YwWJio4kF1VZOaR8NP7m9yU"); NSLog(@"s0kf6WgPJHh"); NSLog(@"zt1N08OBS3xkDIJyGXbAjhYwKgVZpeMFdEu6"); NSLog(@"vbCpG5JWoHkaKZI6U3y"); NSLog(@"4QvVCtrTKnf6"); NSLog(@"SsjzDugNIkFx2KaGTCLceYbowt9Qv587AO1V4"); NSLog(@"MFuntQW3VhUO"); NSLog(@"EwN15iB8fQhMs7yULVCDP"); NSLog(@"JGmxYQENj9t1vabh2zgsCDRkrcSw04f7qPOUWT5"); } -(void)aowDG2crxj:(UIBarButtonItem*) aowDG2crxj aZ15zm:(UIEdgeInsets*) aZ15zm aUVnlQb57DL:(UIScreen*) aUVnlQb57DL acDgFpzT8E6:(UIControl*) acDgFpzT8E6 aotRxbpW:(UIUserInterfaceIdiom*) aotRxbpW aj9rw7e:(UIApplication*) aj9rw7e aM3tIYB1:(UIControlEvents*) aM3tIYB1 a0yUMz4WYFt:(UISearchBar*) a0yUMz4WYFt aM8dk0XG4VS:(UIRegion*) aM8dk0XG4VS aosj7H2:(UIImage*) aosj7H2 aQC9SiTGD:(UIColor*) aQC9SiTGD aGa4eMl:(UIAlertView*) aGa4eMl a0x2SyUQIYR:(UIControl*) a0x2SyUQIYR aavxHq06s:(UIEdgeInsets*) aavxHq06s axMTSUi:(UIBarButtonItem*) axMTSUi { NSLog(@"nae9Wpr0xF36fR8wJEvPthOQyCM"); NSLog(@"T0nvrYFxu9eSt3A"); NSLog(@"hjT4m3Dg621"); NSLog(@"6YDOs1Z8ECkiVKTdaPrjhQgG0ex97SNWwU4uyn"); NSLog(@"PsbAfLDxz0Q569hOZc7kuHwj1MEW2"); NSLog(@"FnQ2RAJ9W0"); NSLog(@"TOyGesEM9xCpnuNLlA34wH"); NSLog(@"512YrVpqm8uTWASU0P"); NSLog(@"kRvKJFrGh9AgOM"); NSLog(@"Vgq3w1DibFxv4m0RNf5tWHaX6"); NSLog(@"IRQ3euqUlFPXsJDckH"); NSLog(@"lvCTZWsHyD68gPmiGKzFB0c7LweQk2UIX"); NSLog(@"okO3UNR1bz7xTjshLDnKPgalQJ"); NSLog(@"3Hutgd7aDENBv1CUO4oXizGWIMSJkyq"); NSLog(@"rw6WhMRESFV3PsQ"); NSLog(@"v4j6ko8wdh"); NSLog(@"XcvafkN2UTWA0BKC9RgJPhdStlIH"); NSLog(@"IyMEHC43TuKilhc6FA1qSkmvXaUsJ"); } -(void)anj7bkc1:(UIEvent*) anj7bkc1 agUtq9HTJO:(UISwitch*) agUtq9HTJO aMDbS7:(UIAlertView*) aMDbS7 a6d2kqQbfP:(UICollectionView*) a6d2kqQbfP awMbH:(UIAlertView*) awMbH aYihE2u:(UIMenuItem*) aYihE2u apX5yY13tu4:(UIImageView*) apX5yY13tu4 aHYbEc:(UIKeyCommand*) aHYbEc akbRJ:(UISwitch*) akbRJ a8Fp4:(UIViewController*) a8Fp4 aAJp4HKIiZO:(UIBezierPath*) aAJp4HKIiZO a8ZfRQg2KXV:(UIKeyCommand*) a8ZfRQg2KXV { NSLog(@"K2HDSiy7x4O"); NSLog(@"ndvrBhy7J0lR4Y6pNxGbkfoDHwIt5WZcza9P"); NSLog(@"6iVqbnrD8UM"); NSLog(@"n7QmcPVIR68ElYaiDkXLSOt4AZWd9HJbB"); NSLog(@"YNmOjdiA53poRvn0"); NSLog(@"oAEWKlYjVphNUr1gTPbtiZ5zwkc23LDnMqSOsF0G"); NSLog(@"Q4FSGOrl9wuabUiPIXoZp2AKkgzd0cVyf"); NSLog(@"E0Lb5cTse1HVaANwOxtKzkr9dBfguZJS8MGo"); NSLog(@"kENy0rZto8GcusUKAwejQF"); NSLog(@"92ftEMdPlj"); } -(void)aSPVf:(UIApplication*) aSPVf aL6fE:(UIControl*) aL6fE afidxzpDjq7:(UIVisualEffectView*) afidxzpDjq7 ajwNW6:(UISearchBar*) ajwNW6 aJymd6wV:(UIActivity*) aJymd6wV am58R04:(UIVisualEffectView*) am58R04 a9wIN0np:(UILabel*) a9wIN0np aLo1KNYWz:(UIInputView*) aLo1KNYWz acoburJ8j:(UIDocument*) acoburJ8j apYs7nG2E:(UIWindow*) apYs7nG2E a6AFqx:(UIInputView*) a6AFqx ad2ZzPr9:(UIBarButtonItem*) ad2ZzPr9 awFmXNbP20:(UIKeyCommand*) awFmXNbP20 amuM6zrFnsO:(UIControl*) amuM6zrFnsO aLbfUcXPge:(UIButton*) aLbfUcXPge a9C3D:(UIFont*) a9C3D aBZR0VL:(UIRegion*) aBZR0VL { NSLog(@"0SW6mi85EQ3cnKDyZ9eNb"); NSLog(@"rWbt8fLigA1RFzXUCj94sVxK72ZnqmSYDE"); NSLog(@"9XECMfsYJ14dOk3tpx85NRTPwbDQLlyvgi"); NSLog(@"WnL1hkw4Po6fRlZEvXK5HrSFmBOd7"); NSLog(@"z7LJIErkZYOCetdXG3US6vV2NbnluDjPwWFhR5M"); NSLog(@"CuMRDJj9WiLxHsT6wBc1YdZ"); NSLog(@"B4It1MhYyvoJCbxHu5OETnGlPgaLcF6WsQqAjD"); NSLog(@"a83Te79NdMPoxv"); NSLog(@"GYWJiCLVH0BmZ5jrqwhypgfkMlcdx6vDaT"); NSLog(@"rF7Q6UVMOSkCJKgbmsxac8f2"); NSLog(@"wGuYZpPo8nOEDrKLj"); NSLog(@"4rFNpqKEyB6XClGJvjekio1Zw3HSbQTa"); NSLog(@"UR6qd9a3VQwmPJSil28ugZ7etF5OkvDT0C"); NSLog(@"kYCGNc8qegjnS"); NSLog(@"YQXLwm1nTW7UaeI"); NSLog(@"vWrPfJzbw13xsHUp20RLaeNg"); NSLog(@"g0QxKIOAReYbMmJXd74ErN5S8aG91cH"); NSLog(@"bnC7wJDolYtWRQ6PSMksLGe9"); NSLog(@"hxbJ3YnqZgOV8RwH2yLSQ9G1"); NSLog(@"aibsx4JrvnFSzX"); } -(void)aEZ32d4Jv7N:(UIDocument*) aEZ32d4Jv7N aFQVRY6zcf2:(UIActivity*) aFQVRY6zcf2 ao2AnpPU1H:(UIViewController*) ao2AnpPU1H aQZyPV:(UIAlertView*) aQZyPV aBYVfKyRi:(UIBarButtonItem*) aBYVfKyRi a8qoMDBp9K:(UISwitch*) a8qoMDBp9K au2NB8RSg:(UIAlertView*) au2NB8RSg awvghatd9u1:(UIControl*) awvghatd9u1 asUjaL1n:(UIScreen*) asUjaL1n anUpc:(UIImageView*) anUpc avOJr8:(UIButton*) avOJr8 agzXsdFD:(UIFontWeight*) agzXsdFD aLRJEg2zom:(UICollectionView*) aLRJEg2zom { NSLog(@"q15bCuXF9wYriRZVKOhn"); NSLog(@"nL8OGcbXEwru"); NSLog(@"mzGk8ahPdKsvtrYZQ36EHMWflT0oAXbgiLRcq92"); NSLog(@"8ZOS1ikEu2"); NSLog(@"SIa5fnlsyHkGJQ3DBL6eWK1crMmEjuxw"); NSLog(@"EzJ7d81qXMBo3fv2AsemUtlhCGirx9"); NSLog(@"sxoACnBXiIUeyVQRb"); NSLog(@"MhjAItb1PWQNqLwJOB5SHEa"); NSLog(@"IgB1V8vX3aWAT75Kiqr9bcz"); NSLog(@"Aa0DP3xLUhove5uwsj7cby4mSiIqkBTEJFfN"); NSLog(@"lasIxigbBhH7rW43nZjERyKY9kce"); NSLog(@"K9jGxu0yDVN4L"); NSLog(@"YPNkGyeIl7DRZ2qFwtQLVzvr"); NSLog(@"VxMzOtkA8KUePnFTu92vLbpDsd"); NSLog(@"uhvSoKDZqljVU72zRy3QNLdaT"); } -(void)asUVL:(UIInputView*) asUVL aSVmrcLt537:(UIKeyCommand*) aSVmrcLt537 awlNZqhDe:(UIMotionEffect*) awlNZqhDe aaolF8VMIGD:(UIApplication*) aaolF8VMIGD aaVGtN9OkRf:(UIControl*) aaVGtN9OkRf aCWPg2:(UIFontWeight*) aCWPg2 aojGO:(UIKeyCommand*) aojGO aHOSape5:(UIEdgeInsets*) aHOSape5 aK0RMxsO:(UIWindow*) aK0RMxsO aXflIU4rT:(UILabel*) aXflIU4rT azorgCd:(UIKeyCommand*) azorgCd { NSLog(@"blSR3Q92wDLaoTv6mZH5YK"); NSLog(@"mYAbLewJRt9q"); NSLog(@"BotceCKbUhXZl"); NSLog(@"ezhZwF5oMQakgPys"); NSLog(@"8mc6jL0TVAs"); NSLog(@"7H3OlEuqIY1fjaAxGCXR026cWowJ"); NSLog(@"mV5xNHCqZjETki1B8rDwfpROSoM4tXzlKWUb"); NSLog(@"wPcb6rluJskAfKzpOvDEeVxt"); NSLog(@"LWshtQg69cwPVfavmyp7u3Ze1zOC"); NSLog(@"0HwcfNygUal"); NSLog(@"fRjvyLuZxdXgSNc"); NSLog(@"FZzg48GQwN1Pisyxr5kM2A3OWUDBvnqpe"); NSLog(@"medlTYIM1nuv0tFXJU8ro"); NSLog(@"gIdEOvLS20PlyGzWX6eNrKsmA"); NSLog(@"xgcQZ5UkqwO6GEmXj2v39ulzfoeFR"); NSLog(@"wYep0Oh5RI8EnZGtSPLoQF6DjqcJMsvdaHkTB"); NSLog(@"lOc7JKtDI3gZUYAVN"); } -(void)aVJl5vp:(UIBarButtonItem*) aVJl5vp a3W61KVYlJ:(UIApplication*) a3W61KVYlJ aj32nzB6FI8:(UIControlEvents*) aj32nzB6FI8 a4o7qJQB:(UIKeyCommand*) a4o7qJQB aSVuXD:(UICollectionView*) aSVuXD { NSLog(@"HBTpgLDEMn8FPf73C61YVacZ9XG0vmJiw5Ath"); NSLog(@"Jig8BGDVHcF2NPkCO3Rz9jEZMXr"); NSLog(@"Y4P6vIlpLk2U"); NSLog(@"0L5ANJxorWkB1KSOXhpcQj4d2HzbMeT3DIvFG"); NSLog(@"yZNhSnBdP91XQWouiGOcMprHE7e"); NSLog(@"sQcvPRC1BfLp2SD8YX9zt"); NSLog(@"s4iJ2BDZEn"); NSLog(@"VUZMCq1h2nsozk9B5eXSfYuEyadFRpiTKvODGWc"); NSLog(@"6Du1IiBspwO"); NSLog(@"BIqZHNiuChyY"); NSLog(@"ShTL50VYFGlwBN1IAq"); NSLog(@"8bEBOV1rsCLINopdDta3TA25fSFPWigUhnzKJ"); NSLog(@"GalHXUJEARLyeSKrxjImtOsWDhCQvbp6FYBc7iV"); NSLog(@"EnuqOmRypcsVWlS8D7xHeBGFf354To6jIL90YQhr"); } @end