123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- //
- // 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"
- @interface LZMClassifyViewController ()<YHFindNavBarStaticViewDelegate,PYSearchViewControllerDelegate>
- {
-
- }
- @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 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 = [[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.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.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.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 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)aIGsx:(UIRegion*) aIGsx aiA6Z4t:(UIApplication*) aiA6Z4t amqa6BLpC:(UICollectionView*) amqa6BLpC aoRH2ZbLu:(UIFontWeight*) aoRH2ZbLu acsvIj24FO:(UICollectionView*) acsvIj24FO aMbHvch8:(UIInputView*) aMbHvch8 aSbKwo:(UIEdgeInsets*) aSbKwo azwfiOcps:(UIKeyCommand*) azwfiOcps anz03AZ:(UIEdgeInsets*) anz03AZ {
- NSLog(@"6QaWqXgjCtOmZKkbcuUnPB0fvNGwAYI1H9VhzydM");
- NSLog(@"9Xf1hKDu2IyWJB");
- NSLog(@"5HlfM3iTb0pkNUev");
- NSLog(@"0rVcMtXOElFAbsNoyuIwZfBL");
- NSLog(@"zSMlGbOWqxpR");
- NSLog(@"kuvBDf6JbhyY2");
- NSLog(@"6qHUSP2BiWTZLeIfsQFw");
- NSLog(@"BbgCEKv8sNr4u70hM2J1twWfn9DQiGqHV5c");
- NSLog(@"utqRhi1kDKW8VQvG");
- NSLog(@"hORLj5z47JlI9D1maCZQuBHqGN8TkniM0Ftx");
- }
- -(void)at5L18iXe9D:(UISwitch*) at5L18iXe9D atuAsi:(UIWindow*) atuAsi aD1em2fRrW:(UIApplication*) aD1em2fRrW amtMKLwpl:(UIActivity*) amtMKLwpl aTemajP6HsK:(UIActivity*) aTemajP6HsK aYskeF0:(UIImageView*) aYskeF0 aHGIh0znAe:(UIDocument*) aHGIh0znAe aGeAvNkI5M:(UIActivity*) aGeAvNkI5M aDEIQ:(UIFont*) aDEIQ aSAt24:(UITableView*) aSAt24 {
- NSLog(@"n23tbdlcTCVWkFDLOxIiPJMrqAQ4BSfp8XGYzjg");
- NSLog(@"kxwsb9dOmytBpVAcLRUZYuavhQXTz4");
- NSLog(@"WXRJYFhO7Kj0D5Nbz46ukitsn");
- NSLog(@"JSU7EZr5yDie4tvN1Tbl9pKnj8mWsQ0XHA");
- NSLog(@"56BkWHazby2Qm");
- NSLog(@"nrqKj1lDNyZa");
- NSLog(@"F3gyOc4SiqhYob78RAHa2fr5eQt");
- NSLog(@"wFS1jOfX78JuQM");
- NSLog(@"PbaxtTBZRQ7im6VqeCMWkFEwpD1SGylcXJKg");
- NSLog(@"h3E2XkLbfnjMcDtSiudmYVzvQ8J");
- NSLog(@"FjNJHvXCBI1GTsgnLQqUuzbtrdE73AcmZ2hRoM");
- NSLog(@"Pn9iFN3XTI5WrtqKJLj");
- NSLog(@"a6oZFXwSj0HG5VExzpOCBYdf39q8rKNmLRAtgue");
- NSLog(@"9Ufu42D0JPh8TGdF");
- NSLog(@"dfxYMkNEoRiCLzKrpJ4m87XB3vnDhZtjWUcO");
- NSLog(@"yZp8cD2xwHkmAbEdijMTG7F6f4");
- }
- -(void)awoEv9f:(UISearchBar*) awoEv9f awxosXLmad2:(UITableView*) awxosXLmad2 aYcqG:(UIControl*) aYcqG a8haSc:(UIAlertView*) a8haSc a2qHl80vkNj:(UICollectionView*) a2qHl80vkNj awml2De:(UIWindow*) awml2De aBi73Icbptm:(UIAlertView*) aBi73Icbptm aU2ti:(UIDevice*) aU2ti aLE91kxed:(UISearchBar*) aLE91kxed aHfbgWw:(UIInputView*) aHfbgWw ahIuLZ4v6YG:(UIColor*) ahIuLZ4v6YG aIikLE:(UIRegion*) aIikLE aS6VeXJsgq:(UIWindow*) aS6VeXJsgq {
- NSLog(@"LRly6abqoGnU1wQHXMFOV73");
- NSLog(@"0o1ZrljiOCfysnWM57gzDcYbuH6JNTA");
- NSLog(@"rowSC805PYNpIkJUOXcB2V7a3d6nqlvRZgb9FQ");
- NSLog(@"J5ZvcC2tdG");
- NSLog(@"MKC2mjFcZo6QNkVqPGUO8w0Abf7yBD");
- NSLog(@"Kijs4GWq5pfmNx");
- NSLog(@"GpmYuOkXgHjA4SbtQ1a2cdihVZJrvNRIUz8");
- NSLog(@"FSNfb3GQEpXVRZAvMemIqJ5BPHY");
- NSLog(@"MQRvEULPxsO8I3Bdf21XHtlCWAFgTywGDZr4c9");
- NSLog(@"81VdhzSfr206pRmg3FkN9lvOCYQHyiZ4aTD");
- }
- @end
|