//
|
// MainBaseController.m
|
// BuWanVideo2.0
|
//
|
// Created by Aeline on 2021/5/24.
|
// Copyright © 2021 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "MainBaseController.h"
|
#import "SearchController.h"
|
#import "LookNoteController.h"
|
#import "subregionViewController.h"
|
|
#import "RecommendNavView.h"
|
|
@interface MainBaseController ()
|
|
@property(nonatomic, nullable, strong) RecommendNavView *viewRecommendNav;
|
|
@property (nonatomic, nullable, strong) NSMutableArray *dataHot;
|
|
@end
|
|
@implementation MainBaseController
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
[self setupMainViewConfig];
|
[self getHotSearch];
|
}
|
|
- (void)getHotSearch {
|
if (![YTHsharedManger startManger].searchTitle || [[YTHsharedManger startManger].searchTitle isEqualToString:@""]) {
|
[[YTHNetInterface startInterface] fetchHotSerchListWithUid:^(BOOL isSuccessful, id result, NSString *error) {
|
if (isSuccessful) {
|
NSDictionary *dic = (NSDictionary *)result;
|
if (!_dataHot) {
|
self.dataHot = [[NSMutableArray alloc] initWithCapacity:0];
|
}
|
[self.dataHot removeAllObjects];
|
NSArray *ar = [[dic objectForKey:@"Data"] objectForKey:@"data"][@"热搜榜"];
|
for (int i =0; i<ar.count; i++) {
|
[self.dataHot addObject:[ar objectAtIndex:i]];
|
}
|
NSInteger rand = arc4random()%self.dataHot.count ;
|
self.viewRecommendNav.title = self.dataHot[rand];
|
[YTHsharedManger startManger].searchTitle = self.viewRecommendNav.title;
|
}
|
}];
|
|
} else {
|
self.viewRecommendNav.title = [YTHsharedManger startManger].searchTitle;
|
}
|
}
|
|
- (void)setupMainViewConfig {
|
[self.view addSubview:self.viewRecommendNav];
|
@weakify(self)
|
self.viewRecommendNav.onSearch = ^{
|
@strongify(self)
|
SearchController *vc = [[SearchController alloc] init];
|
vc.ptitle = [YTHsharedManger startManger].searchTitle;
|
vc.hidesBottomBarWhenPushed = YES;
|
[self.navigationController pushViewController:vc animated:YES];
|
};
|
self.viewRecommendNav.onRecord = ^{
|
@strongify(self)
|
LookNoteController *LookNoteLookNoteVC=[[LookNoteController alloc] init];
|
[LookNoteLookNoteVC setHidesBottomBarWhenPushed:YES];
|
[self.navigationController pushViewController:LookNoteLookNoteVC animated:YES];
|
};
|
self.viewRecommendNav.onCategory = ^{
|
@strongify(self)
|
subregionViewController *subregionViewControllerVC=[[subregionViewController alloc] init];
|
[subregionViewControllerVC setHidesBottomBarWhenPushed:YES];
|
[self.navigationController pushViewController:subregionViewControllerVC animated:YES];
|
};
|
}
|
|
- (RecommendNavView *)viewRecommendNav {
|
if (!_viewRecommendNav) {
|
_viewRecommendNav = [[RecommendNavView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, kStatusBarH + ALNavBarH)];
|
}
|
return _viewRecommendNav;
|
}
|
|
@end
|