301 lines
12 KiB
Objective-C
301 lines
12 KiB
Objective-C
//
|
|
// QXWithDrawViewController.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/5/26.
|
|
//
|
|
|
|
#import "QXWithDrawViewController.h"
|
|
#import "QXWalletTopView.h"
|
|
#import "QXWithDrawInputView.h"
|
|
#import "QXWithDrawTypeCell.h"
|
|
#import "QXReVerificationPopView.h"
|
|
#import "QXMineNetwork.h"
|
|
#import "QXWithDrawRecordVC.h"
|
|
|
|
@interface QXWithDrawViewController ()<UITableViewDelegate,UITableViewDataSource,QXWithDrawInputViewDelegate>
|
|
@property (nonatomic,strong)QXWalletTopView *topView;
|
|
@property (nonatomic,strong)QXWithDrawInputView *withDrawInputView;
|
|
@property (nonatomic,strong)UITableView *tableView;
|
|
@property (nonatomic,strong)QXPayTypeModel *selectedPayTypeModel;
|
|
@property (nonatomic,strong)UIButton *commitBtn;
|
|
@property (nonatomic,strong)UIButton *agreeBtn;
|
|
@property (nonatomic,strong)YYLabel *textLabel;
|
|
@property (nonatomic,strong)NSString *protocolTitle;
|
|
@property (nonatomic,strong)NSString *protocolUrl;
|
|
@end
|
|
|
|
@implementation QXWithDrawViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
[super viewWillAppear:animated];
|
|
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
|
[self getPrice];
|
|
}
|
|
-(void)setNavgationItems{
|
|
[super setNavgationItems];
|
|
self.navigationItem.title = QXText(@"提现");
|
|
UIButton*recordBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
|
|
[recordBtn setTitle:QXText(@"提现记录") forState:(UIControlStateNormal)];
|
|
[recordBtn setTitleColor:RGB16(0xFF8ACC) forState:(UIControlStateNormal)];
|
|
recordBtn.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
[recordBtn addTarget:self action:@selector(recordAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:recordBtn];
|
|
}
|
|
- (void)initSubViews{
|
|
self.protocolTitle = @"《灵活就业合作伙伴协议》";
|
|
QXPayTypeModel *model1 = [[QXPayTypeModel alloc] init];
|
|
model1.type = @"1";
|
|
model1.name = @"微信";
|
|
model1.icon = @"recharge_wechat";
|
|
QXPayTypeModel *model2 = [[QXPayTypeModel alloc] init];
|
|
model2.type = @"2";
|
|
model2.name = @"支付宝";
|
|
model2.icon = @"recharge_alipay";
|
|
[self.dataArray addObject:model1];
|
|
[self.dataArray addObject:model2];
|
|
[self.view addSubview:self.topView];
|
|
[self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.right.mas_equalTo(-16);
|
|
make.top.mas_equalTo(NavContentHeight+12);
|
|
make.height.mas_equalTo(ScaleWidth(112));
|
|
}];
|
|
|
|
[self.view addSubview:self.withDrawInputView];
|
|
[self.withDrawInputView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.right.mas_equalTo(-16);
|
|
make.top.equalTo(self.topView.mas_bottom).offset(12);
|
|
make.height.mas_equalTo(95);
|
|
}];
|
|
|
|
|
|
[self.view addSubview:self.tableView];
|
|
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.right.mas_equalTo(-16);
|
|
make.top.equalTo(self.withDrawInputView.mas_bottom).offset(20);
|
|
make.bottom.equalTo(self.view).offset(-kSafeAreaBottom);
|
|
}];
|
|
|
|
self.commitBtn = [[UIButton alloc] init];
|
|
[self.commitBtn setTitle:QXText(@"立即提现") forState:(UIControlStateNormal)];
|
|
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];;
|
|
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
|
[self.commitBtn addRoundedCornersWithRadius:21];
|
|
self.commitBtn.backgroundColor = QXConfig.themeColor;
|
|
[self.commitBtn addTarget:self action:@selector(withDrawAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.view addSubview:self.commitBtn];
|
|
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(38);
|
|
make.right.mas_equalTo(-38);
|
|
make.height.mas_equalTo(42);
|
|
make.bottom.mas_equalTo(-(kSafeAreaBottom));
|
|
}];
|
|
[self getPrice];
|
|
|
|
NSString *str = [NSString stringWithFormat:@"%@%@",QXText(@"我已阅读并同意"),self.protocolTitle];
|
|
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str];
|
|
MJWeakSelf
|
|
[attr yy_setTextHighlightRange:[str rangeOfString:self.protocolTitle] color:RGB16(0xFF8ACC) backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
|
QXLOG(@"点击灵活就业协议");
|
|
QXBaseWebViewController *vc = [[QXBaseWebViewController alloc] init];
|
|
vc.urlStr = weakSelf.protocolUrl;
|
|
[weakSelf.navigationController pushViewController:vc animated:YES];
|
|
}];
|
|
[attr yy_setFont:[UIFont systemFontOfSize:12] range:NSMakeRange(0, str.length)];
|
|
[attr yy_setColor:RGB16(0x333333) range:NSMakeRange(0, str.length)];
|
|
[attr yy_setColor:RGB16(0xFF8ACC) range:[str rangeOfString:self.protocolTitle]];
|
|
_textLabel = [[YYLabel alloc] init];
|
|
_textLabel.attributedText = attr;
|
|
_textLabel.userInteractionEnabled = YES;
|
|
[self.view addSubview:self.textLabel];
|
|
[self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(42);
|
|
make.centerX.equalTo(self.view).offset(17);
|
|
make.bottom.equalTo(self.commitBtn.mas_top).offset(-10);
|
|
}];
|
|
|
|
|
|
self.agreeBtn = [[UIButton alloc] init];
|
|
[self.agreeBtn setImage:[UIImage imageNamed:@"login_agreement_nor"] forState:(UIControlStateNormal)];
|
|
[self.agreeBtn setImage:[UIImage imageNamed:@"login_agreement_sel"] forState:(UIControlStateSelected)];
|
|
[self.view addSubview:self.agreeBtn];
|
|
[self.agreeBtn addTarget:self action:@selector(agreeAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.agreeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.equalTo(self.textLabel.mas_left);
|
|
make.width.height.mas_equalTo(40);
|
|
make.centerY.equalTo(self.textLabel);
|
|
}];
|
|
}
|
|
-(void)recordAction{
|
|
QXWithDrawRecordVC *vc = [[QXWithDrawRecordVC alloc] init];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
|
|
-(void)getPrice{
|
|
MJWeakSelf
|
|
[QXMineNetwork getWalletInfoSuccessBlock:^(NSString * _Nonnull coin, NSString * _Nonnull earnings, NSString * _Nonnull title, NSString * _Nonnull url) {
|
|
weakSelf.topView.coin = earnings;
|
|
weakSelf.protocolUrl = url;
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
|
|
[QXMineNetwork getWalletConfigSuccessBlock:^(NSString * _Nonnull coin_exchange_rate, NSString * _Nonnull withdrawal_service_fee, NSString * _Nonnull rmb_coin_ratio) {
|
|
weakSelf.withDrawInputView.fee = withdrawal_service_fee;
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
|
|
[QXMineNetwork walletPayTypeWithUserId:QXGlobal.shareGlobal.loginModel.user_id successBlock:^(QXPayTypeStatusModel * _Nonnull model) {
|
|
[weakSelf.dataArray removeAllObjects];
|
|
weakSelf.selectedPayTypeModel = nil;
|
|
if (model.wx.is_with_draw_open.intValue == 1 && model.wx.is_bind.intValue == 1) {
|
|
[weakSelf.dataArray addObject:model.wx];
|
|
}
|
|
if (model.ali.is_with_draw_open.intValue == 1 && model.ali.is_bind.intValue == 1) {
|
|
[weakSelf.dataArray addObject:model.ali];
|
|
}
|
|
if (model.bank.is_with_draw_open.intValue == 1 && model.bank.is_bind.intValue == 1) {
|
|
[weakSelf.dataArray addObject:model.bank];
|
|
}
|
|
[weakSelf.tableView reloadData];
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
}
|
|
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
|
[self.view endEditing:YES];
|
|
}
|
|
-(void)withDrawAction:(UIButton*)sender{
|
|
if (self.agreeBtn.selected == NO) {
|
|
showToast(@"请先阅读并同意灵活就业协议");
|
|
return;
|
|
}
|
|
if (self.withDrawInputView.textField.text.longValue == 0) {
|
|
showToast(@"请输入提现金额");
|
|
return;
|
|
}
|
|
if (self.selectedPayTypeModel == nil) {
|
|
showToast(@"请选择提现方式");
|
|
return;
|
|
}
|
|
MJWeakSelf
|
|
QXReVerificationPopView *popView = [[QXReVerificationPopView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(200))];
|
|
popView.commitBlock = ^(NSString * _Nonnull code) {
|
|
QXLOG(@"验证码为%@",code);
|
|
[[QXGlobal shareGlobal] hideViewBlock:^{
|
|
[weakSelf withDrawNetworkWithCode:code];
|
|
}];
|
|
};
|
|
[[QXGlobal shareGlobal] showView:popView popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
-(void)withDrawNetworkWithCode:(NSString*)code{
|
|
MJWeakSelf
|
|
showLoadingInView(self.view);
|
|
[QXMineNetwork walletWithDrawWithNumber:self.withDrawInputView.textField.text type:self.selectedPayTypeModel.type sms_code:code successBlock:^(NSDictionary * _Nonnull dict) {
|
|
hideLoadingInView(weakSelf.view);
|
|
showToast(@"提现成功");
|
|
[self getPrice];
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
hideLoadingInView(weakSelf.view);
|
|
showToast(msg);
|
|
}];
|
|
}
|
|
#pragma mark - UITableViewDelegate,UITableViewDataSource
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
return self.dataArray.count;
|
|
}
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
QXWithDrawTypeCell *cell = [QXWithDrawTypeCell cellWithTableView:tableView];
|
|
cell.model = self.dataArray[indexPath.row];
|
|
return cell;
|
|
}
|
|
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 35)];
|
|
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 0, SCREEN_WIDTH-32, 35)];
|
|
titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
|
titleLabel.textColor = QXConfig.textColor;
|
|
titleLabel.text = QXText(@"提现方式");
|
|
[header addSubview:titleLabel];
|
|
return header;
|
|
}
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|
return 35;
|
|
}
|
|
|
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
QXPayTypeModel *model = self.dataArray[indexPath.row];
|
|
if (model == self.selectedPayTypeModel) {
|
|
return;
|
|
}
|
|
if (self.selectedPayTypeModel) {
|
|
self.selectedPayTypeModel.isSelected = NO;
|
|
}
|
|
model.isSelected = YES;
|
|
self.selectedPayTypeModel = model;
|
|
[tableView reloadData];
|
|
}
|
|
#pragma mark - QXWithDrawInputViewDelegate 提现
|
|
-(void)didClickAll{
|
|
if (self.topView.coin.intValue == 0) {
|
|
self.withDrawInputView.textField.text = @"0";
|
|
}else{
|
|
// self.withDrawInputView.textField.text = self.topView.coin;
|
|
self.withDrawInputView.textField.text = [NSString stringWithFormat:@"%ld",self.topView.coin.longValue];
|
|
}
|
|
}
|
|
|
|
-(QXWalletTopView *)topView{
|
|
if (!_topView) {
|
|
_topView = [[QXWalletTopView alloc] init];
|
|
_topView.type = QXWalletTopViewTypeWithDraw;
|
|
}
|
|
return _topView;
|
|
}
|
|
-(QXWithDrawInputView *)withDrawInputView{
|
|
if (!_withDrawInputView) {
|
|
_withDrawInputView = [[QXWithDrawInputView alloc] init];
|
|
_withDrawInputView.delegate = self;
|
|
_withDrawInputView.type = QXWithDrawInputViewTypeWithDraw;
|
|
}
|
|
return _withDrawInputView;
|
|
}
|
|
-(UITableView *)tableView{
|
|
if (!_tableView) {
|
|
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:(UITableViewStyleGrouped)];
|
|
_tableView.dataSource = self;
|
|
_tableView.delegate = self;
|
|
_tableView.backgroundColor = [UIColor clearColor];
|
|
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
_tableView.rowHeight = 40;
|
|
_tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
|
|
}
|
|
return _tableView;
|
|
}
|
|
/*
|
|
#pragma mark - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
// Get the new view controller using [segue destinationViewController].
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
|
|
-(void)agreeAction:(UIButton*)sender{
|
|
self.agreeBtn.selected = !self.agreeBtn.selected;
|
|
}
|
|
@end
|