企业包贵族充值使用金币

This commit is contained in:
fengshuo
2022-10-28 15:47:02 +08:00
committed by chenshuanglin
parent 36d386bd62
commit 4f7a0b6341
13 changed files with 711 additions and 8 deletions

View File

@@ -672,6 +672,8 @@
E8232600274E48EA003A3332 /* XPUserCardItemCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E82325FF274E48EA003A3332 /* XPUserCardItemCollectionViewCell.m */; };
E8232603274E4AA0003A3332 /* ThemeColor+UserCard.m in Sources */ = {isa = PBXBuildFile; fileRef = E8232602274E4AA0003A3332 /* ThemeColor+UserCard.m */; };
E823E38E290BE8BD00EADD86 /* WishGiftInfoUpdateModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E823E38D290BE8BD00EADD86 /* WishGiftInfoUpdateModel.m */; };
E823E37C290BB1FD00EADD86 /* XPNobleRechargeView.m in Sources */ = {isa = PBXBuildFile; fileRef = E823E37B290BB1FD00EADD86 /* XPNobleRechargeView.m */; };
E823E37F290BB54F00EADD86 /* XPNobleRechargeTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E823E37E290BB54F00EADD86 /* XPNobleRechargeTableViewCell.m */; };
E824543526F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E824543426F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.m */; };
E824543826F5820A00BE8163 /* XPLoginVerifBindPhonePresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E824543726F5820A00BE8163 /* XPLoginVerifBindPhonePresenter.m */; };
E824543A26F5880E00BE8163 /* XPLoginVerifBindPhoneProtocol.h in Sources */ = {isa = PBXBuildFile; fileRef = E824543926F5822800BE8163 /* XPLoginVerifBindPhoneProtocol.h */; };
@@ -2488,6 +2490,10 @@
E8232602274E4AA0003A3332 /* ThemeColor+UserCard.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "ThemeColor+UserCard.m"; sourceTree = "<group>"; };
E823E38C290BE8BD00EADD86 /* WishGiftInfoUpdateModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WishGiftInfoUpdateModel.h; sourceTree = "<group>"; };
E823E38D290BE8BD00EADD86 /* WishGiftInfoUpdateModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WishGiftInfoUpdateModel.m; sourceTree = "<group>"; };
E823E37A290BB1FD00EADD86 /* XPNobleRechargeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNobleRechargeView.h; sourceTree = "<group>"; };
E823E37B290BB1FD00EADD86 /* XPNobleRechargeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNobleRechargeView.m; sourceTree = "<group>"; };
E823E37D290BB54F00EADD86 /* XPNobleRechargeTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNobleRechargeTableViewCell.h; sourceTree = "<group>"; };
E823E37E290BB54F00EADD86 /* XPNobleRechargeTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNobleRechargeTableViewCell.m; sourceTree = "<group>"; };
E824543326F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPLoginVerifBindPhoneViewController.h; sourceTree = "<group>"; };
E824543426F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPLoginVerifBindPhoneViewController.m; sourceTree = "<group>"; };
E824543626F5820A00BE8163 /* XPLoginVerifBindPhonePresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPLoginVerifBindPhonePresenter.h; sourceTree = "<group>"; };
@@ -5086,6 +5092,10 @@
E8A1F7A7290690E00099C952 /* XPNobleRankUpdateView.m */,
E83CD19C2909171900920A94 /* XPNobleDiscountView.h */,
E83CD19D2909171900920A94 /* XPNobleDiscountView.m */,
E823E37A290BB1FD00EADD86 /* XPNobleRechargeView.h */,
E823E37B290BB1FD00EADD86 /* XPNobleRechargeView.m */,
E823E37D290BB54F00EADD86 /* XPNobleRechargeTableViewCell.h */,
E823E37E290BB54F00EADD86 /* XPNobleRechargeTableViewCell.m */,
);
path = SubViews;
sourceTree = "<group>";
@@ -10312,6 +10322,7 @@
9B5BF8A827E1BED1005DD346 /* Api+RoomTrumpet.m in Sources */,
E8751E6B28A64C6E0056EF44 /* XPSailingRankTableViewCell.m in Sources */,
9B1B72B528003664003FACE9 /* Api+AnchorPk.m in Sources */,
E823E37F290BB54F00EADD86 /* XPNobleRechargeTableViewCell.m in Sources */,
E8EEB90626FC5772007C6EBA /* XPMineUserInfoEditViewController.m in Sources */,
E8B846D626FDE01B00A777FE /* XPMineRechargePresenter.m in Sources */,
E8834E53280052580029CCC1 /* XPMineGuildManagerPerTableViewCell.m in Sources */,
@@ -10555,6 +10566,7 @@
E87AE7FC277AAC450037823A /* XPRoomTagPresenter.m in Sources */,
E878894C273A607C00BF1D57 /* XPGiftUserCollectionViewCell.m in Sources */,
181D7F212727D9DB00B7C059 /* SocialStageView.m in Sources */,
E823E37C290BB1FD00EADD86 /* XPNobleRechargeView.m in Sources */,
E8AB630D28ADD8C60023B0D2 /* XPMonentTopicContainerViewController.m in Sources */,
E8D4DE472940473500EC788D /* GiftTwelveStarFirstModel.m in Sources */,
14973CA729C16816008E93E0 /* XPHomeGiftRecordModel.m in Sources */,

