You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
4.1 KiB
132 lines
4.1 KiB
4 years ago
|
//
|
||
|
// TFInterimViewController.m
|
||
|
// TFReader
|
||
|
//
|
||
|
// Created by 谢腾飞 on 2020/12/14.
|
||
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "TFInterimViewController.h"
|
||
|
#import "TFGenderViewController.h"
|
||
|
#import "TFRecommendBookController.h"
|
||
|
#import "TFRecommendBookModel.h"
|
||
|
|
||
|
@interface TFInterimViewController ()
|
||
|
|
||
|
@property (nonatomic ,strong) TFGenderViewController *insterestGender;
|
||
|
@property (nonatomic ,strong) TFRecommendBookController *insterestBooks;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation TFInterimViewController
|
||
|
|
||
|
- (void)viewWillAppear:(BOOL)animated
|
||
|
{
|
||
|
[super viewWillAppear:animated];
|
||
|
|
||
|
[UIApplication sharedApplication].statusBarHidden = NO;
|
||
|
|
||
|
[self setStatusBarDefaultStyle];
|
||
|
}
|
||
|
|
||
|
- (void)viewDidLoad
|
||
|
{
|
||
|
[super viewDidLoad];
|
||
|
|
||
|
[self initialize];
|
||
|
[self createSubviews];
|
||
|
}
|
||
|
|
||
|
- (void)initialize
|
||
|
{
|
||
|
[self hiddenNavigationBar:YES];
|
||
|
|
||
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nextStepNotification:) name:Notification_Insterest_Change object:nil];
|
||
|
}
|
||
|
|
||
|
- (void)createSubviews
|
||
|
{
|
||
|
self.insterestBooks = [[TFRecommendBookController alloc] init];
|
||
|
[self addChildViewController:self.insterestBooks];
|
||
|
[self.view addSubview:self.insterestBooks.view];
|
||
|
|
||
|
self.insterestGender = [[TFGenderViewController alloc] init];
|
||
|
[self addChildViewController:self.insterestGender];
|
||
|
[self.view addSubview:self.insterestGender.view];
|
||
|
|
||
|
UIButton *skipButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
|
skipButton.backgroundColor = [UIColor clearColor];
|
||
|
[skipButton setTitle:TFLocalizedString(@"跳过") forState:UIControlStateNormal];
|
||
|
[skipButton setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||
|
[skipButton.titleLabel setFont:kFont12];
|
||
|
[skipButton addTarget:self action:@selector(skipButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[self.view addSubview:skipButton];
|
||
|
|
||
|
[skipButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.mas_equalTo(self.view.mas_right).with.offset(- kHalfMargin);
|
||
|
make.top.mas_equalTo(kStatusBarHeight + kMargin);
|
||
|
make.width.mas_equalTo(50);
|
||
|
make.height.mas_equalTo(20);
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (void)nextStepNotification:(NSNotification *)notification
|
||
|
{
|
||
|
if ([notification.object isEqualToString:@"step_one"]) {
|
||
|
[self networkRequest];
|
||
|
|
||
|
} else if ([notification.object isEqualToString:@"step_two"]) {
|
||
|
[self skipButtonClick];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)skipButtonClick
|
||
|
{
|
||
|
[self dismissViewControllerAnimated:YES completion:nil];
|
||
|
}
|
||
|
|
||
|
- (void)networkRequest
|
||
|
{
|
||
|
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||
|
params[@"channel_id"] = @(TFSystemInfoManager.sexChannel);
|
||
|
|
||
|
WS(weakSelf)
|
||
|
[TFNetworkTools POST:Start_Recommend parameters:params model:TFRecommendBookModel.class success:^(BOOL isSuccess, TFRecommendBookModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||
|
|
||
|
if (isSuccess) {
|
||
|
NSMutableArray *t_arr = [NSMutableArray array];
|
||
|
|
||
|
for (TFProductionModel *model in t_model.book) {
|
||
|
model.productionType = TFProductionTypeNovel;
|
||
|
[t_arr addObject:model];
|
||
|
}
|
||
|
|
||
|
for (TFProductionModel *model in t_model.comic) {
|
||
|
model.productionType = TFProductionTypeComic;
|
||
|
[t_arr addObject:model];
|
||
|
}
|
||
|
|
||
|
for (TFProductionModel *model in t_model.audio) {
|
||
|
model.productionType = TFProductionTypeAudio;
|
||
|
[t_arr addObject:model];
|
||
|
}
|
||
|
|
||
|
SS(strongSelf)
|
||
|
if (t_arr.count == 0) {
|
||
|
[weakSelf skipButtonClick];
|
||
|
} else {
|
||
|
[self.insterestGender willMoveToParentViewController:nil];
|
||
|
[self.insterestGender removeFromParentViewController];
|
||
|
[self.insterestGender.view removeFromSuperview];
|
||
|
strongSelf.insterestBooks.productionArray = [t_arr copy];
|
||
|
}
|
||
|
} else {
|
||
|
[weakSelf skipButtonClick];
|
||
|
}
|
||
|
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||
|
[weakSelf skipButtonClick];
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
@end
|