小说绘上架版本
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFMonthlyTicketViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFMonthlyTicketViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
//
|
||||
// TFMonthlyTicketViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFMonthlyTicketViewController.h"
|
||||
#import "TFMonthlyTicketModel.h"
|
||||
#import "NSObject+Observer.h"
|
||||
#import "TFWebViewController.h"
|
||||
#import "TFMonthlyTicketViewCell.h"
|
||||
|
||||
@interface TFMonthlyTicketViewController ()<UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFMonthlyTicketModel *logModel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFMonthlyTicketViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Login_Success object:nil];
|
||||
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"月票记录")];
|
||||
|
||||
UIButton *_rightBtn = nil;
|
||||
WS(weakSelf)
|
||||
[self setNavigationBarRightButton:({
|
||||
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_rightBtn = rightBtn;
|
||||
rightBtn.hidden = YES;
|
||||
rightBtn.adjustsImageWhenHighlighted = NO;
|
||||
[rightBtn setImage:[UIImage imageNamed:@"book_help"] forState:UIControlStateNormal];
|
||||
[rightBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
|
||||
TFWebViewController *vc = [[TFWebViewController alloc] init];
|
||||
vc.URLString = weakSelf.logModel.ticket_rule ?: @"";
|
||||
vc.navTitle = TFLocalizedString(@"月票说明");
|
||||
vc.isPresentState = NO;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
}]];
|
||||
rightBtn;
|
||||
})];
|
||||
[_rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.navigationBar.navTitleLabel);
|
||||
make.right.equalTo(self.view).offset(- kMoreHalfMargin);
|
||||
make.height.width.mas_equalTo(21);
|
||||
}];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
[self.view addSubview:self.mainTableView];
|
||||
[self.mainTableView setContentInset:UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0)];
|
||||
self.mainTableView.dataSource = self;
|
||||
[self.mainTableView registerClass:TFMonthlyTicketViewCell.class forCellReuseIdentifier:@"Identifier"];
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.view).offset(PUB_NAVBAR_HEIGHT);
|
||||
make.left.right.bottom.equalTo(self.view);
|
||||
}];
|
||||
|
||||
[self createEmptyView];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)createEmptyView
|
||||
{
|
||||
WS(weakSelf)
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"登录后查看月票记录") buttonTitle:TFLocalizedString(@"立即登录") tapBlock:^{
|
||||
[TFLoginOptionsViewController presentLoginView:^(TFUserInfoManager * _Nonnull userDataModel) {
|
||||
weakSelf.emptyView = nil;
|
||||
[weakSelf createEmptyView];
|
||||
}];
|
||||
}];
|
||||
} else {
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无月票记录") buttonTitle:@"" tapBlock:^{
|
||||
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.logModel.list.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFMonthlyTicketViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Identifier" forIndexPath:indexPath];
|
||||
[cell setTicketListModel:self.logModel.list[indexPath.row]];
|
||||
[cell setSplitLineHidden:self.logModel.list.count == indexPath.row + 1];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
[self.mainTableView xtfei_showEmptyView];
|
||||
return;
|
||||
}
|
||||
|
||||
NSDictionary *params = @{
|
||||
@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber]
|
||||
};
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POSTQuick:Book_Reward_Ticket_Log parameters:params model:TFMonthlyTicketModel.class success:^(BOOL isSuccess, TFMonthlyTicketModel *_Nullable t_model, BOOL isCache, TFNetworkRequestModel *requestModel) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
if (isSuccess) {
|
||||
if (t_model.current_page == 1) {
|
||||
weakSelf.logModel = t_model;
|
||||
} else {
|
||||
weakSelf.logModel.list = [weakSelf.logModel.list arrayByAddingObjectsFromArray:t_model.list];
|
||||
}
|
||||
|
||||
[weakSelf.mainTableView reloadData];
|
||||
|
||||
if (t_model.current_page >= t_model.total_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
|
||||
}
|
||||
if (weakSelf.logModel.list.count > 0) {
|
||||
[weakSelf.mainTableView xtfei_hideEmptyView];
|
||||
} else {
|
||||
[weakSelf.mainTableView xtfei_showEmptyView];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[TFPromptManager showPromptWithError:error defaultText:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// TFMonthlyTicketModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFMonthlyTicketListModel, TFPagingModel;
|
||||
|
||||
@interface TFMonthlyTicketModel : TFPagingModel
|
||||
|
||||
@property (nonatomic ,copy) NSArray<TFMonthlyTicketListModel *> *list;
|
||||
@property (nonatomic ,copy) NSString *ticket_rule;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFMonthlyTicketListModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *title;
|
||||
@property (nonatomic ,copy) NSString *desc;
|
||||
@property (nonatomic ,copy) NSString *time;
|
||||
@property (nonatomic ,assign) NSInteger log_id;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TFMonthlyTicketModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFMonthlyTicketModel.h"
|
||||
|
||||
@implementation TFMonthlyTicketModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{
|
||||
@"list" : TFMonthlyTicketListModel.class
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFMonthlyTicketListModel
|
||||
|
||||
@end
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFMonthlyTicketViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFMonthlyTicketModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFMonthlyTicketViewCell : UITableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFMonthlyTicketListModel *ticketListModel;
|
||||
|
||||
- (void)setSplitLineHidden:(BOOL)hidden;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// TFMonthlyTicketViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFMonthlyTicketViewCell.h"
|
||||
#import "NSObject+Observer.h"
|
||||
|
||||
@interface TFMonthlyTicketViewCell ()
|
||||
{
|
||||
UIView *_splitLine;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFMonthlyTicketViewCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
UILabel *nameLabel = [[UILabel alloc] init];
|
||||
nameLabel.textColor = kBlackColor;
|
||||
nameLabel.font = kFont14;
|
||||
[self.contentView addSubview:nameLabel];
|
||||
[nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.contentView).offset(kMoreHalfMargin);
|
||||
make.left.equalTo(self.contentView).offset(kMoreHalfMargin);
|
||||
}];
|
||||
|
||||
UILabel *timeLabel = [[UILabel alloc] init];
|
||||
timeLabel.textColor = kGrayTextColor;
|
||||
timeLabel.font = kFont14;
|
||||
[self.contentView addSubview:timeLabel];
|
||||
[timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(nameLabel.mas_bottom).offset(kHalfMargin);
|
||||
make.left.equalTo(self.contentView).offset(kMoreHalfMargin);
|
||||
}];
|
||||
|
||||
UILabel *descLabel = [[UILabel alloc] init];
|
||||
descLabel.textColor = kGrayTextColor;
|
||||
descLabel.font = kFont14;
|
||||
[self.contentView addSubview:descLabel];
|
||||
[descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.contentView);
|
||||
make.right.equalTo(self.contentView).offset(-kMoreHalfMargin);
|
||||
}];
|
||||
|
||||
_splitLine = [[UIView alloc] init];
|
||||
_splitLine.backgroundColor = kGrayLineColor;
|
||||
[self.contentView addSubview:_splitLine];
|
||||
[_splitLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(kCellLineHeight);
|
||||
make.bottom.equalTo(self.contentView);
|
||||
make.left.equalTo(self.contentView).offset(kMoreHalfMargin);
|
||||
make.right.equalTo(self.contentView).offset(-kMoreHalfMargin);
|
||||
make.top.equalTo(timeLabel.mas_bottom).offset(kMoreHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
[self addObserver:KEY_PATH(self, ticketListModel) complete:^(id _Nonnull obj, id _Nullable oldVal, TFMonthlyTicketListModel * _Nullable newVal) {
|
||||
nameLabel.text = newVal.title ?: @"";
|
||||
timeLabel.text = newVal.time ?: @"";
|
||||
descLabel.text = newVal.desc ?: @"";
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setSplitLineHidden:(BOOL)hidden
|
||||
{
|
||||
_splitLine.hidden = hidden;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user