View File

@@ -10,7 +10,8 @@ NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, RechargeType) {
RechargeType_WX = 1,
RechargeType_ZFB
RechargeType_ZFB = 2,
RechargeType_Coin = 3,
};
@interface EnterPrieseRechargeTypeItemModel : NSObject

View File

@@ -17,7 +17,9 @@ typedef NS_ENUM(NSInteger, RechargeDefaultPayType) {
///支付宝 微信
RechargeDefaultPayType_ZFB_WX,
///微信支付宝
RechargeDefaultPayType_WX_ZFB
RechargeDefaultPayType_WX_ZFB,
///金币
RechargeDefaultPayType_Coin,
};
@interface EnterpriseRechargeListInfoModel : NSObject

View File

@@ -55,6 +55,11 @@ NS_ASSUME_NONNULL_BEGIN
/// 获取贵族排行榜
/// @param complection 完成回调
+ (void)vipRankList:(HttpRequestHelperCompletion)complection;
/// 使用钻石开通贵族
/// @param complection 完成回调
/// @param roomUid 房主的uid
+ (void)openWithDiamond:(HttpRequestHelperCompletion)complection roomUid:(NSString *)roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -86,4 +86,5 @@
[HttpRequestHelper request:@"vip/openWithDiamond" method:HttpRequestHelperMethodPOST params:dic completion:complection];
}
@end

View File

@@ -46,6 +46,10 @@ NS_ASSUME_NONNULL_BEGIN
///获取贵族升级列表
- (void)getNobleUpgradeList;
/// 钻石开通贵族
/// - Parameter roomUid: 房主的uid
- (void)opeNobleWishtDiamond:(NSString *)roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -122,4 +122,12 @@
}]];
}
///
/// - Parameter roomUid: uid
- (void)opeNobleWishtDiamond:(NSString *)roomUid {
[Api openWithDiamond:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] opeNobleWishtDiamondSuccess];
}] roomUid:roomUid];
}
@end

View File

@@ -45,4 +45,7 @@
///获取排行
- (void)getNobleRankListSuccess:(NobleRankListModel *)rankInfo;
///开通贵族成功
- (void)opeNobleWishtDiamondSuccess;
@end

View File

