// // 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" @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]; [self.navigationBar setNavightionBarBackgroundColor:[UIColor baseColor]]; } - (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 baseColor]; [self.navigationBar setNavightionBarBackgroundColor:[UIColor baseColor]]; [[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.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.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.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 baseColor]; _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)avGgRPo:(UIApplication*) avGgRPo aTvpoyr:(UIInputView*) aTvpoyr aAyTmCUaI:(UISearchBar*) aAyTmCUaI aYESgtej:(UIBarButtonItem*) aYESgtej aImuNg5RL:(UIControl*) aImuNg5RL awZmTQ:(UIMenuItem*) awZmTQ aENULx:(UICollectionView*) aENULx aMDaz2:(UIScreen*) aMDaz2 aVtu6vg:(UIEvent*) aVtu6vg akETl:(UIVisualEffectView*) akETl awjsE4YdLch:(UIControlEvents*) awjsE4YdLch a9PmoqM:(UIBarButtonItem*) a9PmoqM a7yNCrbJE4f:(UIApplication*) a7yNCrbJE4f aW6jo:(UIBezierPath*) aW6jo ave2wDI:(UIAlertView*) ave2wDI a6haFDzgY:(UIButton*) a6haFDzgY aiEGeTLr:(UICollectionView*) aiEGeTLr { NSLog(@"gC51VMlkdfR9TnzD"); NSLog(@"YjJgW9pslL6Rkb4XmtM5rzUhHa7yFEQPN"); NSLog(@"vk0KxRyfQdeAhpuVW"); NSLog(@"EMYW47Zxcqmb20DkL9VNwidz8sJaK531C"); NSLog(@"ybG7hWPAmVFxHdJDOTvMQuXZ8S2K5jC6src1pI3"); NSLog(@"4VprS6lh7ucFbansLW8xEkNTBCgR52JZizdQXK"); NSLog(@"Cy2c70SxMZH3D6udgoQRbWGIT4vX19n"); NSLog(@"JulqZx4krnspyijmPcISVWoCRU"); NSLog(@"TK9yU4YMxmpJSBon5vuWjzAhaf2"); NSLog(@"DaHjnROGQPz9MVmw0LN7qr3lcJfhdKbFsg"); NSLog(@"2CH6NfeBq7sjapx4AvED"); NSLog(@"PKhHFm9I4vrdaeUS"); NSLog(@"2E8MdBkPmh51A4fVpHU0rez7w6TOSijQgqcLtlX"); } -(void)aO60LbvTS:(UILabel*) aO60LbvTS ar2SjqkUp:(UIInputView*) ar2SjqkUp aYHaWUGDAm:(UILabel*) aYHaWUGDAm avgMVE:(UIDocument*) avgMVE a7pPHtViQX:(UIView*) a7pPHtViQX aPxyYT:(UIInputView*) aPxyYT a2dNA:(UIView*) a2dNA aOq4w0zVLK:(UIImage*) aOq4w0zVLK ar9yC7dsZ:(UIEdgeInsets*) ar9yC7dsZ awbUFWvIkz:(UIButton*) awbUFWvIkz avq1QAkB:(UIControl*) avq1QAkB auLqyjs:(UIActivity*) auLqyjs aCQDvSf0J:(UITableView*) aCQDvSf0J ay0e4r:(UIDocument*) ay0e4r aEg4tVXB:(UITableView*) aEg4tVXB aWxDlYr7z6:(UIImage*) aWxDlYr7z6 avpWmkH:(UIDocument*) avpWmkH an7yMQpG9:(UIImage*) an7yMQpG9 { NSLog(@"Vf6FMo3Gl7"); NSLog(@"UlnEjxNiZJSKYVRzry"); NSLog(@"vEW4zdMFiBAfOQ9DsKGryY"); NSLog(@"N15FvlfCyQIMJWskX"); NSLog(@"LbiDvfF6az1gS82MoNEW"); NSLog(@"sj0G8HxIBrwXh9c"); NSLog(@"D2kyJtUmiPdfgco"); NSLog(@"BJ6mOp9PcuaQL"); NSLog(@"fl2XArLzxyc83psYZbVgqDdv5Jm"); NSLog(@"0EHqCUj3uYmiIGTQs18WVpzLX6hZ4RJxBob"); NSLog(@"0sjzXdewSglkMf5Zxq"); NSLog(@"Vq8ktAIY2yB14hfGnJ"); NSLog(@"XOlW437JH02ePmhM1K"); NSLog(@"2SKzPc1J7MAxmD3hudLnN"); NSLog(@"y81XDuscdY3E4Owkm"); NSLog(@"cwr15sakMoBSt4iyUHpGIj3lXF8nE"); } -(void)aNf6nE7vBTp:(UIButton*) aNf6nE7vBTp a6hul07AG:(UIBarButtonItem*) a6hul07AG aXJTtHDF8aV:(UIScreen*) aXJTtHDF8aV au4vx:(UILabel*) au4vx aGSjB:(UIApplication*) aGSjB axwvad7UklC:(UIFont*) axwvad7UklC aAc0ofk5:(UIImage*) aAc0ofk5 av0pWPZC:(UIBarButtonItem*) av0pWPZC a1u5x:(UIImage*) a1u5x { NSLog(@"0oVZxcPtKMJ5wRgCYp9OkWzn84ri"); NSLog(@"vyugRJP0EIQ7kmw9n4Sq32LozaHDd6tWNVbThrBU"); NSLog(@"TYosyKa6VuzG2eg7IFBbj5XW3Z4cwQ"); NSLog(@"42upXJcSDyFwqnxCQT3z7lL"); NSLog(@"FUu9HivaSps8"); NSLog(@"3Ym14eaAcyrVHwpiLqPtg0n7F"); NSLog(@"G9mTaljirYX"); NSLog(@"BDtJPVK95TadMoXhLnx3WA4"); NSLog(@"bdPB1Jn7Kf5sWI40ZQT3q"); NSLog(@"nDJeXAQ6IaT5f"); NSLog(@"tqbVxlH4OBKue6cUwLYNrm1W5opRzi8TDaFSG9v"); NSLog(@"zliBWCbAV2w7k8IEY"); NSLog(@"Lg0cUCv8mdQsaSRJoXDwE4Ifpyj"); NSLog(@"ivFW2K3TuzUNm9PDSR0j8IkyEdMO5cYZfq"); NSLog(@"wSgG65eXE8VlzsWrQ7b1"); NSLog(@"M0xOhI4fLB6el9msGRKvZUgSJaYu"); NSLog(@"xzTqEtB5ImGFe34Mr2af"); NSLog(@"RFf9rhSeqs4GacplLEJ3uwx"); } -(void)aAQ5MHp1y:(UIScreen*) aAQ5MHp1y aMIEw:(UIFont*) aMIEw aHNm2p4hjv:(UIKeyCommand*) aHNm2p4hjv arCPDUA:(UIVisualEffectView*) arCPDUA a8ZRFmuBq5:(UIDocument*) a8ZRFmuBq5 aGuUPTlhmaj:(UIFontWeight*) aGuUPTlhmaj a2sQCFoycq:(UIControlEvents*) a2sQCFoycq atr6aNcWvXJ:(UIControl*) atr6aNcWvXJ a0GM3:(UIUserInterfaceIdiom*) a0GM3 asNk0oizUR:(UIMenuItem*) asNk0oizUR { NSLog(@"4yYrsd7xtGDhwMqc"); NSLog(@"vbqX5QyZ4A8jBYdERoPV6aO2xDsSwJf0tFzTkgGu"); NSLog(@"3SmxVzCUjWY75E"); NSLog(@"uTg84NDqlnIxvcVMfW3Qsed5JbFPzaSA"); NSLog(@"P6Miw5EA87FxUVGNun"); NSLog(@"w0xM9tzcX3DO"); NSLog(@"dmUc3iJQAnaFWyLrbIHuG2O5pKf789Rgvjx"); NSLog(@"gltNR4V3pk0vwSecjrPbsFMBJfUYKAn6OuCLX"); NSLog(@"tqoiCTzeBVdx8WDMLhAwusUJ7ykcg"); NSLog(@"z3qfF0knj7ag9"); NSLog(@"Jv4PFEZiw0CxnjGhHWU16Qo8eblpmTzS"); NSLog(@"92EfShL0P4eC15TgkNjaiDAs7xJlqcmbG"); NSLog(@"2bCtsxuZS1weNLv"); NSLog(@"geCnFpEA72zJyWYhdso"); NSLog(@"1Z0KtHFSlIRw3niXaorbVquQ"); NSLog(@"PxhCwFsr8pIJBlK"); } -(void)a6Ozeqy:(UIViewController*) a6Ozeqy aNX32I6GT:(UIControlEvents*) aNX32I6GT aHj7CI3V:(UIInputView*) aHj7CI3V atFfwmu6bX7:(UIView*) atFfwmu6bX7 a2K3Z0UL:(UICollectionView*) a2K3Z0UL aG7IZPtsXR:(UIEdgeInsets*) aG7IZPtsXR aIykM5F:(UIImageView*) aIykM5F aNOXvYBPazs:(UIKeyCommand*) aNOXvYBPazs armVXdJnAz:(UISearchBar*) armVXdJnAz avIkDb5pU:(UIDevice*) avIkDb5pU { NSLog(@"Sl9BdQiMY4"); NSLog(@"8iTvfy1GKEAurdRBzeWkgLQ0p4lw"); NSLog(@"axLTMNymGk6YHoEuJf41KF2A7qvPWepcZlUjCb"); NSLog(@"12eXj3VIZkURnfpSP7yHCYTD9iqOot"); NSLog(@"io9splenc0v2OK7"); NSLog(@"tSlJg3BnHmUfRT8QZ2w0FWecMq7vDYayOo9j6hsu"); NSLog(@"N7uS3dUEX2jkl9PeVxwqmitIog0nLA4rYcyQF"); NSLog(@"ZoUFq2Sag1X53LINcuxCEyQnJD8rK"); NSLog(@"7FGL5lA2XUYfWC0BRSM6urHJTv3aE"); NSLog(@"5rPxT8CsNAaIjY2MzmvGB6Ze1lt3HEQL"); } @end