小说绘上架版本
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFRewardRecordViewController.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 TFRewardRecordViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// TFRewardRecordViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRewardRecordViewController.h"
|
||||
#import "TFRewardRecordViewCell.h"
|
||||
#import "TFRewardRecordModel.h"
|
||||
|
||||
@interface TFRewardRecordViewController ()<UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFRewardRecordModel *recordModel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFRewardRecordViewController
|
||||
|
||||
- (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(@"打赏记录")];
|
||||
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:TFRewardRecordViewCell.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];
|
||||
|
||||
WS(weakSelf)
|
||||
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.recordModel.list.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFRewardRecordViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Identifier" forIndexPath:indexPath];
|
||||
[cell setRecordModel:self.recordModel.list[indexPath.row]];
|
||||
[cell setSplitLineHidden:self.recordModel.list.count == indexPath.row + 1];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
if (!TFUserInfoManager.isLogin || [TFNetworkManager networkingStatus] == NO) {
|
||||
[self.mainTableView xtfei_showEmptyView];
|
||||
return;
|
||||
}
|
||||
|
||||
NSDictionary *params = @{
|
||||
@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber]
|
||||
};
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POSTQuick:Book_Reward_Gift_Log parameters:params model:TFRewardRecordModel.class success:^(BOOL isSuccess, TFRewardRecordModel *_Nullable t_model, BOOL isCache, TFNetworkRequestModel *requestModel) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
if (isSuccess) {
|
||||
if (t_model.current_page == 1) {
|
||||
weakSelf.recordModel = t_model;
|
||||
} else {
|
||||
weakSelf.recordModel.list = [weakSelf.recordModel.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.recordModel.list.count > 0) {
|
||||
[weakSelf.mainTableView xtfei_hideEmptyView];
|
||||
} else {
|
||||
[weakSelf.mainTableView xtfei_showEmptyView];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
if (weakSelf.recordModel.list.count > 0) {
|
||||
[weakSelf.mainTableView xtfei_hideEmptyView];
|
||||
} else {
|
||||
[weakSelf.mainTableView xtfei_showEmptyView];
|
||||
}
|
||||
[TFPromptManager showPromptWithError:error defaultText:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user