充值列表可以配置支付方式
This commit is contained in:
@@ -6,9 +6,13 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "EnterpriseRechargeListInfoModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSInteger, RechargeType) {
|
||||
RechargeType_WX = 1,
|
||||
RechargeType_ZFB
|
||||
};
|
||||
|
||||
@interface EnterPrieseRechargeTypeItemModel : NSObject
|
||||
///图片
|
||||
@property (nonatomic,copy) NSString *imageName;
|
||||
|
@@ -9,9 +9,15 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class EnterpriseRechargeInfoModel;
|
||||
typedef NS_ENUM(NSInteger, RechargeType) {
|
||||
RechargeType_WX = 1,
|
||||
RechargeType_ZFB
|
||||
typedef NS_ENUM(NSInteger, RechargeDefaultPayType) {
|
||||
///只有微信
|
||||
RechargeDefaultPayType_WX = 1,
|
||||
///支付宝
|
||||
RechargeDefaultPayType_ZFB,
|
||||
///支付宝 微信
|
||||
RechargeDefaultPayType_ZFB_WX,
|
||||
///微信支付宝
|
||||
RechargeDefaultPayType_WX_ZFB
|
||||
};
|
||||
|
||||
@interface EnterpriseRechargeListInfoModel : NSObject
|
||||
@@ -20,7 +26,7 @@ typedef NS_ENUM(NSInteger, RechargeType) {
|
||||
///充值列表
|
||||
@property(nonatomic,strong) NSArray <EnterpriseRechargeInfoModel *> *list;
|
||||
///默认的支付方式
|
||||
@property(nonatomic,assign) RechargeType defaultPay;
|
||||
@property(nonatomic,assign) RechargeDefaultPayType defaultPay;
|
||||
@end
|
||||
|
||||
|
||||
|
@@ -17,7 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@end
|
||||
@interface XPEnterpriseRechargePayTableViewCell : UITableViewCell
|
||||
///默认的充值类型
|
||||
@property (nonatomic,assign) RechargeType type;
|
||||
@property (nonatomic,assign) RechargeDefaultPayType type;
|
||||
///当前选中的支付类型
|
||||
@property (nonatomic,strong, readonly) EnterPrieseRechargeTypeItemModel *currentItem;
|
||||
///代理
|
||||
@property (nonatomic,weak) id<XPEnterpriseRechargePayTableViewCellDelegate> delegate;
|
||||
@end
|
||||
|
@@ -18,10 +18,18 @@
|
||||
@interface XPEnterpriseRechargePayTableViewCell ()<UITableViewDelegate, UITableViewDataSource>
|
||||
///背景
|
||||
@property (nonatomic,strong) UIView * backView;
|
||||
///容器
|
||||
@property (nonatomic,strong) UIStackView *stackView;
|
||||
///显示充值方式
|
||||
@property (nonatomic,strong) UILabel *titleLabel;
|
||||
///列表
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
///查看更多支付方式
|
||||
@property (nonatomic,strong) UIView * moreView;
|
||||
///箭头
|
||||
@property (nonatomic,strong) UIButton *arrowButton;
|
||||
///更多方式
|
||||
@property (nonatomic,strong) UILabel *moreLabel;
|
||||
///充值的列表
|
||||
@property (nonatomic,strong) NSMutableArray<EnterPrieseRechargeTypeItemModel *> *rechargeTypeList;
|
||||
///当前选中的支付类型
|
||||
@@ -48,8 +56,15 @@
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.contentView addSubview:self.backView];
|
||||
[self.backView addSubview:self.titleLabel];
|
||||
[self.backView addSubview:self.tableView];
|
||||
|
||||
[self.backView addSubview:self.stackView];
|
||||
|
||||
[self.stackView addArrangedSubview:self.titleLabel];
|
||||
[self.stackView addArrangedSubview:self.tableView];
|
||||
[self.stackView addArrangedSubview:self.moreView];
|
||||
|
||||
[self.moreView addSubview:self.moreLabel];
|
||||
[self.moreView addSubview:self.arrowButton];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
@@ -58,14 +73,29 @@
|
||||
make.top.bottom.mas_equalTo(self.contentView);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.backView).offset(10);
|
||||
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.backView).inset(10);
|
||||
make.top.mas_equalTo(self.backView).offset(15);
|
||||
make.bottom.mas_equalTo(self.backView);
|
||||
}];
|
||||
|
||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(0);
|
||||
make.left.right.bottom.mas_equalTo(self.backView);
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(15);
|
||||
}];
|
||||
|
||||
[self.moreView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(50);
|
||||
}];
|
||||
|
||||
[self.moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.moreView).offset(-7);
|
||||
make.centerY.mas_equalTo(self.moreView);
|
||||
}];
|
||||
|
||||
[self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(11, 20));
|
||||
make.centerY.mas_equalTo(self.moreView);
|
||||
make.left.mas_equalTo(self.moreLabel.mas_right).offset(3);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -86,12 +116,16 @@
|
||||
} else {
|
||||
infoModel.isSelect = NO;
|
||||
}
|
||||
infoModel.isLastOne = (indexPath.row == (self.rechargeTypeList.count - 1));
|
||||
cell.rechargeTypeModel = infoModel;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.rechargeTypeList.count > 0) {
|
||||
if (self.rechargeTypeList.count == 1) {
|
||||
return;
|
||||
}
|
||||
self.currentItem = [self.rechargeTypeList objectAtIndex:indexPath.row];
|
||||
[self.tableView reloadData];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPEnterpriseRechargePayTableViewCell:didChooseItem:)]) {
|
||||
@@ -99,15 +133,73 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setType:(RechargeType)type {
|
||||
_type =type;
|
||||
self.currentItem = _type == RechargeType_WX ? self.wxPayItem : self.aliPayItem;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPEnterpriseRechargePayTableViewCell:didChooseItem:)]) {
|
||||
[self.delegate xPEnterpriseRechargePayTableViewCell:self didChooseItem:self.currentItem];
|
||||
#pragma mark - Event Response
|
||||
- (void)arrowButtonAction:(UIButton *)sender {
|
||||
sender.selected = !sender.selected;
|
||||
if (self.type == RechargeDefaultPayType_WX) {
|
||||
self.moreView.hidden = YES;
|
||||
if (![self.rechargeTypeList containsObject:self.aliPayItem]) {
|
||||
[self.rechargeTypeList addObject:self.aliPayItem];
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
} else if(self.type == RechargeDefaultPayType_ZFB) {
|
||||
self.moreView.hidden = YES;
|
||||
if (![self.rechargeTypeList containsObject:self.wxPayItem]) {
|
||||
[self.rechargeTypeList addObject:self.wxPayItem];
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setType:(RechargeDefaultPayType)type {
|
||||
_type =type;
|
||||
[self.rechargeTypeList removeAllObjects];
|
||||
switch (_type) {
|
||||
case RechargeDefaultPayType_WX:
|
||||
{
|
||||
[self.rechargeTypeList addObject:self.wxPayItem];
|
||||
self.currentItem = self.wxPayItem;
|
||||
self.moreView.hidden = NO;
|
||||
}
|
||||
break;
|
||||
case RechargeDefaultPayType_ZFB:
|
||||
{
|
||||
[self.rechargeTypeList addObject:self.aliPayItem];
|
||||
self.currentItem = self.aliPayItem;
|
||||
self.moreView.hidden = NO;
|
||||
}
|
||||
break;
|
||||
case RechargeDefaultPayType_WX_ZFB:
|
||||
{
|
||||
[self.rechargeTypeList addObject:self.wxPayItem];
|
||||
[self.rechargeTypeList addObject:self.aliPayItem];
|
||||
self.currentItem = self.wxPayItem;
|
||||
self.moreView.hidden = YES;
|
||||
}
|
||||
break;
|
||||
case RechargeDefaultPayType_ZFB_WX:
|
||||
{
|
||||
[self.rechargeTypeList addObject:self.aliPayItem];
|
||||
[self.rechargeTypeList addObject:self.wxPayItem];
|
||||
self.currentItem = self.aliPayItem;
|
||||
self.moreView.hidden = YES;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
[self.rechargeTypeList addObject:self.aliPayItem];
|
||||
[self.rechargeTypeList addObject:self.wxPayItem];
|
||||
self.currentItem = self.aliPayItem;
|
||||
self.moreView.hidden = YES;
|
||||
}
|
||||
break;
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
- (UITableView *)tableView {
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||
@@ -127,21 +219,31 @@
|
||||
- (NSMutableArray<EnterPrieseRechargeTypeItemModel *> *)rechargeTypeList {
|
||||
if (!_rechargeTypeList) {
|
||||
_rechargeTypeList = [NSMutableArray array];
|
||||
EnterPrieseRechargeTypeItemModel * wxItem = [[EnterPrieseRechargeTypeItemModel alloc] init];
|
||||
wxItem.imageName = @"mine_recharge_wechat";
|
||||
wxItem.title = @"微信";
|
||||
wxItem.type = RechargeType_WX;
|
||||
|
||||
}
|
||||
return _rechargeTypeList;
|
||||
}
|
||||
|
||||
- (EnterPrieseRechargeTypeItemModel *)aliPayItem {
|
||||
if (!_aliPayItem) {
|
||||
EnterPrieseRechargeTypeItemModel * zfbItem = [[EnterPrieseRechargeTypeItemModel alloc] init];
|
||||
zfbItem.imageName = @"mine_recharge_alipay";
|
||||
zfbItem.title = @"支付宝";
|
||||
zfbItem.isSelect = YES;
|
||||
zfbItem.type = RechargeType_ZFB;
|
||||
_aliPayItem = zfbItem;
|
||||
[_rechargeTypeList addObject:zfbItem];
|
||||
[_rechargeTypeList addObject:wxItem];
|
||||
}
|
||||
return _rechargeTypeList;
|
||||
return _aliPayItem;
|
||||
}
|
||||
|
||||
- (EnterPrieseRechargeTypeItemModel *)wxPayItem {
|
||||
if (!_wxPayItem) {
|
||||
EnterPrieseRechargeTypeItemModel * wxItem = [[EnterPrieseRechargeTypeItemModel alloc] init];
|
||||
wxItem.imageName = @"mine_recharge_wechat";
|
||||
wxItem.title = @"微信";
|
||||
wxItem.type = RechargeType_WX;
|
||||
_wxPayItem = wxItem;
|
||||
}
|
||||
return _wxPayItem;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
@@ -154,6 +256,17 @@
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (UIStackView *)stackView {
|
||||
if (!_stackView) {
|
||||
_stackView = [[UIStackView alloc] init];
|
||||
_stackView.axis = UILayoutConstraintAxisVertical;
|
||||
_stackView.distribution = UIStackViewDistributionFill;
|
||||
_stackView.alignment = UIStackViewAlignmentFill;
|
||||
_stackView.spacing = 0;
|
||||
}
|
||||
return _stackView;
|
||||
}
|
||||
|
||||
- (UIView *)backView {
|
||||
if (!_backView) {
|
||||
_backView = [[UIView alloc] init];
|
||||
@@ -164,5 +277,35 @@
|
||||
return _backView;
|
||||
}
|
||||
|
||||
- (UIView *)moreView {
|
||||
if (!_moreView) {
|
||||
_moreView = [[UIView alloc] init];
|
||||
_moreView.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return _moreView;
|
||||
}
|
||||
|
||||
|
||||
- (UILabel *)moreLabel {
|
||||
if (!_moreLabel) {
|
||||
_moreLabel = [[UILabel alloc] init];
|
||||
_moreLabel.font = [UIFont systemFontOfSize:13];
|
||||
_moreLabel.textColor = [ThemeColor mainTextColor];
|
||||
_moreLabel.text = @"展开更多支付方式";
|
||||
}
|
||||
return _moreLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)arrowButton {
|
||||
if (!_arrowButton) {
|
||||
_arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_arrowButton setImage:[UIImage imageNamed:@"room_setting_arrow"] forState:UIControlStateNormal];
|
||||
[_arrowButton setImage:[UIImage imageNamed:@"room_setting_arrow"] forState:UIControlStateSelected];
|
||||
_arrowButton.transform = CGAffineTransformMakeRotation(M_PI / 2);
|
||||
[_arrowButton addTarget:self action:@selector(arrowButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _arrowButton;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@@ -56,6 +56,11 @@
|
||||
|
||||
@implementation XPMineRechargeViewController
|
||||
|
||||
+ (void)load {
|
||||
NSString *universalLink = @"https://6cqhk.share2dlink.com/";
|
||||
[WXApi registerApp:KeyWithType(KeyType_WechatAppid) universalLink:universalLink];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self];
|
||||
}
|
||||
@@ -71,8 +76,6 @@
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
|
||||
NSString *universalLink = @"https://6cqhk.share2dlink.com/";
|
||||
[WXApi registerApp:KeyWithType(KeyType_WechatAppid) universalLink:universalLink];
|
||||
[self initData];
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
@@ -81,7 +84,7 @@
|
||||
#pragma mark - Private Method
|
||||
- (void)initData {
|
||||
[self.presenter getUserWalletInfo];
|
||||
[self.presenter getRechargeList:@"3"];
|
||||
[self.presenter getRechargeList:@"1"];
|
||||
}
|
||||
|
||||
- (void)initSubViews {
|
||||
@@ -157,7 +160,9 @@
|
||||
return cell;
|
||||
} else {
|
||||
XPEnterpriseRechargePayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPEnterpriseRechargePayTableViewCell class])];
|
||||
cell.type = self.listInfo.defaultPay;
|
||||
if (self.currentItem == nil) {
|
||||
cell.type = self.listInfo.defaultPay;
|
||||
}
|
||||
cell.delegate = self;
|
||||
return cell;
|
||||
}
|
||||
@@ -166,6 +171,10 @@
|
||||
#pragma mark - XPEnterpriseRechargeFootViewDelegate
|
||||
- (void)xPEnterpriseRechargeFootView:(XPEnterpriseRechargeFootView *)view didClickRecharge:(UIButton *)sender {
|
||||
if (self.rechargeInfo.chargeProdId.length >0) {
|
||||
if (self.currentItem == nil) {
|
||||
XPEnterpriseRechargePayTableViewCell * cell = (XPEnterpriseRechargePayTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]];
|
||||
self.currentItem = cell.currentItem;
|
||||
}
|
||||
NSString * payType= self.currentItem.type == RechargeType_WX ? @"wx" : @"alipay_v2";
|
||||
[self.presenter requestPay:self.rechargeInfo.chargeProdId payChannel:payType];
|
||||
}
|
||||
@@ -185,6 +194,31 @@
|
||||
#pragma mark - XPEnterpriseRechargePayTableViewCellDelegate
|
||||
- (void)xPEnterpriseRechargePayTableViewCell:(XPEnterpriseRechargePayTableViewCell *)view didChooseItem:(EnterPrieseRechargeTypeItemModel *)itemInfo {
|
||||
self.currentItem = itemInfo;
|
||||
[self.datasource removeAllObjects];
|
||||
switch (itemInfo.type) {
|
||||
case RechargeType_WX:
|
||||
{
|
||||
if (self.listInfo.list.count > 0) {
|
||||
[self.datasource addObjectsFromArray:self.listInfo.list];
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
break;
|
||||
case RechargeType_ZFB:
|
||||
{
|
||||
if (self.listInfo.list.count > 0) {
|
||||
[self.datasource addObjectsFromArray:self.listInfo.list];
|
||||
}
|
||||
|
||||
if (itemInfo.type == RechargeType_ZFB && self.listInfo.bigList.count > 0) {
|
||||
[self.datasource addObjectsFromArray: self.listInfo.bigList];
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - XPEnterpriseRechargeProtocol
|
||||
@@ -199,7 +233,7 @@
|
||||
[self.datasource addObjectsFromArray:info.list];
|
||||
}
|
||||
|
||||
if (info.defaultPay == RechargeType_ZFB && info.bigList.count > 0) {
|
||||
if ((info.defaultPay == RechargeDefaultPayType_ZFB || info.defaultPay == RechargeDefaultPayType_ZFB_WX) && info.bigList.count > 0) {
|
||||
[self.datasource addObjectsFromArray: info.bigList];
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
|
Reference in New Issue
Block a user