首充使用微信支付宝支付 支付宝支持杉德支付

This commit is contained in:
fengshuo
2022-05-16 22:36:18 +08:00
parent 2fb443bac4
commit fd10db28af
8 changed files with 317 additions and 17 deletions

View File

@@ -1251,6 +1251,8 @@
E8F9168E27ECA69500F10D8F /* HomeLittleGameRoomModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8F9168D27ECA69500F10D8F /* HomeLittleGameRoomModel.m */; };
F183EF412935E1C000E2465F /* HomeEveryOneSearchModel.m in Sources */ = {isa = PBXBuildFile; fileRef = F183EF402935E1C000E2465F /* HomeEveryOneSearchModel.m */; };
F1D8556F2931FC86008C418F /* XPRoomYearActivityView.m in Sources */ = {isa = PBXBuildFile; fileRef = F1D8556E2931FC86008C418F /* XPRoomYearActivityView.m */; };
F1152AC928E49A71007CB09A /* app_launch_screen01.png in Resources */ = {isa = PBXBuildFile; fileRef = F1152AC828E49A71007CB09A /* app_launch_screen01.png */; };
E8FDB61D28325187003EFEA9 /* XPEnterpriseFirstRechargePayView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8FDB61C28325187003EFEA9 /* XPEnterpriseFirstRechargePayView.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -3604,6 +3606,9 @@
F183EF402935E1C000E2465F /* HomeEveryOneSearchModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeEveryOneSearchModel.m; sourceTree = "<group>"; };
F1D8556D2931FC86008C418F /* XPRoomYearActivityView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomYearActivityView.h; sourceTree = "<group>"; };
F1D8556E2931FC86008C418F /* XPRoomYearActivityView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomYearActivityView.m; sourceTree = "<group>"; };
F1152AC828E49A71007CB09A /* app_launch_screen01.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = app_launch_screen01.png; sourceTree = "<group>"; };
E8FDB61B28325187003EFEA9 /* XPEnterpriseFirstRechargePayView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPEnterpriseFirstRechargePayView.h; sourceTree = "<group>"; };
E8FDB61C28325187003EFEA9 /* XPEnterpriseFirstRechargePayView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPEnterpriseFirstRechargePayView.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -6499,6 +6504,8 @@
E83A2A42282F562A002AD58F /* Cell */,
E83A2A35282F4E85002AD58F /* XPMineRechargeViewController.h */,
E83A2A36282F4E85002AD58F /* XPMineRechargeViewController.m */,
E8FDB61B28325187003EFEA9 /* XPEnterpriseFirstRechargePayView.h */,
E8FDB61C28325187003EFEA9 /* XPEnterpriseFirstRechargePayView.m */,
);
path = View;
sourceTree = "<group>";
@@ -9812,6 +9819,7 @@
187EEEFE26E8A82C002833B2 /* NSObject+AutoCoding.m in Sources */,
E873EB0C2809850D0071030D /* MessageContentCustomView.m in Sources */,
E884C36F2743AAC800E1EBED /* AttachmentModel.m in Sources */,
E8FDB61D28325187003EFEA9 /* XPEnterpriseFirstRechargePayView.m in Sources */,
E8AC721926F46E0B007D6E91 /* XPMineSettingItemModel.m in Sources */,
E8E859D428264C2300EE4857 /* DDASLLogger.m in Sources */,
9BE01AF02893E31700B50299 /* NewUserRechargeModel.m in Sources */,

View File

@@ -10,10 +10,10 @@
NS_ASSUME_NONNULL_BEGIN
@class EnterpriseRechargeInfoModel;
typedef NS_ENUM(NSInteger, RechargeDefaultPayType) {
///只有微信
RechargeDefaultPayType_WX = 1,
///支付宝
RechargeDefaultPayType_ZFB,
RechargeDefaultPayType_ZFB = 1,
///微信
RechargeDefaultPayType_WX,
///支付宝 微信
RechargeDefaultPayType_ZFB_WX,
///微信支付宝

View File

@@ -47,7 +47,7 @@
- (void)initSubViewConstraints {
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView).offset(10);
make.left.mas_equalTo(self.contentView).offset(0);
make.centerY.mas_equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(24, 24));
}];