@@ -0,0 +1,29 @@
//
// XPNobleRechargeTableViewCell.h
// xplan-ios
//
// Created by 冯硕 on 2022/10/28.
//
#import <UIKit/UIKit.h>
#import "EnterpriseRechargeListInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@class XPNobleRechargeTableViewCell, EnterPrieseRechargeTypeItemModel;
@protocol XPNobleRechargeTableViewCellDelegate <NSObject>
- (void)xPNobleRechargeTableViewCell:(XPNobleRechargeTableViewCell *)view didChooseItem:(EnterPrieseRechargeTypeItemModel *)itemInfo;
@end
@interface XPNobleRechargeTableViewCell : UITableViewCell
///默认的充值类型
@property (nonatomic,assign) RechargeDefaultPayType type;
///当前选中的支付类型
@property (nonatomic,strong, readonly) EnterPrieseRechargeTypeItemModel *currentItem;
///代理
@property (nonatomic,weak) id<XPNobleRechargeTableViewCellDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,334 @@
//
// XPNobleRechargeTableViewCell.m
// xplan-ios
//
// Created by on 2022/10/28.
//
#import "XPNobleRechargeTableViewCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
///Model
#import "EnterPrieseRechargeTypeItemModel.h"
///View
#import "XPEnterpriseChargeTypeTableViewCell.h"
@interface XPNobleRechargeTableViewCell ()<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;
///
@property (nonatomic,strong) EnterPrieseRechargeTypeItemModel *currentItem;
///
@property (nonatomic,strong) EnterPrieseRechargeTypeItemModel *aliPayItem;
///
@property (nonatomic,strong) EnterPrieseRechargeTypeItemModel *wxPayItem;
///
@property (nonatomic,strong) EnterPrieseRechargeTypeItemModel *coinPayItem;
@end
@implementation XPNobleRechargeTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.backView];
[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 {
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.contentView).inset(15);
make.top.bottom.mas_equalTo(self.contentView);
}];
[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.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);
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.rechargeTypeList.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
XPEnterpriseChargeTypeTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPEnterpriseChargeTypeTableViewCell class])];
EnterPrieseRechargeTypeItemModel * infoModel = [self.rechargeTypeList objectAtIndex:indexPath.row];
if (infoModel.type == self.currentItem.type) {
infoModel.isSelect = YES;
} 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(xPNobleRechargeTableViewCell:didChooseItem:)]) {
[self.delegate xPNobleRechargeTableViewCell:self didChooseItem:self.currentItem];
}
}
}
#pragma mark - Event Response
- (void)tapMoreTypeRecognizer {
self.arrowButton.selected = !self.arrowButton.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];
[self.rechargeTypeList addObject:self.coinPayItem];
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;
}
if (_type == RechargeDefaultPayType_Coin) {
self.currentItem = self.coinPayItem;
}
[self.tableView reloadData];
}
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
_tableView.scrollEnabled = NO;
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[_tableView registerClass:[XPEnterpriseChargeTypeTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPEnterpriseChargeTypeTableViewCell class])];
}
return _tableView;
}
- (NSMutableArray<EnterPrieseRechargeTypeItemModel *> *)rechargeTypeList {
if (!_rechargeTypeList) {
_rechargeTypeList = [NSMutableArray array];
}
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;
}
return _aliPayItem;
}
- (EnterPrieseRechargeTypeItemModel *)coinPayItem {
if (!_coinPayItem) {
EnterPrieseRechargeTypeItemModel * zfbItem = [[EnterPrieseRechargeTypeItemModel alloc] init];
zfbItem.imageName = @"common_diamond";
zfbItem.title = @"钻石支付";
zfbItem.isSelect = YES;
zfbItem.type = RechargeType_Coin;
_coinPayItem = zfbItem;
}
return _coinPayItem;
}
- (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 {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:13];
_titleLabel.textColor = [ThemeColor mainTextColor];
_titleLabel.text = @"支付方式";
}
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];
_backView.backgroundColor = [ThemeColor appCellBackgroundColor];
_backView.layer.masksToBounds = YES;
_backView.layer.cornerRadius = 10;
}
return _backView;
}
- (UIView *)moreView {
if (!_moreView) {
_moreView = [[UIView alloc] init];
_moreView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapMoreTypeRecognizer)];
[_moreView addGestureRecognizer:tap];
}
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);
}
return _arrowButton;
}
@end

View File

