diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 11aa0d0e..5e04d59f 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -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 = ""; }; E823E38C290BE8BD00EADD86 /* WishGiftInfoUpdateModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WishGiftInfoUpdateModel.h; sourceTree = ""; }; E823E38D290BE8BD00EADD86 /* WishGiftInfoUpdateModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WishGiftInfoUpdateModel.m; sourceTree = ""; }; + E823E37A290BB1FD00EADD86 /* XPNobleRechargeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNobleRechargeView.h; sourceTree = ""; }; + E823E37B290BB1FD00EADD86 /* XPNobleRechargeView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNobleRechargeView.m; sourceTree = ""; }; + E823E37D290BB54F00EADD86 /* XPNobleRechargeTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNobleRechargeTableViewCell.h; sourceTree = ""; }; + E823E37E290BB54F00EADD86 /* XPNobleRechargeTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNobleRechargeTableViewCell.m; sourceTree = ""; }; E824543326F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPLoginVerifBindPhoneViewController.h; sourceTree = ""; }; E824543426F57D6E00BE8163 /* XPLoginVerifBindPhoneViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPLoginVerifBindPhoneViewController.m; sourceTree = ""; }; E824543626F5820A00BE8163 /* XPLoginVerifBindPhonePresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPLoginVerifBindPhonePresenter.h; sourceTree = ""; }; @@ -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 = ""; @@ -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 */, diff --git a/xplan-ios/Main/Mine/View/EnterpriseRecharge/Model/EnterPrieseRechargeTypeItemModel.h b/xplan-ios/Main/Mine/View/EnterpriseRecharge/Model/EnterPrieseRechargeTypeItemModel.h index 1d08a555..29448263 100644 --- a/xplan-ios/Main/Mine/View/EnterpriseRecharge/Model/EnterPrieseRechargeTypeItemModel.h +++ b/xplan-ios/Main/Mine/View/EnterpriseRecharge/Model/EnterPrieseRechargeTypeItemModel.h @@ -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 diff --git a/xplan-ios/Main/Mine/View/EnterpriseRecharge/Model/EnterpriseRechargeListInfoModel.h b/xplan-ios/Main/Mine/View/EnterpriseRecharge/Model/EnterpriseRechargeListInfoModel.h index ff37d0a1..b1fa4f06 100644 --- a/xplan-ios/Main/Mine/View/EnterpriseRecharge/Model/EnterpriseRechargeListInfoModel.h +++ b/xplan-ios/Main/Mine/View/EnterpriseRecharge/Model/EnterpriseRechargeListInfoModel.h @@ -17,7 +17,9 @@ typedef NS_ENUM(NSInteger, RechargeDefaultPayType) { ///支付宝 微信 RechargeDefaultPayType_ZFB_WX, ///微信支付宝 - RechargeDefaultPayType_WX_ZFB + RechargeDefaultPayType_WX_ZFB, + ///金币 + RechargeDefaultPayType_Coin, }; @interface EnterpriseRechargeListInfoModel : NSObject diff --git a/xplan-ios/Main/Mine/View/Noble/Api/Api+NobleCenter.h b/xplan-ios/Main/Mine/View/Noble/Api/Api+NobleCenter.h index 5fd02d0c..2f171f64 100644 --- a/xplan-ios/Main/Mine/View/Noble/Api/Api+NobleCenter.h +++ b/xplan-ios/Main/Mine/View/Noble/Api/Api+NobleCenter.h @@ -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 diff --git a/xplan-ios/Main/Mine/View/Noble/Api/Api+NobleCenter.m b/xplan-ios/Main/Mine/View/Noble/Api/Api+NobleCenter.m index cdbf31ea..e4331d53 100644 --- a/xplan-ios/Main/Mine/View/Noble/Api/Api+NobleCenter.m +++ b/xplan-ios/Main/Mine/View/Noble/Api/Api+NobleCenter.m @@ -86,4 +86,5 @@ [HttpRequestHelper request:@"vip/openWithDiamond" method:HttpRequestHelperMethodPOST params:dic completion:complection]; } + @end diff --git a/xplan-ios/Main/Mine/View/Noble/Presenter/XPNobleCenterPresenter.h b/xplan-ios/Main/Mine/View/Noble/Presenter/XPNobleCenterPresenter.h index 6a706aeb..c7c48d30 100644 --- a/xplan-ios/Main/Mine/View/Noble/Presenter/XPNobleCenterPresenter.h +++ b/xplan-ios/Main/Mine/View/Noble/Presenter/XPNobleCenterPresenter.h @@ -46,6 +46,10 @@ NS_ASSUME_NONNULL_BEGIN ///获取贵族升级列表 - (void)getNobleUpgradeList; + +/// 钻石开通贵族 +/// - Parameter roomUid: 房主的uid +- (void)opeNobleWishtDiamond:(NSString *)roomUid; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Noble/Presenter/XPNobleCenterPresenter.m b/xplan-ios/Main/Mine/View/Noble/Presenter/XPNobleCenterPresenter.m index 743abe50..843726c9 100644 --- a/xplan-ios/Main/Mine/View/Noble/Presenter/XPNobleCenterPresenter.m +++ b/xplan-ios/Main/Mine/View/Noble/Presenter/XPNobleCenterPresenter.m @@ -122,4 +122,12 @@ }]]; } +/// 钻石开通贵族 +/// - Parameter roomUid: 房主的uid +- (void)opeNobleWishtDiamond:(NSString *)roomUid { + [Api openWithDiamond:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] opeNobleWishtDiamondSuccess]; + }] roomUid:roomUid]; +} + @end diff --git a/xplan-ios/Main/Mine/View/Noble/Protocol/XPNobleCenterProtocol.h b/xplan-ios/Main/Mine/View/Noble/Protocol/XPNobleCenterProtocol.h index e2a245f9..2c8dfeac 100644 --- a/xplan-ios/Main/Mine/View/Noble/Protocol/XPNobleCenterProtocol.h +++ b/xplan-ios/Main/Mine/View/Noble/Protocol/XPNobleCenterProtocol.h @@ -45,4 +45,7 @@ ///获取排行 - (void)getNobleRankListSuccess:(NobleRankListModel *)rankInfo; +///开通贵族成功 +- (void)opeNobleWishtDiamondSuccess; + @end diff --git a/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeTableViewCell.h b/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeTableViewCell.h new file mode 100644 index 00000000..b4fe3433 --- /dev/null +++ b/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeTableViewCell.h @@ -0,0 +1,29 @@ +// +// XPNobleRechargeTableViewCell.h +// xplan-ios +// +// Created by 冯硕 on 2022/10/28. +// + +#import +#import "EnterpriseRechargeListInfoModel.h" +NS_ASSUME_NONNULL_BEGIN +@class XPNobleRechargeTableViewCell, EnterPrieseRechargeTypeItemModel; +@protocol XPNobleRechargeTableViewCellDelegate + + +- (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 delegate; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeTableViewCell.m b/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeTableViewCell.m new file mode 100644 index 00000000..d41ff94f --- /dev/null +++ b/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeTableViewCell.m @@ -0,0 +1,334 @@ +// +// XPNobleRechargeTableViewCell.m +// xplan-ios +// +// Created by 冯硕 on 2022/10/28. +// + +#import "XPNobleRechargeTableViewCell.h" +///Third +#import +///Tool +#import "ThemeColor.h" +///Model +#import "EnterPrieseRechargeTypeItemModel.h" +///View +#import "XPEnterpriseChargeTypeTableViewCell.h" + +@interface XPNobleRechargeTableViewCell () +///背景 +@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 *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 *)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 diff --git a/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeView.h b/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeView.h new file mode 100644 index 00000000..d5d28f48 --- /dev/null +++ b/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeView.h @@ -0,0 +1,21 @@ +// +// XPNobleRechargeView.h +// xplan-ios +// +// Created by 冯硕 on 2022/10/28. +// + +#import + +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 diff --git a/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeView.m b/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeView.m new file mode 100644 index 00000000..70ff678b --- /dev/null +++ b/xplan-ios/Main/Mine/View/Noble/View/SubViews/XPNobleRechargeView.m @@ -0,0 +1,284 @@ +// +// XPNobleRechargeView.m +// xplan-ios +// +// Created by 冯硕 on 2022/10/28. +// + +#import "XPNobleRechargeView.h" +////Third +#import +#import +#import +#import +///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 () +/// +@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 diff --git a/xplan-ios/Main/Mine/View/Noble/View/XPNobleCenterViewController.m b/xplan-ios/Main/Mine/View/Noble/View/XPNobleCenterViewController.m index af0a4b4d..f8e4a420 100644 --- a/xplan-ios/Main/Mine/View/Noble/View/XPNobleCenterViewController.m +++ b/xplan-ios/Main/Mine/View/Noble/View/XPNobleCenterViewController.m @@ -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]; }