View File

@@ -134,8 +134,8 @@
}
}
#pragma mark - Event Response
- (void)arrowButtonAction:(UIButton *)sender {
sender.selected = !sender.selected;
- (void)tapMoreTypeRecognizer {
self.arrowButton.selected = !self.arrowButton.selected;
if (self.type == RechargeDefaultPayType_WX) {
self.moreView.hidden = YES;
if (![self.rechargeTypeList containsObject:self.aliPayItem]) {
@@ -281,6 +281,8 @@
if (!_moreView) {
_moreView = [[UIView alloc] init];
_moreView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapMoreTypeRecognizer)];
[_moreView addGestureRecognizer:tap];
}
return _moreView;
}
@@ -302,7 +304,6 @@
[_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;
}

View File

@@ -0,0 +1,19 @@
//
// XPEnterpriseFirstRechargePayView.h
// xplan-ios
//
// Created by 冯硕 on 2022/5/16.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class FirstRechargeModel;
@interface XPEnterpriseFirstRechargePayView : UIView
///充值信息
@property (nonatomic,strong) FirstRechargeModel *rechargeInfo;
///首充的vc
@property (nonatomic,weak) UIViewController *firstrechargeVC;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,265 @@
//
// XPEnterpriseFirstRechargePayView.m
// xplan-ios
//
// Created by on 2022/5/16.
//
#import "XPEnterpriseFirstRechargePayView.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"
///Model
#import "EnterpriseRechargeListInfoModel.h"
#import "FirstRechargeModel.h"
#import "EnterPrieseRechargeTypeItemModel.h"
///View
#import "XPEnterpriseRechargePayTableViewCell.h"
#import "XPWebViewController.h"
@interface XPEnterpriseFirstRechargePayView ()<UITableViewDelegate, UITableViewDataSource, XPEnterpriseRechargePayTableViewCellDelegate>
///
@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 XPEnterpriseFirstRechargePayView
- (void)dealloc {
NSLog(@"aaaaaa");
}
- (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];
} 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, 310) 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(310);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.top.mas_equalTo(15);
}];
[self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(15);
}];
[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(130);
}];
[self.payButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(45);
make.left.right.mas_equalTo(self).inset(47);
make.bottom.mas_equalTo(self.mas_bottom).offset(-15);
}];
}
#pragma mark - UITableViewDelegate And UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 130;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
XPEnterpriseRechargePayTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPEnterpriseRechargePayTableViewCell class])];
cell.delegate = self;
cell.type = self.payType;
return cell;
}
#pragma mark - XPEnterpriseRechargePayTableViewCellDelegate
- (void)xPEnterpriseRechargePayTableViewCell:(XPEnterpriseRechargePayTableViewCell *)view didChooseItem:(EnterPrieseRechargeTypeItemModel *)itemInfo {
self.currentItem = itemInfo;
}
#pragma mark - Event Response
- (void)payButtonAction:(UIButton *)sender {
if (self.currentItem == nil) {
XPEnterpriseRechargePayTableViewCell * cell = (XPEnterpriseRechargePayTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
self.currentItem = cell.currentItem;
}
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"]) {
[self.firstrechargeVC dismissViewControllerAnimated:NO completion:^{
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"]) {
[self.firstrechargeVC dismissViewControllerAnimated:NO completion:nil];
NSString * signedStr = [infoData objectForKey:@"orderData"];
NSString * scheme = @"daeplayappp";
[[AlipaySDK defaultService] payOrder:signedStr fromScheme:scheme callback:^(NSDictionary *resultDic) {
}];
}
}
} else if ([payChannel isEqualToString:@"alipay"]) {
[self.firstrechargeVC dismissViewControllerAnimated:NO completion:nil];
if ([data isKindOfClass:[NSString class]]) {
NSString * scheme = @"daeplayappp";
NSString * signedStr = [infoData objectForKey:@"orderData"];
[[AlipaySDK defaultService] payOrder:signedStr fromScheme:scheme callback:^(NSDictionary *resultDic) {
}];
}
}else if ([payChannel isEqualToString:@"wx"]){
if ([infoData isKindOfClass:[NSDictionary class]]) {
[self.firstrechargeVC dismissViewControllerAnimated:NO completion:nil];
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.rechargeInfo.chargeProdId payChannel:payChannel clientIp:clientIp uid:uid ticket:ticket];
}
#pragma mark - Getters And Setters
- (void)setRechargeInfo:(FirstRechargeModel *)rechargeInfo {
_rechargeInfo = rechargeInfo;
if (_rechargeInfo) {
self.moneyLabel.text = [NSString stringWithFormat:@"¥%ld", rechargeInfo.chargeMoney];
}
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:16];
_titleLabel.textColor = [ThemeColor mainTextColor];
_titleLabel.text = @"支付";
_titleLabel.textAlignment = NSTextAlignmentCenter;
}
return _titleLabel;
}
- (UILabel *)moneyLabel {
if (!_moneyLabel) {
_moneyLabel = [[UILabel alloc] init];
_moneyLabel.font = [UIFont systemFontOfSize:28];
_moneyLabel.textColor = [ThemeColor mainTextColor];
_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:[XPEnterpriseRechargePayTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPEnterpriseRechargePayTableViewCell 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

@@ -14,6 +14,7 @@
#import "UIImage+Utils.h"
#import "XPFirstRechargeFlowLayout.h"
#import "NSArray+Safe.h"
#import "TTPopup.h"
///Model
#import "FirstRechargeModel.h"
///View
@@ -22,7 +23,7 @@
#import "XPFirstRechargePresenter.h"
#import "XPFirstRechargeProtocol.h"
///VC
#import "XPMineRechargeViewController.h"
#import "XPEnterpriseFirstRechargePayView.h"
@interface XPFirstRechargeViewController ()<XPFirstRechargeProtocol, UICollectionViewDelegate, UICollectionViewDataSource>
///View
@@ -53,6 +54,8 @@
@property (nonatomic,strong) NSArray<FirstRechargeModel *> *originArray;
///
@property (nonatomic,weak) UINavigationController * currentNav;
///
@property (nonatomic,strong) FirstRechargeModel *selectRechargeInfo;
@end
@implementation XPFirstRechargeViewController
@@ -161,6 +164,7 @@
}
- (void)createExtraRewardAttrebute:(FirstRechargeModel *)model {
self.selectRechargeInfo = model;
self.descripTextView.text = model.chargeProdDesc;
NSString * title = model.chargeProdTitle;
NSString * giveMoneyStr = [NSString stringWithFormat:@"%ld", model.giveMoney];
@@ -224,9 +228,11 @@
}
- (void)rechargeButtonAction:(UIButton *)sender {
[self dismissViewControllerAnimated:YES completion:nil];
XPMineRechargeViewController * rechargeVC = [[XPMineRechargeViewController alloc] init];
[self.currentNav pushViewController:rechargeVC animated:YES];
XPEnterpriseFirstRechargePayView * rechargetView =[[XPEnterpriseFirstRechargePayView alloc] init];
rechargetView.rechargeInfo = self.selectRechargeInfo;
rechargetView.firstrechargeVC = self;
[TTPopup popupView:rechargetView style:TTPopupStyleActionSheet];
}
- (void)buttonAction:(UIButton *)sender {

View File

@@ -466,12 +466,13 @@ NSString * const kCheckResultFinish = @"checkResultFinish";
if (![_url hasPrefix:@"http"] && ![_url hasPrefix:@"https"]){
_url = [NSString stringWithFormat:@"%@/%@", API_HOST_URL, _url];
}
if (![_url containsString:@"?"]) {
_url = [NSString stringWithFormat:@"%@?platform=%@", _url, [YYUtility appName]];
} else {
_url = [NSString stringWithFormat:@"%@&platform=%@", _url, [YYUtility appName]];
}
if (![_url containsString:@"alipayh5"]) {
if (![_url containsString:@"?"]) {
_url = [NSString stringWithFormat:@"%@?platform=%@", _url, [YYUtility appName]];
} else {
_url = [NSString stringWithFormat:@"%@&platform=%@", _url, [YYUtility appName]];
}
}
// urlString
NSString *noSpaceTextUrl = [_url stringByReplacingOccurrencesOfString:@" " withString:@""];