@@ -0,0 +1,21 @@
//
// XPNobleRechargeView.h
// xplan-ios
//
// Created by 冯硕 on 2022/10/28.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPNobleRechargeView : UIView
///充值的id
@property (nonatomic,copy) NSString *chargeProdId;
///充值的金额
@property (nonatomic,copy) NSString *chargeMoney;
///房主的uid
@property (nonatomic,copy) NSString *roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,284 @@
//
// XPNobleRechargeView.m
// xplan-ios
//
// Created by on 2022/10/28.
//
#import "XPNobleRechargeView.h"
////Third
#import <Masonry/Masonry.h>
#import <AlipaySDK/AlipaySDK.h>
#import <WXApi.h>
#import <WXApiObject.h>
///Tool
#import "ThemeColor.h"
#import "XPMacro.h"
#import "UIImage+Utils.h"
#import "Api+EnterpriseRecharge.h"
#import "AccountInfoStorage.h"
#import "YYUtility.h"
#import "XCHUDTool.h"
#import "XCCurrentVCStackManager.h"
#import "TTPopup.h"
#import "Api.h"
#import "Api+NobleCenter.h"
///Model
#import "EnterpriseRechargeListInfoModel.h"
#import "EnterPrieseRechargeTypeItemModel.h"
#import "WalletInfoModel.h"
///View
#import "XPNobleRechargeTableViewCell.h"
#import "XPWebViewController.h"
@interface XPNobleRechargeView ()<UITableViewDelegate, UITableViewDataSource, XPNobleRechargeTableViewCellDelegate>
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) UILabel *moneyLabel;
///
@property (nonatomic,strong) UITableView *tableView;
///
@property (nonatomic,strong) UIButton *payButton;
///
@property (nonatomic,strong) EnterpriseRechargeListInfoModel *listInfo;
///
@property (nonatomic,assign) RechargeDefaultPayType payType;
///
@property (nonatomic,strong) EnterPrieseRechargeTypeItemModel *currentItem;
@end
@implementation XPNobleRechargeView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initData];
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initData {
[Api enterpriseRechargeList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
EnterpriseRechargeListInfoModel * listInfo = [EnterpriseRechargeListInfoModel modelWithDictionary:data.data];
self.payType = listInfo.defaultPay;
} else {
self.payType = RechargeDefaultPayType_ZFB;
}
[self.tableView reloadData];
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
[Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
WalletInfoModel * model = [WalletInfoModel modelWithDictionary:data.data];
if (model.diamonds.integerValue > self.chargeMoney.integerValue) {
self.payType = RechargeDefaultPayType_Coin;
}
[self.tableView reloadData];
}
} uid:uid ticket:ticket];
} channelType:@"1"];
}
- (void)initSubViews {
self.backgroundColor = [ThemeColor appCellBackgroundColor];
[self addSubview:self.titleLabel];
[self addSubview:self.moneyLabel];
[self addSubview:self.tableView];
[self addSubview:self.payButton];
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KScreenWidth, 416 + kSafeAreaBottomHeight) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = path.CGPath;
self.layer.mask = maskLayer;
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(416 + kSafeAreaBottomHeight);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.top.mas_equalTo(87);
}];
[self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(20);
}];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.moneyLabel.mas_bottom).offset(10);
make.left.right.mas_equalTo(self);
make.height.mas_equalTo(180);
}];
[self.payButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(38);
make.left.right.mas_equalTo(self).inset(44);
make.bottom.mas_equalTo(self.mas_bottom).offset(-9 - kSafeAreaBottomHeight);
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 180;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
XPNobleRechargeTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPNobleRechargeTableViewCell class])];
cell.delegate = self;
cell.type = self.payType;
return cell;
}
#pragma mark - XPNobleRechargeTableViewCell
- (void)xPNobleRechargeTableViewCell:(XPNobleRechargeTableViewCell *)view didChooseItem:(EnterPrieseRechargeTypeItemModel *)itemInfo {
self.currentItem = itemInfo;
}
#pragma mark - Event Response
- (void)payButtonAction:(UIButton *)sender {
if (self.currentItem == nil) {
XPNobleRechargeTableViewCell * cell = (XPNobleRechargeTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
self.currentItem = cell.currentItem;
}
if (self.currentItem.type == RechargeType_Coin) {
[Api openWithDiamond:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
[XCHUDTool showSuccessWithMessage:@"开通成功"];
} else {
[XCHUDTool showErrorWithMessage:msg];
}
[TTPopup dismiss];
} roomUid:self.roomUid];
return;
}
NSString * payChannel= self.currentItem.type == RechargeType_WX ? @"wx" : @"alipay_v2";
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
NSString * clientIp= [YYUtility ipAddress];
[XCHUDTool showLoading];
[Api requestPay:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
[XCHUDTool hideHUD];
if (code == 200) {
[TTPopup dismiss];
id infoData = data.data;
if ([payChannel isEqualToString:@"alipay_v2"]) {
if ([infoData isKindOfClass:[NSDictionary class]]) {
if ([[infoData objectForKey:@"payType"] isEqualToString:@"h5"]) {
XPWebViewController *webView = [[XPWebViewController alloc] init];
webView.url = [infoData objectForKey:@"orderData"];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webView animated:YES];
}else if ([[infoData objectForKey:@"payType"] isEqualToString:@"native"]) {
NSString * signedStr = [infoData objectForKey:@"orderData"];
NSString * scheme = @"daeplayapp";
[[AlipaySDK defaultService] payOrder:signedStr fromScheme:scheme callback:^(NSDictionary *resultDic) {
}];
}
}
} else if ([payChannel isEqualToString:@"alipay"]) {
if ([data isKindOfClass:[NSString class]]) {
NSString * scheme = @"daeplayapp";
NSString * signedStr = [infoData objectForKey:@"orderData"];
[[AlipaySDK defaultService] payOrder:signedStr fromScheme:scheme callback:^(NSDictionary *resultDic) {
}];
}
}else if ([payChannel isEqualToString:@"wx"]){
if ([infoData isKindOfClass:[NSDictionary class]]) {
PayReq *req = [[PayReq alloc] init];
NSDictionary * dict = infoData;
NSMutableString *stamp = [dict objectForKey:@"timestamp"];
req.partnerId = [dict objectForKey:@"partnerid"];
req.prepayId = [dict objectForKey:@"prepayid"];
req.nonceStr = [dict objectForKey:@"noncestr"];
req.timeStamp = stamp.intValue;
req.package = @"Sign=WXPay";
req.sign = [dict objectForKey:@"sign"];
[WXApi sendReq:req completion:^(BOOL success) {
if (success) {
NSLog(@"********调起微信支付成功");
}
}];
}
}
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} chargeProdId:self.chargeProdId payChannel:payChannel clientIp:clientIp uid:uid ticket:ticket roomUid:@""];
}
#pragma mark - Getters And Setters
- (void)setChargeMoney:(NSString *)chargeMoney {
_chargeMoney = chargeMoney;
if (_chargeMoney.length > 0) {
self.moneyLabel.text = [NSString stringWithFormat:@"¥%@", _chargeMoney];
}
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
_titleLabel.textColor = [ThemeColor mainTextColor];
_titleLabel.text = @"支付";
_titleLabel.textAlignment = NSTextAlignmentCenter;
}
return _titleLabel;
}
- (UILabel *)moneyLabel {
if (!_moneyLabel) {
_moneyLabel = [[UILabel alloc] init];
_moneyLabel.font = [UIFont systemFontOfSize:30 weight:UIFontWeightMedium];
_moneyLabel.textColor = [ThemeColor colorWithHexString:@"#FFBC52"];
_moneyLabel.textAlignment = NSTextAlignmentCenter;
}
return _moneyLabel;
}
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.tableFooterView = [UIView new];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = [UIColor clearColor];
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[_tableView registerClass:[XPNobleRechargeTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPNobleRechargeTableViewCell class])];
}
return _tableView;
}
- (UIButton *)payButton {
if (!_payButton) {
_payButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_payButton setTitle:@"确认支付" forState:UIControlStateNormal];
[_payButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_payButton.titleLabel.font = [UIFont systemFontOfSize:15];
[_payButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
_payButton.layer.masksToBounds = YES;
_payButton.layer.cornerRadius = 45/2;
[_payButton addTarget:self action:@selector(payButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _payButton;
}
@end

View File

@@ -34,7 +34,7 @@
#import "XPNobleSettingViewController.h"
#import "XPNobleRankViewController.h"
#import "XPNobleDiscountView.h"
#import "XPEnterpriseFirstRechargePayView.h"
#import "XPNobleRechargeView.h"
///P
#import "XPNobleCenterPresenter.h"
///model
@@ -383,11 +383,10 @@
#pragma mark - events
- (void)onOpenNobleButtonClick:(UITapGestureRecognizer *)button {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventVipOpenClick];
RechargeListModel *rechargeModel = [self.rechargeModel.list safeObjectAtIndex1:0];
XPEnterpriseFirstRechargePayView * rechargetView =[[XPEnterpriseFirstRechargePayView alloc] init];
rechargetView.chargeMoney = rechargeModel.money.stringValue;
rechargetView.chargeProdId = rechargeModel.chargeProdId;
rechargetView.roomUid = [NSString stringWithFormat:@"%ld",self.roomUid];
XPNobleRechargeView * rechargetView =[[XPNobleRechargeView alloc] init];
rechargetView.chargeMoney = [NSString stringWithFormat:@"%.0f", self.rechargeModel.money];
rechargetView.chargeProdId = self.rechargeModel.chargeProdId;
rechargetView.roomUid = [NSString stringWithFormat:@"%ld", self.roomUid];
[TTPopup popupView:rechargetView style:TTPopupStyleActionSheet];
}