小说绘上架版本
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TFAboutViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAboutViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
//
|
||||
// TFAboutViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAboutViewController.h"
|
||||
#import "WXYZ_AboutModel.h"
|
||||
#import "TFAboutTableViewCell.h"
|
||||
#import "TFWebViewController.h"
|
||||
|
||||
@interface TFAboutViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) WXYZ_AboutModel *aboutModel;
|
||||
|
||||
@property (nonatomic ,strong) UILabel *companyLabel;
|
||||
@end
|
||||
|
||||
@implementation TFAboutViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"联系客服")];
|
||||
|
||||
self.view.backgroundColor = kGrayViewColor;
|
||||
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(self.view.mas_height).with.offset(- PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
[self.mainTableView setTableHeaderView:[self headerView]];
|
||||
|
||||
self.companyLabel = [[UILabel alloc] init];
|
||||
self.companyLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.companyLabel.textColor = [UIColor grayColor];
|
||||
self.companyLabel.numberOfLines = 0;
|
||||
self.companyLabel.font = kFont10;
|
||||
[self.mainTableView addSubview:self.companyLabel];
|
||||
|
||||
[self.companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(30);
|
||||
make.bottom.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - (is_iPhoneX?15.0f:0.0f));
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.aboutModel.about.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFAboutTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFAboutTableViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[TFAboutTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFAboutTableViewCell"];
|
||||
|
||||
}
|
||||
cell.contactInfoModel = [self.aboutModel.about objectAtIndex:indexPath.row];
|
||||
cell.hiddenEndLine = (indexPath.row == self.aboutModel.about.count - 1);
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
WXYZ_ContactInfoModel *t_model = [self.aboutModel.about objectAtIndex:indexPath.row];
|
||||
|
||||
if ([t_model.action isEqualToString:@"url"]) {
|
||||
TFWebViewController *vc = [[TFWebViewController alloc] init];
|
||||
vc.navTitle = t_model.title?:@"";
|
||||
vc.URLString = t_model.content?:@"";
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
} else if ([t_model.action isEqualToString:@"telphone"]) {
|
||||
NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",t_model.content]];
|
||||
[[UIApplication sharedApplication] openURL:phoneURL options:@{} completionHandler:nil];
|
||||
} else {
|
||||
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
||||
pasteboard.string = t_model.content?:@"";
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已复制到粘贴板")];
|
||||
}
|
||||
}
|
||||
|
||||
- (UIView *)headerView
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 180)];
|
||||
view.backgroundColor = kWhiteColor;
|
||||
|
||||
UIImageView *iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[[[[NSBundle mainBundle] infoDictionary] valueForKeyPath:@"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles"] lastObject]]];
|
||||
iconImageView.layer.cornerRadius = 12.0;
|
||||
iconImageView.layer.masksToBounds = YES;
|
||||
[view addSubview:iconImageView];
|
||||
[iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(view.mas_centerX);
|
||||
make.bottom.mas_equalTo(view.mas_centerY).with.offset(10);
|
||||
make.width.height.mas_equalTo(60);
|
||||
}];
|
||||
|
||||
UILabel *appNameLabel = [[UILabel alloc] init];
|
||||
appNameLabel.text = App_Name;
|
||||
appNameLabel.textAlignment = NSTextAlignmentCenter;
|
||||
appNameLabel.textColor = kBlackColor;
|
||||
appNameLabel.font = kMainFont;
|
||||
[view addSubview:appNameLabel];
|
||||
|
||||
[appNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(iconImageView.mas_centerX);
|
||||
make.top.mas_equalTo(iconImageView.mas_bottom).with.offset(10);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:About_Soft parameters:nil model:WXYZ_AboutModel.class success:^(BOOL isSuccess, WXYZ_AboutModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.aboutModel = t_model;
|
||||
weakSelf.companyLabel.text = t_model.company;
|
||||
}
|
||||
[weakSelf.mainTableView reloadData];
|
||||
} failure:nil];
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// WXYZ_AboutModel.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/10/15.
|
||||
// Copyright © 2018 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class WXYZ_ContactInfoModel;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_AboutModel : NSObject
|
||||
|
||||
@property (nonatomic, strong) NSArray <WXYZ_ContactInfoModel *> *about;
|
||||
|
||||
@property (nonatomic, copy) NSString *company; // 公司
|
||||
|
||||
@end
|
||||
|
||||
@interface WXYZ_ContactInfoModel : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSString *title;
|
||||
|
||||
@property (nonatomic, copy) NSString *content;
|
||||
|
||||
@property (nonatomic, copy) NSString *action;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// WXYZ_AboutModel.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/10/15.
|
||||
// Copyright © 2018 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_AboutModel.h"
|
||||
|
||||
@implementation WXYZ_AboutModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
|
||||
return @{
|
||||
@"about" : [WXYZ_ContactInfoModel class]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_ContactInfoModel
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFAboutTableViewCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "WXYZ_AboutModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAboutTableViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic, strong) WXYZ_ContactInfoModel *contactInfoModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// TFAboutTableViewCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAboutTableViewCell.h"
|
||||
|
||||
@interface TFAboutTableViewCell ()
|
||||
{
|
||||
UILabel *titleLabel;
|
||||
UILabel *detailTitleLabel;
|
||||
UIImageView *connerImage;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFAboutTableViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
titleLabel.textColor = kBlackColor;
|
||||
titleLabel.font = kMainFont;
|
||||
[self.contentView addSubview:titleLabel];
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.width.mas_equalTo(120);
|
||||
make.height.mas_equalTo(kLabelHeight);
|
||||
}];
|
||||
|
||||
connerImage = [[UIImageView alloc] init];
|
||||
connerImage.image = [UIImage imageNamed:@"public_more"];
|
||||
connerImage.hidden = NO;
|
||||
[self.contentView addSubview:connerImage];
|
||||
[connerImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.width.height.mas_equalTo(10);
|
||||
}];
|
||||
|
||||
detailTitleLabel = [[UILabel alloc] init];
|
||||
detailTitleLabel.textAlignment = NSTextAlignmentRight;
|
||||
detailTitleLabel.textColor = kGrayTextColor;
|
||||
detailTitleLabel.font = kFont12;
|
||||
[self.contentView addSubview:detailTitleLabel];
|
||||
[detailTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(connerImage);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.left.equalTo(titleLabel.mas_right).offset(kHalfMargin);
|
||||
make.height.mas_equalTo(kLabelHeight);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setContactInfoModel:(WXYZ_ContactInfoModel *)contactInfoModel
|
||||
{
|
||||
_contactInfoModel = contactInfoModel;
|
||||
|
||||
titleLabel.text = contactInfoModel.title?:@"";
|
||||
[titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:titleLabel]);
|
||||
}];
|
||||
|
||||
if (![contactInfoModel.action isEqualToString:@"url"]) {
|
||||
detailTitleLabel.text = contactInfoModel.content?:@"";
|
||||
connerImage.hidden = YES;
|
||||
} else {
|
||||
detailTitleLabel.text = @"";
|
||||
connerImage.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFAppraiseCommViewController.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 TFAppraiseCommViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
//
|
||||
// TFAppraiseCommViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAppraiseCommViewController.h"
|
||||
#import "TFAppraiseDetailViewController.h"
|
||||
#import "TFAppraiseCommViewCell.h"
|
||||
|
||||
@interface TFAppraiseCommViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAppraiseCommViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Login_Success object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.view.mas_top);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - self.pageViewHeight);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
|
||||
[self createEmptyView];
|
||||
}
|
||||
|
||||
- (void)createEmptyView
|
||||
{
|
||||
WS(weakSelf)
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"登录后可查看评论内容") buttonTitle:TFLocalizedString(@"立即登录") tapBlock:^{
|
||||
[TFLoginOptionsViewController presentLoginView:^(TFUserInfoManager * _Nonnull userInfo) {
|
||||
weakSelf.emptyView = nil;
|
||||
[weakSelf createEmptyView];
|
||||
}];
|
||||
}];
|
||||
} else {
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无评论内容") buttonTitle:nil tapBlock:^{
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
static NSString *cellName = @"TFAppraiseCommViewCell";
|
||||
TFAppraiseCommViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFAppraiseCommViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.commentsDetailModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
cell.hiddenEndLine = indexPath.row == self.dataSourceArray.count - 1;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFCommentsListModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
TFAppraiseDetailViewController *vc = [[TFAppraiseDetailViewController alloc] init];
|
||||
vc.productionType = self.productionType;
|
||||
vc.comment_id = t_model.comment_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
if ([TFNetworkManager networkingStatus] == NO) {
|
||||
[self.mainTableView endRefreshing];
|
||||
[self.mainTableView xtfei_showEmptyView];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Comments_List;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Comments_List;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Comments_List;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:url parameters:@{@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber]} model:TFCommentsModel.class success:^(BOOL isSuccess, TFCommentsModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.mainTableView showRefreshFooter];
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
[weakSelf.mainTableView reloadData];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFAppraiseDetailViewController.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 TFAppraiseDetailViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) NSInteger comment_id;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+251
@@ -0,0 +1,251 @@
|
||||
//
|
||||
// TFAppraiseDetailViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAppraiseDetailViewController.h"
|
||||
#import "TFAppraiseDetailHeaderView.h"
|
||||
#import "TFCommentsViewCell.h"
|
||||
#import "TFAppraiseDetailModel.h"
|
||||
|
||||
@interface TFAppraiseDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFAppraiseDetailModel *appraiseDetailModel;
|
||||
@property (nonatomic ,strong) UILabel *footerView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAppraiseDetailViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenSeparator];
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"评论详情")];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableViewGroup.delegate = self;
|
||||
self.mainTableViewGroup.dataSource = self;
|
||||
[self.view addSubview:self.mainTableViewGroup];
|
||||
|
||||
[self.mainTableViewGroup setTableFooterView:self.footerView];
|
||||
|
||||
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(self.view.mas_height).with.offset(- PUB_NAVBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 0) {
|
||||
return 1;
|
||||
}
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == 0) {
|
||||
WS(weakSelf)
|
||||
static NSString *cellName = @"TFAppraiseDetailHeaderView";
|
||||
TFAppraiseDetailHeaderView *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFAppraiseDetailHeaderView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.commentProductionClickBlock = ^{
|
||||
switch (weakSelf.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = weakSelf.appraiseDetailModel.production_id;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *vc = [[TFComicDetailViewController alloc] init];
|
||||
vc.comic_id = weakSelf.appraiseDetailModel.production_id;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = weakSelf.appraiseDetailModel.production_id;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
cell.appraiseDetailModel = self.appraiseDetailModel;
|
||||
cell.productionType = self.productionType;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
} else {
|
||||
static NSString *cellName = @"TFCommentsViewCell";
|
||||
TFCommentsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFCommentsViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.commentModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
cell.hiddenEndLine = indexPath.row == self.dataSourceArray.count - 1;
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFCommentsListModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
self.comment_id = t_model.comment_id;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 0) {
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
return 44;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)];
|
||||
|
||||
if (section == 1) {
|
||||
UILabel *headerTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kMargin, 0, SCREEN_WIDTH - kMargin, 44)];
|
||||
headerTitleLabel.textColor = kBlackColor;
|
||||
headerTitleLabel.text = [NSString stringWithFormat:@"%@ (%@)", TFLocalizedString(@"全部回复"), [TFUtilsHelper formatStringWithInteger:self.appraiseDetailModel.total_count]];
|
||||
headerTitleLabel.font = kBoldMainFont;
|
||||
headerTitleLabel.backgroundColor = [UIColor clearColor];
|
||||
[view addSubview:headerTitleLabel];
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 0) {
|
||||
return 10;
|
||||
}
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
if (section == 0) {
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
} else {
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
- (UILabel *)footerView
|
||||
{
|
||||
if (!_footerView) {
|
||||
_footerView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN)];
|
||||
_footerView.textColor = kGrayTextColor;
|
||||
_footerView.textAlignment = NSTextAlignmentCenter;
|
||||
_footerView.font = kFont10;
|
||||
}
|
||||
return _footerView;
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
NSDictionary *parameters = [NSDictionary dictionary];
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
parameters = @{@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber], @"comment_id":[TFUtilsHelper formatStringWithInteger:self.comment_id], @"type":@"1"};
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
parameters = @{@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber], @"comment_id":[TFUtilsHelper formatStringWithInteger:self.comment_id], @"type":@"2"};
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
parameters = @{@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber], @"comment_id":[TFUtilsHelper formatStringWithInteger:self.comment_id], @"type":@"3"};
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[TFNetworkTools POST:Comment_Detail parameters:parameters model:TFAppraiseDetailModel.class success:^(BOOL isSuccess, TFAppraiseDetailModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
weakSelf.appraiseDetailModel = t_model;
|
||||
|
||||
[weakSelf.mainTableViewGroup showRefreshFooter];
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableViewGroup hideRefreshFooter];
|
||||
weakSelf.footerView.text = TFLocalizedString(@"已显示全部");
|
||||
weakSelf.footerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 30);
|
||||
} else {
|
||||
weakSelf.footerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN);
|
||||
}
|
||||
|
||||
if (t_model.total_count == 0) {
|
||||
weakSelf.footerView.text = TFLocalizedString(@"暂无评论回复");
|
||||
weakSelf.footerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 30);
|
||||
}
|
||||
[weakSelf.mainTableViewGroup setTableFooterView:weakSelf.footerView];
|
||||
}
|
||||
[weakSelf.mainTableViewGroup endRefreshing];
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
[weakSelf.mainTableViewGroup xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableViewGroup endRefreshing];
|
||||
[weakSelf.mainTableViewGroup xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFAppraiseViewController.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 TFAppraiseViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
//
|
||||
// TFAppraiseViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAppraiseViewController.h"
|
||||
#import "TFAppraiseCommViewController.h"
|
||||
|
||||
@interface TFAppraiseViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAppraiseViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubViews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Hidden_Tabbar object:@"1"];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"我的评论")];
|
||||
[self hiddenSeparator];
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
#if TF_Enable_Book
|
||||
TFAppraiseCommViewController *bookVC = [[TFAppraiseCommViewController alloc] init];
|
||||
bookVC.productionType = TFProductionTypeNovel;
|
||||
[self addChildViewController:bookVC];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
TFAppraiseCommViewController *comicVC = [[TFAppraiseCommViewController alloc] init];
|
||||
comicVC.productionType = TFProductionTypeComic;
|
||||
[self addChildViewController:comicVC];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
TFAppraiseCommViewController *audioVC = [[TFAppraiseCommViewController alloc] init];
|
||||
audioVC.productionType = TFProductionTypeAudio;
|
||||
[self addChildViewController:audioVC];
|
||||
#endif
|
||||
|
||||
NSMutableArray *titleArr = [NSMutableArray array];
|
||||
NSMutableArray *childArr = [NSMutableArray array];
|
||||
|
||||
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
|
||||
#if TF_Enable_Book
|
||||
if ([siteNumber integerValue] == 1) {
|
||||
[titleArr addObject:TFLocalizedString(@"小说")];
|
||||
[childArr addObject:bookVC];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
if ([siteNumber integerValue] == 2) {
|
||||
[titleArr addObject:TFLocalizedString(@"漫画")];
|
||||
[childArr addObject:comicVC];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
if ([siteNumber integerValue] == 3) {
|
||||
[titleArr addObject:TFLocalizedString(@"听书")];
|
||||
[childArr addObject:audioVC];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count <= 1) {
|
||||
[titleArr removeAllObjects];
|
||||
[titleArr addObject:TFLocalizedString(@"评论")];
|
||||
}
|
||||
|
||||
self.pageViewHeight = titleArr.count > 1?self.pageViewHeight:0;
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT + self.pageViewHeight, SCREEN_WIDTH, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - self.pageViewHeight) parentVC:self childVCs:childArr];
|
||||
self.pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, self.pageViewHeight) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:self.pageTitleView];
|
||||
}
|
||||
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
|
||||
@end
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// TFAppraiseDetailModel.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
|
||||
|
||||
@interface TFAppraiseDetailModel : TFCommentsModel
|
||||
|
||||
@property (nonatomic ,assign) NSInteger production_id; // 作品id
|
||||
@property (nonatomic ,assign) NSInteger chapter_id;
|
||||
@property (nonatomic ,copy) NSString *name; // 作品名
|
||||
@property (nonatomic ,assign) NSInteger comment_id;
|
||||
@property (nonatomic ,assign) NSInteger uid;
|
||||
@property (nonatomic ,copy) NSString *nickname;
|
||||
@property (nonatomic ,copy) NSString *avatar;
|
||||
@property (nonatomic ,copy) NSString *time;
|
||||
@property (nonatomic ,assign) NSInteger like_num;
|
||||
@property (nonatomic ,copy) NSString *content;
|
||||
@property (nonatomic ,assign) BOOL is_vip;
|
||||
@property (nonatomic ,copy) NSString *cover;
|
||||
@property (nonatomic ,copy) NSString *author;
|
||||
@property (nonatomic ,copy) NSString *reply_info;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFAppraiseDetailModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAppraiseDetailModel.h"
|
||||
|
||||
@implementation TFAppraiseDetailModel
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"production_id" : @[@"book_id", @"comic_id", @"audio_id"],
|
||||
@"name" : @[@"name", @"title", @"book_name", @"comic_name", @"audio_name"]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFAppraiseCommViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicTableViewCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAppraiseCommViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFCommentsListModel *commentsDetailModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
//
|
||||
// TFAppraiseCommViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAppraiseCommViewCell.h"
|
||||
|
||||
@interface TFAppraiseCommViewCell ()
|
||||
|
||||
@property (nonatomic ,strong) UIImageView *avatarView; //头像
|
||||
@property (nonatomic ,strong) UILabel *nickNameLabel; //昵称
|
||||
@property (nonatomic ,strong) UIImageView *vipView; // VIP标识
|
||||
@property (nonatomic ,strong) UILabel *timeLabel; //发布时间
|
||||
@property (nonatomic ,strong) UILabel *commentLabel; //评论
|
||||
@property (nonatomic ,strong) YYLabel *replyCommentLabel; //二级评论
|
||||
@property (nonatomic ,strong) UILabel *bookNameLabel;
|
||||
@property (nonatomic ,strong) UILabel *commentCountLabel;
|
||||
@end
|
||||
|
||||
@implementation TFAppraiseCommViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
// 头像
|
||||
self.avatarView = [[UIImageView alloc] initWithCornerRadiusAdvance:35.0f / 2 rectCornerType:UIRectCornerAllCorners];
|
||||
[self.contentView addSubview:self.avatarView];
|
||||
|
||||
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
|
||||
make.width.height.mas_equalTo(35.0f);
|
||||
}];
|
||||
|
||||
// 昵称
|
||||
self.nickNameLabel = [[UILabel alloc] init];
|
||||
self.nickNameLabel.textColor = kGrayTextDeepColor;
|
||||
self.nickNameLabel.font = kFont13;
|
||||
self.nickNameLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.contentView addSubview:self.nickNameLabel];
|
||||
|
||||
[self.nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.avatarView.mas_right).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.avatarView.mas_top);
|
||||
make.width.mas_equalTo(200);
|
||||
make.height.mas_equalTo(self.avatarView.mas_height).multipliedBy(0.6);
|
||||
}];
|
||||
|
||||
self.vipView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_vip_normal"]];
|
||||
self.vipView.hidden = YES;
|
||||
[self addSubview:self.vipView];
|
||||
|
||||
[self.vipView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nickNameLabel.mas_right);
|
||||
make.centerY.mas_equalTo(self.nickNameLabel.mas_centerY);
|
||||
make.height.mas_equalTo(10);
|
||||
make.width.mas_equalTo(kGeometricWidth(10, 138, 48));
|
||||
}];
|
||||
|
||||
self.timeLabel = [[UILabel alloc] init];
|
||||
self.timeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.timeLabel.font = kFont10;
|
||||
self.timeLabel.textColor = kGrayTextColor;
|
||||
[self.contentView addSubview:self.timeLabel];
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nickNameLabel.mas_left);
|
||||
make.bottom.mas_equalTo(self.avatarView.mas_bottom);
|
||||
make.right.mas_equalTo(self.contentView.mas_right);
|
||||
make.height.mas_equalTo(self.avatarView.mas_height).multipliedBy(0.4);
|
||||
}];
|
||||
|
||||
// 二级评论
|
||||
self.replyCommentLabel = [[YYLabel alloc] init];
|
||||
self.replyCommentLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.replyCommentLabel.textColor = kGrayTextDeepColor;
|
||||
self.replyCommentLabel.font = kFont13;
|
||||
self.replyCommentLabel.backgroundColor = kGrayViewColor;
|
||||
self.replyCommentLabel.numberOfLines = 0;
|
||||
self.replyCommentLabel.textContainerInset = UIEdgeInsetsMake(6, 5, 4, 5);
|
||||
[self.contentView addSubview:self.replyCommentLabel];
|
||||
|
||||
[self.replyCommentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nickNameLabel.mas_left);
|
||||
make.top.mas_equalTo(self.avatarView.mas_bottom);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
// 评论
|
||||
self.commentLabel = [[UILabel alloc] init];
|
||||
self.commentLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.commentLabel.font = kMainFont;
|
||||
self.commentLabel.numberOfLines = 0;
|
||||
self.commentLabel.textColor = kBlackColor;
|
||||
[self.contentView addSubview:self.commentLabel];
|
||||
|
||||
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nickNameLabel.mas_left);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.top.mas_equalTo(self.replyCommentLabel.mas_bottom).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(200);
|
||||
}];
|
||||
|
||||
self.commentCountLabel = [[UILabel alloc] init];
|
||||
self.commentCountLabel.font = kFont10;
|
||||
self.commentCountLabel.textAlignment = NSTextAlignmentRight;
|
||||
self.commentCountLabel.textColor = kGrayTextColor;
|
||||
[self.contentView addSubview:self.commentCountLabel];
|
||||
|
||||
[self.commentCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.top.mas_equalTo(self.commentLabel.mas_bottom).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(100);
|
||||
make.height.mas_equalTo(15);
|
||||
}];
|
||||
|
||||
self.bookNameLabel = [[UILabel alloc] init];
|
||||
self.bookNameLabel.font = kFont10;
|
||||
self.bookNameLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.bookNameLabel.textColor = kGrayTextColor;
|
||||
[self.contentView addSubview:self.bookNameLabel];
|
||||
|
||||
[self.bookNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nickNameLabel.mas_left);
|
||||
make.right.mas_equalTo(self.commentCountLabel.mas_left).with.offset(- kHalfMargin);
|
||||
make.centerY.mas_equalTo(self.commentCountLabel.mas_centerY);
|
||||
make.height.mas_equalTo(self.commentCountLabel.mas_height);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setCommentsDetailModel:(TFCommentsListModel *)commentsDetailModel
|
||||
{
|
||||
if (!commentsDetailModel) {
|
||||
return;
|
||||
}
|
||||
|
||||
_commentsDetailModel = commentsDetailModel;
|
||||
|
||||
self.timeLabel.text = [NSString stringWithFormat:@"%@",commentsDetailModel.time ? : @""];
|
||||
self.commentLabel.text = [NSString stringWithFormat:@"%@",commentsDetailModel.content ? : @""];
|
||||
|
||||
[self.commentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:self.commentLabel.font labelWidth:(SCREEN_WIDTH - 35.0f - kMargin) labelText:self.commentLabel.text] - kHalfMargin);
|
||||
}];
|
||||
|
||||
[self.avatarView setImageWithURL:[NSURL URLWithString:commentsDetailModel.avatar ? : @""] placeholder:HoldUserAvatar options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
|
||||
self.nickNameLabel.text = [NSString stringWithFormat:@"%@",commentsDetailModel.nickname ? : @""];
|
||||
[self.nickNameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.nickNameLabel]);
|
||||
}];
|
||||
|
||||
if (commentsDetailModel.is_vip == 1) {
|
||||
self.vipView.hidden = NO;
|
||||
} else {
|
||||
self.vipView.hidden = YES;
|
||||
}
|
||||
|
||||
self.commentCountLabel.text = [NSString stringWithFormat:TFLocalizedString(@"%@条回复"), [TFUtilsHelper formatStringWithInteger:commentsDetailModel.reply_num]];
|
||||
[self.commentCountLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.commentCountLabel]);
|
||||
}];
|
||||
|
||||
self.bookNameLabel.text = commentsDetailModel.name_title ? : @"";
|
||||
|
||||
if (commentsDetailModel.reply_info.length > 0) {
|
||||
|
||||
CGFloat replyHeight = [TFViewHelper getDynamicHeightWithLabelFont:kFont11 labelWidth:(SCREEN_WIDTH - 2 * kMargin - 35.0f - kHalfMargin) labelText:commentsDetailModel.reply_info ? : @""];
|
||||
NSString *replyInfo = [NSString stringWithFormat:@"%@",commentsDetailModel.reply_info ? : @""];
|
||||
|
||||
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
|
||||
style.lineSpacing = 3;
|
||||
|
||||
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:replyInfo];
|
||||
[attrString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, replyInfo.length)];
|
||||
[attrString addAttribute:NSFontAttributeName value:kFont11 range:NSMakeRange(0, replyInfo.length)];
|
||||
|
||||
self.replyCommentLabel.attributedText = attrString;
|
||||
[self.replyCommentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.avatarView.mas_bottom).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(replyHeight);
|
||||
}];
|
||||
} else {
|
||||
self.replyCommentLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:@""];
|
||||
[self.replyCommentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.avatarView.mas_bottom);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
}
|
||||
|
||||
[self.commentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:self.commentLabel.font labelWidth:(SCREEN_WIDTH - 35.0f - kMargin) labelText:self.commentLabel.text] - kHalfMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFAppraiseDetailHeaderView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFAppraiseDetailModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAppraiseDetailHeaderView : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,copy) void (^commentProductionClickBlock)(void);
|
||||
|
||||
@property (nonatomic ,strong) TFAppraiseDetailModel *appraiseDetailModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
//
|
||||
// TFAppraiseDetailHeaderView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAppraiseDetailHeaderView.h"
|
||||
|
||||
@interface TFAppraiseDetailHeaderView ()
|
||||
|
||||
@property (nonatomic ,strong) UIImageView *avatarView; //头像
|
||||
@property (nonatomic ,strong) UILabel *nickNameLabel; //昵称
|
||||
@property (nonatomic ,strong) UIImageView *vipView; // VIP标识
|
||||
@property (nonatomic ,strong) UILabel *timeLabel; //发布时间
|
||||
@property (nonatomic ,strong) UILabel *commentLabel; //评论
|
||||
@property (nonatomic ,strong) YYLabel *replycommentLabel; // 二级评论
|
||||
@property (nonatomic ,strong) TFProductionCoverView *coverView;
|
||||
@property (nonatomic ,strong) UIButton *baseBtn;
|
||||
@property (nonatomic ,strong) UILabel *titleLabel;
|
||||
@property (nonatomic ,strong) UILabel *authorLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAppraiseDetailHeaderView
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
// 头像
|
||||
self.avatarView = [[UIImageView alloc] initWithCornerRadiusAdvance:35.0f / 2 rectCornerType:UIRectCornerAllCorners];
|
||||
[self.contentView addSubview:self.avatarView];
|
||||
|
||||
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kMargin);
|
||||
make.width.height.mas_equalTo(35.0f);
|
||||
}];
|
||||
|
||||
// 昵称
|
||||
self.nickNameLabel = [[UILabel alloc] init];
|
||||
self.nickNameLabel.textColor = kGrayTextDeepColor;
|
||||
self.nickNameLabel.font = kFont13;
|
||||
self.nickNameLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.contentView addSubview:self.nickNameLabel];
|
||||
|
||||
[self.nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.avatarView.mas_right).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.avatarView.mas_top);
|
||||
make.width.mas_equalTo(200);
|
||||
make.height.mas_equalTo(self.avatarView.mas_height).multipliedBy(0.6);
|
||||
}];
|
||||
|
||||
self.vipView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_vip_normal"]];
|
||||
self.vipView.hidden = YES;
|
||||
[self.contentView addSubview:self.vipView];
|
||||
|
||||
[self.vipView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.nickNameLabel.mas_right);
|
||||
make.centerY.mas_equalTo(self.nickNameLabel.mas_centerY);
|
||||
make.height.mas_equalTo(10);
|
||||
make.width.mas_equalTo(kGeometricWidth(10, 138, 48));
|
||||
}];
|
||||
|
||||
self.timeLabel = [[UILabel alloc] init];
|
||||
self.timeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.timeLabel.font = kFont10;
|
||||
self.timeLabel.textColor = kGrayTextColor;
|
||||
[self.contentView addSubview:self.timeLabel];
|
||||
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.avatarView.mas_right).with.offset(kHalfMargin);
|
||||
make.bottom.mas_equalTo(self.avatarView.mas_bottom);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(self.avatarView.mas_height).multipliedBy(0.4);
|
||||
}];
|
||||
|
||||
// 二级评论
|
||||
self.replycommentLabel = [[YYLabel alloc] init];
|
||||
self.replycommentLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.replycommentLabel.textColor = kGrayTextDeepColor;
|
||||
self.replycommentLabel.font = kFont13;
|
||||
self.replycommentLabel.backgroundColor = kGrayViewColor;
|
||||
self.replycommentLabel.numberOfLines = 0;
|
||||
self.replycommentLabel.textContainerInset = UIEdgeInsetsMake(6, 5, 4, 5);
|
||||
[self.contentView addSubview:self.replycommentLabel];
|
||||
|
||||
[self.replycommentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.avatarView.mas_left);
|
||||
make.top.mas_equalTo(self.avatarView.mas_bottom);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
// 评论
|
||||
self.commentLabel = [[UILabel alloc] init];
|
||||
self.commentLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.commentLabel.font = kFont12;
|
||||
self.commentLabel.numberOfLines = 0;
|
||||
self.commentLabel.textColor = KGrayTextMiddleColor;
|
||||
[self.contentView addSubview:self.commentLabel];
|
||||
|
||||
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.top.mas_equalTo(self.replycommentLabel.mas_bottom).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(200);
|
||||
}];
|
||||
|
||||
self.baseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.baseBtn.backgroundColor = kGrayViewColor;
|
||||
[ self.baseBtn addTarget:self action:@selector(commentProductionClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.contentView addSubview: self.baseBtn];
|
||||
|
||||
[ self.baseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.top.mas_equalTo(self.commentLabel.mas_bottom).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH, 3, 1) - kMargin);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
self.coverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
self.coverView.userInteractionEnabled = NO;
|
||||
[ self.baseBtn addSubview:self.coverView];
|
||||
|
||||
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo( self.baseBtn.mas_left).with.offset(kHalfMargin);
|
||||
make.centerY.mas_equalTo( self.baseBtn.mas_centerY);
|
||||
make.height.mas_equalTo( self.baseBtn.mas_height).with.offset(- kMargin);
|
||||
make.width.mas_equalTo(kGeometricWidth(kGeometricHeight(SCREEN_WIDTH, 3, 1) - 2 * kMargin, 3, 4));
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.textColor = kBlackColor;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.titleLabel.numberOfLines = 1;
|
||||
self.titleLabel.font = kMainFont;
|
||||
[ self.baseBtn addSubview:self.titleLabel];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.coverView.mas_right).with.offset(kHalfMargin);
|
||||
make.bottom.mas_equalTo( self.baseBtn.mas_centerY);
|
||||
make.right.mas_equalTo( self.baseBtn.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
self.authorLabel = [[UILabel alloc] init];
|
||||
self.authorLabel.textColor = kGrayTextColor;
|
||||
self.authorLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.authorLabel.font = kFont10;
|
||||
[ self.baseBtn addSubview:self.authorLabel];
|
||||
|
||||
[self.authorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_left);
|
||||
make.right.mas_equalTo(self.titleLabel.mas_right);
|
||||
make.height.mas_equalTo(30);
|
||||
make.top.mas_equalTo( self.baseBtn.mas_centerY);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setAppraiseDetailModel:(TFAppraiseDetailModel *)appraiseDetailModel
|
||||
{
|
||||
_appraiseDetailModel = appraiseDetailModel;
|
||||
|
||||
self.timeLabel.text = [NSString stringWithFormat:@"%@",appraiseDetailModel.time ? : @""];
|
||||
|
||||
self.commentLabel.text = [NSString stringWithFormat:@"%@",appraiseDetailModel.content ? : @""];
|
||||
|
||||
[self.commentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:self.commentLabel.font labelWidth:(SCREEN_WIDTH - 35.0f - kMargin) labelText:self.commentLabel.text] - kHalfMargin);
|
||||
}];
|
||||
|
||||
[self.avatarView setImageWithURL:[NSURL URLWithString:appraiseDetailModel.avatar ? : @""] placeholder:HoldUserAvatar options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
|
||||
|
||||
self.nickNameLabel.text = [NSString stringWithFormat:@"%@",appraiseDetailModel.nickname ? : @""];
|
||||
[self.nickNameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.nickNameLabel]);
|
||||
}];
|
||||
|
||||
if (appraiseDetailModel.is_vip == 1) {
|
||||
self.vipView.hidden = NO;
|
||||
} else {
|
||||
self.vipView.hidden = YES;
|
||||
}
|
||||
|
||||
self.coverView.coverImageUrl = appraiseDetailModel.cover;
|
||||
|
||||
self.titleLabel.text = appraiseDetailModel.name ? : @"";
|
||||
|
||||
self.authorLabel.text = appraiseDetailModel.author ? : @"";
|
||||
|
||||
if (appraiseDetailModel.reply_info.length > 0) {
|
||||
CGFloat replyHeight = [TFViewHelper getDynamicHeightWithLabelFont:kFont11 labelWidth:(SCREEN_WIDTH - 2 * kMargin - 35.0f - kHalfMargin) labelText:appraiseDetailModel.reply_info];
|
||||
NSString *replyInfo = [NSString stringWithFormat:@"%@",appraiseDetailModel.reply_info];
|
||||
|
||||
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
|
||||
style.lineSpacing = 3;
|
||||
|
||||
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:replyInfo];
|
||||
[attrString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, replyInfo.length)];
|
||||
[attrString addAttribute:NSFontAttributeName value:kFont11 range:NSMakeRange(0, replyInfo.length)];
|
||||
|
||||
self.replycommentLabel.attributedText = attrString;
|
||||
[self.replycommentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.avatarView.mas_bottom).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(replyHeight);
|
||||
}];
|
||||
} else {
|
||||
self.replycommentLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:@""];
|
||||
[self.replycommentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.avatarView.mas_bottom);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setProductionType:(TFProductionType)productionType
|
||||
{
|
||||
[super setProductionType:productionType];
|
||||
|
||||
self.coverView.productionType = productionType;
|
||||
}
|
||||
|
||||
- (void)commentProductionClick
|
||||
{
|
||||
if (self.commentProductionClickBlock) {
|
||||
self.commentProductionClickBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFGuideViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFGuideViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *guideString;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// TFGuideViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFGuideViewController.h"
|
||||
#import "YYTextView.h"
|
||||
|
||||
@interface TFGuideViewController ()
|
||||
|
||||
@property (nonatomic ,strong) YYTextView *rulesView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFGuideViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"签到规则")];
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.rulesView = [[YYTextView alloc] init];
|
||||
self.rulesView.backgroundColor = kWhiteColor;
|
||||
self.rulesView.editable = NO;
|
||||
self.rulesView.selectable = NO;
|
||||
self.rulesView.textColor = KGrayTextMiddleColor;
|
||||
self.rulesView.font = kMainFont;
|
||||
[self.view addSubview:self.rulesView];
|
||||
|
||||
[self.rulesView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT + kHalfMargin);
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:self.guideString ? : @""];
|
||||
text.lineSpacing = 8;
|
||||
text.font = kMainFont;
|
||||
text.color = KGrayTextMiddleColor;
|
||||
self.rulesView.attributedText = text;
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFTaskViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFTaskViewController : TFBasicViewController
|
||||
|
||||
// 完成阅读作品任务
|
||||
+ (void)taskReadRequestWithProduction_id:(NSInteger)production_id;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
//
|
||||
// TFTaskViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFTaskViewController.h"
|
||||
#import "TFTaskTableViewCell.h"
|
||||
#import "TFTaskHeaderView.h"
|
||||
#import "WXYZ_TaskModel.h"
|
||||
#import "TFShareManager.h"
|
||||
// 充值
|
||||
#import "TFRechargeViewController.h"
|
||||
// 包月
|
||||
#import "TFUpgradeMemberController.h"
|
||||
#import "WXYZ_UserDataViewController.h"
|
||||
#import "TFGuideViewController.h"
|
||||
|
||||
@interface TFTaskViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) WXYZ_TaskModel *taskModel;
|
||||
@property (nonatomic ,weak) TFTaskHeaderView *headerView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFTaskViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shareSuccess) name:Notification_Share_Success object:nil];
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"福利中心")];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
UIButton *_rightBtn = nil;
|
||||
|
||||
WS(weakSelf)
|
||||
[self setNavigationBarRightButton:({
|
||||
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_rightBtn = rightBtn;
|
||||
rightBtn.adjustsImageWhenHighlighted = NO;
|
||||
[rightBtn setImage:[UIImage imageNamed:@"book_help"] forState:UIControlStateNormal];
|
||||
[rightBtn addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
|
||||
NSString *t_rules = [weakSelf.taskModel.sign_info.sign_rules componentsJoinedByString:@"\n"];
|
||||
// if (t_rules.length > 0 && t_rules) {
|
||||
TFGuideViewController *vc = [[TFGuideViewController alloc] init];
|
||||
vc.guideString = t_rules;
|
||||
[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(19);
|
||||
}];
|
||||
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
|
||||
#if TF_Sign_Mode
|
||||
TFTaskHeaderView *headerView = [[TFTaskHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 160)];
|
||||
self.headerView = headerView;
|
||||
headerView.signClickBlock = ^{
|
||||
[weakSelf netRequest];
|
||||
};
|
||||
[self.mainTableView setTableHeaderView:headerView];
|
||||
#endif
|
||||
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return self.taskModel.task_menu.count;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return [self.taskModel.task_menu objectAtIndex:section].task_list.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFTaskTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFTaskTableViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[TFTaskTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFTaskTableViewCell"];
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
cell.taskModel = [[self.taskModel.task_menu objectAtIndex:indexPath.section].task_list objectAtIndex:indexPath.row];
|
||||
cell.taskClickBlock = ^(NSString * _Nonnull taskAction) {
|
||||
if ([taskAction isEqualToString:@"share_app"]) {
|
||||
[TFShareManager shareApp];
|
||||
} else if ([taskAction isEqualToString:@"read_book"]) {
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Tabbar_Index object:@"1"];
|
||||
});
|
||||
} else if ([taskAction isEqualToString:@"comment_book"]) {
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Tabbar_Index object:@"1"];
|
||||
});
|
||||
} else if ([taskAction isEqualToString:@"finish_info"]) {
|
||||
[[TFViewHelper getCurrentNavigationController] pushViewController:[[WXYZ_UserDataViewController alloc] init] animated:YES];
|
||||
} else if ([taskAction isEqualToString:@"add_book"]) {
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Tabbar_Index object:@"1"];
|
||||
});
|
||||
} else if ([taskAction isEqualToString:@"recharge"]) {
|
||||
[weakSelf.navigationController pushViewController:[[TFRechargeViewController alloc] init] animated:YES];
|
||||
} else if ([taskAction isEqualToString:@"vip"]) {
|
||||
[weakSelf.navigationController pushViewController:[[TFUpgradeMemberController alloc] init] animated:YES];
|
||||
}
|
||||
};
|
||||
|
||||
cell.hiddenEndLine = (indexPath.row == [self.taskModel.task_menu objectAtIndex:indexPath.section].task_list.count - 1);
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return 40 + kMargin;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
if (section == self.taskModel.task_menu.count - 1) {
|
||||
return PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET;
|
||||
}
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
|
||||
return view;
|
||||
}
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
|
||||
UIView *titleLableBack = [[UIView alloc] init];
|
||||
titleLableBack.backgroundColor = [UIColor whiteColor];
|
||||
[view addSubview:titleLableBack];
|
||||
|
||||
[titleLableBack mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(view.mas_bottom);
|
||||
make.width.mas_equalTo(view.mas_width);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
// 主标题
|
||||
UILabel *mainTitleLabel = [[UILabel alloc] init];
|
||||
mainTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
mainTitleLabel.textColor = kBlackColor;
|
||||
mainTitleLabel.backgroundColor = kWhiteColor;
|
||||
mainTitleLabel.text = [self.taskModel.task_menu objectAtIndex:section].task_title;
|
||||
mainTitleLabel.font = kBoldFont15;
|
||||
[view addSubview:mainTitleLabel];
|
||||
|
||||
[mainTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin + 4 + 5);
|
||||
make.top.mas_equalTo(view.mas_top).with.offset(10);
|
||||
make.width.mas_equalTo(view.mas_width).with.multipliedBy(0.5);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
UIView *mainTitleHoldView = [[UIView alloc] init];
|
||||
mainTitleHoldView.backgroundColor = kMainColor;
|
||||
mainTitleHoldView.layer.cornerRadius = 3.0;
|
||||
[view addSubview:mainTitleHoldView];
|
||||
|
||||
[mainTitleHoldView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.centerY.mas_equalTo(mainTitleLabel.mas_centerY);
|
||||
make.width.mas_equalTo(4);
|
||||
make.height.mas_equalTo(kLabelHeight * 2 - 2 * kMargin - 6);
|
||||
}];
|
||||
|
||||
UIView *line = [[UIView alloc] init];
|
||||
line.backgroundColor = kGrayLineColor;
|
||||
[view addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.bottom.mas_equalTo(view.mas_bottom).with.offset( - kCellLineHeight);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
|
||||
make.height.mas_equalTo(kCellLineHeight);
|
||||
}];
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)guideClick
|
||||
{
|
||||
NSString *t_rules = [self.taskModel.sign_info.sign_rules componentsJoinedByString:@"\n"];
|
||||
if (t_rules.length > 0 && t_rules) {
|
||||
TFGuideViewController *vc = [[TFGuideViewController alloc] init];
|
||||
vc.guideString = t_rules;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Task_Center parameters:nil model:WXYZ_TaskModel.class success:^(BOOL isSuccess, WXYZ_TaskModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.taskModel = t_model;
|
||||
weakSelf.headerView.signInfoModel = self.taskModel.sign_info;
|
||||
}
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView reloadData];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
// 完成阅读任务
|
||||
+ (void)taskReadRequestWithProduction_id:(NSInteger)production_id
|
||||
{
|
||||
// 完成阅读任务
|
||||
if (TFUserInfoManager.isLogin) {
|
||||
if (![TFSystemInfoManager.taskReadProductionId isEqualToString:[TFUtilsHelper formatStringWithInteger:production_id]]) {
|
||||
[TFNetworkTools POST:Task_Read parameters:nil model:nil success:^(BOOL isSuccess, NSDictionary *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
TFSystemInfoManager.taskReadProductionId = [TFUtilsHelper formatStringWithInteger:production_id];
|
||||
} failure:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)shareSuccess
|
||||
{
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// WXYZ_TaskModel.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/11/15.
|
||||
// Copyright © 2018 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class WXYZ_TaskMenuModel, WXYZ_TaskListModel, WXYZ_SignInfoModel;
|
||||
|
||||
@interface WXYZ_TaskModel : NSObject
|
||||
|
||||
@property (nonatomic, strong) WXYZ_SignInfoModel *sign_info;
|
||||
|
||||
@property (nonatomic, strong) NSArray <WXYZ_TaskMenuModel *>*task_menu;
|
||||
|
||||
@end
|
||||
|
||||
@interface WXYZ_SignInfoModel : NSObject
|
||||
|
||||
@property (nonatomic, assign) NSInteger sign_status;
|
||||
|
||||
@property (nonatomic, strong) NSArray *sign_rules;
|
||||
|
||||
@property (nonatomic, copy) NSString *unit;
|
||||
|
||||
@property (nonatomic, assign) NSInteger max_award;
|
||||
|
||||
@property (nonatomic, assign) NSInteger sign_days;
|
||||
|
||||
@end
|
||||
|
||||
@interface WXYZ_TaskMenuModel : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSString *task_title;
|
||||
|
||||
@property (nonatomic, strong) NSArray <WXYZ_TaskListModel *>*task_list;
|
||||
|
||||
@end
|
||||
|
||||
@interface WXYZ_TaskListModel : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSString *task_award;
|
||||
|
||||
@property (nonatomic, copy) NSString *task_label;
|
||||
|
||||
@property (nonatomic, copy) NSString *task_desc;
|
||||
|
||||
@property (nonatomic, assign) NSInteger task_state;
|
||||
|
||||
@property (nonatomic, assign) NSInteger task_id;
|
||||
|
||||
@property (nonatomic, copy) NSString *task_action;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// WXYZ_TaskModel.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/11/15.
|
||||
// Copyright © 2018 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_TaskModel.h"
|
||||
|
||||
@implementation WXYZ_TaskModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
|
||||
return @{@"task_menu" : [WXYZ_TaskMenuModel class]};
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_SignInfoModel
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_TaskMenuModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
|
||||
return @{@"task_list" : [WXYZ_TaskListModel class]};
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation WXYZ_TaskListModel
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFTaskHeaderView.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class WXYZ_SignInfoModel;
|
||||
typedef void(^SignClickBlock)(void);
|
||||
|
||||
@interface TFTaskHeaderView : UIView
|
||||
|
||||
@property (nonatomic ,strong) WXYZ_SignInfoModel *signInfoModel;
|
||||
|
||||
@property (nonatomic ,copy) SignClickBlock signClickBlock;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,167 @@
|
||||
//
|
||||
// TFTaskHeaderView.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFTaskHeaderView.h"
|
||||
#import "WXYZ_TaskModel.h"
|
||||
#import "TFSignModel.h"
|
||||
#import "TFSignAlertView.h"
|
||||
|
||||
@interface TFTaskHeaderView ()
|
||||
|
||||
@property (nonatomic ,strong) UILabel *signLabel;
|
||||
@property (nonatomic ,strong) UIButton *signBtn;
|
||||
@property (nonatomic ,strong) UILabel *promptLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFTaskHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
NSMutableAttributedString *t_atr = [[NSMutableAttributedString alloc] initWithString:TFLocalizedString(@"您已连续签到") attributes:@{NSFontAttributeName : kBoldFont19, NSForegroundColorAttributeName : kBlackColor}];
|
||||
t_atr.lineSpacing = kQuarterMargin;
|
||||
|
||||
|
||||
UIImageView *signImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kGeometricWidth(50, 196, 276), 50.0)];
|
||||
signImageView.backgroundColor = kMainColor;
|
||||
signImageView.layer.cornerRadius = 8.5;
|
||||
signImageView.layer.masksToBounds = YES;
|
||||
|
||||
self.signLabel = [[UILabel alloc] init];
|
||||
self.signLabel.text = @"0";
|
||||
self.signLabel.backgroundColor = [UIColor clearColor];
|
||||
self.signLabel.font = kBoldFont27;
|
||||
self.signLabel.textColor = kWhiteColor;
|
||||
[signImageView addSubview:self.signLabel];
|
||||
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.equalTo(signImageView);
|
||||
}];
|
||||
|
||||
|
||||
NSMutableAttributedString *attributeView = [NSMutableAttributedString attachmentStringWithContent:signImageView contentMode:UIViewContentModeBottom attachmentSize:CGSizeMake(kGeometricWidth(50, 196, 276) + 10, 50.0) alignToFont : kBoldFont19 alignment:YYTextVerticalAlignmentCenter];
|
||||
|
||||
[t_atr appendAttributedString:attributeView];
|
||||
[t_atr appendAttributedString:[[NSAttributedString alloc] initWithString:TFLocalizedString(@"天") attributes:@{NSFontAttributeName : kBoldFont19, NSForegroundColorAttributeName : kBlackColor}]];
|
||||
|
||||
|
||||
YYLabel *signLabel = [[YYLabel alloc] init];
|
||||
signLabel.backgroundColor = [UIColor clearColor];
|
||||
signLabel.numberOfLines = 0;
|
||||
signLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 120.0 - kMargin;
|
||||
signLabel.attributedText = t_atr;
|
||||
[self addSubview:signLabel];
|
||||
[signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self).offset(kMargin);
|
||||
make.centerY.equalTo(self);
|
||||
make.width.mas_equalTo(signLabel.preferredMaxLayoutWidth);
|
||||
}];
|
||||
|
||||
|
||||
self.signBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.signBtn.userInteractionEnabled = NO;
|
||||
[self.signBtn setImage:[UIImage imageNamed:TFLocalizedString(@"task_unsign")] forState:UIControlStateNormal];
|
||||
[self.signBtn addTarget:self action:@selector(signClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:self.signBtn];
|
||||
|
||||
[self.signBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right);
|
||||
make.centerY.mas_equalTo(self.mas_centerY);
|
||||
make.width.height.mas_equalTo(120);
|
||||
}];
|
||||
|
||||
|
||||
self.promptLabel = [[UILabel alloc] init];
|
||||
self.promptLabel.font = kFont10;
|
||||
self.promptLabel.textColor = kGrayTextLightColor;
|
||||
self.promptLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self addSubview:self.promptLabel];
|
||||
|
||||
[self.promptLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(signLabel.mas_left);
|
||||
make.bottom.mas_equalTo(self.mas_bottom).with.offset(- kHalfMargin);
|
||||
make.width.mas_equalTo(self.mas_width);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setSignInfoModel:(WXYZ_SignInfoModel *)signInfoModel
|
||||
{
|
||||
_signInfoModel = signInfoModel;
|
||||
|
||||
if (signInfoModel.sign_status == 0) {
|
||||
[self.signBtn setImage:[UIImage imageNamed:TFLocalizedString(@"task_unsign")] forState:UIControlStateNormal];
|
||||
self.signBtn.userInteractionEnabled = YES;
|
||||
} else {
|
||||
[self.signBtn setImage:[UIImage imageNamed:TFLocalizedString(@"task_signed")] forState:UIControlStateNormal];
|
||||
self.signBtn.userInteractionEnabled = NO;
|
||||
}
|
||||
|
||||
self.signLabel.text = [TFUtilsHelper formatStringWithInteger:signInfoModel.sign_days];
|
||||
|
||||
NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@%@%@", TFLocalizedString(@"提示:"), TFLocalizedString(@"连续签到最高可获得"), [TFUtilsHelper formatStringWithInteger:signInfoModel.max_award], signInfoModel.unit?:TFSystemInfoManager.masterUnit]];
|
||||
|
||||
NSString *suffix = [NSString stringWithFormat:@"%@%@", [TFUtilsHelper formatStringWithInteger:signInfoModel.max_award], signInfoModel.unit?:TFSystemInfoManager.masterUnit];
|
||||
|
||||
[attributedStr addAttribute:NSForegroundColorAttributeName value:kColorRGBA(251, 100, 26, 1) range:NSMakeRange(attributedStr.length - suffix.length, suffix.length)];
|
||||
self.promptLabel.attributedText = attributedStr;
|
||||
}
|
||||
|
||||
- (void)signClick
|
||||
{
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Sign_Click parameters:nil model:TFSignModel.class success:^(BOOL isSuccess, TFSignModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
if (isSuccess) {
|
||||
if ((t_model.book.count > 0 || t_model.comic.count > 0) && t_model.award.length > 0 && t_model.tomorrow_award.length > 0) {
|
||||
|
||||
NSMutableArray *t_arr = [NSMutableArray array];
|
||||
|
||||
for (TFProductionModel *t in t_model.book) {
|
||||
t.productionType = TFProductionTypeNovel;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
for (TFProductionModel *t in t_model.comic) {
|
||||
t.productionType = TFProductionTypeComic;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
for (TFProductionModel *t in t_model.audio) {
|
||||
t.productionType = TFProductionTypeAudio;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
TFSignAlertView *alert = [[TFSignAlertView alloc] init];
|
||||
alert.alertTitle = t_model.award;
|
||||
alert.alertDetailContent = t_model.tomorrow_award;
|
||||
alert.bookList = [t_arr copy];
|
||||
[alert showAlertView];
|
||||
}
|
||||
|
||||
!weakSelf.signClickBlock ?: weakSelf.signClickBlock();
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:requestModel.msg];
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// TFTaskTableViewCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class WXYZ_TaskListModel;
|
||||
|
||||
typedef void(^TaskClickBlock)(NSString *taskAction);
|
||||
|
||||
@interface TFTaskTableViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) WXYZ_TaskListModel *taskModel;
|
||||
|
||||
@property (nonatomic ,copy) TaskClickBlock taskClickBlock;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// TFTaskTableViewCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/3.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFTaskTableViewCell.h"
|
||||
#import "WXYZ_TaskModel.h"
|
||||
|
||||
@interface TFTaskTableViewCell ()
|
||||
{
|
||||
UILabel *taskLabel;
|
||||
UILabel *taskDescLabel;
|
||||
UILabel *taskAward;
|
||||
|
||||
UIButton *taskStateButton;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFTaskTableViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
taskLabel = [[UILabel alloc] init];
|
||||
taskLabel.font = kMainFont;
|
||||
taskLabel.textAlignment = NSTextAlignmentLeft;
|
||||
taskLabel.textColor = kBlackColor;
|
||||
[self.contentView addSubview:taskLabel];
|
||||
|
||||
[taskLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH / 2);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
taskDescLabel = [[UILabel alloc] init];
|
||||
taskDescLabel.textColor = kGrayTextColor;
|
||||
taskDescLabel.textAlignment = NSTextAlignmentLeft;
|
||||
taskDescLabel.font = kFont11;
|
||||
[self.contentView addSubview:taskDescLabel];
|
||||
|
||||
[taskDescLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(taskLabel.mas_left);
|
||||
make.top.mas_equalTo(taskLabel.mas_bottom);
|
||||
make.height.mas_equalTo(taskLabel.mas_height);
|
||||
}];
|
||||
|
||||
taskAward = [[UILabel alloc] init];
|
||||
taskAward.textColor = kColorRGBA(251, 100, 26, 1);
|
||||
taskAward.textAlignment = NSTextAlignmentLeft;
|
||||
taskAward.font = kFont10;
|
||||
[self.contentView addSubview:taskAward];
|
||||
|
||||
[taskAward mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(taskLabel.mas_right);
|
||||
make.centerY.mas_equalTo(taskLabel.mas_centerY);
|
||||
make.height.mas_equalTo(taskLabel.mas_height);
|
||||
make.right.equalTo(taskDescLabel);
|
||||
}];
|
||||
|
||||
taskStateButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
taskStateButton.backgroundColor = kColorRGBA(251, 100, 26, 1);
|
||||
taskStateButton.layer.cornerRadius = 10;
|
||||
taskStateButton.clipsToBounds = YES;
|
||||
[taskStateButton setTitle:TFLocalizedString(@"去完成") forState:UIControlStateNormal];
|
||||
[taskStateButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
[taskStateButton.titleLabel setFont:kFont10];
|
||||
[taskStateButton addTarget:self action:@selector(taskClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.contentView addSubview:taskStateButton];
|
||||
|
||||
[taskStateButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.height.mas_equalTo(20);
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont10 labelHeight:20.0 labelText:taskStateButton.titleLabel.text] + kHalfMargin);
|
||||
}];
|
||||
|
||||
[taskDescLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(taskStateButton.mas_left).offset(-kHalfMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setTaskModel:(WXYZ_TaskListModel *)taskModel
|
||||
{
|
||||
_taskModel = taskModel;
|
||||
|
||||
if (taskModel) {
|
||||
taskLabel.text = taskModel.task_label;
|
||||
[taskLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kMainFont labelHeight:20 labelText:taskModel.task_label]);
|
||||
}];
|
||||
|
||||
|
||||
taskDescLabel.text = taskModel.task_desc;
|
||||
taskAward.text = taskModel.task_award;
|
||||
if (taskModel.task_state == 0) {
|
||||
[taskStateButton setTitle:TFLocalizedString(@"去完成") forState:UIControlStateNormal];
|
||||
taskStateButton.backgroundColor = kColorRGBA(251, 100, 26, 1);
|
||||
[taskStateButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont10 labelHeight:20.0 labelText:taskStateButton.titleLabel.text] + kHalfMargin);
|
||||
}];
|
||||
} else {
|
||||
[taskStateButton setTitle:TFLocalizedString(@"已完成") forState:UIControlStateNormal];
|
||||
taskStateButton.backgroundColor = kColorRGBA(213, 216, 217, 1);
|
||||
[taskStateButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont10 labelHeight:20.0 labelText:taskStateButton.titleLabel.text] + kHalfMargin);
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (void)taskClick
|
||||
{
|
||||
if (_taskModel.task_state == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TFUserInfoManager.isLogin && ![_taskModel.task_action isEqualToString:@"recharge"] && ![_taskModel.task_action isEqualToString:@"vip"]) {
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.taskClickBlock) {
|
||||
self.taskClickBlock(_taskModel.task_action);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFRecordsPageViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRecordsPageViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *unit;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
//
|
||||
// TFRecordsPageViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRecordsPageViewController.h"
|
||||
#import "TFRecordsTableViewCell.h"
|
||||
#import "WXYZ_RecordsModel.h"
|
||||
|
||||
@interface TFRecordsPageViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFRecordsPageViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess) name:Notification_Login_Success object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT + 44);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - 44);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
|
||||
[self createEmptyView];
|
||||
}
|
||||
|
||||
- (void)createEmptyView
|
||||
{
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"登录后查看流水记录") buttonTitle:TFLocalizedString(@"立即登录") tapBlock:^{
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
}];
|
||||
} else {
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无流水记录") buttonTitle:nil tapBlock:^{
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFRecordsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFRecordsTableViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[TFRecordsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFRecordsTableViewCell"];
|
||||
}
|
||||
cell.listModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return 65;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)loginSuccess
|
||||
{
|
||||
[self netRequest];
|
||||
self.emptyView = nil;
|
||||
[self createEmptyView];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
if ([TFNetworkManager networkingStatus] == NO) {
|
||||
[self.mainTableView xtfei_showEmptyView];
|
||||
return;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"unit"] = self.unit;
|
||||
params[@"page_num"] = [TFUtilsHelper formatStringWithInteger:self.currentPageNumber];
|
||||
|
||||
[TFNetworkTools POST:Consumption_Records parameters:params model:WXYZ_RecordsModel.class success:^(BOOL isSuccess, WXYZ_RecordsModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
[weakSelf.mainTableView reloadData];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFRecordsViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRecordsViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) NSInteger pageIndex;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// TFRecordsViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRecordsViewController.h"
|
||||
#import "TFRecordsPageViewController.h"
|
||||
|
||||
@interface TFRecordsViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFRecordsViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"流水记录")];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
TFRecordsPageViewController *vc1 = [[TFRecordsPageViewController alloc] init];
|
||||
vc1.unit = @"currencyUnit";
|
||||
|
||||
TFRecordsPageViewController *vc2 = [[TFRecordsPageViewController alloc] init];
|
||||
vc2.unit = @"subUnit";
|
||||
|
||||
NSArray *titleArr = @[[NSString stringWithFormat:@"%@", TFSystemInfoManager.masterUnit], TFSystemInfoManager.subUnit];
|
||||
NSArray *childArr = @[vc1, vc2];
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, SCREEN_HEIGHT) parentVC:self childVCs:childArr];
|
||||
self.pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 44) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = [UIColor whiteColor];
|
||||
[self.view addSubview:self.pageTitleView];
|
||||
|
||||
if (self.pageIndex == 1) {
|
||||
self.pageTitleView.selectedIndex = 1;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// WXYZ_RecordsModel.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/7/12.
|
||||
// Copyright © 2018年 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class WXBookRecordsListModel, TFPagingModel;
|
||||
|
||||
@interface WXYZ_RecordsModel : TFPagingModel
|
||||
|
||||
@property (nonatomic, strong) NSArray<WXBookRecordsListModel *> *list; //明细列表
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface WXBookRecordsListModel : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSString *article; //string 明细说明
|
||||
|
||||
@property (nonatomic, copy) NSString *detail; //string 明细
|
||||
|
||||
@property (nonatomic, assign) NSInteger detail_type; //int 明细类型 1-充值 2-消费
|
||||
|
||||
@property (nonatomic, copy) NSString *date; //string 日期
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// WXYZ_RecordsModel.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/7/12.
|
||||
// Copyright © 2018年 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_RecordsModel.h"
|
||||
|
||||
@implementation WXYZ_RecordsModel
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
|
||||
return @{@"list" : [WXBookRecordsListModel class]};
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation WXBookRecordsListModel
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFRecordsTableViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "WXYZ_RecordsModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRecordsTableViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) WXBookRecordsListModel *listModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// TFRecordsTableViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRecordsTableViewCell.h"
|
||||
|
||||
@interface TFRecordsTableViewCell ()
|
||||
{
|
||||
UILabel *titleLabel;
|
||||
UILabel *dateLabel;
|
||||
UILabel *moneyLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFRecordsTableViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
titleLabel.textColor = kBlackColor;
|
||||
titleLabel.font = kMainFont;
|
||||
[self.contentView addSubview:titleLabel];
|
||||
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_centerY).with.offset(- 1);
|
||||
make.height.mas_equalTo(20);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH * 2 / 3);
|
||||
}];
|
||||
|
||||
dateLabel = [[UILabel alloc] init];
|
||||
dateLabel.textAlignment = NSTextAlignmentLeft;
|
||||
dateLabel.textColor = kGrayTextLightColor;
|
||||
dateLabel.font = kFont12;
|
||||
[self.contentView addSubview:dateLabel];
|
||||
|
||||
[dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_centerY).with.offset(1);
|
||||
make.height.mas_equalTo(20);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH * 2 / 3);
|
||||
}];
|
||||
|
||||
moneyLabel = [[UILabel alloc] init];
|
||||
moneyLabel.textAlignment = NSTextAlignmentRight;
|
||||
moneyLabel.textColor = kBlackColor;
|
||||
moneyLabel.font = kFont13;
|
||||
[self.contentView addSubview:moneyLabel];
|
||||
|
||||
[moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.height.mas_equalTo(40);
|
||||
make.width.mas_equalTo(150);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setListModel:(WXBookRecordsListModel *)listModel
|
||||
{
|
||||
titleLabel.text = listModel.article;
|
||||
dateLabel.text = listModel.date;
|
||||
|
||||
if (listModel.detail.length > 0) {
|
||||
moneyLabel.text = listModel.detail?:@"";
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// TFDownloadCacheViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFDownloadCacheViewController : TFBasicViewController
|
||||
|
||||
// 只显示小说模块
|
||||
@property (nonatomic ,assign) BOOL onlyBookMode;
|
||||
|
||||
@property (nonatomic ,assign) BOOL pushFromReader;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
//
|
||||
// TFDownloadCacheViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFDownloadCacheViewController.h"
|
||||
#import "TFComicDownloadManagerController.h"
|
||||
#import "TFNovelDownloadManagerController.h"
|
||||
#import "WXYZ_AudioDownloadCacheViewController.h"
|
||||
|
||||
#import "SGPagingView.h"
|
||||
|
||||
@interface TFDownloadCacheViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@property (nonatomic ,weak) TFNovelDownloadManagerController *bookVC;
|
||||
|
||||
@property (nonatomic ,weak) TFComicDownloadManagerController *comicVC;
|
||||
|
||||
@property (nonatomic ,weak) WXYZ_AudioDownloadCacheViewController *audioVC;
|
||||
|
||||
@property (nonatomic ,weak) UIButton *rightButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFDownloadCacheViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubViews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self setStatusBarDefaultStyle];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Hidden_Tabbar object:@"1"];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"下载缓存")];
|
||||
[self hiddenSeparator];
|
||||
[self setNavigationBarRightButton:({
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.rightButton = button;
|
||||
[button setTitle:TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
button.titleLabel.font = kFont14;
|
||||
[button setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
[button addTarget:self action:@selector(editEvent) forControlEvents:UIControlEventTouchUpInside];
|
||||
button.backgroundColor = [UIColor clearColor];
|
||||
button;
|
||||
})];
|
||||
[self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.view).offset(-kMargin);
|
||||
make.centerY.equalTo(self.navigationBar.navTitleLabel);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)editEvent {
|
||||
NSInteger index = self.pageTitleView.signBtnIndex;
|
||||
switch (index) {
|
||||
case 0:
|
||||
{
|
||||
BOOL isEdtting = !self.bookVC.editStateBlock ?: self.bookVC.editStateBlock();
|
||||
[self.rightButton setTitle:isEdtting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
BOOL isEdtting = !self.comicVC.editStateBlock ?: self.comicVC.editStateBlock();
|
||||
[self.rightButton setTitle:isEdtting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
BOOL isEdtting = !self.audioVC.editStateBlock ?: self.audioVC.editStateBlock();
|
||||
[self.rightButton setTitle:isEdtting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
#if TF_Enable_Book
|
||||
TFNovelDownloadManagerController *bookVC = [[TFNovelDownloadManagerController alloc] init];
|
||||
self.bookVC = bookVC;
|
||||
WS(weakSelf)
|
||||
bookVC.changeEditStateBlock = ^(BOOL status) {
|
||||
[weakSelf.rightButton setTitle:status ? TFLocalizedString(@"编辑") : TFLocalizedString(@"取消") forState:UIControlStateNormal];
|
||||
};
|
||||
bookVC.pushFromReader = self.pushFromReader;
|
||||
[self addChildViewController:bookVC];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
TFComicDownloadManagerController *comicVC = [[TFComicDownloadManagerController alloc] init];
|
||||
self.comicVC = comicVC;
|
||||
comicVC.changeEditStateBlock = ^(BOOL status) {
|
||||
[weakSelf.rightButton setTitle:status ? TFLocalizedString(@"编辑") : TFLocalizedString(@"取消") forState:UIControlStateNormal];
|
||||
};
|
||||
[self addChildViewController:comicVC];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
WXYZ_AudioDownloadCacheViewController *audioVC = [[WXYZ_AudioDownloadCacheViewController alloc] init];
|
||||
self.audioVC = audioVC;
|
||||
audioVC.changeEditStateBlock = ^(BOOL status) {
|
||||
[weakSelf.rightButton setTitle:status ? TFLocalizedString(@"编辑") : TFLocalizedString(@"取消") forState:UIControlStateNormal];
|
||||
};
|
||||
audioVC.productionType = TFProductionTypeAudio;
|
||||
[self addChildViewController:audioVC];
|
||||
#endif
|
||||
|
||||
NSMutableArray *titleArr = [NSMutableArray array];
|
||||
NSMutableArray *childArr = [NSMutableArray array];
|
||||
|
||||
if (self.onlyBookMode) {
|
||||
|
||||
#if TF_Enable_Book
|
||||
// [titleArr addObject:TFLocalizedString(@"小说")];
|
||||
[childArr addObject:bookVC];
|
||||
#endif
|
||||
|
||||
} else {
|
||||
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
|
||||
#if TF_Enable_Book
|
||||
if ([siteNumber integerValue] == 1) {
|
||||
[titleArr addObject:TFLocalizedString(@"小说")];
|
||||
[childArr addObject:bookVC];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
if ([siteNumber integerValue] == 2) {
|
||||
[titleArr addObject:TFLocalizedString(@"漫画")];
|
||||
[childArr addObject:comicVC];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
if ([siteNumber integerValue] == 3) {
|
||||
[titleArr addObject:TFLocalizedString(@"听书")];
|
||||
[childArr addObject:audioVC];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count <= 1) {
|
||||
[titleArr removeAllObjects];
|
||||
[titleArr addObject:TFLocalizedString(@"下载")];
|
||||
}
|
||||
}
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT + self.pageViewHeight, SCREEN_WIDTH, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - self.pageViewHeight) parentVC:self childVCs:childArr];
|
||||
_pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
if (titleArr.count > 0) {
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, self.pageViewHeight) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:_pageTitleView];
|
||||
} else {
|
||||
self.pageContentCollectionView.frame = CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView index:(NSInteger)index
|
||||
{
|
||||
TFBasicViewController *vc = [pageContentCollectionView.childViewControllers objectAtIndex:index];
|
||||
[vc cancleTableViewCellEditingState];
|
||||
switch (index) {
|
||||
case 0:
|
||||
[self.rightButton setTitle:self.bookVC.isEditting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
break;
|
||||
case 1:
|
||||
[self.rightButton setTitle:self.comicVC.isEditting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
break;
|
||||
case 2:
|
||||
[self.rightButton setTitle:self.audioVC.isEditting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
|
||||
@end
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TFDownloadViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFDownloadViewController : TFBasicViewController
|
||||
|
||||
// 选择存储器
|
||||
@property (nonatomic ,strong) NSMutableDictionary *selectSourceDictionary;
|
||||
// index合集
|
||||
@property (nonatomic ,strong) NSMutableDictionary *cellIndexDictionary;
|
||||
// 重置选择存储器
|
||||
- (void)resetSelectSourceDicWithDataSourceArray:(NSArray <TFProductionChapterModel *>*)dataSourceArray productionType:(TFProductionType)productionType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// TFDownloadViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFDownloadViewController.h"
|
||||
#import "WXYZ_ComicDownloadManager.h"
|
||||
#import "WXYZ_AudioDownloadManager.h"
|
||||
|
||||
@interface TFDownloadViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFDownloadViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
}
|
||||
|
||||
// 重置选择存储器
|
||||
- (void)resetSelectSourceDicWithDataSourceArray:(NSArray <TFProductionChapterModel *>*)dataSourceArray productionType:(TFProductionType)productionType
|
||||
{
|
||||
// 刷新数据后,已选择章节的恢复设置为已选择
|
||||
NSMutableDictionary *t_selectDictionary = [self.selectSourceDictionary mutableCopy];
|
||||
|
||||
[self.selectSourceDictionary removeAllObjects];
|
||||
|
||||
// index合集
|
||||
[self.cellIndexDictionary removeAllObjects];
|
||||
|
||||
NSMutableArray *t_arr = [dataSourceArray mutableCopy];
|
||||
|
||||
for (int i = 0; i < t_arr.count; i++) {
|
||||
TFProductionChapterModel *t_chapterModel = [t_arr objectAtIndex:i];
|
||||
if (productionType == TFProductionTypeComic) {
|
||||
|
||||
WXYZ_ProductionDownloadState state = [[WXYZ_ComicDownloadManager sharedManager] getChapterDownloadStateWithProduction_id:t_chapterModel.production_id chapter_id:t_chapterModel.chapter_id];
|
||||
[self.selectSourceDictionary setObject:[TFUtilsHelper formatStringWithInteger:state] forKey:[TFUtilsHelper formatStringWithInteger:t_chapterModel.chapter_id]];
|
||||
|
||||
} else if (productionType == TFProductionTypeAudio) {
|
||||
WXYZ_ProductionDownloadState state = [[WXYZ_AudioDownloadManager sharedManager] getChapterDownloadStateWithProduction_id:t_chapterModel.production_id chapter_id:t_chapterModel.chapter_id];
|
||||
[self.selectSourceDictionary setObject:[TFUtilsHelper formatStringWithInteger:state] forKey:[TFUtilsHelper formatStringWithInteger:t_chapterModel.chapter_id]];
|
||||
}
|
||||
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
|
||||
[self.cellIndexDictionary setObject:indexPath forKey:[TFUtilsHelper formatStringWithInteger:t_chapterModel.chapter_id]];
|
||||
}
|
||||
|
||||
|
||||
for (NSString *t_key in t_selectDictionary.allKeys) {
|
||||
if ([[t_selectDictionary objectForKey:t_key] integerValue] == WXYZ_ProductionDownloadStateSelected) {
|
||||
[self.selectSourceDictionary setObject:[TFUtilsHelper formatStringWithInteger:WXYZ_ProductionDownloadStateSelected] forKey:t_key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)selectSourceDictionary
|
||||
{
|
||||
if (!_selectSourceDictionary) {
|
||||
_selectSourceDictionary = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _selectSourceDictionary;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)cellIndexDictionary
|
||||
{
|
||||
if (!_cellIndexDictionary) {
|
||||
_cellIndexDictionary = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _cellIndexDictionary;
|
||||
}
|
||||
|
||||
@end
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// WXYZ_BindPhoneViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/7/27.
|
||||
// Copyright © 2018年 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
@interface WXYZ_BindPhoneViewController : TFBasicViewController
|
||||
|
||||
/// 绑定成功回调
|
||||
@property (nonatomic, copy) void(^completionBlock)(void);
|
||||
|
||||
@end
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
//
|
||||
// WXYZ_BindPhoneViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/7/27.
|
||||
// Copyright © 2018年 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_BindPhoneViewController.h"
|
||||
#import "TFAreaCodeViewController.h"
|
||||
#import "TFValidationButton.h"
|
||||
#import "UIView+LayoutCallback.h"
|
||||
#import "NSObject+Observer.h"
|
||||
|
||||
@interface WXYZ_BindPhoneViewController ()
|
||||
|
||||
@property (nonatomic, weak) UITextField *accountTextField;
|
||||
|
||||
@property (nonatomic, weak) UITextField *codeTextField;
|
||||
|
||||
@property (nonatomic, weak) TFValidationButton *sendCodeButton;
|
||||
|
||||
@property (nonatomic, weak) UIButton *loginButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_BindPhoneViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - 初始化
|
||||
- (void)initialize {
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"绑定手机号")];
|
||||
self.view.backgroundColor = kWhiteColor;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UI
|
||||
- (void)createSubviews {
|
||||
UIView *leftView = ({
|
||||
UIView *leftView = [[UIView alloc] init];
|
||||
leftView.backgroundColor = kWhiteColor;
|
||||
UILabel *zoneLabel = [[UILabel alloc] init];
|
||||
zoneLabel.backgroundColor = kWhiteColor;
|
||||
zoneLabel.textColor = kBlackColor;
|
||||
zoneLabel.font = kFont18;
|
||||
zoneLabel.text = [NSString stringWithFormat:@"%@%@", @"+", TFSystemInfoManager.zoneNumber];
|
||||
[leftView addSubview:zoneLabel];
|
||||
[zoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.centerY.equalTo(leftView);
|
||||
}];
|
||||
|
||||
UIImageView *downImageView = [[UIImageView alloc] init];
|
||||
downImageView.backgroundColor = kWhiteColor;
|
||||
downImageView.image = [[UIImage imageNamed:@"public_dropDown"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
||||
[leftView addSubview:downImageView];
|
||||
[downImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(zoneLabel.mas_right).offset(kQuarterMargin);
|
||||
make.centerY.equalTo(zoneLabel);
|
||||
make.width.height.mas_equalTo(15.0);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
[leftView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
|
||||
TFAreaCodeViewController *vc = [[TFAreaCodeViewController alloc] init];
|
||||
vc.areaCodeBlock = ^(NSString * _Nonnull areaCode) {
|
||||
TFSystemInfoManager.zoneNumber = areaCode;
|
||||
zoneLabel.text = [NSString stringWithFormat:@"%@%@", @"+", TFSystemInfoManager.zoneNumber];
|
||||
};
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
}]];
|
||||
|
||||
leftView;
|
||||
});
|
||||
[self.view addSubview:leftView];
|
||||
leftView.frameBlock = ^(UIView * _Nonnull view) {
|
||||
[view addBorderLineWithBorderWidth:1.0 borderColor:kGrayLineColor cornerRadius:0.0 borderType:UIBorderSideTypeBottom];
|
||||
};
|
||||
CGFloat width = SCREEN_WIDTH - 4 * kMargin;
|
||||
CGFloat height = kGeometricWidth(width, 61.0, 334.0);
|
||||
[leftView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.view).offset(2 * kMargin);
|
||||
make.top.equalTo(self.view).offset(PUB_NAVBAR_HEIGHT + kLineX(40.0));
|
||||
make.size.mas_equalTo(CGSizeMake(90.0, height));
|
||||
}];
|
||||
|
||||
UITextField *accountTextField = ({
|
||||
UITextField *accountTextField = [[UITextField alloc] init];
|
||||
self.accountTextField = accountTextField;
|
||||
accountTextField.backgroundColor = [UIColor whiteColor];
|
||||
accountTextField.font = kFont16;
|
||||
accountTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
||||
accountTextField.textColor = kBlackColor;
|
||||
[accountTextField addTarget:self action:@selector(textDidChange:) forControlEvents:UIControlEventEditingChanged];
|
||||
accountTextField.keyboardType = UIKeyboardTypeNumberPad;
|
||||
accountTextField.placeholder = TFLocalizedString(@"手机号");
|
||||
accountTextField.frameBlock = ^(UIView * _Nonnull view) {
|
||||
[view addBorderLineWithBorderWidth:kCellLineHeight borderColor:kGrayLineColor cornerRadius:0 borderType:UIBorderSideTypeBottom];
|
||||
};
|
||||
accountTextField;
|
||||
});
|
||||
[self.view addSubview:accountTextField];
|
||||
[accountTextField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
if (leftView.hidden) {
|
||||
make.left.equalTo(leftView);
|
||||
} else {
|
||||
make.left.equalTo(leftView.mas_right);
|
||||
}
|
||||
make.top.height.equalTo(leftView);
|
||||
make.right.equalTo(self.view).offset(-2 * kMargin);
|
||||
}];
|
||||
|
||||
NSString *maxText = [NSString stringWithFormat:@"(%@)%@", @"59", TFLocalizedString(@"后重新发送")];
|
||||
CGFloat maxWidth = [TFViewHelper getDynamicWidthWithLabelFont:kMainFont labelHeight:height labelText:maxText maxWidth:SCREEN_WIDTH / 2.0 - 50.0];
|
||||
UIView *rightView = ({
|
||||
UIView *rightView = [[UIView alloc] init];
|
||||
TFValidationButton *sendCodeButton = [[TFValidationButton alloc] initWithFrame:CGRectZero identify:@"login_timer"];
|
||||
self.sendCodeButton = sendCodeButton;
|
||||
sendCodeButton.enabled = NO;
|
||||
[sendCodeButton.titleLabel setFont:kMainFont];
|
||||
sendCodeButton.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[sendCodeButton setTitleColor:kRedColor forState:UIControlStateNormal];
|
||||
[sendCodeButton setTitleColor:kColorRGB(199, 199, 205) forState:UIControlStateDisabled];
|
||||
[sendCodeButton addTarget:self action:@selector(sendCodeEvent:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[rightView addSubview:sendCodeButton];
|
||||
[sendCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.center.equalTo(rightView);
|
||||
make.height.mas_equalTo(sendCodeButton.intrinsicContentSize.height);
|
||||
make.width.mas_equalTo(maxWidth);
|
||||
}];
|
||||
UIView *lineView = [[UIView alloc] init];
|
||||
lineView.backgroundColor = kGrayLineColor;
|
||||
[rightView addSubview:lineView];
|
||||
[lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(rightView);
|
||||
make.size.mas_equalTo(CGSizeMake(1.0, kMargin));
|
||||
make.centerY.equalTo(rightView);
|
||||
}];
|
||||
rightView;
|
||||
});
|
||||
[self.view addSubview:rightView];
|
||||
rightView.frameBlock = ^(UIView * _Nonnull view) {
|
||||
[view addBorderLineWithBorderWidth:1.0 borderColor:kGrayLineColor cornerRadius:0.0 borderType:UIBorderSideTypeBottom];
|
||||
};
|
||||
[rightView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.height.equalTo(accountTextField);
|
||||
make.top.equalTo(accountTextField.mas_bottom).offset(kMargin);
|
||||
make.width.mas_equalTo(maxWidth + kMargin);
|
||||
}];
|
||||
|
||||
UITextField *codeTextField = ({
|
||||
UITextField *codeTextField = [[UITextField alloc] init];
|
||||
self.codeTextField = codeTextField;
|
||||
codeTextField.backgroundColor = accountTextField.backgroundColor;
|
||||
codeTextField.keyboardType = UIKeyboardTypeNumberPad;
|
||||
codeTextField.font = accountTextField.font;
|
||||
codeTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
||||
codeTextField.textColor = accountTextField.textColor;
|
||||
codeTextField.placeholder = TFLocalizedString(@"验证码");
|
||||
[codeTextField addTarget:self action:@selector(textDidChange:) forControlEvents:UIControlEventEditingChanged];
|
||||
codeTextField.frameBlock = ^(UIView * _Nonnull view) {
|
||||
[view addBorderLineWithBorderWidth:kCellLineHeight borderColor:kGrayLineColor cornerRadius:0 borderType:UIBorderSideTypeBottom];
|
||||
};
|
||||
codeTextField;
|
||||
});
|
||||
[self.view addSubview:codeTextField];
|
||||
[codeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(leftView);
|
||||
make.top.equalTo(rightView);
|
||||
make.height.equalTo(accountTextField);
|
||||
make.right.equalTo(rightView.mas_left);
|
||||
}];
|
||||
|
||||
UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
self.loginButton = loginButton;
|
||||
loginButton.titleLabel.font = kFont15;
|
||||
[loginButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
[loginButton setTitleColor:kGrayTextColor forState:UIControlStateDisabled];
|
||||
[loginButton setTitle:TFLocalizedString(@"绑定") forState:UIControlStateNormal];
|
||||
[loginButton addObserver:KEY_PATH(loginButton, enabled) complete:^(UIButton * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
obj.backgroundColor = [newVal boolValue] ? kRedColor : kColorRGB(229, 230, 231);
|
||||
}];
|
||||
loginButton.enabled = NO;
|
||||
loginButton.frameBlock = ^(UIButton * _Nonnull button) {
|
||||
button.layer.cornerRadius = (CGRectGetWidth(button.bounds) + CGRectGetHeight(button.bounds)) * 0.058;
|
||||
};
|
||||
[loginButton addTarget:self action:@selector(bindPhone) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:loginButton];
|
||||
[loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.view).offset(2 * kMargin);
|
||||
make.right.equalTo(self.view).offset(-2 * kMargin);
|
||||
make.top.equalTo(codeTextField.mas_bottom).offset(is_iPhone4 || is_iPhone5 ? 40 : 60);
|
||||
make.height.equalTo(loginButton.mas_width).multipliedBy(44.0 / 334.0);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Event
|
||||
- (void)textDidChange:(UITextField *)textField {
|
||||
if (self.sendCodeButton.countdownState == NO) {
|
||||
self.sendCodeButton.enabled = (self.accountTextField.text.length > 0);
|
||||
}
|
||||
|
||||
self.loginButton.enabled = (self.accountTextField.text.length > 0 && self.codeTextField.text.length > 0);
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
[self.view endEditing:YES];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - 网络请求
|
||||
- (void)sendCodeEvent:(TFValidationButton *)button
|
||||
{
|
||||
NSDictionary *params = @{
|
||||
@"mobile" : [TFSystemInfoManager.zoneNumber stringByAppendingString:self.accountTextField.text]
|
||||
};
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Send_Verification_Code parameters:params model:nil success:^(BOOL isSuccess, id _Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
[button startTiming];
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"验证码已发送")];
|
||||
[weakSelf.codeTextField becomeFirstResponder];
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg ?: TFLocalizedString(@"发送失败")];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[TFPromptManager showPromptWithError:error defaultText:TFLocalizedString(@"发送失败")];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)bindPhone {
|
||||
self.view.userInteractionEnabled = NO;
|
||||
|
||||
NSDictionary *params = @{
|
||||
@"mobile" : [TFSystemInfoManager.zoneNumber stringByAppendingString:self.accountTextField.text],
|
||||
@"code" : self.codeTextField.text
|
||||
};
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Phone_Binding parameters:params model:TFUserInfoManager.class success:^(BOOL isSuccess, TFUserInfoManager * _Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"绑定成功")];
|
||||
!weakSelf.completionBlock ?: weakSelf.completionBlock();
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
|
||||
weakSelf.view.userInteractionEnabled = YES;
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[TFPromptManager showPromptWithError:error defaultText:nil];
|
||||
weakSelf.view.userInteractionEnabled = YES;
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// WXYZ_CancelAccountViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/21.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_CancelAccountViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
//
|
||||
// WXYZ_CancelAccountViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/21.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_CancelAccountViewController.h"
|
||||
#import "TFWebViewController.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#import "WXYZ_CancelAccountTableViewCell.h"
|
||||
|
||||
@interface WXYZ_CancelAccountViewController () <UITableViewDataSource, UITableViewDelegate>
|
||||
|
||||
@property (nonatomic, strong) UIView *headerView;
|
||||
|
||||
@property (nonatomic, strong) UIButton *agreementButton;
|
||||
|
||||
@property (nonatomic, strong) UIButton *applyButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_CancelAccountViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"注销账号")];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.dataSourceArray = [NSMutableArray arrayWithArray:@[
|
||||
@[TFLocalizedString(@"账号安全"), TFLocalizedString(@"最好使用常用设备提交申请,注销申请审核后,注销操作立即生效。")],
|
||||
@[TFLocalizedString(@"账号状态"), TFLocalizedString(@"申请注销的账号应为正常使用中的状态,应处于未封禁或未被审查的状态。")],
|
||||
@[TFLocalizedString(@"账号财产已结清"), TFLocalizedString(@"申请注销的账号无有效状态的会员,没有余额等;且没有任何未结清、未完成的交易。")]
|
||||
]];
|
||||
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
// self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET, 0);
|
||||
[self.mainTableView setTableHeaderView:self.headerView];
|
||||
self.mainTableView.tableFooterView = [self footerView];
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - (PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET) - kMargin);
|
||||
}];
|
||||
|
||||
self.applyButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.applyButton.alpha = 0.6;
|
||||
self.applyButton.backgroundColor = kRedColor;
|
||||
[self.applyButton setTitle:TFLocalizedString(@"申请注销") forState:UIControlStateNormal];
|
||||
[self.applyButton addTarget:self action:@selector(applyClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:self.applyButton];
|
||||
|
||||
[self.applyButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_TABBAR_OFFSET);
|
||||
make.left.mas_equalTo(0);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
}];
|
||||
|
||||
[self.mainTableView reloadData];
|
||||
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
static NSString *cellName = @"WXYZ_CancelAccountTableViewCell";
|
||||
WXYZ_CancelAccountTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[WXYZ_CancelAccountTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.titleString = [self.dataSourceArray objectAtIndex:indexPath.row][0];
|
||||
cell.detailString = [self.dataSourceArray objectAtIndex:indexPath.row][1];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
//section头间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
CGFloat height = [TFViewHelper getDynamicHeightWithLabelFont:kBoldFont15 labelWidth:SCREEN_WIDTH labelText:TFLocalizedString(@"申请注销前,您的账号需要注意以下条款:") maxHeight:MAXFLOAT];
|
||||
return height + kMargin;
|
||||
}
|
||||
//section头视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
CGFloat height = [TFViewHelper getDynamicHeightWithLabelFont:kBoldFont15 labelWidth:SCREEN_WIDTH labelText:TFLocalizedString(@"申请注销前,您的账号需要注意以下条款:") maxHeight:MAXFLOAT];
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, height + kMargin)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kHalfMargin, kMargin, SCREEN_WIDTH - kHalfMargin - kHalfMargin, height)];
|
||||
titleLabel.numberOfLines = 2;
|
||||
titleLabel.text = TFLocalizedString(@"申请注销前,您的账号需要注意以下条款:");
|
||||
titleLabel.textColor = kBlackColor;
|
||||
titleLabel.font = kBoldFont15;
|
||||
[view addSubview:titleLabel];
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
//section底部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)footerView {
|
||||
UIView *view = nil;
|
||||
if (SCREEN_HEIGHT <= 667.0) {
|
||||
view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kLabelHeight + kLabelHeight)];
|
||||
} else {
|
||||
view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kLabelHeight + kHalfMargin)];
|
||||
}
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
|
||||
if (!self.agreementButton) {
|
||||
self.agreementButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
// self.agreementButton.frame = CGRectMake(kHalfMargin, kHalfMargin, 30, 30);
|
||||
self.agreementButton.selected = NO;
|
||||
self.agreementButton.adjustsImageWhenHighlighted = NO;
|
||||
[self.agreementButton setImageEdgeInsets:UIEdgeInsetsMake(7, 0, 7, 14)];
|
||||
[self.agreementButton setImage:[UIImage imageNamed:@"audio_download_unselect"] forState:UIControlStateNormal];
|
||||
[self.agreementButton setImage:[UIImage imageNamed:@"audio_download_select"] forState:UIControlStateSelected];
|
||||
[self.agreementButton addTarget:self action:@selector(agreementClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[view addSubview:self.agreementButton];
|
||||
[self.agreementButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(view);
|
||||
make.left.equalTo(view).offset(kHalfMargin);
|
||||
make.width.height.mas_equalTo(30.0);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
NSString *prefix = TFLocalizedString(@"我已阅读并接受");
|
||||
NSString *suffix = TFLocalizedString(@"《用户注销协议》");
|
||||
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@", prefix, suffix]];
|
||||
text.lineSpacing = 5;
|
||||
text.font = kMainFont;
|
||||
[text setTextHighlightRange:NSMakeRange(prefix.length, suffix.length) color:kMainColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
TFWebViewController *vc = [[TFWebViewController alloc] init];
|
||||
vc.navTitle = TFLocalizedString(@"用户注销协议");
|
||||
AppDelegate *delegate = (AppDelegate *)kRCodeSync([UIApplication sharedApplication].delegate);
|
||||
vc.URLString = delegate.checkSettingModel.protocol_list.logoff ?: [NSString stringWithFormat:@"%@%@?language=%@", APIURL, Log_Off, TFLanguageManager.serverLocalized];
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
}];
|
||||
[text setTextHighlightRange:NSMakeRange(0, 7) color:kBlackColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
[weakSelf agreementClick];
|
||||
}];
|
||||
|
||||
YYLabel *tipsLabel = [[YYLabel alloc] init];
|
||||
tipsLabel.numberOfLines = 0;
|
||||
tipsLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 2 * kMargin;
|
||||
tipsLabel.attributedText = text;
|
||||
tipsLabel.textAlignment = NSTextAlignmentLeft;
|
||||
tipsLabel.userInteractionEnabled = YES;
|
||||
[view addSubview:tipsLabel];
|
||||
[tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(view).offset(kMargin + 10);
|
||||
make.centerY.equalTo(self.agreementButton);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - (kMargin + kMargin));
|
||||
}];
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
- (UIView *)headerView
|
||||
{
|
||||
if (!_headerView) {
|
||||
|
||||
NSString *str = TFLocalizedString(@"重要提醒:个人账号可以申请注销。为了避免被盗号或非本人操作所带来的损失,注销前需要确认账号所属,以及可能涉及的虚拟财产结算。");
|
||||
|
||||
_headerView = [[UIView alloc] init];
|
||||
_headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, [TFViewHelper getDynamicHeightWithLabelFont:kMainFont labelWidth:(SCREEN_WIDTH - (kMargin + kHalfMargin)) labelText:str] + 80 + 2 * kMargin);
|
||||
_headerView.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
UIView *headerBackView = [[UIView alloc] init];
|
||||
headerBackView.backgroundColor = kGrayViewColor;
|
||||
headerBackView.layer.cornerRadius = 12;
|
||||
[_headerView addSubview:headerBackView];
|
||||
|
||||
[headerBackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.top.mas_equalTo(kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
|
||||
make.height.mas_equalTo(_headerView.mas_height).with.offset(- kHalfMargin);
|
||||
}];
|
||||
|
||||
UIImageView *headerImageView = [[UIImageView alloc] init];
|
||||
headerImageView.image = [UIImage imageNamed:@"cancel_account"];
|
||||
[_headerView addSubview:headerImageView];
|
||||
|
||||
[headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(kMargin);
|
||||
make.centerX.mas_equalTo(_headerView.mas_centerX);
|
||||
make.width.height.mas_equalTo(80);
|
||||
}];
|
||||
|
||||
UILabel *headerLabel = [[UILabel alloc] init];
|
||||
headerLabel.numberOfLines = 0;
|
||||
headerLabel.font = kMainFont;
|
||||
headerLabel.textColor = kColorRGB(96, 106, 100);
|
||||
[_headerView addSubview:headerLabel];
|
||||
|
||||
[headerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin + kHalfMargin);
|
||||
make.top.mas_equalTo(headerImageView.mas_bottom).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - 2 * (kMargin + kHalfMargin));
|
||||
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:kMainFont labelWidth:(SCREEN_WIDTH - (kMargin + kHalfMargin)) labelText:str]);
|
||||
}];
|
||||
|
||||
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithAttributedString:[[NSAttributedString alloc] initWithString:str]];
|
||||
// [attributeString addAttribute:NSFontAttributeName value:kBoldMainFont range:NSMakeRange(0, 5)];
|
||||
headerLabel.attributedText = attributeString;
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
- (void)agreementClick
|
||||
{
|
||||
self.agreementButton.selected = !self.agreementButton.selected;
|
||||
|
||||
if (self.agreementButton.selected) {
|
||||
self.applyButton.alpha = 1;
|
||||
} else {
|
||||
self.applyButton.alpha = 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applyClick
|
||||
{
|
||||
if (self.agreementButton.selected) {
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Cancel_Account parameters:nil model:nil success:^(BOOL isSuccess, id _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
[TFUserInfoManager logout];
|
||||
|
||||
weakSelf.agreementButton.selected = NO;
|
||||
weakSelf.applyButton.alpha = 0.6;
|
||||
|
||||
[weakSelf.navigationController popToRootViewControllerAnimated:YES];
|
||||
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"注销成功")];
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// WXYZ_UserDataViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/7/17.
|
||||
// Copyright © 2018年 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
@interface WXYZ_UserDataViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
+309
@@ -0,0 +1,309 @@
|
||||
//
|
||||
// WXYZ_UserDataViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/7/17.
|
||||
// Copyright © 2018年 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_UserDataViewController.h"
|
||||
#import "WXYZ_BindPhoneViewController.h"
|
||||
#import "WXYZ_CancelAccountViewController.h"
|
||||
|
||||
#import "WXYZ_UserDataTableViewCell.h"
|
||||
|
||||
#import "TFWeChatPermissionsManager.h"
|
||||
#import "TFTencentPermissionsManager.h"
|
||||
#import "TFURLProtocol.h"
|
||||
|
||||
#import "WXYZ_ImagePicker.h"
|
||||
#import "TFTextFieldAlertView.h"
|
||||
|
||||
#import "TFUserDataModel.h"
|
||||
|
||||
typedef NS_ENUM(NSUInteger, WXYZ_UserInfoStyle) {
|
||||
WXYZ_UserInfoStyleName,
|
||||
WXYZ_UserInfoStyleGender,
|
||||
WXYZ_UserInfoStyleAvatar
|
||||
};
|
||||
|
||||
@interface WXYZ_UserDataViewController () <UITableViewDataSource, UITableViewDelegate, UIActionSheetDelegate, DPImagePickerDelegate, TFWeChatPermissionsDelegate, TFTencentPermissionsDelegate>
|
||||
|
||||
@property (nonatomic, strong) TFUserDataModel *userDataModel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_UserDataViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self netRequest];
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[TFURLProtocol startMonitor];
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"个人资料")];
|
||||
|
||||
#if TF_WeChat_Login_Mode
|
||||
[TFWeChatPermissionsManager sharedManager].delegate = self;
|
||||
#endif
|
||||
#if TF_QQ_Login_Mode
|
||||
[TFTencentPermissionsManager sharedManager].delegate = self;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableViewGroup.delegate = self;
|
||||
self.mainTableViewGroup.dataSource = self;
|
||||
[self.view addSubview:self.mainTableViewGroup];
|
||||
|
||||
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return self.userDataModel.panel_list.count;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.userDataModel.panel_list[section].count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
WXYZ_UserDataTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WXYZ_UserDataTableViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[WXYZ_UserDataTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"WXYZ_UserDataTableViewCell"];
|
||||
}
|
||||
|
||||
cell.cellModel = self.userDataModel.panel_list[indexPath.section][indexPath.row];
|
||||
cell.hiddenEndLine = (indexPath.row == self.userDataModel.panel_list[indexPath.section].count - 1);
|
||||
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
WS(weakSelf)
|
||||
WXYZ_UserDataTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
|
||||
|
||||
// 修改头像
|
||||
if ([cell.cellModel.action isEqualToString:@"avatar"] && cell.cellModel.is_click) {
|
||||
WXYZ_ImagePicker *picker = [WXYZ_ImagePicker sharedManager];
|
||||
picker.editPhoto = YES;
|
||||
picker.delegate = self;
|
||||
[picker showInController:self];
|
||||
return;
|
||||
}
|
||||
|
||||
// 修改昵称
|
||||
if ([cell.cellModel.action isEqualToString:@"nickname"] && cell.cellModel.is_click) {
|
||||
TFTextFieldAlertView *alert = [[TFTextFieldAlertView alloc] init];
|
||||
alert.alertTitle = TFLocalizedString(@"修改昵称");
|
||||
alert.placeHoldTitle = cell.cellModel.desc ?: @"";
|
||||
alert.endEditedBlock = ^(NSString *inputText) {
|
||||
[weakSelf setUserInfoNetRequestWithStyle:WXYZ_UserInfoStyleName url:Set_NickName parametersKey:@"nickname" parametersValue:inputText editedImage:nil];
|
||||
};
|
||||
[alert showAlertView];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([cell.cellModel.action isEqualToString:@"gender"] && cell.cellModel.is_click) {
|
||||
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
if (is_iPad) {
|
||||
UIPopoverPresentationController *popover = actionSheet.popoverPresentationController;
|
||||
|
||||
if (popover) {
|
||||
popover.sourceView = self.view;
|
||||
popover.sourceRect = self.view.bounds;
|
||||
popover.permittedArrowDirections = UIPopoverArrowDirectionDown;
|
||||
}
|
||||
}
|
||||
[actionSheet addAction:[UIAlertAction actionWithTitle:TFLocalizedString(@"男") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||
[weakSelf setUserInfoNetRequestWithStyle:WXYZ_UserInfoStyleGender url:Set_Gender parametersKey:@"gender" parametersValue:@"2" editedImage:nil];
|
||||
}]];
|
||||
|
||||
[actionSheet addAction:[UIAlertAction actionWithTitle:TFLocalizedString(@"女") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||
[weakSelf setUserInfoNetRequestWithStyle:WXYZ_UserInfoStyleGender url:Set_Gender parametersKey:@"gender" parametersValue:@"1" editedImage:nil];
|
||||
}]];
|
||||
|
||||
[actionSheet addAction:[UIAlertAction actionWithTitle:TFLocalizedString(@"取消") style:UIAlertActionStyleCancel handler:nil]];
|
||||
|
||||
[[TFViewHelper getWindowRootController] presentViewController:actionSheet animated:YES completion:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
// 注销账号
|
||||
if ([cell.cellModel.action isEqualToString:@"cancel"] && cell.cellModel.is_click) {
|
||||
[self.navigationController pushViewController:[[WXYZ_CancelAccountViewController alloc] init] animated:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
// 绑定手机号
|
||||
if ([cell.cellModel.action isEqualToString:@"mobile"] && cell.cellModel.is_click) {
|
||||
WXYZ_BindPhoneViewController *vc = [[WXYZ_BindPhoneViewController alloc] init];
|
||||
WS(weakSelf)
|
||||
vc.completionBlock = ^{
|
||||
[weakSelf netRequest];
|
||||
};
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
// 绑定微信
|
||||
if ([cell.cellModel.action isEqualToString:@"wechat"] && cell.cellModel.is_click) {
|
||||
[self weChatBindingRequest];
|
||||
}
|
||||
|
||||
// 绑定QQ
|
||||
if ([cell.cellModel.action isEqualToString:@"QQ"] && cell.cellModel.is_click) {
|
||||
[self qqBindingRequest];
|
||||
}
|
||||
}
|
||||
|
||||
//section头部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return kHalfMargin;
|
||||
}
|
||||
//section头部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
return view;
|
||||
}
|
||||
|
||||
//section底部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
//section底部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
return view;
|
||||
}
|
||||
|
||||
#pragma mark - DPImagePickerDelegate
|
||||
- (void)imagePickerDidFinishPickingWithOriginalImage:(UIImage *)originalImage editedImage:(UIImage *)editedImage;
|
||||
{
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusLoading promptTitle:TFLocalizedString(@"上传中")];
|
||||
|
||||
[self setUserInfoNetRequestWithStyle:WXYZ_UserInfoStyleAvatar url:Set_Avatar parametersKey:@"avatar" parametersValue:[TFViewHelper getBase64StringWithImageData:UIImagePNGRepresentation(editedImage)] editedImage:[TFViewHelper fixOrientation:editedImage]];
|
||||
}
|
||||
|
||||
- (void)setUserInfoNetRequestWithStyle:(WXYZ_UserInfoStyle)style url:(NSString *)url parametersKey:(NSString *)parametersKey parametersValue:(NSString *)parametersValue editedImage:(UIImage *)editedImage
|
||||
{
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:url parameters:@{parametersKey:parametersValue} model:nil success:^(BOOL isSuccess, NSDictionary *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
switch (style) {
|
||||
case WXYZ_UserInfoStyleName:
|
||||
{
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"修改成功")];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_NickName_Changed object:parametersValue];
|
||||
}
|
||||
break;
|
||||
case WXYZ_UserInfoStyleGender:
|
||||
{
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"修改成功")];
|
||||
}
|
||||
break;
|
||||
case WXYZ_UserInfoStyleAvatar:
|
||||
{
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"修改成功")];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Avatar_Changed object:editedImage];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
|
||||
}
|
||||
|
||||
[weakSelf netRequest];
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
- (void)weChatBindingRequest
|
||||
{
|
||||
if (![TFWeChatPermissionsManager isInstallWechat]) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"您的手机没有安装微信")];
|
||||
return ;
|
||||
}
|
||||
[[TFWeChatPermissionsManager sharedManager] weChatPermissionsType:TFWeChatPermissionsTypeBinding];
|
||||
}
|
||||
|
||||
- (void)wechatResponseSuccess:(TFUserInfoManager *)userData
|
||||
{
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"微信绑定成功")];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)wechatResponseFail:(NSString *)error
|
||||
{
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"绑定失败")];
|
||||
}
|
||||
|
||||
- (void)qqBindingRequest
|
||||
{
|
||||
if (![TFTencentPermissionsManager isInstallTencent]) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"您的手机没有安装QQ或TIM")];
|
||||
return ;
|
||||
}
|
||||
[[TFTencentPermissionsManager sharedManager] tencentPermissionsType:TFTencentPermissionsTypeBinding];
|
||||
}
|
||||
|
||||
- (void)tencentPermissionsSuccess:(TFUserInfoManager *)userData
|
||||
{
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"QQ绑定成功")];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)tencentPermissionsFail:(NSString *)error
|
||||
{
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"绑定失败")];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:User_Data parameters:nil model:nil success:^(BOOL isSuccess, NSDictionary *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
TFUserDataModel *model = [TFUserDataModel modelWithDictionary:t_model[@"data"]];
|
||||
weakSelf.userDataModel = model;
|
||||
|
||||
}
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[TFURLProtocol stopMonitor];
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// WXYZ_CancelAccountTableViewCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/23.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_CancelAccountTableViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic, copy) NSString *titleString;
|
||||
|
||||
@property (nonatomic, copy) NSString *detailString;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// WXYZ_CancelAccountTableViewCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/23.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_CancelAccountTableViewCell.h"
|
||||
|
||||
@implementation WXYZ_CancelAccountTableViewCell
|
||||
{
|
||||
UIImageView *pointView;
|
||||
UILabel *cellTitleLabel;
|
||||
UILabel *cellDetailLabel;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
cellTitleLabel = [[UILabel alloc] init];
|
||||
cellTitleLabel.textColor = kBlackColor;
|
||||
cellTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
cellTitleLabel.font = kBoldMainFont;
|
||||
cellTitleLabel.numberOfLines = 1;
|
||||
[self.contentView addSubview:cellTitleLabel];
|
||||
|
||||
[cellTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
cellDetailLabel = [[UILabel alloc] init];
|
||||
cellDetailLabel.textColor = kGrayTextColor;
|
||||
cellDetailLabel.textAlignment = NSTextAlignmentLeft;
|
||||
cellDetailLabel.font = kMainFont;
|
||||
cellDetailLabel.numberOfLines = 0;
|
||||
[self.contentView addSubview:cellDetailLabel];
|
||||
|
||||
[cellDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(cellTitleLabel.mas_left);
|
||||
make.top.mas_equalTo(cellTitleLabel.mas_bottom);
|
||||
make.right.mas_equalTo(cellTitleLabel.mas_right);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
|
||||
}];
|
||||
|
||||
pointView = [[UIImageView alloc] init];
|
||||
pointView.image = [UIImage imageNamed:@"cancel_point"];
|
||||
[self.contentView addSubview:pointView];
|
||||
|
||||
[pointView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(cellTitleLabel.mas_left);
|
||||
make.centerY.mas_equalTo(cellTitleLabel.mas_centerY);
|
||||
make.width.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)setTitleString:(NSString *)titleString
|
||||
{
|
||||
_titleString = titleString;
|
||||
cellTitleLabel.text = titleString;
|
||||
}
|
||||
|
||||
- (void)setDetailString:(NSString *)detailString
|
||||
{
|
||||
_detailString = detailString;
|
||||
cellDetailLabel.text = detailString;
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// WXYZ_UserDataTableViewCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2020/5/30.
|
||||
// Copyright © 2020 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBasicTableViewCell.h"
|
||||
|
||||
@class TFUserDataListModel;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_UserDataTableViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic, strong) TFUserDataListModel *cellModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// WXYZ_UserDataTableViewCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2020/5/30.
|
||||
// Copyright © 2020 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_UserDataTableViewCell.h"
|
||||
#import "TFUserDataModel.h"
|
||||
|
||||
@implementation WXYZ_UserDataTableViewCell
|
||||
{
|
||||
UILabel *cellTitleLabel;
|
||||
UILabel *cellDetailTitleLabel;
|
||||
UIImageView *connerImageView;
|
||||
UIImageView *avatarImageView;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
cellTitleLabel = [[UILabel alloc] init];
|
||||
cellTitleLabel.textColor = kBlackColor;
|
||||
cellTitleLabel.font = kMainFont;
|
||||
cellTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.contentView addSubview:cellTitleLabel];
|
||||
|
||||
[cellTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH / 2);
|
||||
make.height.mas_equalTo(self.contentView.mas_height);
|
||||
}];
|
||||
|
||||
connerImageView = [[UIImageView alloc] init];
|
||||
connerImageView.image = [UIImage imageNamed:@"public_more"];
|
||||
[self.contentView addSubview:connerImageView];
|
||||
|
||||
[connerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.width.mas_equalTo(10);
|
||||
make.height.mas_equalTo(10);
|
||||
}];
|
||||
|
||||
avatarImageView = [[UIImageView alloc] init];
|
||||
avatarImageView.layer.cornerRadius = 25;
|
||||
avatarImageView.clipsToBounds = YES;
|
||||
[self.contentView addSubview:avatarImageView];
|
||||
|
||||
[avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(connerImageView.mas_left).with.offset(- kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(50);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
cellDetailTitleLabel = [[UILabel alloc] init];
|
||||
cellDetailTitleLabel.font = kFont12;
|
||||
cellDetailTitleLabel.textAlignment = NSTextAlignmentRight;
|
||||
cellDetailTitleLabel.textColor = kGrayTextColor;
|
||||
[self.contentView addSubview:cellDetailTitleLabel];
|
||||
|
||||
[cellDetailTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(cellTitleLabel.mas_right);
|
||||
make.right.mas_equalTo(connerImageView.mas_left).with.offset(- kHalfMargin);
|
||||
make.top.mas_equalTo(avatarImageView.mas_bottom);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setCellModel:(TFUserDataListModel *)cellModel
|
||||
{
|
||||
_cellModel = cellModel;
|
||||
|
||||
if ([cellModel.action isEqualToString:@"avatar"]) {
|
||||
[avatarImageView setImageWithURL:[NSURL URLWithString:cellModel.desc?:@""] placeholder:HoldUserAvatar options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
|
||||
[avatarImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(50);
|
||||
}];
|
||||
cellDetailTitleLabel.text = @"";
|
||||
[cellDetailTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
} else {
|
||||
avatarImageView.image = nil;
|
||||
[avatarImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
cellDetailTitleLabel.text = cellModel.desc?:@"";
|
||||
[cellDetailTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
}
|
||||
|
||||
cellTitleLabel.text = cellModel.title?:@"";
|
||||
cellTitleLabel.textColor = [UIColor colorWithHexString:cellModel.title_color?:@""];
|
||||
cellDetailTitleLabel.textColor = [UIColor colorWithHexString:cellModel.desc_color?:@""];
|
||||
|
||||
connerImageView.hidden = !cellModel.is_click;
|
||||
if (cellModel.is_click) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
[cellDetailTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
if (cellModel.is_click) {
|
||||
make.right.mas_equalTo(connerImageView.mas_left).with.offset(- kHalfMargin);
|
||||
} else {
|
||||
make.right.equalTo(connerImageView.mas_left).offset(10);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFFeedBackRecordViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/23.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFFeedBackRecordViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// TFFeedBackRecordViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/23.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFFeedBackRecordViewController.h"
|
||||
#import "TFFeedBackRecordViewCell.h"
|
||||
#import "TFFeedBackRecordModel.h"
|
||||
|
||||
@interface TFFeedBackRecordViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFFeedBackRecordViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"我的反馈")];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.view.backgroundColor = kGrayViewColor;
|
||||
|
||||
self.mainTableViewGroup.delegate = self;
|
||||
self.mainTableViewGroup.dataSource = self;
|
||||
[self.view addSubview:self.mainTableViewGroup];
|
||||
|
||||
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableViewGroup.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableViewGroup.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableViewGroup.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableViewGroup title:TFLocalizedString(@"您还没有任何反馈") tapBlock:^{
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
static NSString *cellName = @"TFFeedBackRecordViewCell";
|
||||
TFFeedBackRecordViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFFeedBackRecordViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.contentModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.section];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return kHalfMargin;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Feed_Back_List parameters:nil model:TFFeedBackRecordModel.class success:^(BOOL isSuccess, TFFeedBackRecordModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableViewGroup endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableViewGroup hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
[weakSelf.mainTableViewGroup xtfei_endLoading];
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFFeedBackViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFFeedBackViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
//
|
||||
// TFFeedBackViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFFeedBackViewController.h"
|
||||
#import "WXYZ_FeedbackSubViewController.h"
|
||||
#import "TFFeedBackRecordViewController.h"
|
||||
#import "TFFeedBackHeaderView.h"
|
||||
#import "TFFeedBackViewCellCell.h"
|
||||
#import "TFFeedBackModel.h"
|
||||
|
||||
@interface TFFeedBackViewController ()<UITableViewDataSource, UITableViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) TFFeedBackModel *feedbackModel;
|
||||
@property (nonatomic ,assign) NSUInteger selectIndex; // 当前选择位置
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFFeedBackViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"首页帮助反馈")];
|
||||
self.selectIndex = 99999;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deletePhoto:) name:TF_DELETE_PHOTO object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableViewGroup.delegate = self;
|
||||
self.mainTableViewGroup.dataSource = self;
|
||||
[self.view addSubview:self.mainTableViewGroup];
|
||||
|
||||
WS(weakSelf)
|
||||
TFFeedBackHeaderView *headerView = [[TFFeedBackHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
|
||||
headerView.leftButtonClick = ^{
|
||||
[weakSelf.navigationController pushViewController:[[TFFeedBackRecordViewController alloc] init] animated:YES];
|
||||
};
|
||||
headerView.rightButtonClick = ^{
|
||||
[weakSelf.navigationController pushViewController:[[WXYZ_FeedbackSubViewController alloc] init] animated:YES];
|
||||
};
|
||||
[self.mainTableViewGroup setTableHeaderView:headerView];
|
||||
|
||||
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return self.feedbackModel.help_list.count;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return [self.feedbackModel.help_list objectAtIndex:section].list.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFHelpListModel *sectionModel = [self.feedbackModel.help_list objectAtIndex:indexPath.section];
|
||||
TFQuestionListModel *indexModel = [sectionModel.list objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
static NSString *cellName = @"TFFeedBackViewCellCell";
|
||||
TFFeedBackViewCellCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFFeedBackViewCellCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.questionModel = indexModel;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return 40;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 40)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kHalfMargin, 0, SCREEN_WIDTH - 2 * kHalfMargin, 40)];
|
||||
titleLabel.text = [self.feedbackModel.help_list objectAtIndex:section].name ? : @"";
|
||||
titleLabel.textColor = kGrayTextColor;
|
||||
titleLabel.font = kFont15;
|
||||
[view addSubview:titleLabel];
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
if (section == self.feedbackModel.help_list.count - 1) {
|
||||
return PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET;
|
||||
}
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFFeedBackViewCellCell *cell = [self.mainTableViewGroup cellForRowAtIndexPath:indexPath];
|
||||
[self.mainTableViewGroup beginUpdates];
|
||||
if (cell.detailCellShowing) {
|
||||
[cell hiddenDetail];
|
||||
} else {
|
||||
[cell showDetail];
|
||||
}
|
||||
[self.mainTableViewGroup endUpdates];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Answer_List parameters:nil model:TFFeedBackModel.class success:^(BOOL isSuccess, TFFeedBackModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.feedbackModel = t_model;
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
- (void)deletePhoto:(NSNotification *)noti
|
||||
{
|
||||
[TFNetworkTools POST:Delete_Upload_Image parameters:@{@"image":[TFUtilsHelper formatStringWithObject:noti.object]} model:nil success:nil failure:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// TFFeedBackModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFHelpListModel, TFQuestionListModel;
|
||||
|
||||
@interface TFFeedBackModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFHelpListModel *>*help_list;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFHelpListModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *name; // 标题
|
||||
@property (nonatomic ,strong) NSArray <TFQuestionListModel *>*list; // 问题列表
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFQuestionListModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *title;
|
||||
@property (nonatomic ,copy) NSString *answer;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// TFFeedBackModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFFeedBackModel.h"
|
||||
|
||||
@implementation TFFeedBackModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"help_list" : [TFHelpListModel class]};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFHelpListModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"list" : [TFQuestionListModel class]};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFQuestionListModel
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// TFFeedBackRecordModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/23.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFFeedbackContentModel, TFPagingModel;
|
||||
|
||||
@interface TFFeedBackRecordModel : TFPagingModel
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFFeedbackContentModel *>*list;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface TFFeedbackContentModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *content; // 用户反馈内容
|
||||
@property (nonatomic ,strong) NSArray <NSString *>* images; // 图片组
|
||||
@property (nonatomic ,copy) NSString *reply; // 管理员回复内容
|
||||
@property (nonatomic ,copy) NSString *created_at; // 反馈时间
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// TFFeedBackRecordModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/23.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFFeedBackRecordModel.h"
|
||||
|
||||
@implementation TFFeedBackRecordModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"list" : [TFFeedbackContentModel class]};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFFeedbackContentModel
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFFeedBackHeaderView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFFeedBackHeaderView : UIView
|
||||
|
||||
@property (nonatomic, copy) void(^leftButtonClick)(void);
|
||||
@property (nonatomic, copy) void(^rightButtonClick)(void);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// TFFeedBackHeaderView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFFeedBackHeaderView.h"
|
||||
|
||||
@implementation TFFeedBackHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
TFButton *leftButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"首页我的反馈") buttonSubTitle:@"" buttonImageName:@"feedback_talk" buttonIndicator:TFButtonIndicatorTitleRight showMaskView:NO];
|
||||
leftButton.graphicDistance = 1;
|
||||
leftButton.buttonImageScale = 0.4;
|
||||
leftButton.buttonTitleFont = kBoldFont15;
|
||||
leftButton.tag = 1;
|
||||
[leftButton addTarget:self action:@selector(menuClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:leftButton];
|
||||
|
||||
[leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.mas_left);
|
||||
make.top.mas_equalTo(self.mas_top);
|
||||
make.height.mas_equalTo(self.mas_height);
|
||||
make.width.mas_equalTo(self.mas_width).multipliedBy(0.5);
|
||||
}];
|
||||
|
||||
UIView *line = [[UIView alloc] init];
|
||||
line.backgroundColor = kGrayViewColor;
|
||||
[self addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(leftButton.mas_right);
|
||||
make.centerY.mas_equalTo(leftButton.mas_centerY);
|
||||
make.width.mas_equalTo(2);
|
||||
make.height.mas_equalTo(self.mas_height).with.multipliedBy(0.5);
|
||||
}];
|
||||
|
||||
TFButton *rightButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"反馈意见") buttonSubTitle:@"" buttonImageName:@"feedback_list" buttonIndicator:TFButtonIndicatorTitleRight showMaskView:NO];
|
||||
rightButton.graphicDistance = 1;
|
||||
rightButton.buttonImageScale = 0.4;
|
||||
rightButton.buttonTitleFont = kBoldFont15;
|
||||
rightButton.tag = 2;
|
||||
[rightButton addTarget:self action:@selector(menuClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:rightButton];
|
||||
|
||||
[rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right);
|
||||
make.top.mas_equalTo(self.mas_top);
|
||||
make.height.mas_equalTo(self.mas_height);
|
||||
make.width.mas_equalTo(self.mas_width).multipliedBy(0.5);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)menuClick:(UIButton *)sender
|
||||
{
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender.tag == 1) {
|
||||
if (self.leftButtonClick) {
|
||||
self.leftButtonClick();
|
||||
}
|
||||
} else if (sender.tag == 2) {
|
||||
if (self.rightButtonClick) {
|
||||
self.rightButtonClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFFeedBackRecordViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/23.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFFeedBackRecordModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFFeedBackRecordViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFFeedbackContentModel *contentModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
//
|
||||
// TFFeedBackRecordViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/23.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFFeedBackRecordViewCell.h"
|
||||
#import "TFPhotoBrowser.h"
|
||||
|
||||
@interface TFFeedBackRecordViewCell ()
|
||||
{
|
||||
UILabel *dateLabel;
|
||||
UILabel *questionLabel;
|
||||
UIView *questionImageBack;
|
||||
UILabel *replyLabel;
|
||||
|
||||
NSArray *questionImageArray;
|
||||
|
||||
UIView *line;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFFeedBackRecordViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
dateLabel = [[UILabel alloc] init];
|
||||
dateLabel.textColor = kGrayTextColor;
|
||||
dateLabel.textAlignment = NSTextAlignmentLeft;
|
||||
dateLabel.font = kFont11;
|
||||
[self.contentView addSubview:dateLabel];
|
||||
|
||||
[dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(self.contentView.mas_width).with.offset(- kMargin);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
questionLabel = [[UILabel alloc] init];
|
||||
questionLabel.textColor = kBlackColor;
|
||||
questionLabel.textAlignment = NSTextAlignmentLeft;
|
||||
questionLabel.font = kMainFont;
|
||||
questionLabel.numberOfLines = 0;
|
||||
[self.contentView addSubview:questionLabel];
|
||||
[questionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(dateLabel.mas_left);
|
||||
make.width.mas_equalTo(dateLabel.mas_width);
|
||||
make.top.mas_equalTo(dateLabel.mas_bottom);
|
||||
}];
|
||||
|
||||
questionImageBack = [[UIView alloc] init];
|
||||
questionImageBack.backgroundColor = kWhiteColor;
|
||||
[self.contentView addSubview:questionImageBack];
|
||||
|
||||
[questionImageBack mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(dateLabel.mas_left);
|
||||
make.top.mas_equalTo(questionLabel.mas_bottom).with.offset(kHalfMargin);
|
||||
make.right.mas_equalTo(dateLabel.mas_right);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
line = [[UIView alloc] init];
|
||||
line.backgroundColor = kGrayLineColor;
|
||||
line.hidden = YES;
|
||||
[self.contentView addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(questionImageBack.mas_bottom).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
|
||||
make.height.mas_equalTo(kCellLineHeight);
|
||||
}];
|
||||
|
||||
replyLabel = [[UILabel alloc] init];
|
||||
replyLabel.textColor = kGrayTextColor;
|
||||
replyLabel.textAlignment = NSTextAlignmentLeft;
|
||||
replyLabel.font = kMainFont;
|
||||
replyLabel.numberOfLines = 10;
|
||||
[self.contentView addSubview:replyLabel];
|
||||
|
||||
[replyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(dateLabel.mas_left);
|
||||
make.top.mas_equalTo(questionImageBack.mas_bottom).with.offset(kMargin);
|
||||
make.right.mas_equalTo(dateLabel.mas_right);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setContentModel:(TFFeedbackContentModel *)contentModel
|
||||
{
|
||||
_contentModel = contentModel;
|
||||
|
||||
dateLabel.text = contentModel.created_at?:@"";
|
||||
|
||||
questionLabel.text = [TFLocalizedString(@"问题:\n\n") stringByAppendingString:contentModel.content?:@""];
|
||||
|
||||
if (questionImageArray.count != contentModel.images.count) {
|
||||
NSInteger buttonNum = contentModel.images.count;//每行多少按钮
|
||||
CGFloat button_W = 60;//按钮宽
|
||||
CGFloat button_H = 60;//按钮高
|
||||
CGFloat space_X = 10;//按钮间距
|
||||
for (NSInteger i = 0; i < buttonNum; i++) {
|
||||
NSInteger loc = i % buttonNum;//列号
|
||||
|
||||
CGFloat button_X = (space_X + button_W) * loc;
|
||||
CGFloat button_Y = 0;
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
button.frame = CGRectMake(button_X, button_Y, button_W, button_H);
|
||||
button.tag = i;
|
||||
button.adjustsImageWhenHighlighted = NO;
|
||||
[button setImageWithURL:[NSURL URLWithString:[contentModel.images objectOrNilAtIndex:i]] forState:UIControlStateNormal options:YYWebImageOptionSetImageWithFadeAnimation];
|
||||
[button addTarget:self action:@selector(watchPhoto:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[questionImageBack addSubview:button];
|
||||
}
|
||||
[questionImageBack mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(70);
|
||||
}];
|
||||
}
|
||||
|
||||
if (contentModel.reply.length > 0) {
|
||||
line.hidden = NO;
|
||||
replyLabel.text = [TFLocalizedString(@"回复:\n\n") stringByAppendingString:contentModel.reply?:@""];
|
||||
[replyLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(questionImageBack.mas_bottom).with.offset(kMargin);
|
||||
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:replyLabel.font labelWidth:(SCREEN_WIDTH - kMargin) labelText:replyLabel.text] - kHalfMargin);
|
||||
}];
|
||||
} else {
|
||||
line.hidden = YES;
|
||||
[replyLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(questionImageBack.mas_bottom).with.offset(CGFLOAT_MIN);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)watchPhoto:(UIButton *)sender
|
||||
{
|
||||
TFPhotoBrowser *browser = [TFPhotoBrowser new];
|
||||
browser.dataSource = self.contentModel.images.mutableCopy;
|
||||
browser.downLoadNeeded = YES;
|
||||
browser.currentPhotoIndex = sender.tag;
|
||||
[[TFViewHelper getCurrentViewController] presentViewController:browser animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TFFeedBackViewCellCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFFeedBackModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFFeedBackViewCellCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFQuestionListModel *questionModel;
|
||||
@property (nonatomic ,assign) BOOL detailCellShowing;
|
||||
|
||||
- (void)showDetail;
|
||||
|
||||
- (void)hiddenDetail;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// TFFeedBackViewCellCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFFeedBackViewCellCell.h"
|
||||
|
||||
@interface TFFeedBackViewCellCell ()
|
||||
{
|
||||
UILabel *questionTitleLabel;
|
||||
UILabel *questionDetailLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFFeedBackViewCellCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
questionTitleLabel = [[UILabel alloc] init];
|
||||
questionTitleLabel.backgroundColor = kWhiteColor;
|
||||
questionTitleLabel.textColor = kBlackColor;
|
||||
questionTitleLabel.font = kMainFont;
|
||||
questionTitleLabel.numberOfLines = 0;
|
||||
questionTitleLabel.userInteractionEnabled = YES;
|
||||
[self.contentView addSubview:questionTitleLabel];
|
||||
|
||||
[questionTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
questionDetailLabel = [[UILabel alloc] init];
|
||||
questionDetailLabel.textColor = kGrayTextColor;
|
||||
questionDetailLabel.font = kMainFont;
|
||||
questionDetailLabel.numberOfLines = 0;
|
||||
[self.contentView addSubview:questionDetailLabel];
|
||||
|
||||
[questionDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(questionTitleLabel.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(questionTitleLabel.mas_bottom);
|
||||
make.right.mas_equalTo(questionTitleLabel.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setQuestionModel:(TFQuestionListModel *)questionModel
|
||||
{
|
||||
_questionModel = questionModel;
|
||||
|
||||
questionTitleLabel.text = [NSString stringWithFormat:@"Q:%@", questionModel.title]?:@"";
|
||||
[questionTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:kMainFont labelWidth:(SCREEN_WIDTH - kMargin) labelText:questionTitleLabel.text]);
|
||||
}];
|
||||
|
||||
questionDetailLabel.text = [NSString stringWithFormat:@"A:%@", questionModel.answer]?:@"";
|
||||
}
|
||||
|
||||
- (void)showDetail
|
||||
{
|
||||
self.detailCellShowing = YES;
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||||
[self->questionDetailLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabel:self->questionDetailLabel] - kHalfMargin);
|
||||
}];
|
||||
[self->questionDetailLabel.superview layoutIfNeeded];//强制绘制
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)hiddenDetail
|
||||
{
|
||||
self.detailCellShowing = NO;
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||||
[self->questionDetailLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
[self->questionDetailLabel.superview layoutIfNeeded];//强制绘制
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFHistoricalRecordCommController.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 TFHistoricalRecordCommController : TFBasicViewController
|
||||
|
||||
// 一键清空历史记录
|
||||
- (void)stepClear;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+469
@@ -0,0 +1,469 @@
|
||||
//
|
||||
// TFHistoricalRecordCommController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFHistoricalRecordCommController.h"
|
||||
|
||||
#if TF_Enable_Book
|
||||
#import "TFReadNovelViewController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
#import "TFComicBrowseViewController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
#import "TFAudioPlayViewController.h"
|
||||
#import "WXYZ_Player.h"
|
||||
#endif
|
||||
|
||||
#import "TFHistoricalRecordCommCell.h"
|
||||
#import "TFPublicAdvertisementViewCell.h"
|
||||
#import "TFReadRecordManager.h"
|
||||
#import "TFCollectionManager.h"
|
||||
|
||||
@interface TFHistoricalRecordCommController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
@end
|
||||
|
||||
@implementation TFHistoricalRecordCommController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Readlog_Delete;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Readlog_Delete;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Readlog_Delete;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
WS(weakSelf)
|
||||
for (NSString *log_id in [self log_idArr]) {
|
||||
[TFNetworkTools POST:url parameters:@{@"log_id":log_id} model:nil success:^(BOOL isSuccess, id _Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (!isSuccess) {
|
||||
// 删除失败,保存删除的log_id下次删除
|
||||
[weakSelf addLog_id:log_id];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf addLog_id:log_id];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.needRefresh = YES;
|
||||
[self hiddenNavigationBar:YES];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Login_Success object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.view.mas_top);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - self.pageViewHeight);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
}];
|
||||
|
||||
[self createEmptyView];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
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:nil tapBlock:^{
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
if (productionModel.ad_type == 0) {
|
||||
WS(weakSelf)
|
||||
TFHistoricalRecordCommCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFHistoricalRecordCommCell"];
|
||||
if (!cell) {
|
||||
cell = [[TFHistoricalRecordCommCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFHistoricalRecordCommCell"];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
cell.productionModel = productionModel;
|
||||
cell.hiddenEndLine = self.dataSourceArray.count - 1 == indexPath.row;
|
||||
cell.continueReadBlock = ^(NSInteger book_id) {
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFReadNovelViewController *vc = [[TFReadNovelViewController alloc] init];
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeNovel] moveCollectionToTopWithProductionModel:productionModel];
|
||||
vc.book_id = book_id;
|
||||
[weakSelf.navigationController pushViewController:vc animated:NO];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicBrowseViewController *vc = [[TFComicBrowseViewController alloc] init];
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] moveCollectionToTopWithProductionModel:productionModel];
|
||||
vc.comicProductionModel = productionModel;
|
||||
vc.chapter_id = [[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeComic] getReadingRecordChapter_idWithProduction_id:productionModel.production_id];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
if ([WXYZ_Player sharedPlayer].state != TFBasicVoicePlayerStatePlaying) {
|
||||
[[WXYZ_Player sharedPlayer] play];
|
||||
}
|
||||
|
||||
TFAudioPlayViewController *vc = [[TFAudioPlayViewController alloc] init];
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] moveCollectionToTopWithProductionModel:productionModel];
|
||||
[vc loadDataWithAudio_id:productionModel.production_id chapter_id:0];
|
||||
TFNavigationController *nav = [[TFNavigationController alloc] initWithRootViewController:vc];
|
||||
[[TFViewHelper getWindowRootController] presentViewController:nav animated:YES completion:nil];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
cell.hiddenEndLine = (self.dataSourceArray.count - 1 == indexPath.row);
|
||||
if (indexPath.row + 1 < self.dataSourceArray.count) {
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row + 1];
|
||||
cell.hiddenEndLine = t_model.advert_id != 0;
|
||||
}
|
||||
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
return cell;
|
||||
} else {
|
||||
TFPublicAdvertisementViewCell *cell = [self.advertDict objectForKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
if (!cell) {
|
||||
static NSString *cellName = @"TFPublicAdvertisementViewCell";
|
||||
cell = [[TFPublicAdvertisementViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
[cell setAdModel:productionModel refresh:self.needRefresh];
|
||||
cell.mainTableView = tableView;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.advertDict setObject:cell forKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *vc = [[TFComicDetailViewController alloc] init];
|
||||
vc.comic_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
if (productionModel.ad_type > 0) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return UITableViewCellEditingStyleDelete;
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return TFLocalizedString(@"删除");
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[self deleteReadlogWithIndexPath:indexPath];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
if ([TFNetworkManager networkingStatus] == NO) {
|
||||
[self.mainTableView xtfei_showEmptyView];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Read_Log_List;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Read_Log_List;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Read_Log_List;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"page_num"] = [TFUtilsHelper formatStringWithInteger:self.currentPageNumber];
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:TFProductionListModel.class success:^(BOOL isSuccess, TFProductionListModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.mainTableView showRefreshFooter];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableView reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)deleteReadlogWithIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
// 获取被删除的cell
|
||||
NSString *log_id;
|
||||
NSMutableArray<NSIndexPath *> *pathArr = [NSMutableArray array];
|
||||
if (indexPath) {
|
||||
[pathArr addObject:indexPath];
|
||||
TFProductionModel *productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
log_id = [TFUtilsHelper formatStringWithInteger:productionModel.log_id];
|
||||
[self.dataSourceArray removeObjectAtIndex:indexPath.row];
|
||||
} else {
|
||||
for (NSInteger i = 0; i < self.dataSourceArray.count; i++) {
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
|
||||
[pathArr addObject:indexPath];
|
||||
}
|
||||
[self.dataSourceArray removeAllObjects];
|
||||
log_id = @"all";
|
||||
}
|
||||
|
||||
// 删除并更新页面
|
||||
if (@available(iOS 11.0, *)) {
|
||||
[self.mainTableView performBatchUpdates:^{
|
||||
[self.mainTableView deleteRowsAtIndexPaths:pathArr withRowAnimation:UITableViewRowAnimationLeft];
|
||||
} completion:^(BOOL finished) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:finished ? TFLocalizedString(@"清除成功") : TFLocalizedString(@"删除失败")];
|
||||
[self.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
} else {
|
||||
[CATransaction begin];
|
||||
[CATransaction setCompletionBlock:^{
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"清除成功")];
|
||||
[self.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
[self.mainTableView beginUpdates];
|
||||
[self.mainTableView deleteRowsAtIndexPaths:pathArr withRowAnimation:UITableViewRowAnimationLeft];
|
||||
[self.mainTableView endUpdates];
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Readlog_Delete;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Readlog_Delete;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Readlog_Delete;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:url parameters:@{@"log_id":log_id} model:nil success:^(BOOL isSuccess, id _Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (!isSuccess) {
|
||||
// 删除失败,保存删除的log_id下次删除
|
||||
[weakSelf addLog_id:log_id];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf addLog_id:log_id];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)stepClear
|
||||
{
|
||||
if (self.dataSourceArray.count == 0) return;
|
||||
|
||||
TFAlertView *alert = [[TFAlertView alloc] init];
|
||||
alert.alertDetailContent = TFLocalizedString(@"是否清除历史记录");
|
||||
alert.confirmButtonClickBlock = ^{
|
||||
[self deleteReadlogWithIndexPath:nil];
|
||||
};
|
||||
[alert showAlertView];
|
||||
}
|
||||
|
||||
- (void)addLog_id:(NSString *)log_id
|
||||
{
|
||||
NSString *filePath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
|
||||
NSString *fullPath = [filePath stringByAppendingPathComponent:@"listory.plist"];
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
|
||||
[[NSFileManager defaultManager] createFileAtPath:fullPath contents:nil attributes:nil];
|
||||
}
|
||||
|
||||
NSArray<NSString *> *arr = [NSArray arrayWithContentsOfFile:fullPath];
|
||||
if (!arr) arr = [NSArray array];
|
||||
NSMutableSet<NSString *> *logSet = [NSMutableSet setWithArray:arr];
|
||||
|
||||
if ([log_id isEqualToString:@"all"]) {
|
||||
for (TFProductionModel *t_model in self.dataSourceArray) {
|
||||
[logSet addObject:[NSString stringWithFormat:@"%zd", t_model.log_id]];
|
||||
}
|
||||
} else {
|
||||
[logSet addObject:log_id];
|
||||
}
|
||||
|
||||
arr = logSet.allObjects;
|
||||
[arr writeToFile:fullPath atomically:YES];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)log_idArr
|
||||
{
|
||||
NSString *filePath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
|
||||
NSString *fullPath = [filePath stringByAppendingPathComponent:@"listory.plist"];
|
||||
|
||||
return [NSArray arrayWithContentsOfFile:fullPath];
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFHistoricalRecordController.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 TFHistoricalRecordController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
//
|
||||
// TFHistoricalRecordController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFHistoricalRecordController.h"
|
||||
#import "TFHistoricalRecordCommController.h"
|
||||
|
||||
@interface TFHistoricalRecordController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
@property (nonatomic ,weak) TFHistoricalRecordCommController *bookVC;
|
||||
@property (nonatomic ,weak) TFHistoricalRecordCommController *comicVC;
|
||||
@property (nonatomic ,weak) TFHistoricalRecordCommController *audioVC;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFHistoricalRecordController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Hidden_Tabbar object:@"1"];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubViews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"历史记录")];
|
||||
[self hiddenSeparator];
|
||||
|
||||
UIButton *rightButton;
|
||||
[self setNavigationBarRightButton:({
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
rightButton = button;
|
||||
[button setTitle:TFLocalizedString(@"清空") forState:UIControlStateNormal];
|
||||
[button setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
button.titleLabel.font = kFont14;
|
||||
button.backgroundColor = [UIColor clearColor];
|
||||
[button addTarget:self action:@selector(stepClear) forControlEvents:UIControlEventTouchUpInside];
|
||||
button;
|
||||
})];
|
||||
|
||||
[rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.view).offset(-kMargin);
|
||||
make.centerY.equalTo(self.navigationBar.navTitleLabel);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
#if TF_Enable_Book
|
||||
TFHistoricalRecordCommController *bookVC = [[TFHistoricalRecordCommController alloc] init];
|
||||
self.bookVC = bookVC;
|
||||
bookVC.productionType = TFProductionTypeNovel;
|
||||
[self addChildViewController:bookVC];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
TFHistoricalRecordCommController *comicVC = [[TFHistoricalRecordCommController alloc] init];
|
||||
self.comicVC = comicVC;
|
||||
comicVC.productionType = TFProductionTypeComic;
|
||||
[self addChildViewController:comicVC];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
TFHistoricalRecordCommController *audioVC = [[TFHistoricalRecordCommController alloc] init];
|
||||
self.audioVC = audioVC;
|
||||
audioVC.productionType = TFProductionTypeAudio;
|
||||
[self addChildViewController:audioVC];
|
||||
#endif
|
||||
|
||||
NSMutableArray *titleArr = [NSMutableArray array];
|
||||
NSMutableArray *childArr = [NSMutableArray array];
|
||||
|
||||
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
|
||||
#if TF_Enable_Book
|
||||
if ([siteNumber integerValue] == 1) {
|
||||
[titleArr addObject:TFLocalizedString(@"小说")];
|
||||
[childArr addObject:bookVC];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
if ([siteNumber integerValue] == 2) {
|
||||
[titleArr addObject:TFLocalizedString(@"漫画")];
|
||||
[childArr addObject:comicVC];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
if ([siteNumber integerValue] == 3) {
|
||||
[titleArr addObject:TFLocalizedString(@"听书")];
|
||||
[childArr addObject:audioVC];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count <= 1) {
|
||||
[titleArr removeAllObjects];
|
||||
[titleArr addObject:TFLocalizedString(@"历史记录")];
|
||||
}
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT + self.pageViewHeight, SCREEN_WIDTH, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - self.pageViewHeight) parentVC:self childVCs:childArr];
|
||||
self.pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, self.pageViewHeight) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:self.pageTitleView];
|
||||
}
|
||||
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView index:(NSInteger)index
|
||||
{
|
||||
TFBasicViewController *vc = [pageContentCollectionView.childViewControllers objectAtIndex:index];
|
||||
[vc cancleTableViewCellEditingState];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
|
||||
// 一键清空历史记录
|
||||
- (void)stepClear
|
||||
{
|
||||
NSInteger index = self.pageTitleView.signBtnIndex;
|
||||
switch (index) {
|
||||
case 0: {
|
||||
[self.bookVC stepClear];
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: {
|
||||
[self.comicVC stepClear];
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: {
|
||||
[self.audioVC stepClear];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFHistoricalRecordCommCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicTableViewCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void(^ContinueReadBlock)(NSInteger book_id);
|
||||
@interface TFHistoricalRecordCommCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *productionModel;
|
||||
@property (nonatomic ,copy) ContinueReadBlock continueReadBlock;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
//
|
||||
// TFHistoricalRecordCommCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFHistoricalRecordCommCell.h"
|
||||
|
||||
@interface TFHistoricalRecordCommCell ()
|
||||
|
||||
@property (nonatomic ,strong) UIView *advertView;
|
||||
@property (nonatomic ,strong) TFProductionCoverView *coverView;
|
||||
@property (nonatomic ,strong) UIButton *continueBtn;
|
||||
@property (nonatomic ,strong) UILabel *titleLabel;
|
||||
@property (nonatomic ,strong) UILabel *recordLabel;
|
||||
@property (nonatomic ,strong) UILabel *timeLabel;
|
||||
@property (nonatomic ,strong) UIView *posterView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFHistoricalRecordCommCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
// 图片
|
||||
self.coverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
self.coverView.userInteractionEnabled = YES;
|
||||
self.coverView.hidden = YES;
|
||||
[self.contentView addSubview:self.coverView];
|
||||
|
||||
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(BOOK_WIDTH_SMALL - kMargin);
|
||||
make.height.mas_equalTo(kGeometricHeight(BOOK_WIDTH_SMALL - kMargin, 3, 4));
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
self.continueBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.continueBtn setHidden:YES];
|
||||
[self.continueBtn.layer setCornerRadius:12];
|
||||
[self.continueBtn setBackgroundColor:kMainColor];
|
||||
[self.continueBtn setTitle:TFLocalizedString(@"历史记录继续阅读") forState:UIControlStateNormal];
|
||||
[self.continueBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
[self.continueBtn.titleLabel setFont:kFont11];
|
||||
[self.continueBtn addTarget:self action:@selector(continueReadClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.contentView addSubview:self.continueBtn];
|
||||
|
||||
[self.continueBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.centerY.mas_equalTo(self.coverView.mas_centerY);
|
||||
make.width.mas_equalTo(70);
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
// 书名
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.numberOfLines = 1;
|
||||
self.titleLabel.hidden = YES;
|
||||
self.titleLabel.backgroundColor = kWhiteColor;
|
||||
self.titleLabel.font = kMainFont;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.coverView.mas_right).with.offset(kHalfMargin);
|
||||
make.right.mas_equalTo(self.continueBtn.mas_left).with.offset(- kHalfMargin);
|
||||
make.top.mas_equalTo(self.coverView.mas_top).mas_offset(10);
|
||||
}];
|
||||
|
||||
// 阅读记录
|
||||
self.recordLabel = [[UILabel alloc] init];
|
||||
self.recordLabel.hidden = YES;
|
||||
self.recordLabel.textColor = kGrayTextColor;
|
||||
self.recordLabel.font = kFont11;
|
||||
self.recordLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.contentView addSubview:self.recordLabel];
|
||||
|
||||
[self.recordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_left);
|
||||
make.centerY.mas_equalTo(self.coverView.centerY).mas_offset(10);
|
||||
make.width.mas_equalTo(self.titleLabel.mas_width);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
// 更新记录
|
||||
self.timeLabel = [[UILabel alloc] init];
|
||||
self.timeLabel.hidden = YES;
|
||||
self.timeLabel.textColor = kGrayTextColor;
|
||||
self.timeLabel.font = kFont10;
|
||||
self.timeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.contentView addSubview:self.timeLabel];
|
||||
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_left);
|
||||
make.top.mas_equalTo(self.recordLabel.mas_bottom);
|
||||
make.width.mas_equalTo(self.titleLabel.mas_width);
|
||||
make.height.mas_equalTo(self.recordLabel.mas_height);
|
||||
}];
|
||||
|
||||
|
||||
self.posterView = [[UIView alloc] init];
|
||||
self.posterView.backgroundColor = [UIColor whiteColor];
|
||||
self.posterView.hidden = YES;
|
||||
[self.contentView addSubview:self.posterView];
|
||||
|
||||
[self.posterView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setAdvertView:(UIView *)advertView
|
||||
{
|
||||
_advertView = advertView;
|
||||
|
||||
[self.posterView addSubview:advertView];
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
_productionModel = productionModel;
|
||||
|
||||
if (productionModel.ad_type != 0) {
|
||||
self.coverView.hidden = YES;
|
||||
self.continueBtn.hidden = YES;
|
||||
self.titleLabel.hidden = YES;
|
||||
self.recordLabel.hidden = YES;
|
||||
self.timeLabel.hidden = YES;
|
||||
self.posterView.hidden = NO;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self.coverView.hidden = NO;
|
||||
self.continueBtn.hidden = NO;
|
||||
self.titleLabel.hidden = NO;
|
||||
self.recordLabel.hidden = NO;
|
||||
self.timeLabel.hidden = NO;
|
||||
self.posterView.hidden = YES;
|
||||
|
||||
self.titleLabel.text = productionModel.name ? : @"";
|
||||
|
||||
if (productionModel.vertical_cover.length > 0) {
|
||||
self.coverView.coverImageUrl = productionModel.vertical_cover;
|
||||
} else if (productionModel.horizontal_cover.length > 0) {
|
||||
self.coverView.coverImageUrl = productionModel.horizontal_cover;
|
||||
} else {
|
||||
self.coverView.coverImageUrl = productionModel.cover;
|
||||
}
|
||||
|
||||
if (self.productionType == TFProductionTypeAudio) {
|
||||
self.recordLabel.text = [NSString stringWithFormat:@"%@%@", TFLocalizedString(@"上次收听到:"), productionModel.record_title ?: @""];
|
||||
} else {
|
||||
self.recordLabel.text = [NSString stringWithFormat:@"%@%@", TFLocalizedString(@"上次阅读到:"), productionModel.record_title ?: @""];
|
||||
}
|
||||
|
||||
self.timeLabel.text = [NSString stringWithFormat:TFLocalizedString(@"%@ 更新至第%@章"), productionModel.last_chapter_time ? : @"", [TFUtilsHelper formatStringWithInteger:productionModel.total_chapters] ?: @""];
|
||||
}
|
||||
|
||||
- (void)continueReadClick
|
||||
{
|
||||
if (self.continueReadBlock) {
|
||||
self.continueReadBlock(_productionModel.production_id);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setProductionType:(TFProductionType)productionType
|
||||
{
|
||||
[super setProductionType:productionType];
|
||||
|
||||
self.coverView.productionType = productionType;
|
||||
|
||||
if (productionType == TFProductionTypeAudio) {
|
||||
[self.continueBtn setTitle:TFLocalizedString(@"历史记录继续收听") forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self.continueBtn setTitle:TFLocalizedString(@"历史记录继续阅读") forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFMineViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFMineViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,317 @@
|
||||
//
|
||||
// TFMineViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFMineViewController.h"
|
||||
#import "WXYZ_UserDataViewController.h"
|
||||
#import "TFAppraiseViewController.h"
|
||||
#import "TFFeedBackViewController.h"
|
||||
#import "TFSetViewController.h"
|
||||
#import "TFRecordsViewController.h"
|
||||
#if TF_Task_Mode && TF_Super_Member_Mode && TF_Recharge_Mode
|
||||
#import "TFTaskViewController.h"
|
||||
#endif
|
||||
#import "TFDownloadCacheViewController.h"
|
||||
#import "TFRechargeViewController.h"
|
||||
#import "TFAboutViewController.h"
|
||||
#import "TFUpgradeMemberController.h"
|
||||
#import "TFHistoricalRecordController.h"
|
||||
#import "TFMineTableViewCell.h"
|
||||
#import "TFMineHeaderView.h"
|
||||
#import "TFUserCenterModel.h"
|
||||
#import "TFCollectionManager.h"
|
||||
#import "TFShareManager.h"
|
||||
#import "TFMonthlyTicketViewController.h"
|
||||
#import "TFRewardRecordViewController.h"
|
||||
#import "TFWebViewController.h"
|
||||
#import "TFLoginOptionsViewController.h"
|
||||
|
||||
@interface TFMineViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFMineHeaderView *headerView;
|
||||
@property (nonatomic ,strong) TFUserCenterModel *userModel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFMineViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
[self netRequest];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Show_Tabbar object:nil];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
|
||||
self.view.backgroundColor = kGrayViewColor;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(avatarChanged:) name:Notification_Avatar_Changed object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nicknameChnaged:) name:Notification_NickName_Changed object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushToUserInfo) name:Notification_Push_UserInfo object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableViewGroup.delegate = self;
|
||||
self.mainTableViewGroup.dataSource = self;
|
||||
[self.view addSubview:self.mainTableViewGroup];
|
||||
|
||||
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(self.view.mas_height).with.offset(- PUB_TABBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
UIView *topCoverView = [[UIView alloc] init];
|
||||
topCoverView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:topCoverView];
|
||||
|
||||
[topCoverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(is_iPhoneX?30:20);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.headerView = [[TFMineHeaderView alloc] init];
|
||||
self.headerView.portraitHandleBlock = ^{
|
||||
if (TFUserInfoManager.isLogin) {
|
||||
[weakSelf.navigationController pushViewController:[[WXYZ_UserDataViewController alloc] init] animated:YES];
|
||||
} else {
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
}
|
||||
};
|
||||
|
||||
// 金币
|
||||
#if TF_Records_Mode
|
||||
self.headerView.goldSelectedBlock = ^{
|
||||
TFRecordsViewController *vc = [[TFRecordsViewController alloc] init];
|
||||
vc.pageIndex = 0;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
#endif
|
||||
|
||||
#if TF_Task_Mode && TF_Super_Member_Mode && TF_Recharge_Mode
|
||||
// 书券余额
|
||||
self.headerView.taskSelectedBlock = ^{
|
||||
TFRecordsViewController *vc = [[TFRecordsViewController alloc] init];
|
||||
vc.pageIndex = 1;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
#endif
|
||||
|
||||
#if TF_Records_Mode
|
||||
// 月票余额
|
||||
self.headerView.voucherSelectedBlock = ^{
|
||||
[weakSelf.navigationController pushViewController:[[TFMonthlyTicketViewController alloc] init] animated:YES];
|
||||
};
|
||||
#endif
|
||||
|
||||
[self.mainTableViewGroup setTableHeaderView:self.headerView];
|
||||
|
||||
self.mainTableViewGroup.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return self.userModel.panel_list.count;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.userModel.panel_list[section].count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFMineTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFMineTableViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[TFMineTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFMineTableViewCell"];
|
||||
}
|
||||
|
||||
cell.cellModel = self.userModel.panel_list[indexPath.section][indexPath.row];
|
||||
cell.hiddenEndLine = (indexPath.row == self.userModel.panel_list[indexPath.section].count - 1);
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFMineTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
|
||||
|
||||
// 充值
|
||||
if ([cell.cellModel.action isEqualToString:@"recharge"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFRechargeViewController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
// 包月
|
||||
if ([cell.cellModel.action isEqualToString:@"vip"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFUpgradeMemberController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
// 任务
|
||||
if ([cell.cellModel.action isEqualToString:@"task"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFTaskViewController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
if ([cell.cellModel.action isEqualToString:@"invite"] && cell.cellModel.enable) {
|
||||
[self shareToFriend];
|
||||
}
|
||||
|
||||
if ([cell.cellModel.action isEqualToString:@"history"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFHistoricalRecordController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
if ([cell.cellModel.action isEqualToString:@"download"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFDownloadCacheViewController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
// 我的书评
|
||||
if ([cell.cellModel.action isEqualToString:@"comment"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFAppraiseViewController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
// 联系客服
|
||||
if ([cell.cellModel.action isEqualToString:@"service"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFAboutViewController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
// 意见反馈
|
||||
if ([cell.cellModel.action isEqualToString:@"feedback"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFFeedBackViewController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
// 设置
|
||||
if ([cell.cellModel.action isEqualToString:@"setting"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFSetViewController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
// 打赏记录
|
||||
if ([cell.cellModel.action isEqualToString:@"reward"] && cell.cellModel.enable) {
|
||||
[self.navigationController pushViewController:[[TFRewardRecordViewController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
// 成为作家
|
||||
if ([cell.cellModel.action isEqualToString:@"url"] && cell.cellModel.enable) {
|
||||
TFWebViewController *vc = [[TFWebViewController alloc] init];
|
||||
vc.URLString = cell.cellModel.content;
|
||||
vc.navTitle = TFLocalizedString(@"成为作家");
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
if ([[self.userModel.panel_list objectOrNilAtIndex:section] count] == 0) {
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
return kHalfMargin;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
return view;
|
||||
}
|
||||
|
||||
//section底部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
if (section == self.userModel.panel_list.count - 1) {
|
||||
return kMargin;
|
||||
}
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
//section底部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kMargin)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)avatarChanged:(NSNotification *)noti
|
||||
{
|
||||
if ([noti.object isKindOfClass:[UIImage class]]) {
|
||||
self.headerView.avatarImage = noti.object;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)nicknameChnaged:(NSNotification *)noti
|
||||
{
|
||||
self.headerView.nickName = noti.object;
|
||||
}
|
||||
|
||||
- (void)pushToUserInfo
|
||||
{
|
||||
[self.navigationController pushViewController:[[WXYZ_UserDataViewController alloc] init] animated:YES];
|
||||
}
|
||||
|
||||
- (void)shareToFriend
|
||||
{
|
||||
[TFShareManager shareApp];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POSTQuick:User_Center parameters:nil model:TFUserCenterModel.class success:^(BOOL isSuccess, TFUserCenterModel *_Nullable t_model, BOOL isCache, TFNetworkRequestModel *requestModel) {
|
||||
[weakSelf.mainTableViewGroup endRefreshing];
|
||||
if (isSuccess) {
|
||||
TFSystemInfoManager.masterUnit = t_model.masterUnit;
|
||||
TFSystemInfoManager.subUnit = t_model.subUnit;
|
||||
weakSelf.userModel = t_model;
|
||||
weakSelf.headerView.userModel = t_model;
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
if (!isCache) {
|
||||
[TFUserInfoManager updateWithDict:requestModel.data];
|
||||
}
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg ?: @""];
|
||||
if (requestModel.code == 302) {
|
||||
[TFUserInfoManager logout];
|
||||
[weakSelf netRequest];
|
||||
}
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableViewGroup endRefreshing];
|
||||
[TFPromptManager showPromptWithError:error defaultText:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// TFUserCenterModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFUserCenterListModel;
|
||||
|
||||
/// 个人中心首页
|
||||
@interface TFUserCenterModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *nickname;
|
||||
|
||||
@property (nonatomic ,copy) NSString *avatar;
|
||||
|
||||
@property (nonatomic ,copy) NSString *user_token;
|
||||
/// 主货币单位
|
||||
@property (nonatomic ,copy) NSString *masterUnit;
|
||||
/// 主货币数量
|
||||
@property (nonatomic ,assign) NSInteger masterRemain;
|
||||
/// 子货币单位
|
||||
@property (nonatomic ,copy) NSString *subUnit;
|
||||
/// 子货币数量
|
||||
@property (nonatomic ,assign) NSInteger subRemain;
|
||||
/// 月票余额
|
||||
@property (nonatomic ,assign) NSInteger ticketRemain;
|
||||
|
||||
@property (nonatomic ,assign ,getter = isVip) BOOL vip;
|
||||
|
||||
@property (nonatomic ,copy) NSString *mobile;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger uid;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger gender;
|
||||
/// 列表信息
|
||||
@property (nonatomic ,copy) NSArray<NSArray <TFUserCenterListModel *> *> *panel_list;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
/// 个人中心列表信息
|
||||
@interface TFUserCenterListModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *title;
|
||||
|
||||
@property (nonatomic ,copy) NSString *desc;
|
||||
/// 16进制颜色
|
||||
@property (nonatomic ,copy) NSString *title_color;
|
||||
/// 16进制颜色
|
||||
@property (nonatomic ,copy) NSString *desc_color;
|
||||
|
||||
@property (nonatomic ,copy) NSString *icon;
|
||||
/// 动作类型
|
||||
@property (nonatomic ,copy) NSString *action;
|
||||
|
||||
@property (nonatomic ,copy) NSString *content;
|
||||
/// 点击状态
|
||||
@property (nonatomic ,assign ,getter = isEnable) BOOL enable;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger group_id;
|
||||
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// TFUserCenterModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFUserCenterModel.h"
|
||||
|
||||
@implementation TFUserCenterModel
|
||||
|
||||
+ (NSDictionary<NSString *, id> *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"vip" : @"is_vip",
|
||||
@"masterUnit" : @"unit",
|
||||
@"masterRemain" : @"goldRemain",
|
||||
@"subRemain" : @"silverRemain"
|
||||
};
|
||||
}
|
||||
|
||||
+ (instancetype)modelWithDictionary:(NSDictionary *)dictionary
|
||||
{
|
||||
TFUserCenterModel *t_model = [super modelWithDictionary:dictionary];
|
||||
NSMutableArray<NSArray <TFUserCenterListModel *> *> *t_list = [NSMutableArray array];
|
||||
for (NSArray *obj in t_model.panel_list) {
|
||||
NSArray<TFUserCenterListModel *> *arr = [NSArray modelArrayWithClass:TFUserCenterListModel.class json:obj];
|
||||
[t_list addObject:arr];
|
||||
}
|
||||
t_model.panel_list = t_list;
|
||||
return t_model;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation TFUserCenterListModel
|
||||
|
||||
+ (NSDictionary<NSString *, id> *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"enable" : @"is_click"
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// TFUserDataModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFUserDataListModel;
|
||||
// 用户资料首页数据
|
||||
@interface TFUserDataModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSArray<NSArray <TFUserDataListModel *> *> *panel_list;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFUserDataListModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *title;
|
||||
|
||||
@property (nonatomic ,copy) NSString *desc;
|
||||
|
||||
@property (nonatomic ,copy) NSString *title_color;
|
||||
|
||||
@property (nonatomic ,copy) NSString *desc_color;
|
||||
|
||||
@property (nonatomic ,copy) NSString *icon;
|
||||
|
||||
@property (nonatomic ,copy) NSString *action;
|
||||
|
||||
@property (nonatomic ,assign) BOOL is_click;
|
||||
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// TFUserDataModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFUserDataModel.h"
|
||||
|
||||
@implementation TFUserDataModel
|
||||
|
||||
+ (instancetype)modelWithDictionary:(NSDictionary *)dictionary
|
||||
{
|
||||
NSMutableArray<NSArray <TFUserDataListModel *> *> *t_list = [NSMutableArray array];
|
||||
NSArray *t_arr = dictionary[@"panel_list"];
|
||||
for (NSArray *obj in t_arr) {
|
||||
NSArray<TFUserDataListModel *> *arr = [NSArray modelArrayWithClass:TFUserDataListModel.class json:obj];
|
||||
[t_list addObject:arr];
|
||||
}
|
||||
TFUserDataModel *t_model = [[self alloc] init];
|
||||
t_model.panel_list = [t_list copy];
|
||||
return t_model;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFUserDataListModel
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// TFMineHeaderView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFUserCenterModel;
|
||||
|
||||
// 触摸头像
|
||||
typedef void(^PortraitHandleBlock)(void);
|
||||
// 触摸头像
|
||||
typedef void(^GoldSelectedBlock)(void);
|
||||
// 触摸头像
|
||||
typedef void(^TaskSelectedBlock)(void);
|
||||
// 触摸头像
|
||||
typedef void(^VoucherSelectedBlock)(void);
|
||||
|
||||
@interface TFMineHeaderView : UIView
|
||||
|
||||
@property (nonatomic ,strong) UIImage *avatarImage;
|
||||
@property (nonatomic ,copy) NSString *nickName;
|
||||
@property (nonatomic ,strong) TFUserCenterModel *userModel;
|
||||
|
||||
@property (nonatomic ,copy) PortraitHandleBlock portraitHandleBlock;
|
||||
@property (nonatomic ,copy) GoldSelectedBlock goldSelectedBlock;
|
||||
@property (nonatomic ,copy) TaskSelectedBlock taskSelectedBlock;
|
||||
@property (nonatomic ,copy) VoucherSelectedBlock voucherSelectedBlock;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,389 @@
|
||||
//
|
||||
// TFMineHeaderView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFMineHeaderView.h"
|
||||
#import "TFUserCenterModel.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#define MenuAvatar_H 70
|
||||
#define MenuNumLabel_H 30
|
||||
#define MenuLabel_H 20
|
||||
|
||||
@interface TFMineHeaderView ()
|
||||
|
||||
@property (nonatomic ,strong) UIButton *userAvatar;
|
||||
@property (nonatomic ,strong) UILabel *userNickname;
|
||||
@property (nonatomic ,strong) UIImageView *vipView;
|
||||
@property (nonatomic ,strong) UILabel *userIDLabel;
|
||||
// 书币
|
||||
@property (nonatomic ,strong) UILabel *goldNumLabel;
|
||||
@property (nonatomic ,strong) UILabel *goldLabel;
|
||||
// 书券
|
||||
#if TF_Task_Mode
|
||||
@property (nonatomic ,strong) UILabel *taskNumLabel;
|
||||
@property (nonatomic ,strong) UILabel *taskLabel;
|
||||
#endif
|
||||
// 月票
|
||||
@property (nonatomic ,strong) UILabel *voucherNumLabel;
|
||||
@property (nonatomic ,strong) UILabel *voucherLabel;
|
||||
@property (nonatomic ,strong) NSString *avatarString;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFMineHeaderView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
|
||||
self.backgroundColor = kWhiteColor;
|
||||
#if TF_Recharge_Mode
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 3 * kMargin + PUB_NAVBAR_OFFSET + MenuAvatar_H + MenuNumLabel_H + MenuLabel_H + kHalfMargin);
|
||||
#else
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 3 * kMargin + PUB_NAVBAR_OFFSET + MenuAvatar_H);
|
||||
#endif
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
self.userAvatar = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.userAvatar.layer setCornerRadius:35];
|
||||
[self.userAvatar setClipsToBounds:YES];
|
||||
[self.userAvatar setBackgroundImage:HoldUserAvatar forState:UIControlStateNormal];
|
||||
[self.userAvatar addTarget:self action:@selector(avatarSelected) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:self.userAvatar];
|
||||
|
||||
[self.userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.mas_left).with.offset(kMargin);
|
||||
make.top.mas_equalTo(2 * kMargin + PUB_NAVBAR_OFFSET);
|
||||
make.width.mas_equalTo(MenuAvatar_H);
|
||||
make.height.mas_equalTo(MenuAvatar_H);
|
||||
}];
|
||||
|
||||
|
||||
self.userNickname = [[UILabel alloc] init];
|
||||
self.userNickname.font = kBoldFont20;
|
||||
self.userNickname.backgroundColor = kWhiteColor;
|
||||
self.userNickname.textColor = kBlackColor;
|
||||
self.userNickname.textAlignment = NSTextAlignmentLeft;
|
||||
self.userNickname.userInteractionEnabled = YES;
|
||||
|
||||
if (TFUserInfoManager.isLogin) {
|
||||
self.userNickname.text = [TFUserInfoManager shareInstance].nickname;
|
||||
} else {
|
||||
self.userNickname.text = TFLocalizedString(@"点我登录");
|
||||
self.userNickname.textColor = kBlackColor;
|
||||
}
|
||||
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarSelected)];
|
||||
[self addSubview:self.userNickname];
|
||||
[self.userNickname addGestureRecognizer:tap];
|
||||
|
||||
[self.userNickname mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.userAvatar.mas_right).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - 100);
|
||||
make.top.mas_equalTo(self.userAvatar.mas_top);
|
||||
make.height.mas_equalTo(MenuAvatar_H);
|
||||
}];
|
||||
|
||||
|
||||
self.userIDLabel = [[UILabel alloc] init];
|
||||
self.userIDLabel.backgroundColor = kWhiteColor;
|
||||
self.userIDLabel.textColor = kGrayTextColor;
|
||||
self.userIDLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.userIDLabel.font = kFont12;
|
||||
[self addSubview:self.userIDLabel];
|
||||
|
||||
[self.userIDLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.userAvatar.mas_right).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.userAvatar.mas_centerY).with.offset(kQuarterMargin + 2);
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
make.height.mas_equalTo(15);
|
||||
}];
|
||||
|
||||
|
||||
#if TF_Super_Member_Mode
|
||||
self.vipView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_vip_normal"]];
|
||||
self.vipView.hidden = YES;
|
||||
[self addSubview:self.vipView];
|
||||
|
||||
[self.vipView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.userIDLabel.mas_right).with.offset(kQuarterMargin);
|
||||
make.centerY.mas_equalTo(self.userIDLabel.mas_centerY);
|
||||
make.height.mas_equalTo(10);
|
||||
make.width.mas_equalTo(kGeometricWidth(10, 138, 48));
|
||||
}];
|
||||
#endif
|
||||
|
||||
|
||||
#if TF_Recharge_Mode
|
||||
self.goldNumLabel = [[UILabel alloc] init];
|
||||
self.goldNumLabel.text = @"--";
|
||||
self.goldNumLabel.textColor = kMainColor;
|
||||
self.goldNumLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.goldNumLabel.backgroundColor = kWhiteColor;
|
||||
self.goldNumLabel.font = kMainFont;
|
||||
self.goldNumLabel.userInteractionEnabled = YES;
|
||||
[self addSubview:self.goldNumLabel];
|
||||
|
||||
[self.goldNumLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goldSelected)]];
|
||||
|
||||
{
|
||||
UIView *line = [[UIView alloc] init];
|
||||
line.backgroundColor = kGrayLineColor;
|
||||
[self addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.goldNumLabel.mas_right);
|
||||
make.top.mas_equalTo(self.goldNumLabel.mas_top).with.offset(5);
|
||||
make.width.mas_equalTo(kCellLineHeight);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
}
|
||||
|
||||
#if TF_Task_Mode
|
||||
self.taskNumLabel = [[UILabel alloc] init];
|
||||
self.taskNumLabel.text = @"--";
|
||||
self.taskNumLabel.textColor = kMainColor;
|
||||
self.taskNumLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.taskNumLabel.backgroundColor = kWhiteColor;
|
||||
self.taskNumLabel.font = kMainFont;
|
||||
self.taskNumLabel.userInteractionEnabled = YES;
|
||||
[self addSubview:self.taskNumLabel];
|
||||
|
||||
[self.taskNumLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(taskSelected)]];
|
||||
|
||||
{
|
||||
UIView *line = [[UIView alloc] init];
|
||||
line.backgroundColor = kGrayLineColor;
|
||||
[self addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.taskNumLabel.mas_right);
|
||||
make.top.mas_equalTo(self.taskNumLabel.mas_top).with.offset(5);
|
||||
make.width.mas_equalTo(kCellLineHeight);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
}
|
||||
#endif
|
||||
|
||||
self.voucherNumLabel = [[UILabel alloc] init];
|
||||
self.voucherNumLabel.text = @"--";
|
||||
self.voucherNumLabel.textColor = kMainColor;
|
||||
self.voucherNumLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.voucherNumLabel.backgroundColor = kWhiteColor;
|
||||
self.voucherNumLabel.font = kMainFont;
|
||||
self.voucherNumLabel.userInteractionEnabled = YES;
|
||||
[self addSubview:self.voucherNumLabel];
|
||||
|
||||
[self.voucherNumLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(voucherSelected)]];
|
||||
|
||||
AppDelegate *delegate = (AppDelegate *)kRCodeSync([UIApplication sharedApplication].delegate);
|
||||
NSMutableArray *labelNumConstraints = [NSMutableArray arrayWithObjects:self.goldNumLabel,
|
||||
#if TF_Task_Mode
|
||||
self.taskNumLabel,
|
||||
#endif
|
||||
nil];
|
||||
if (delegate.checkSettingModel.system_setting.monthly_ticket_switch == 1) {
|
||||
[labelNumConstraints addObject:self.voucherNumLabel];
|
||||
}
|
||||
[labelNumConstraints mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
|
||||
[labelNumConstraints mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.userAvatar.mas_bottom).with.offset(kMargin);
|
||||
make.height.mas_equalTo(MenuNumLabel_H);
|
||||
}];
|
||||
|
||||
self.goldLabel = [[UILabel alloc] init];
|
||||
self.goldLabel.text = [NSString stringWithFormat:@"%@", TFSystemInfoManager.masterUnit];
|
||||
self.goldLabel.textColor = kGrayTextColor;
|
||||
self.goldLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.goldLabel.backgroundColor = kWhiteColor;
|
||||
self.goldLabel.font = kFont12;
|
||||
self.goldLabel.userInteractionEnabled = YES;
|
||||
[self addSubview:self.goldLabel];
|
||||
[self.goldLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goldSelected)]];
|
||||
|
||||
#if TF_Task_Mode
|
||||
self.taskLabel = [[UILabel alloc] init];
|
||||
self.taskLabel.text = TFLocalizedString(@"书券");
|
||||
self.taskLabel.textColor = kGrayTextColor;
|
||||
self.taskLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.taskLabel.backgroundColor = kWhiteColor;
|
||||
self.taskLabel.font = kFont12;
|
||||
self.taskLabel.userInteractionEnabled = YES;
|
||||
[self addSubview:self.taskLabel];
|
||||
[self.taskLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(taskSelected)]];
|
||||
#endif
|
||||
|
||||
self.voucherLabel = [[UILabel alloc] init];
|
||||
self.voucherLabel.text = TFLocalizedString(@"月票");
|
||||
self.voucherLabel.textColor = kGrayTextColor;
|
||||
self.voucherLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.voucherLabel.backgroundColor = kWhiteColor;
|
||||
self.voucherLabel.font = kFont12;
|
||||
self.voucherLabel.userInteractionEnabled = YES;
|
||||
[self addSubview:self.voucherLabel];
|
||||
[self.voucherLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(voucherSelected)]];
|
||||
|
||||
NSMutableArray *labelConstraints = [NSMutableArray arrayWithObjects:self.goldLabel,
|
||||
#if TF_Task_Mode
|
||||
self.taskLabel,
|
||||
#endif
|
||||
nil];
|
||||
if (delegate.checkSettingModel.system_setting.monthly_ticket_switch == 1) {
|
||||
[labelConstraints addObject:self.voucherLabel];
|
||||
}
|
||||
[labelConstraints mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
|
||||
[labelConstraints mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.goldNumLabel.mas_bottom);
|
||||
make.height.mas_equalTo(MenuLabel_H);
|
||||
}];
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma mark - 点击事件
|
||||
|
||||
- (void)avatarSelected
|
||||
{
|
||||
if (self.portraitHandleBlock) {
|
||||
self.portraitHandleBlock();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)goldSelected
|
||||
{
|
||||
if (self.goldSelectedBlock) {
|
||||
self.goldSelectedBlock();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)taskSelected
|
||||
{
|
||||
if (self.taskSelectedBlock) {
|
||||
self.taskSelectedBlock();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)voucherSelected
|
||||
{
|
||||
if (self.voucherSelectedBlock) {
|
||||
self.voucherSelectedBlock();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 设置变量
|
||||
|
||||
- (void)setAvatarImage:(UIImage *)avatarImage
|
||||
{
|
||||
_avatarImage = avatarImage;
|
||||
|
||||
[self.userAvatar setBackgroundImage:avatarImage forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
- (void)setNickName:(NSString *)nickName
|
||||
{
|
||||
_nickName = nickName;
|
||||
|
||||
self.userNickname.text = nickName;
|
||||
}
|
||||
|
||||
- (void)setUserModel:(TFUserCenterModel *)userModel
|
||||
{
|
||||
_userModel = userModel;
|
||||
|
||||
#if TF_Super_Member_Mode
|
||||
// VIP
|
||||
if (userModel.isVip) {
|
||||
self.vipView.image = [UIImage imageNamed:@"public_vip_select"];
|
||||
} else {
|
||||
self.vipView.image = [UIImage imageNamed:@"public_vip_normal"];
|
||||
}
|
||||
#endif
|
||||
|
||||
// 昵称
|
||||
if (userModel.nickname.length > 0) {
|
||||
self.userNickname.text = userModel.nickname?:@"";
|
||||
self.userNickname.textColor = kBlackColor;
|
||||
self.userIDLabel.hidden = NO;
|
||||
self.vipView.hidden = NO;
|
||||
[self.userNickname mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
} else {
|
||||
self.userNickname.text = TFLocalizedString(@"点我登录");
|
||||
self.userNickname.textColor = kBlackColor;
|
||||
self.userIDLabel.hidden = YES;
|
||||
self.vipView.hidden = YES;
|
||||
[self.userNickname mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(MenuAvatar_H);
|
||||
}];
|
||||
}
|
||||
|
||||
// 用户id
|
||||
if (!userModel.uid) {
|
||||
self.userIDLabel.hidden = YES;
|
||||
self.userIDLabel.text = @"";
|
||||
} else {
|
||||
self.userIDLabel.hidden = NO;
|
||||
self.userIDLabel.text = [NSString stringWithFormat:@"ID:%@", [TFUtilsHelper formatStringWithInteger:userModel.uid]];
|
||||
}
|
||||
|
||||
[self.userIDLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.userIDLabel]);
|
||||
}];
|
||||
|
||||
// 主货币单位
|
||||
if (userModel.masterUnit.length > 0) {
|
||||
self.goldLabel.text = [NSString stringWithFormat:@"%@", userModel.masterUnit];
|
||||
} else {
|
||||
self.goldLabel.text = [NSString stringWithFormat:@"%@", TFSystemInfoManager.masterUnit];
|
||||
}
|
||||
|
||||
#if TF_Task_Mode
|
||||
// 子货币单位
|
||||
if (userModel.subUnit.length > 0) {
|
||||
self.taskLabel.text = [NSString stringWithFormat:@"%@", userModel.subUnit];
|
||||
} else {
|
||||
self.taskLabel.text = [NSString stringWithFormat:@"%@", TFSystemInfoManager.subUnit];
|
||||
}
|
||||
#endif
|
||||
|
||||
if (userModel.masterRemain <= 0 && !TFUserInfoManager.isLogin) {
|
||||
self.goldNumLabel.text = @"--";
|
||||
} else {
|
||||
self.goldNumLabel.text = [TFUtilsHelper formatStringWithInteger:userModel.masterRemain];
|
||||
}
|
||||
|
||||
// 月票数量
|
||||
if (userModel.ticketRemain <= 0 && !TFUserInfoManager.isLogin) {
|
||||
self.voucherNumLabel.text = @"--";
|
||||
} else {
|
||||
self.voucherNumLabel.text = [TFUtilsHelper formatStringWithInteger:userModel.ticketRemain];
|
||||
}
|
||||
|
||||
#if TF_Task_Mode
|
||||
// 子货币数量
|
||||
if (userModel.subRemain <= 0 && !TFUserInfoManager.isLogin) {
|
||||
self.taskNumLabel.text = @"--";
|
||||
} else {
|
||||
self.taskNumLabel.text = [TFUtilsHelper formatStringWithInteger:userModel.subRemain];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (![self.avatarString isEqualToString:userModel.avatar]) {
|
||||
self.avatarString = userModel.avatar;
|
||||
[self.userAvatar setBackgroundImageWithURL:[NSURL URLWithString:userModel.avatar?:@""] forState:UIControlStateNormal placeholder:HoldUserAvatar];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFMineTableViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFUserCenterListModel;
|
||||
@interface TFMineTableViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFUserCenterListModel *cellModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// TFMineTableViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFMineTableViewCell.h"
|
||||
#import "TFUserCenterModel.h"
|
||||
|
||||
@interface TFMineTableViewCell ()
|
||||
|
||||
@property (nonatomic ,strong) UIImageView *iconView;
|
||||
@property (nonatomic ,strong) UILabel *titleLabel;
|
||||
@property (nonatomic ,strong) UILabel *subtitleLabel;
|
||||
@property (nonatomic ,strong) UIImageView *connerView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFMineTableViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
[self setupSubview];
|
||||
[self setupSubviewFrame];
|
||||
}
|
||||
|
||||
- (void)setupSubview
|
||||
{
|
||||
self.iconView = [[UIImageView alloc] init];
|
||||
self.iconView.image = HoldImage;
|
||||
[self.contentView addSubview:self.iconView];
|
||||
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.backgroundColor = kWhiteColor;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.titleLabel.textColor = kBlackColor;
|
||||
self.titleLabel.font = kMainFont;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
|
||||
|
||||
self.connerView = [[UIImageView alloc] init];
|
||||
self.connerView.image = [UIImage imageNamed:@"public_more"];
|
||||
[self.contentView addSubview:self.connerView];
|
||||
|
||||
|
||||
self.subtitleLabel = [[UILabel alloc] init];
|
||||
self.subtitleLabel.numberOfLines = 2;
|
||||
self.subtitleLabel.textAlignment = NSTextAlignmentRight;
|
||||
self.subtitleLabel.textColor = kGrayTextColor;
|
||||
self.subtitleLabel.backgroundColor = kWhiteColor;
|
||||
self.subtitleLabel.font = kFont12;
|
||||
[self.contentView addSubview:self.subtitleLabel];
|
||||
}
|
||||
|
||||
- (void)setupSubviewFrame
|
||||
{
|
||||
[self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin + kQuarterMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.width.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.iconView.mas_right).with.offset(kHalfMargin + kQuarterMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.width.mas_equalTo(120);
|
||||
make.height.mas_equalTo(kLabelHeight);
|
||||
}];
|
||||
|
||||
|
||||
[self.connerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.width.height.mas_equalTo(10);
|
||||
}];
|
||||
|
||||
|
||||
[self.subtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.connerView.mas_left).with.offset(- kQuarterMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.left.equalTo(self.titleLabel.mas_right).offset(kQuarterMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setCellModel:(TFUserCenterListModel *)cellModel
|
||||
{
|
||||
if (_cellModel != cellModel) {
|
||||
_cellModel = cellModel;
|
||||
|
||||
self.titleLabel.text = cellModel.title ? : @"";
|
||||
|
||||
[self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.titleLabel]);
|
||||
}];
|
||||
|
||||
self.subtitleLabel.text = cellModel.desc ? : @"";
|
||||
|
||||
self.titleLabel.textColor = [UIColor colorWithHexString:cellModel.title_color ? : @""];
|
||||
|
||||
self.subtitleLabel.textColor = [UIColor colorWithHexString:cellModel.desc_color ? : @""];
|
||||
|
||||
[self.iconView setImageWithURL:[NSURL URLWithString:cellModel.icon ? : @""] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
|
||||
|
||||
self.connerView.hidden = !cellModel.enable;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+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
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFRechargeViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRechargeViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) BOOL pushFromReader;
|
||||
@property (nonatomic ,assign) NSInteger production_id;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+306
@@ -0,0 +1,306 @@
|
||||
//
|
||||
// TFRechargeViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRechargeViewController.h"
|
||||
#import "TFRecordsViewController.h"
|
||||
#import "TFRechargeViewCell.h"
|
||||
#import "TFMemberInstructionsViewCell.h"
|
||||
#import "TFRechargeHeaderView.h"
|
||||
|
||||
#import "TFRechargeModel.h"
|
||||
#import "TFIAPManager.h"
|
||||
|
||||
@interface TFRechargeViewController ()<UITableViewDelegate, UITableViewDataSource, UIGestureRecognizerDelegate, TFIAPManagerResultsDelegate>
|
||||
{
|
||||
NSInteger goodsSelectIndex; // 商品选择位置
|
||||
UILabel *priceLabel;
|
||||
UIButton *confirmButton;
|
||||
}
|
||||
|
||||
@property (nonatomic ,strong) TFRechargeModel *rechargeModel;
|
||||
@property (nonatomic ,strong) TFRechargeHeaderView *headerView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFRechargeViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self setStatusBarLightContentStyle];
|
||||
[kNotification postNotificationName:Notification_Hidden_Tabbar object:@"1"];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
if (self.pushFromReader) {
|
||||
id target = self.navigationController.interactivePopGestureRecognizer.delegate;
|
||||
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:target action:NSSelectorFromString(@"handleNavigationTransition:")];
|
||||
panGesture.delegate = self; // 设置手势代理,拦截手势触发
|
||||
[self.view addGestureRecognizer:panGesture];
|
||||
|
||||
// 一定要禁止系统自带的滑动手势
|
||||
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
|
||||
}
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Recharge_Success object:nil];
|
||||
|
||||
[self setNavigationBarTitle:[NSString stringWithFormat:TFLocalizedString(@"%@充值"), TFSystemInfoManager.masterUnit]];
|
||||
self.navigationBar.backgroundColor = kColorRGB(46, 46, 48);
|
||||
self.navigationBar.navTitleLabel.textColor = kWhiteColor;
|
||||
[self.navigationBar setLightLeftButton];
|
||||
|
||||
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
rightButton.frame = CGRectMake(SCREEN_WIDTH - 64.0f - kHalfMargin, PUB_NAVBAR_HEIGHT - 2 - 40.0f, 64.0f, 40.0f);
|
||||
[rightButton setTitle:TFLocalizedString(@"充值记录") forState:UIControlStateNormal];
|
||||
[rightButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
[rightButton.titleLabel setFont:kFont12];
|
||||
[rightButton addTarget:self action:@selector(rechargeRecordClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.navigationBar addSubview:rightButton];
|
||||
|
||||
goodsSelectIndex = 0;
|
||||
[TFIAPManager sharedManager].delegate = self;
|
||||
self.view.backgroundColor = kGrayViewColor;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Login_Success object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableViewGroup.delegate = self;
|
||||
self.mainTableViewGroup.dataSource = self;
|
||||
[self.view addSubview:self.mainTableViewGroup];
|
||||
|
||||
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_TABBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
|
||||
self.headerView = [[TFRechargeHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_NAVBAR_HEIGHT + 60 + 2 * kMargin)];
|
||||
[self.mainTableViewGroup setTableHeaderView:self.headerView];
|
||||
|
||||
UIView *toolBar = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - PUB_TABBAR_HEIGHT, SCREEN_WIDTH, PUB_TABBAR_HEIGHT)];
|
||||
toolBar.backgroundColor = kWhiteColor;
|
||||
toolBar.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||
toolBar.layer.shadowOffset = CGSizeMake(0, 0);
|
||||
toolBar.layer.shadowOpacity = 0.1f;
|
||||
toolBar.layer.shadowRadius = 1.0f;
|
||||
[self.view addSubview:toolBar];
|
||||
|
||||
confirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
confirmButton.adjustsImageWhenHighlighted = NO;
|
||||
[confirmButton setBackgroundImage:[UIImage imageNamed:@"member_pay_btn"] forState:UIControlStateNormal];
|
||||
[confirmButton setTitle:TFLocalizedString(@"立即充值") forState:UIControlStateNormal];
|
||||
[confirmButton setTitleColor:kColorRGBA(122, 70, 0, 1) forState:UIControlStateNormal];
|
||||
[confirmButton.titleLabel setFont:[UIFont boldSystemFontOfSize:kFontSize14]];
|
||||
[confirmButton addTarget:self action:@selector(confirmButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[toolBar addSubview:confirmButton];
|
||||
|
||||
[confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(toolBar.mas_right);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(150);
|
||||
make.height.mas_equalTo(PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
}];
|
||||
|
||||
priceLabel = [[UILabel alloc] init];
|
||||
priceLabel.font = kMainFont;
|
||||
priceLabel.textColor = kBlackColor;
|
||||
[toolBar addSubview:priceLabel];
|
||||
|
||||
[priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.top.mas_equalTo(0);
|
||||
make.right.mas_equalTo(confirmButton.mas_left);
|
||||
make.height.mas_equalTo(confirmButton.mas_height);
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 0) {
|
||||
return self.rechargeModel.list.count;
|
||||
}
|
||||
|
||||
if (section == 1 && (self.rechargeModel.about.count <= 0 || !self.rechargeModel.about)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
switch (indexPath.section) {
|
||||
case 0:
|
||||
{
|
||||
TFRechargeViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFRechargeViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[TFRechargeViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFRechargeViewCell"];
|
||||
}
|
||||
cell.goodsModel = [self.rechargeModel.list objectAtIndex:indexPath.row];
|
||||
cell.cellSelected = (goodsSelectIndex == indexPath.row);
|
||||
cell.selectionStyle = UITableViewCellAccessoryNone;
|
||||
return cell;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
TFMemberInstructionsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFMemberInstructionsViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[TFMemberInstructionsViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFMemberInstructionsViewCell"];
|
||||
}
|
||||
cell.about = self.rechargeModel.about;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return [[UITableViewCell alloc] init];
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == 0) {
|
||||
goodsSelectIndex = indexPath.row;
|
||||
[self.mainTableViewGroup reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
//section头间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 1 && (self.rechargeModel.about.count <= 0 || !self.rechargeModel.about)) {
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
return 50;
|
||||
}
|
||||
|
||||
//section头视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
if (!self.rechargeModel) {
|
||||
return [[UIView alloc] init];
|
||||
}
|
||||
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
|
||||
view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
UILabel *headerTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kHalfMargin, 0, SCREEN_WIDTH - kHalfMargin, 50)];
|
||||
if (section == 0) {
|
||||
headerTitleLabel.text = TFLocalizedString(@"充值套餐");
|
||||
} else if (section == 1) {
|
||||
headerTitleLabel.text = TFLocalizedString(@"充值说明");
|
||||
}
|
||||
|
||||
headerTitleLabel.font = kBoldFont15;
|
||||
headerTitleLabel.textColor = kBlackColor;
|
||||
[view addSubview:headerTitleLabel];
|
||||
|
||||
NSMutableAttributedString *priceString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@", TFLocalizedString(@"总计:"), [self.rechargeModel.list objectAtIndex:goodsSelectIndex].fat_price?:@""]];
|
||||
NSString *str = [self.rechargeModel.list objectAtIndex:goodsSelectIndex].fat_price?:@"";
|
||||
[priceString addAttribute:NSFontAttributeName value:kBoldFont22 range:NSMakeRange(priceString.length - str.length, str.length)];
|
||||
[priceString addAttribute:NSForegroundColorAttributeName value:kColorRGB(228, 185, 122) range:NSMakeRange(priceString.length - str.length, str.length)];
|
||||
|
||||
priceLabel.attributedText = priceString;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
//section底部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 1 && (self.rechargeModel.about.count <= 0 || !self.rechargeModel.about)) {
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
return kHalfMargin;
|
||||
}
|
||||
//section底部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
if (!self.rechargeModel) {
|
||||
return [[UIView alloc] init];
|
||||
}
|
||||
UIView *view = [[UIView alloc] init];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
return view;
|
||||
}
|
||||
|
||||
#pragma mark IApRequestResultsDelegate
|
||||
- (void)requestSuccess
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.mainTableViewGroup.userInteractionEnabled = YES;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)filedWithErrorCode:(NSInteger)errorCode andError:(NSString *)error
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.mainTableViewGroup.userInteractionEnabled = YES;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)rechargeRecordClick
|
||||
{
|
||||
TFRecordsViewController *vc = [[TFRecordsViewController alloc] init];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)confirmButtonClick
|
||||
{
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.rechargeModel.list.count > 0) {
|
||||
TFGoodsModel *goodsModel = [self.rechargeModel.list objectOrNilAtIndex:goodsSelectIndex];
|
||||
self.mainTableViewGroup.userInteractionEnabled = NO;
|
||||
[TFIAPManager sharedManager].production_id = self.production_id;
|
||||
[TFIAPManager sharedManager].productionType = self.productionType;
|
||||
[[TFIAPManager sharedManager] requestProductWithId:[NSString stringWithFormat:@"%@", goodsModel.apple_id]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Pay_Center parameters:nil model:TFRechargeModel.class success:^(BOOL isSuccess, TFRechargeModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.rechargeModel = t_model;
|
||||
weakSelf.headerView.rechargeModel = t_model;
|
||||
}
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// TFRechargeModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFGoodsModel, TFTagModel, TFPayModel;
|
||||
|
||||
@interface TFRechargeModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) NSArray<TFGoodsModel *> *list;
|
||||
|
||||
@property (nonatomic ,strong) NSArray<NSString *> *about;
|
||||
|
||||
@property (nonatomic ,copy) NSString *tips;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger goldRemain;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger silverRemain;
|
||||
|
||||
@property (nonatomic ,copy) NSString *goldUnit;
|
||||
|
||||
@property (nonatomic ,copy) NSString *silverUnit;
|
||||
|
||||
@property (nonatomic ,assign) BOOL thirdOn;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface TFGoodsModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *note;
|
||||
|
||||
@property (nonatomic ,copy) NSString *price;
|
||||
|
||||
@property (nonatomic ,copy) NSString *title;
|
||||
|
||||
@property (nonatomic ,copy) NSString *sub_title;
|
||||
|
||||
@property (nonatomic ,copy) NSString *flag;
|
||||
|
||||
@property (nonatomic ,copy) NSString *apple_id;
|
||||
|
||||
@property (nonatomic ,copy) NSString *fat_price; //金额,带单位
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFPayModel *>*pal_channel;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger goods_id;
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFTagModel *> *tag;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface TFPayModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *icon; //icon
|
||||
|
||||
@property (nonatomic ,copy) NSString *title; //名称
|
||||
|
||||
@property (nonatomic ,assign) NSInteger channel_id; //渠道id
|
||||
|
||||
@property (nonatomic ,assign) NSInteger pay_type; //渠道类型 1原生支付(如支付宝app支付和微信app支付) 2三方wap支付 3三方sdk支付
|
||||
|
||||
@property (nonatomic ,copy) NSString *gateway; //跳转网关
|
||||
|
||||
@property (nonatomic ,copy) NSString *channel_code; //渠道码,原生和三方SDK支付时需要关注 alipay-支付宝 wechat-微信支付
|
||||
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// TFRechargeModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRechargeModel.h"
|
||||
|
||||
@implementation TFRechargeModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"list" : [TFGoodsModel class],
|
||||
@"user" : [TFUserInfoManager class]
|
||||
};
|
||||
}
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"list" : @"items",
|
||||
@"goldUnit" : @"unit_tag.currencyUnit",
|
||||
@"silverUnit" : @"unit_tag.subUnit"
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation TFGoodsModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{
|
||||
@"tag" : [TFTagModel class],
|
||||
@"pal_channel" : [TFPayModel class]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation TFPayModel
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFRechargeHeaderView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFRechargeModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRechargeHeaderView : UIView
|
||||
|
||||
@property (nonatomic ,strong) TFRechargeModel *rechargeModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// TFRechargeHeaderView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRechargeHeaderView.h"
|
||||
|
||||
@interface TFRechargeHeaderView ()
|
||||
{
|
||||
UILabel *goldRemainLabel;
|
||||
UILabel *goldUnitLabel;
|
||||
|
||||
UILabel *subRemainLabel;
|
||||
UILabel *subUnitLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFRechargeHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.backgroundColor = kColorRGB(46, 46, 48);
|
||||
|
||||
goldUnitLabel = [[UILabel alloc] init];
|
||||
goldUnitLabel.textAlignment = NSTextAlignmentCenter;
|
||||
goldUnitLabel.textColor = kColorRGB(231, 185, 117);
|
||||
goldUnitLabel.font = kMainFont;
|
||||
[self addSubview:goldUnitLabel];
|
||||
|
||||
[goldUnitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.mas_left).with.offset(kMargin);
|
||||
make.bottom.mas_equalTo(self.mas_bottom).with.offset(- kMargin);
|
||||
make.width.mas_equalTo((SCREEN_WIDTH - 2 * kMargin) / 2);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
goldRemainLabel = [[UILabel alloc] init];
|
||||
goldRemainLabel.textAlignment = NSTextAlignmentCenter;
|
||||
goldRemainLabel.textColor = kColorRGB(231, 185, 117);
|
||||
goldRemainLabel.font = kBoldFont30;
|
||||
[self addSubview:goldRemainLabel];
|
||||
|
||||
[goldRemainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(goldUnitLabel.mas_left);
|
||||
make.bottom.mas_equalTo(goldUnitLabel.mas_top).with.offset(- kHalfMargin);
|
||||
make.width.mas_equalTo(goldUnitLabel.mas_width);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
UIView *line = [[UIView alloc] init];
|
||||
line.backgroundColor = kGrayViewColor;
|
||||
[self addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(goldRemainLabel.mas_right);
|
||||
make.top.mas_equalTo(goldRemainLabel.mas_top);
|
||||
make.bottom.mas_equalTo(goldUnitLabel.mas_bottom);
|
||||
make.width.mas_equalTo(kCellLineHeight);
|
||||
}];
|
||||
|
||||
subUnitLabel = [[UILabel alloc] init];
|
||||
subUnitLabel.textAlignment = NSTextAlignmentCenter;
|
||||
subUnitLabel.textColor = kWhiteColor;
|
||||
subUnitLabel.font = kMainFont;
|
||||
[self addSubview:subUnitLabel];
|
||||
|
||||
[subUnitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kMargin);
|
||||
make.top.mas_equalTo(goldUnitLabel.mas_top);
|
||||
make.width.mas_equalTo(goldUnitLabel.mas_width);
|
||||
make.height.mas_equalTo(goldUnitLabel.mas_height);
|
||||
}];
|
||||
|
||||
subRemainLabel = [[UILabel alloc] init];
|
||||
subRemainLabel.textAlignment = NSTextAlignmentCenter;
|
||||
subRemainLabel.textColor = kWhiteColor;
|
||||
subRemainLabel.font = kBoldFont30;
|
||||
[self addSubview:subRemainLabel];
|
||||
|
||||
[subRemainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(subUnitLabel.mas_right);
|
||||
make.top.mas_equalTo(goldRemainLabel.mas_top);
|
||||
make.width.mas_equalTo(subUnitLabel.mas_width);
|
||||
make.height.mas_equalTo(goldRemainLabel.mas_height);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)setRechargeModel:(TFRechargeModel *)rechargeModel
|
||||
{
|
||||
_rechargeModel = rechargeModel;
|
||||
|
||||
goldUnitLabel.text = rechargeModel.goldUnit?:@"";
|
||||
subUnitLabel.text = rechargeModel.silverUnit?:@"";
|
||||
|
||||
if (TFUserInfoManager.isLogin) {
|
||||
goldRemainLabel.text = [TFUtilsHelper formatStringWithInteger:rechargeModel.goldRemain];
|
||||
subRemainLabel.text = [TFUtilsHelper formatStringWithInteger:rechargeModel.silverRemain];
|
||||
} else {
|
||||
goldRemainLabel.text = @"--";
|
||||
subRemainLabel.text = @"--";
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFRechargeViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFRechargeModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFRechargeViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFGoodsModel *goodsModel;
|
||||
|
||||
@property (nonatomic ,assign) BOOL cellSelected;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// TFRechargeViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRechargeViewCell.h"
|
||||
|
||||
@interface TFRechargeViewCell ()
|
||||
{
|
||||
UIView *backView;
|
||||
|
||||
UIImageView *tagImageView;
|
||||
UILabel *tagTitleLabel;
|
||||
|
||||
UILabel *cellTitleLabel;
|
||||
UILabel *priceTitleLabel;
|
||||
UILabel *originPriceTitleLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFRechargeViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
tagImageView = [[UIImageView alloc] init];
|
||||
tagImageView.hidden = YES;
|
||||
tagImageView.backgroundColor = [UIColor clearColor];
|
||||
UIImage *tagImage = [UIImage imageNamed:@"member_tag.png"];
|
||||
tagImageView.image = [tagImage resizableImageWithCapInsets:UIEdgeInsetsMake(tagImage.size.height * 0.5, tagImage.size.width * 0.5, tagImage.size.height * 0.5 - 1.0, tagImage.size.width * 0.5 - 1.0)];
|
||||
[self.contentView addSubview:tagImageView];
|
||||
|
||||
tagTitleLabel = [[UILabel alloc] init];
|
||||
tagTitleLabel.textColor = kWhiteColor;
|
||||
tagTitleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
tagTitleLabel.font = kFont10;
|
||||
tagTitleLabel.hidden = YES;
|
||||
[self.contentView addSubview:tagTitleLabel];
|
||||
|
||||
[tagTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.height.mas_equalTo(20);
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
[tagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(tagTitleLabel);
|
||||
}];
|
||||
|
||||
backView = [[UIView alloc] init];
|
||||
backView.backgroundColor = kWhiteColor;
|
||||
backView.layer.cornerRadius = 4;
|
||||
backView.layer.borderWidth = 1;
|
||||
backView.layer.borderColor = kColorRGB(243, 231, 213).CGColor;
|
||||
[self.contentView addSubview:backView];
|
||||
|
||||
[backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(tagTitleLabel.mas_left);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.top.mas_equalTo(tagTitleLabel.mas_centerY);
|
||||
make.height.mas_equalTo(80);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
cellTitleLabel = [[UILabel alloc] init];
|
||||
cellTitleLabel.textColor = kColorRGB(101, 101, 101);
|
||||
cellTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
cellTitleLabel.font = kBoldMainFont;
|
||||
[self.contentView addSubview:cellTitleLabel];
|
||||
|
||||
[cellTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(backView.mas_centerY);
|
||||
make.left.mas_equalTo(backView.mas_left).with.offset(kMargin);
|
||||
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.3);
|
||||
}];
|
||||
|
||||
originPriceTitleLabel = [[UILabel alloc] init];
|
||||
originPriceTitleLabel.textColor = kColorRGB(153, 153, 153);
|
||||
originPriceTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
originPriceTitleLabel.numberOfLines = 0;
|
||||
originPriceTitleLabel.font = kFont10;
|
||||
[self.contentView addSubview:originPriceTitleLabel];
|
||||
|
||||
[originPriceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(backView.mas_centerY);
|
||||
make.left.mas_equalTo(cellTitleLabel.mas_left);
|
||||
make.width.mas_equalTo(cellTitleLabel.mas_width);
|
||||
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.3);
|
||||
}];
|
||||
|
||||
priceTitleLabel = [[UILabel alloc] init];
|
||||
priceTitleLabel.textColor = kColorRGB(232, 165, 72);
|
||||
priceTitleLabel.textAlignment = NSTextAlignmentRight;
|
||||
priceTitleLabel.font = kBoldMainFont;
|
||||
[self.contentView addSubview:priceTitleLabel];
|
||||
|
||||
[priceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(backView.mas_right).with.offset(- kHalfMargin);
|
||||
make.width.mas_equalTo(120);
|
||||
make.centerY.mas_equalTo(backView.mas_centerY);
|
||||
make.height.mas_equalTo(backView.mas_height);
|
||||
}];
|
||||
|
||||
[cellTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(priceTitleLabel.mas_left).offset(-kHalfMargin);
|
||||
}];
|
||||
|
||||
[self.contentView bringSubviewToFront:tagImageView];
|
||||
[self.contentView bringSubviewToFront:tagTitleLabel];
|
||||
}
|
||||
|
||||
- (void)setGoodsModel:(TFGoodsModel *)goodsModel
|
||||
{
|
||||
_goodsModel = goodsModel;
|
||||
|
||||
if (goodsModel.tag.count > 0) {
|
||||
if ([goodsModel.tag firstObject].tab.length > 0) {
|
||||
tagImageView.hidden = NO;
|
||||
tagTitleLabel.hidden = NO;
|
||||
tagTitleLabel.text =[goodsModel.tag firstObject].tab?:@"";
|
||||
[tagTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:tagTitleLabel] + kMargin);
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
tagImageView.hidden = YES;
|
||||
tagTitleLabel.hidden = YES;
|
||||
}
|
||||
|
||||
cellTitleLabel.text = goodsModel.title?:@"";
|
||||
originPriceTitleLabel.text = goodsModel.note?:@"";
|
||||
if (goodsModel.fat_price.length > 0) {
|
||||
priceTitleLabel.attributedText = [TFViewHelper resetFontWithFont:kBoldFont25 string:goodsModel.fat_price?:@"" range:NSMakeRange(1, goodsModel.fat_price.length - 1)];
|
||||
} else {
|
||||
priceTitleLabel.text = @"0";
|
||||
}
|
||||
[priceTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(priceTitleLabel.intrinsicContentSize.width);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)setCellSelected:(BOOL)cellSelected
|
||||
{
|
||||
_cellSelected = cellSelected;
|
||||
|
||||
if (cellSelected) {
|
||||
backView.backgroundColor = kColorRGB(255, 247, 235);
|
||||
backView.layer.borderColor = kColorRGB(223, 174, 103).CGColor;
|
||||
cellTitleLabel.textColor = kColorRGB(88, 48, 0);
|
||||
originPriceTitleLabel.textColor = kColorRGB(130, 106, 80);
|
||||
} else {
|
||||
backView.backgroundColor = kWhiteColor;
|
||||
backView.layer.borderColor = kColorRGB(243, 231, 213).CGColor;
|
||||
cellTitleLabel.textColor = kColorRGB(101, 101, 101);
|
||||
originPriceTitleLabel.textColor = kColorRGB(153, 153, 153);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+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
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// TFRewardRecordModel.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 TFRewardRecordListModel, TFPagingModel;
|
||||
|
||||
@interface TFRewardRecordModel : TFPagingModel
|
||||
|
||||
@property (nonatomic ,copy) NSArray<TFRewardRecordListModel *> *list;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface TFRewardRecordListModel : 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
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TFRewardRecordModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRewardRecordModel.h"
|
||||
|
||||
@implementation TFRewardRecordModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{
|
||||
@"list" : TFRewardRecordListModel.class
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFRewardRecordListModel
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFRewardRecordViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFRewardRecordListModel;
|
||||
|
||||
@interface TFRewardRecordViewCell : UITableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFRewardRecordListModel *recordModel;
|
||||
|
||||
- (void)setSplitLineHidden:(BOOL)hidden;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// TFRewardRecordViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFRewardRecordViewCell.h"
|
||||
#import "TFRewardRecordModel.h"
|
||||
#import "NSObject+Observer.h"
|
||||
|
||||
@interface TFRewardRecordViewCell ()
|
||||
{
|
||||
UIView *_splitLine;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFRewardRecordViewCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[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(kMargin);
|
||||
make.left.equalTo(self.contentView).offset(kMoreHalfMargin);
|
||||
}];
|
||||
|
||||
UILabel *descLabel = [[UILabel alloc] init];
|
||||
descLabel.textColor = kGrayTextColor;
|
||||
descLabel.font = kFont13;
|
||||
[self.contentView addSubview:descLabel];
|
||||
[descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(nameLabel.mas_bottom).offset(kHalfMargin);
|
||||
make.left.equalTo(nameLabel);
|
||||
}];
|
||||
|
||||
UILabel *timeLabel = [[UILabel alloc] init];
|
||||
timeLabel.textColor = kGrayTextColor;
|
||||
timeLabel.font = kFont13;
|
||||
[self.contentView addSubview:timeLabel];
|
||||
[timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(descLabel.mas_bottom).offset(kHalfMargin);
|
||||
make.left.equalTo(nameLabel);
|
||||
}];
|
||||
|
||||
_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(kHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
[self addObserver:KEY_PATH(self, recordModel) complete:^(id _Nonnull obj, id _Nullable oldVal, TFRewardRecordListModel * _Nullable newVal) {
|
||||
nameLabel.text = newVal.title ? : @"";
|
||||
timeLabel.text = newVal.time ? : @"";
|
||||
descLabel.text = newVal.desc ? : @"";
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setSplitLineHidden:(BOOL)hidden
|
||||
{
|
||||
_splitLine.hidden = hidden;
|
||||
}
|
||||
|
||||
@end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user