admin
2022-01-17 b63ed504f6d1e652d9fbd67c1490e7821b159c75
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
//  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