小说绘上架版本

This commit is contained in:
xtfei2011
2021-02-07 11:24:08 +08:00
commit ee5c1c8b12
1762 changed files with 115892 additions and 0 deletions
@@ -0,0 +1,20 @@
//
// TFUpgradeMemberController.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFUpgradeMemberController : TFBasicViewController
@property (nonatomic ,copy) void(^paySuccessBlock)(void);
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,297 @@
//
// TFUpgradeMemberController.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUpgradeMemberController.h"
#import "TFWebViewController.h"
#import "TFUpgradeMemberModel.h"
#import "TFRechargeModel.h"
#import "TFUpgradeMemberViewCell.h"
#import "TFMemberPrivilegeViewCell.h"
#import "TFMemberInstructionsViewCell.h"
#import "TFUpgradeMemberHeaderView.h"
#import "TFIAPManager.h"
@interface TFUpgradeMemberController ()<UITableViewDelegate, UITableViewDataSource, TFIAPManagerResultsDelegate>
{
UILabel *priceLabel;
UIButton *confirmButton;
NSInteger goodsSelectIndex;
NSInteger payStyleIndex;
}
@property (nonatomic ,strong) TFUpgradeMemberHeaderView *headerView;
@property (nonatomic ,strong) TFUpgradeMemberModel *memberModel;
@end
@implementation TFUpgradeMemberController
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubviews];
[self netRequest];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setStatusBarLightContentStyle];
}
- (void)initialize
{
[self setNavigationBarTitle:TFLocalizedString(@"开通会员")];
self.navigationBar.backgroundColor = kColorRGB(46, 46, 48);
self.navigationBar.navTitleLabel.textColor = kWhiteColor;
[self.navigationBar setLightLeftButton];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Login_Success object:nil];
self.view.backgroundColor = kGrayViewColor;
goodsSelectIndex = 0;
[TFIAPManager sharedManager].delegate = self;
}
- (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 = [[TFUpgradeMemberHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_NAVBAR_HEIGHT + kGeometricHeight(SCREEN_WIDTH - kMargin, 1053, 215) + 30)];
[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 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 1 && (self.memberModel.about.count <= 0 || !self.memberModel.about)) {
return 0;
}
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
case 0: {
WS(weakSelf)
TFUpgradeMemberViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFUpgradeMemberViewCell"];
if (!cell) {
cell = [[TFUpgradeMemberViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFUpgradeMemberViewCell"];
}
cell.goodsList = self.memberModel.list;
cell.selectItemBlock = ^(NSInteger itemIndex) {
SS(strongSelf)
strongSelf->goodsSelectIndex = itemIndex;
strongSelf->payStyleIndex = 0;
[weakSelf.mainTableViewGroup reloadData];
};
cell.selectionStyle = UITableViewCellAccessoryNone;
return cell;
}
break;
case 1:
{
TFMemberPrivilegeViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFMemberPrivilegeViewCell"];
if (!cell) {
cell = [[TFMemberPrivilegeViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFMemberPrivilegeViewCell"];
}
cell.privilege = self.memberModel.privilege;
cell.selectionStyle = UITableViewCellAccessoryNone;
return cell;
}
break;
case 2:
{
TFMemberInstructionsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFMemberInstructionsViewCell"];
if (!cell) {
cell = [[TFMemberInstructionsViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFMemberInstructionsViewCell"];
}
cell.about = self.memberModel.about;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
break;
default:
break;
}
return [[UITableViewCell alloc] init];
}
//section头间距
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 2 && (self.memberModel.about.count <= 0 || !self.memberModel.about)) {
return CGFLOAT_MIN;
}
return 50;
}
//section头视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (!self.memberModel) {
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(@"会员特权");
} else {
headerTitleLabel.text = TFLocalizedString(@"会员说明");
}
headerTitleLabel.font = kBoldFont15;
headerTitleLabel.textColor = kBlackColor;
[view addSubview:headerTitleLabel];
NSMutableAttributedString *priceString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@", TFLocalizedString(@"总计:"), [self.memberModel.list objectAtIndex:goodsSelectIndex].fat_price?:@""]];
NSString *str = [self.memberModel.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 == 2 && (self.memberModel.about.count <= 0 || !self.memberModel.about)) {
return CGFLOAT_MIN;
}
return kHalfMargin;
}
// section底部视图
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if (!self.memberModel) {
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;
if (self.paySuccessBlock) {
self.paySuccessBlock();
}
[self netRequest];
});
}
- (void)filedWithErrorCode:(NSInteger)errorCode andError:(NSString *)error
{
dispatch_async(dispatch_get_main_queue(), ^{
self.mainTableViewGroup.userInteractionEnabled = YES;
});
}
- (void)confirmButtonClick
{
if (!TFUserInfoManager.isLogin) {
[TFLoginOptionsViewController presentLoginView:nil];
return;
}
if (self.memberModel.list.count > 0) {
TFGoodsModel *goodsModel = [self.memberModel.list objectOrNilAtIndex:goodsSelectIndex];
self.mainTableViewGroup.userInteractionEnabled = NO;
[[TFIAPManager sharedManager] requestProductWithId:[NSString stringWithFormat:@"%@", goodsModel.apple_id]];
}
}
- (void)netRequest
{
WS(weakSelf)
[TFNetworkTools POST:Member_Center parameters:nil model:TFUpgradeMemberModel.class success:^(BOOL isSuccess, TFUpgradeMemberModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
if (isSuccess) {
weakSelf.headerView.userModel = t_model.user;
weakSelf.memberModel = t_model;
}
[weakSelf.mainTableViewGroup reloadData];
} failure:nil];
}
@end
@@ -0,0 +1,44 @@
//
// TFUpgradeMemberModel.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class TFMemberInfoModel, TFGoodsModel, TFPrivilegeModel;
@interface TFUpgradeMemberModel : NSObject
@property (nonatomic ,strong) NSArray<TFPrivilegeModel *> *privilege;
@property (nonatomic ,strong) TFMemberInfoModel *user;
@property (nonatomic ,strong) NSArray<TFGoodsModel *> *list;
@property (nonatomic ,strong) NSArray<NSString *> *about; // 提示
@property (nonatomic ,assign) BOOL thirdOn;
@end
@interface TFPrivilegeModel : NSObject
@property (nonatomic ,copy) NSString *label;
@property (nonatomic ,copy) NSString *icon;
@property (nonatomic ,copy) NSString *url;
@property (nonatomic ,copy) NSString *desc;
@property (nonatomic ,copy) NSString *action;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,37 @@
//
// TFUpgradeMemberModel.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUpgradeMemberModel.h"
#import "TFRechargeModel.h"
@implementation TFUpgradeMemberModel
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
{
return @{@"list" : [TFGoodsModel class], @"privilege" : [TFPrivilegeModel class]};
}
@end
@implementation TFPrivilegeModel
+ (NSDictionary *)modelCustomPropertyMapper
{
return @{
@"production_descirption" :@"description",
@"visited" :@"view",
@"record_title" :@"chapter_title",
@"production_id" :@[@"book_id", @"comic_id", @"audio_id"],
@"name" :@[@"name", @"title", @"book_name", @"comic_name", @"audio_name"],
@"total_chapters" :@[@"total_chapters", @"total_chapter"]
};
}
@end
@@ -0,0 +1,20 @@
//
// TFMemberInstructionsViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFMemberInstructionsViewCell : TFBasicTableViewCell
@property (nonatomic ,strong) NSArray<NSString *> *about;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,97 @@
//
// TFMemberInstructionsViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFMemberInstructionsViewCell.h"
#import "TFWebViewController.h"
#import "WXYZ_FeedbackSubViewController.h"
#import "AppDelegate.h"
@interface TFMemberInstructionsViewCell ()
{
YYTextView *aboutTextView;
}
@end
@implementation TFMemberInstructionsViewCell
- (void)createSubviews
{
[super createSubviews];
aboutTextView = [[YYTextView alloc] init];
aboutTextView.backgroundColor = [UIColor whiteColor];
aboutTextView.editable = NO;
aboutTextView.scrollEnabled = NO;
aboutTextView.selectable = NO;
[self.contentView addSubview:aboutTextView];
[aboutTextView 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(10);
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
}];
}
- (void)setAbout:(NSArray<NSString *> *)about
{
_about = about;
if (about.count > 0 && ![[about firstObject] isEqualToString:@""]) {
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] init];
for (NSString *t_str in about) {
[str appendString:[t_str stringByAppendingString:@"\n\n"]];
}
[str setColor:kGrayTextColor];
[str setFont:kFont12];
[str setTextHighlightRange:[str.string localizedStandardRangeOfString:TFLocalizedString(@"《用户协议》")] color:kMainColor backgroundColor:[UIColor whiteColor] 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.user ?: [NSString stringWithFormat:@"%@%@?language=%@", APIURL, User_Agreement, TFLanguageManager.serverLocalized];
vc.isPresentState = NO;
[[TFViewHelper getCurrentNavigationController] pushViewController:vc animated:YES];
}];
[str setTextHighlightRange:[str.string localizedStandardRangeOfString:TFLocalizedString(@"《隐私协议》")] color:kMainColor backgroundColor:[UIColor whiteColor] 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.privacy ?: [NSString stringWithFormat:@"%@%@?language=%@", APIURL, Privacy_Policy, TFLanguageManager.serverLocalized];;
vc.isPresentState = NO;
[[TFViewHelper getCurrentNavigationController] pushViewController:vc animated:YES];
}];
[str setTextHighlightRange:[str.string localizedStandardRangeOfString:TFLocalizedString(@"《会员服务协议》")] color:kMainColor backgroundColor:[UIColor whiteColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
TFWebViewController *vc = [[TFWebViewController alloc] init];
vc.navTitle = TFLocalizedString(@"会员服务协议");
vc.URLString = [NSString stringWithFormat:@"%@%@?language=%@", APIURL, Membership_Service, TFLanguageManager.serverLocalized];
vc.isPresentState = NO;
[[TFViewHelper getCurrentNavigationController] pushViewController:vc animated:YES];
}];
[str setTextHighlightRange:[str.string localizedStandardRangeOfString:TFLocalizedString(@"【意见反馈】")] color:kMainColor backgroundColor:[UIColor whiteColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
[[TFViewHelper getWindowRootController] presentViewController:[[WXYZ_FeedbackSubViewController alloc] init] animated:YES completion:nil];
}];
aboutTextView.attributedText = str;
CGFloat footerHeight = [TFViewHelper getDynamicHeightWithLabelFont:kFont12 labelWidth:SCREEN_WIDTH - kMargin labelText:str.string] - 2 * kMargin;
[aboutTextView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(footerHeight);
}];
}
}
@end
@@ -0,0 +1,20 @@
//
// TFMemberPrivilegeItemCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFUpgradeMemberModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFMemberPrivilegeItemCell : UICollectionViewCell
@property (nonatomic ,strong) TFPrivilegeModel *privilegeModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,63 @@
//
// TFMemberPrivilegeItemCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFMemberPrivilegeItemCell.h"
@interface TFMemberPrivilegeItemCell ()
{
UIImageView *privilegeIcon;
UILabel *privilegeLabel;
}
@end
@implementation TFMemberPrivilegeItemCell
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
privilegeIcon = [[UIImageView alloc] init];
[self addSubview:privilegeIcon];
[privilegeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.top.mas_equalTo(self.mas_top);
make.width.height.mas_equalTo(self.mas_width).multipliedBy(0.5);
}];
privilegeLabel = [[UILabel alloc] init];
privilegeLabel.textAlignment = NSTextAlignmentCenter;
privilegeLabel.textColor = kBlackColor;
privilegeLabel.font = kMainFont;
[self addSubview:privilegeLabel];
[privilegeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.mas_left).with.offset(kQuarterMargin);
make.top.mas_equalTo(privilegeIcon.mas_bottom).with.offset(kHalfMargin + kQuarterMargin);
make.right.mas_equalTo(self.mas_right).with.offset(- kQuarterMargin);
make.height.mas_equalTo(20);
}];
}
- (void)setPrivilegeModel:(TFPrivilegeModel *)privilegeModel
{
_privilegeModel = privilegeModel;
[privilegeIcon setImageWithURL:[NSURL URLWithString:privilegeModel.icon] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
privilegeLabel.text = privilegeModel.label?:@"";
}
@end
@@ -0,0 +1,21 @@
//
// TFMemberPrivilegeViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicTableViewCell.h"
#import "TFUpgradeMemberModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFMemberPrivilegeViewCell : TFBasicTableViewCell <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic ,strong) NSArray<TFPrivilegeModel *> *privilege;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,84 @@
//
// TFMemberPrivilegeViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFMemberPrivilegeViewCell.h"
#import "TFMemberPrivilegeItemCell.h"
@interface TFMemberPrivilegeViewCell ()
{
UICollectionView *mainCollectionView;
}
@end
@implementation TFMemberPrivilegeViewCell
- (void)createSubviews
{
[super createSubviews];
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumLineSpacing = 0;
flowLayout.minimumInteritemSpacing = 0;
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
flowLayout.itemSize = CGSizeMake(SCREEN_WIDTH / 4 , SCREEN_WIDTH / 4);
mainCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
[mainCollectionView registerClass:[TFMemberPrivilegeItemCell class] forCellWithReuseIdentifier:@"TFMemberPrivilegeItemCell"];
mainCollectionView.backgroundColor = [UIColor clearColor];
mainCollectionView.alwaysBounceVertical = NO;
mainCollectionView.showsVerticalScrollIndicator = NO;
mainCollectionView.showsHorizontalScrollIndicator = NO;
mainCollectionView.delegate = self;
mainCollectionView.dataSource = self;
[self.contentView addSubview:mainCollectionView];
[mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView.mas_left);
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
make.width.mas_equalTo(self.contentView.mas_width);
make.height.mas_equalTo(SCREEN_WIDTH / 4);
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
}];
}
- (void)setPrivilege:(NSArray<TFPrivilegeModel *> *)privilege
{
_privilege = privilege;
if (privilege.count > 0) {
[mainCollectionView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo((SCREEN_WIDTH / 4) * (privilege.count % 4 == 0?(privilege.count / 4):((privilege.count / 4) + 1)));
}];
[mainCollectionView reloadData];
}
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.privilege.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TFMemberPrivilegeItemCell";
TFMemberPrivilegeItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
cell.privilegeModel = [self.privilege objectOrNilAtIndex:indexPath.row];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
// TFProductionModel *labelListModel = [self.model.list objectOrNilAtIndex:indexPath.row];
// if (self.cellDidSelectItemBlock) {
// self.cellDidSelectItemBlock(labelListModel.production_id);
// }
}
@end
@@ -0,0 +1,20 @@
//
// TFUpgradeMemberHeaderView.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFMemberModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFUpgradeMemberHeaderView : UIView
@property (nonatomic ,strong) TFMemberInfoModel *userModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,127 @@
//
// TFUpgradeMemberHeaderView.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUpgradeMemberHeaderView.h"
@interface TFUpgradeMemberHeaderView ()
{
UIImageView *userBackImageView;
UIImageView *userAvatar;
UILabel *userNickname;
UIImageView *vipImageView;
UILabel *noticeLabel;
}
@end
@implementation TFUpgradeMemberHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
self.backgroundColor = kColorRGB(46, 46, 48);
userBackImageView = [[UIImageView alloc] init];
userBackImageView.image = [UIImage imageNamed:@"member_bg"];
[self addSubview:userBackImageView];
[userBackImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kHalfMargin);
make.bottom.mas_equalTo(self.mas_bottom);
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH - kMargin, 1053, 215));
}];
userAvatar = [[UIImageView alloc] initWithCornerRadiusAdvance:(kGeometricHeight(SCREEN_WIDTH - kMargin, 1053, 215) - kMargin) / 2 rectCornerType:UIRectCornerAllCorners];
[userBackImageView addSubview:userAvatar];
[userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kHalfMargin);
make.centerY.mas_equalTo(userBackImageView.mas_centerY);
make.width.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH - kMargin, 1053, 215) - kMargin);
}];
userNickname = [[UILabel alloc] init];
userNickname.backgroundColor = [UIColor clearColor];
userNickname.textColor = kBlackColor;
userNickname.font = kMainFont;
userNickname.textAlignment = NSTextAlignmentLeft;
[userBackImageView addSubview:userNickname];
[userNickname mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(userAvatar.mas_right).with.offset(kHalfMargin);
make.bottom.mas_equalTo(userAvatar.mas_centerY);
make.width.mas_equalTo(10);
make.height.mas_equalTo(20);
}];
vipImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_vip_normal"]];
vipImageView.hidden = YES;
[userBackImageView addSubview:vipImageView];
[vipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(userNickname.mas_right).with.offset(kQuarterMargin);
make.centerY.mas_equalTo(userNickname.mas_centerY);
make.height.mas_equalTo(12);
make.width.mas_equalTo(kGeometricWidth(12, 138, 48));
}];
noticeLabel = [[UILabel alloc] init];
noticeLabel.backgroundColor = [UIColor clearColor];
noticeLabel.textColor = kColorRGB(225, 162, 70);
noticeLabel.font = kFont11;
noticeLabel.textAlignment = NSTextAlignmentLeft;
[userBackImageView addSubview:noticeLabel];
[noticeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(userNickname.mas_left);
make.top.mas_equalTo(userAvatar.mas_centerY).with.offset(6);
make.right.mas_equalTo(userBackImageView.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(userNickname.mas_height);
}];
}
- (void)setUserModel:(TFMemberInfoModel *)userModel
{
if (!userModel) {
userNickname.text = TFLocalizedString(@"未登录");
noticeLabel.text = TFLocalizedString(@"开通会员免费畅读会员书库");
return;
}
[userAvatar setImageWithURL:[NSURL URLWithString:userModel.avatar?:@""] placeholder:HoldUserAvatar options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
noticeLabel.text = userModel.vip_desc;
if (userModel.nickname.length == 0 || !userModel.nickname || !TFUserInfoManager.isLogin) {
userNickname.text = TFLocalizedString(@"未登录");
vipImageView.hidden = YES;
} else {
userNickname.text = userModel.nickname?:@"";
vipImageView.hidden = NO;
if (userModel.baoyue_status == 1) {
noticeLabel.text = userModel.expiry_date.length > 0 ? userModel.expiry_date :userModel.vip_desc;
vipImageView.image = [UIImage imageNamed:@"public_vip_select"];
} else {
vipImageView.image = [UIImage imageNamed:@"public_vip_normal"];
}
}
[userNickname mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:userNickname maxWidth:SCREEN_WIDTH * 0.7]);
}];
}
@end
@@ -0,0 +1,22 @@
//
// TFUpgradeMemberItemCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFRechargeModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFUpgradeMemberItemCell : UICollectionViewCell
@property (nonatomic ,strong) TFGoodsModel *goodsModel;
@property (nonatomic ,assign) BOOL cellSelected;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,167 @@
//
// TFUpgradeMemberItemCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUpgradeMemberItemCell.h"
@interface TFUpgradeMemberItemCell ()
{
UIView *backView;
UIImageView *tagImageView;
UILabel *tagTitleLabel;
UILabel *cellTitleLabel;
UILabel *priceTitleLabel;
UILabel *originPriceTitleLabel;
}
@end
@implementation TFUpgradeMemberItemCell
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
backView = [[UIView alloc] init];
backView.backgroundColor = kWhiteColor;
backView.layer.cornerRadius = 4;
backView.layer.borderWidth = 1;
backView.layer.borderColor = kColorRGB(243, 231, 213).CGColor;
[self addSubview:backView];
[backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.centerY.mas_equalTo(self.mas_centerY);
make.width.mas_equalTo(self.mas_width);
make.height.mas_equalTo(self.mas_height);
}];
// 设置端盖的值
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) resizingMode:UIImageResizingModeTile];
[self addSubview:tagImageView];
tagTitleLabel = [[UILabel alloc] init];
tagTitleLabel.textColor = kWhiteColor;
tagTitleLabel.textAlignment = NSTextAlignmentCenter;
tagTitleLabel.font = kFont10;
tagTitleLabel.hidden = YES;
[self addSubview:tagTitleLabel];
[tagTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(backView.mas_top);
make.left.mas_equalTo(backView.mas_left);
make.height.mas_equalTo(20);
make.width.mas_equalTo(CGFLOAT_MIN);
}];
[tagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(tagTitleLabel);
}];
priceTitleLabel = [[UILabel alloc] init];
priceTitleLabel.textColor = kColorRGB(232, 165, 72);
priceTitleLabel.textAlignment = NSTextAlignmentCenter;
priceTitleLabel.font = kBoldMainFont;
[self addSubview:priceTitleLabel];
[priceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(backView.mas_left).with.offset(kQuarterMargin);
make.right.mas_equalTo(backView.mas_right).with.offset(- kQuarterMargin);
make.centerY.mas_equalTo(backView.mas_centerY);
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.2);
}];
cellTitleLabel = [[UILabel alloc] init];
cellTitleLabel.textColor = kColorRGB(101, 101, 101);
cellTitleLabel.textAlignment = NSTextAlignmentCenter;
cellTitleLabel.font = kBoldMainFont;
[self addSubview:cellTitleLabel];
[cellTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(backView.mas_top);
make.left.mas_equalTo(priceTitleLabel.mas_left);
make.width.mas_equalTo(priceTitleLabel.mas_width);
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.4);
}];
originPriceTitleLabel = [[UILabel alloc] init];
originPriceTitleLabel.textColor = kColorRGB(153, 153, 153);
originPriceTitleLabel.textAlignment = NSTextAlignmentCenter;
originPriceTitleLabel.numberOfLines = 2;
originPriceTitleLabel.font = kFont10;
[self addSubview:originPriceTitleLabel];
[originPriceTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(priceTitleLabel.mas_bottom);
make.left.mas_equalTo(priceTitleLabel.mas_left);
make.width.mas_equalTo(priceTitleLabel.mas_width);
make.height.mas_equalTo(backView.mas_height).multipliedBy(0.4);
}];
}
- (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) {
if (([TFViewHelper getDynamicWidthWithLabel:tagTitleLabel] + kMargin) > (CGRectGetWidth(self.contentView.bounds) - kHalfMargin)) {
make.width.mas_equalTo(CGRectGetWidth(self.contentView.bounds) - kHalfMargin);
} else {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:tagTitleLabel] + kMargin);
}
}];
}
} else {
tagImageView.hidden = YES;
tagTitleLabel.hidden = YES;
}
cellTitleLabel.text = goodsModel.title?:@"";
originPriceTitleLabel.text = goodsModel.sub_title?:@"";
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";
}
}
- (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
@@ -0,0 +1,23 @@
//
// TFUpgradeMemberViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicTableViewCell.h"
#import "TFRechargeModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFUpgradeMemberViewCell : TFBasicTableViewCell <UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic ,strong) NSArray<TFGoodsModel *> *goodsList;
@property (nonatomic ,copy) void (^selectItemBlock)(NSInteger itemIndex);
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,85 @@
//
// TFUpgradeMemberViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/13.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFUpgradeMemberViewCell.h"
#import "TFUpgradeMemberItemCell.h"
#import "WXYZ_ShadowView.h"
@interface TFUpgradeMemberViewCell ()
{
UICollectionView *mainCollectionView;
NSInteger selectIndex;
}
@end
@implementation TFUpgradeMemberViewCell
- (void)createSubviews
{
[super createSubviews];
selectIndex = 0;
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumLineSpacing = kMargin;
flowLayout.minimumInteritemSpacing = 0;
flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH - 5 * kMargin) / 3 , (SCREEN_WIDTH - 5 * kMargin) / 3 * 1.1);
flowLayout.sectionInset = UIEdgeInsetsMake(0, kHalfMargin, 0, kHalfMargin);
mainCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
[mainCollectionView registerClass:[TFUpgradeMemberItemCell class] forCellWithReuseIdentifier:@"TFUpgradeMemberItemCell"];
mainCollectionView.backgroundColor = [UIColor clearColor];
mainCollectionView.alwaysBounceVertical = NO;
mainCollectionView.showsVerticalScrollIndicator = NO;
mainCollectionView.showsHorizontalScrollIndicator = NO;
mainCollectionView.delegate = self;
mainCollectionView.dataSource = self;
[self.contentView addSubview:mainCollectionView];
[mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView.mas_left);
make.top.mas_equalTo(self.contentView.mas_top);
make.width.mas_equalTo(self.contentView.mas_width);
make.height.mas_equalTo((SCREEN_WIDTH - 5 * kMargin) / 3 * 1.1 + kMargin);
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
}];
}
- (void)setGoodsList:(NSArray<TFGoodsModel *> *)goodsList
{
_goodsList = goodsList;
[mainCollectionView reloadData];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.goodsList.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TFUpgradeMemberItemCell";
TFUpgradeMemberItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
cell.goodsModel = [self.goodsList objectOrNilAtIndex:indexPath.row];
cell.cellSelected = selectIndex == indexPath.row;
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
selectIndex = indexPath.row;
[mainCollectionView reloadData];
if (self.selectItemBlock) {
self.selectItemBlock(indexPath.row);
}
}
@end