// // SPWalletTixianVC.m // SweetParty // // Created by bj_szd on 2022/6/10. // #import "SPWalletTixianVC.h" #import "SPWalletModel.h" #import "SPWalletBindBankVC.h" #import "ZWTimer.h" #import "SPWalletDuihuanVC.h" #import "SPWalletRecordListVC.h" #import "LMTixianQianyueViewController.h" #import "LMTixianRecordViewController.h" @interface SPWalletTixianVC () @property (weak, nonatomic) IBOutlet UIView *balanceBgV; @property (weak, nonatomic) IBOutlet UILabel *balanceLab; @property (weak, nonatomic) IBOutlet UIButton *bindBtn; @property (weak, nonatomic) IBOutlet UITextField *tixianTF; @property (weak, nonatomic) IBOutlet UITextField *codeTF; @property (weak, nonatomic) IBOutlet UIButton *codeBtn; @property (weak, nonatomic) IBOutlet UIButton *confirmBtn; @property (weak, nonatomic) IBOutlet UILabel *decLab; @property (weak, nonatomic) IBOutlet UIButton *xieyiSelBtn; @property (nonatomic, strong) SPWalletModel *model; @property (nonatomic, strong) ZWTimer *timer; @property (nonatomic, assign) NSInteger leftSecond; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *topLayout; @property (nonatomic, assign) NSInteger tixianType; @property (weak, nonatomic) IBOutlet UIButton *aliSelectButton; @property (weak, nonatomic) IBOutlet UIButton *bankSelectButton; @end @implementation SPWalletTixianVC - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self fetchData]; } - (void)viewDidLoad { [super viewDidLoad]; self.leftSecond = 60; self.tixianType = 1; // [self showNaviBarWithTitle:@"提现"]; // [self onChangeNaviWhiteStyle]; [self createUI]; } - (void)requestGet_sign_status { NSDictionary *params = @{}; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/yun/get_sign_status" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) { NSDictionary *data = [responseDic safeDictionaryForKey:@"data"]; NSString *status = [data safeStringForKey:@"status"]; if ([status isEqualToString:@"1"]){ if (self.tixianType == 1){ NSLog(@"提现支付宝"); [self tixianAliMethod]; }else if (self.tixianType == 2){ NSLog(@"提现银行卡"); [self tixianQianyueBank]; } }else{ [self requestget_sign_contract_url]; } } Failure:^(id _Nonnull errorData) { }]; } //获取签约url - (void)requestget_sign_contract_url { NSDictionary *params = @{}; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/yun/get_sign_contract_url" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) { NSDictionary *data = [responseDic safeDictionaryForKey:@"data"]; NSString *url = [data safeStringForKey:@"url"]; LMTixianQianyueViewController *qyv = [[LMTixianQianyueViewController alloc] init]; qyv.url = url; qyv.modalPresentationStyle = 0; [self presentViewController:qyv animated:YES completion:^{ }]; } Failure:^(id _Nonnull errorData) { }]; } - (void)fetchData { NSDictionary *params = @{}; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/get_user_money" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) { SPWalletModel *model = [SPWalletModel mj_objectWithKeyValues:responseDic[@"data"]]; self.model = model; self.balanceLab.text = [NSString stringWithFormat:@"%.2f", [model.money doubleValue]]; if (model.alipay_account.length > 0) { self.bindBtn.selected = YES; } } Failure:^(id _Nonnull errorData) { }]; } - (void)createUI { // self.balanceBgV.backgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(ScreenWidth-14*2, 130) direction:FXGradientChangeDirectionHorizontal startColor:HEXCOLOR(0x7E9AF9) endColor:HEXCOLOR(0x6B42F0)]; [self.confirmBtn setJianBianWithCGSize:CGSizeMake(ScreenWidth-27*2, 49)]; UIImageView *bgImgV = [[UIImageView alloc] initWithImage:ImageNamed(@"home_bg")]; [self.view addSubview:bgImgV]; [self.view sendSubviewToBack:bgImgV]; [bgImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.right.equalTo(self.view); make.height.mas_equalTo(ScreenWidth/375*812); }]; [self showNaviBarWithTitle:@"提现"]; self.topLayout.constant = yb_NavigationBar_H+10; [ControlCreator createButton:self.view rect:CGRectMake(ScreenWidth-65-10, yb_StatusBar_H+7, 65, 30) text:@"提现记录" font:YBMediumFont(13) color:HEXCOLOR(0x111111) backguoundColor:nil imageName:nil target:self action:@selector(onRightClick)]; self.tixianTF.attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:@"请输入提现金额" attributes:@{NSForegroundColorAttributeName:[HEXCOLOR(0x333333) colorWithAlphaComponent:0.6]}]; self.codeTF.attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:@"请输入验证码" attributes:@{NSForegroundColorAttributeName:[HEXCOLOR(0x333333) colorWithAlphaComponent:0.6]}]; self.decLab.text = [NSString stringWithFormat:@"提现服务费:%.0f%%", 100-[GVUSER.withdraw_rate floatValue]*100]; } - (void)onRightClick { LMTixianRecordViewController *rvc = [[LMTixianRecordViewController alloc] init]; [rvc pushSelf]; } - (IBAction)selectAliButtonClick:(UIButton *)sender { self.tixianType = 1; sender.selected = YES; self.bankSelectButton.selected = NO; } - (IBAction)selectBankButtonClick:(UIButton *)sender { self.tixianType = 2; sender.selected = YES; self.aliSelectButton.selected = NO; } - (IBAction)onMingxi:(id)sender { SPWalletRecordListVC *vc = [[SPWalletRecordListVC alloc] init]; vc.type = 2; [vc pushSelf]; } - (IBAction)onBindBank:(id)sender { SPWalletBindBankVC *vc = [[SPWalletBindBankVC alloc] init]; vc.model = self.model; [vc pushSelf]; } - (IBAction)onAllTixian:(id)sender { if ([self.model.money integerValue] > 0) { self.tixianTF.text = [NSString stringWithFormat:@"%ld", [self.model.money integerValue]]; }else { [HelpPageDefine showMessage:@"可提现金额不足"]; } } - (IBAction)onGetCode:(id)sender { //type 1,其他时候使用,2,注册时候用 BJPicCodeView *view = LoadNib(@"BJPicCodeView"); view.frame = [UIScreen mainScreen].bounds; [MainWindow() addSubview:view]; view.onConfirmBlock = ^(NSString * _Nonnull picCodeStr, NSString * _Nonnull codeKey) { [self onSendSmsCodeWith:picCodeStr codeKey:codeKey]; }; } - (void)onSendSmsCodeWith:(NSString *)picCodeStr codeKey:(NSString *)codeKey { //type 1,其他时候使用,2,注册时候用 NSDictionary *params = @{@"mobile":[BJUserManager userInfo].user_name, @"type":@"1", @"captcha_code":picCodeStr, @"captcha_key":codeKey}; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/login/send_sms" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) { self.leftSecond = 60; [self.timer startTimer:1 delegate:self repeats:YES]; } Failure:^(id _Nonnull errorData) { }]; } - (IBAction)onConfirm:(id)sender { //获取云账户签约状态 [self requestGet_sign_status]; } - (void)tixianAliMethod { if (self.xieyiSelBtn.selected == NO){ [HelpPageDefine showMessage:@"请阅读并同意协议"]; return; } if (self.tixianTF.text.length <= 0) { [HelpPageDefine showMessage:@"请输入提现金额"]; return; } if (self.codeTF.text.length <= 0) { [HelpPageDefine showMessage:@"请输入验证码"]; return; } //1是支付宝 2银行卡 NSDictionary *params = @{@"money":self.tixianTF.text, @"code":self.codeTF.text, @"type":@"1"}; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/user_withdrawal" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) { [self fetchData]; } Failure:^(id _Nonnull errorData) { }]; } - (void)tixianBankMethod { if (self.tixianTF.text.length <= 0) { [HelpPageDefine showMessage:@"请输入提现金额"]; return; } if (self.codeTF.text.length <= 0) { [HelpPageDefine showMessage:@"请输入验证码"]; return; } //1是支付宝 2银行卡 NSDictionary *params = @{@"money":self.tixianTF.text, @"code":self.codeTF.text}; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/user_withdrawal_bank" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) { [self fetchData]; } Failure:^(id _Nonnull errorData) { }]; } - (void)tixianQianyueBank { if (self.xieyiSelBtn.selected == NO){ [HelpPageDefine showMessage:@"请阅读并同意协议"]; return; } if (self.tixianTF.text.length <= 0) { [HelpPageDefine showMessage:@"请输入提现金额"]; return; } if (self.codeTF.text.length <= 0) { [HelpPageDefine showMessage:@"请输入验证码"]; return; } //1是支付宝 2银行卡 NSDictionary *params = @{@"money":self.tixianTF.text, @"code":self.codeTF.text, @"type":@"2"}; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/user/user_withdrawal" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) { [self fetchData]; } Failure:^(id _Nonnull errorData) { }]; } - (IBAction)onSelXieyi:(id)sender { self.xieyiSelBtn.selected = !self.xieyiSelBtn.isSelected; } - (IBAction)onJumpXieyi:(id)sender { [self requestget_sign_contract_url]; } - (void)onTimerFired:(ZWTimer *)timer { NSString *str = [NSString stringWithFormat:@"%ld秒后重发", self.leftSecond]; self.codeBtn.userInteractionEnabled = NO; self.leftSecond -= 1; if (self.leftSecond < 0) { str = @"获取验证码"; [self.timer stopTimer]; self.codeBtn.userInteractionEnabled = YES; } self.codeBtn.titleLabel.text = str; [self.codeBtn setTitle:str forState:UIControlStateNormal]; } - (ZWTimer *)timer { if (!_timer) { _timer = [[ZWTimer alloc] init]; } return _timer; } @end