小说绘上架版本
This commit is contained in:
+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
|
||||
Reference in New Issue
Block a user