#import "YOUPAIHRChatRoomGuildBalanceVC.h" #import "IQActionSheetPickerView.h" #import "LZPickerWindow.h" #import "UIViewController+TFPresent.h" #import "PGPickerView.h" #import "YOUPAILZProfitListVC.h" #import "YOUPAIHRGuildDetailVC.h" @interface YOUPAIHRChatRoomGuildBalanceVC () @property (nonatomic, weak) UILabel *youpaipprofitL; // 收益的钻石 @property (nonatomic, weak) UILabel *youpaipprofitMoneyL; // 收益的钻石等于多少钱 @property (nonatomic, strong) UITextField *youpaipnameTextField; @property (nonatomic, strong) UITextField *youpaipaccountTextField; @property (nonatomic, strong) UILabel *youpaipmoneyLabel; @property (nonatomic, strong) UIButton *youpaipwithdrawBtn; @property(nonatomic,assign)NSInteger youpaipmin_money;//收益的余额 @property(nonatomic,assign)CGFloat youpaipincome_money;//收益的余额 @property(nonatomic,strong)NSMutableArray* youpaipmoneyArray; @property(nonatomic,strong)NSString* youpaipname;//真实姓名 @property(nonatomic,strong)NSString* youpaipaccount;//账号 @property(nonatomic,assign)NSInteger youpaipverify;//账户是否通过认证 @property (nonatomic, strong) NSString *youpaipselectedMoney; @end @implementation YOUPAIHRChatRoomGuildBalanceVC - (void)youpaifinitData{ [LCHttpHelper requestWithURLString:WalletWithdraw parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 self.youpaipverify = [[[dict objectForKey:@"data"]objectForKey:LCStr(word39)] integerValue]; self.youpaipmin_money = [[[dict objectForKey:@"data"]objectForKey:@"min_money"] integerValue]; self.youpaipmoneyArray = [[dict objectForKey:@"data"]objectForKey:@"list"]; self.youpaipaccount = [[dict objectForKey:@"data"]objectForKey:LCStr(word40)]; self.youpaipname = [[dict objectForKey:@"data"]objectForKey:LCStr(word41)]; self.youpaipincome_money = [[[dict objectForKey:@"data"]objectForKey:@"income_money"] floatValue]; [self youpaifupdateData]; }else{ [ZCHUDHelper showTitle:dict[@"message"]]; } }failure:^(NSError *error) { }]; } - (void)youpaifupdateData{ self.youpaipnameTextField.text = self.youpaipname; self.youpaipaccountTextField.text = self.youpaipaccount; if (self.youpaipaccount.length >0 && self.youpaipverify==1) { self.youpaipnameTextField.enabled = NO; self.youpaipaccountTextField.enabled = NO; }else{ self.youpaipnameTextField.enabled = YES; self.youpaipaccountTextField.enabled = YES; } if (self.youpaipincome_money>self.youpaipmin_money) { self.youpaipmoneyLabel.text = [NSString stringWithFormat:@"%zd",self.youpaipmin_money]; }else{ self.youpaipmoneyLabel.text = @"0"; } [self youpaifverifyWithdrawBtn]; } - (void)youpaifverifyWithdrawBtn{ if ( [self.youpaipnameTextField.text isEqualToString:@""]||[self.youpaipaccountTextField.text isEqualToString:@""]||[self.youpaipmoneyLabel.text isEqualToString:@""]){ [self.youpaipwithdrawBtn setBackgroundImage:nil forState:(UIControlStateNormal)]; self.youpaipwithdrawBtn.userInteractionEnabled = NO; }else{ [self.youpaipwithdrawBtn setBackgroundImage:[LCTools ColorImage:self.youpaipwithdrawBtn.frame.size FromColors:@[HexColorFromRGB(0xFFD33F),HexColorFromRGB(0xF37A19)] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)]; self.youpaipwithdrawBtn.userInteractionEnabled = YES; } } - (void)viewDidLoad { [super viewDidLoad]; self.youpaipmoneyArray = [NSMutableArray array]; self.title = LCStr(word9);//@"我的收益"; [self youpaifinitUI]; [self youpaifrequestWalleetInfo]; [self youpaifinitData]; } - (void)youpaifinitUI{ self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifprofitAction) title:@"查看明细" font:LCFont14 titleColor:HexColorFromRGB(0xffffff) highlightedColor:HexColorFromRGB(0xffffff) titleEdgeInsets:UIEdgeInsetsZero]; UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0.0f, NavBarHeight, KScreenWidth, KScreenHeight - NavBarHeight)]; scrollView.showsVerticalScrollIndicator = NO; scrollView.showsHorizontalScrollIndicator = NO; scrollView.delegate = self; [self.view addSubview:scrollView]; UIImageView *headerImgV = [[UIImageView alloc] init]; headerImgV.image = [UIImage imageNamed:@"vqu_images_profit_bg"]; [scrollView addSubview:headerImgV]; [headerImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.width.offset(KScreenWidth - 28.0f); make.top.offset(10.0f); make.height.offset(128.0f); }]; UILabel *profitDescL = [[UILabel alloc] init]; profitDescL.font = LCFont14; profitDescL.text = LCStr(word9);//@"我的收益"; profitDescL.textColor = [UIColor whiteColor]; [headerImgV addSubview:profitDescL]; [profitDescL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(28.0f); make.top.offset(31.0f); }]; UILabel *youpaipprofitL = [[UILabel alloc] init]; youpaipprofitL.font = LCFont(36.0f); youpaipprofitL.text = @"0"; youpaipprofitL.textColor = [UIColor whiteColor]; [headerImgV addSubview:youpaipprofitL]; self.youpaipprofitL = youpaipprofitL; [youpaipprofitL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(28.0f); make.top.equalTo(profitDescL.mas_bottom).offset(16.0f); }]; UILabel *youpaipprofitMoneyL = [[UILabel alloc] init]; youpaipprofitMoneyL.font = LCFont(17.0f); youpaipprofitMoneyL.text = @"= 0元"; youpaipprofitMoneyL.textColor = [UIColor whiteColor]; [headerImgV addSubview:youpaipprofitMoneyL]; self.youpaipprofitMoneyL = youpaipprofitMoneyL; [youpaipprofitMoneyL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(youpaipprofitL.mas_right).offset(8.0f); make.top.equalTo(youpaipprofitL.mas_centerY).offset(-6.0f); }]; UILabel *labe1 = [[UILabel alloc] init]; labe1.text = LCStr(word6);//@"请输入提现支付宝账户:"; labe1.textColor = HexColorFromRGB(0x9F9DA5); labe1.font = LCFont(12); [scrollView addSubview:labe1]; [labe1 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.top.equalTo(headerImgV.mas_bottom).offset(20.0f); }]; UIView *nameView = [[UIView alloc] initWithFrame:CGRectMake(12,CGRectGetMaxY(labe1.frame) + 12.0f,KScreenWidth-24,48)]; nameView.backgroundColor = HexColorFromRGB(0x2A2935); nameView.layer.cornerRadius = 5; nameView.layer.masksToBounds = YES; [scrollView addSubview:nameView]; [nameView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.top.equalTo(labe1.mas_bottom).offset(12.0f); make.width.offset(KScreenWidth - 28.0f); make.height.offset(48.0f); }]; UILabel* nameTipLabel = [[UILabel alloc]init]; nameTipLabel.text = @"真实姓名:"; nameTipLabel.textColor = [UIColor whiteColor]; nameTipLabel.font = LCFont14; [nameView addSubview:nameTipLabel]; [nameTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(12.0f); make.top.bottom.offset(0.0f); make.width.offset(80.0f); }]; UITextField* youpaipnameTextField = [[UITextField alloc]init]; self.youpaipnameTextField = youpaipnameTextField; youpaipnameTextField.tintColor = ZYPinkColor; youpaipnameTextField.textColor = [UIColor whiteColor]; youpaipnameTextField.clearButtonMode = UITextFieldViewModeWhileEditing; [[youpaipnameTextField valueForKey:@"_clearButton"] setImage:[UIImage imageNamed:@"vqu_images_D_nick_clean"] forState:UIControlStateNormal]; [youpaipnameTextField addTarget:self action:@selector(textFieldDidEditing:) forControlEvents:UIControlEventEditingChanged]; NSMutableAttributedString* attrStrName = [[NSMutableAttributedString alloc]initWithString:LCStr(word42)];//@"请输入支付宝实名认证名字" [attrStrName addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, attrStrName.length)]; [attrStrName addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0x6C6B70) range:NSMakeRange(0, attrStrName.length)]; youpaipnameTextField.attributedPlaceholder = attrStrName; [nameView addSubview:youpaipnameTextField]; [youpaipnameTextField mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(nameTipLabel.mas_right).offset(0.0f); make.top.bottom.offset(0.0f); make.right.offset(-12.0f); }]; UIView *accountView = [[UIView alloc] init]; accountView.backgroundColor = HexColorFromRGB(0x2A2935); accountView.layer.cornerRadius = 5; accountView.layer.masksToBounds = YES; [scrollView addSubview:accountView]; [accountView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.top.equalTo(nameView.mas_bottom).offset(7.0f); make.width.offset(KScreenWidth - 28.0f); make.height.offset(48.0f); }]; UILabel* accountTipLabel = [[UILabel alloc]init]; accountTipLabel.text = LCStr(word7);//@"支付宝账号:"; accountTipLabel.textColor = [UIColor whiteColor]; accountTipLabel.font = LCFont14; [accountView addSubview:accountTipLabel]; [accountTipLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(12.0f); make.top.bottom.offset(0.0f); make.width.offset(94.0f); }]; UITextField* youpaipaccountTextField = [[UITextField alloc]init]; self.youpaipaccountTextField = youpaipaccountTextField; youpaipaccountTextField.tintColor = ZYPinkColor; youpaipaccountTextField.textColor = [UIColor whiteColor]; youpaipaccountTextField.clearButtonMode = UITextFieldViewModeWhileEditing; [[youpaipaccountTextField valueForKey:@"_clearButton"] setImage:[UIImage imageNamed:@"vqu_images_D_nick_clean"] forState:UIControlStateNormal]; [youpaipaccountTextField addTarget:self action:@selector(textFieldDidEditing:) forControlEvents:UIControlEventEditingChanged]; NSMutableAttributedString* attrStrAccount = [[NSMutableAttributedString alloc]initWithString:LCStr(word8)];//请输入支付宝账号 [attrStrAccount addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(0, attrStrAccount.length)]; [attrStrAccount addAttribute:NSForegroundColorAttributeName value:HexColorFromRGB(0x6C6B70) range:NSMakeRange(0, attrStrAccount.length)]; youpaipaccountTextField.attributedPlaceholder = attrStrAccount; [accountView addSubview:youpaipaccountTextField]; [youpaipaccountTextField mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(accountTipLabel.mas_right).offset(0.0f); make.top.bottom.offset(0.0f); make.right.offset(-12.0f); }]; UILabel* botLabel = [[UILabel alloc]init]; botLabel.text = LCStr(word26);//@"注:真实姓名需与支付宝实名认证相同,否则无法到账"; botLabel.textColor = HexColorFromRGB(0x6C6B70); botLabel.font = LCFont(10); botLabel.textAlignment = NSTextAlignmentLeft; [scrollView addSubview:botLabel]; [botLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.top.equalTo(accountView.mas_bottom).offset(7.0f); }]; UILabel* moneyTip = [[UILabel alloc]init]; moneyTip.textColor = HexColorFromRGB(0x9F9DA5); moneyTip.font = LCFont(12); moneyTip.text =LCStr(word17);//请输入提现金额(元): [scrollView addSubview:moneyTip]; [moneyTip mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.top.equalTo(botLabel.mas_bottom).offset(28.0f); }]; UIView *monView = [[UIView alloc] init]; monView.layer.cornerRadius = 5; monView.layer.masksToBounds = YES; monView.backgroundColor = HexColorFromRGB(0x2A2935); [scrollView addSubview:monView]; [monView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.width.offset(KScreenWidth - 28.0f); make.height.offset(54.0f); make.top.equalTo(moneyTip.mas_bottom).offset(12.0f); }]; UILabel* monFL = [[UILabel alloc]init]; monFL.textAlignment = NSTextAlignmentCenter; monFL.textColor = [UIColor whiteColor]; monFL.font = LCBoldFont(25); monFL.text = @"¥"; [monView addSubview:monFL]; [monFL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(12.0f); make.top.bottom.offset(0.0f); make.width.offset(23.0f); }]; UILabel* monValue = [[UILabel alloc]init]; monValue.textColor = [UIColor whiteColor]; monValue.font = LCBoldFont(25); monValue.text = @"0"; monValue.userInteractionEnabled = YES; [monView addSubview:monValue]; [monValue mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(monFL.mas_right).offset(7.0f); make.top.bottom.offset(0.0f); make.right.offset(-12.0f); }]; UITapGestureRecognizer* monTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(youpaifmonValueHandel:)]; [monValue addGestureRecognizer:monTap]; self.youpaipmoneyLabel = monValue; UILabel* botTipL = [[UILabel alloc] init]; botTipL.textColor = HexColorFromRGB(0x6C6B70); botTipL.font = LCFont(10); botTipL.numberOfLines= 0; [scrollView addSubview:botTipL]; botTipL.text =LCStr(word27);// @"1.每天可提交一次申请,1~3个工作日到账(节假日顺延);\n2.100元以下收取2%的手续费,100~500元收取1%的手续费,500元以上免手续费。"; [botTipL mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(14.0f); make.width.offset(KScreenWidth - 28.0f); make.top.equalTo(monView.mas_bottom).offset(7.0f); }]; UIButton* youpaipwithdrawBtn = [[UIButton alloc]initWithFrame:CGRectMake(60, CGRectGetMaxY(botTipL.frame)+45.0f, KScreenWidth-120, 48)]; youpaipwithdrawBtn.uxy_acceptEventInterval = 3.0; youpaipwithdrawBtn.userInteractionEnabled = NO; youpaipwithdrawBtn.backgroundColor = HexColorFromRGB(0x4F4B5B); youpaipwithdrawBtn.layer.cornerRadius = 24.0; youpaipwithdrawBtn.layer.masksToBounds = YES; youpaipwithdrawBtn.titleLabel.font = LCFont16; [youpaipwithdrawBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)]; [youpaipwithdrawBtn setTitle:LCStr(word18) forState:(UIControlStateNormal)];//确认提现 [youpaipwithdrawBtn addTarget:self action:@selector(youpaifapplyWithdraw) forControlEvents:(UIControlEventTouchUpInside)]; [scrollView addSubview:youpaipwithdrawBtn]; [youpaipwithdrawBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.offset(40.0f); make.width.offset(KScreenWidth - 80.0f); make.top.equalTo(botTipL.mas_bottom).offset(45.0f); make.height.offset(48.0f); }]; self.youpaipwithdrawBtn = youpaipwithdrawBtn; [scrollView layoutIfNeeded]; CGFloat height = CGRectGetMaxY(self.youpaipwithdrawBtn.frame) + 40.0f + SafeHeight; if (height < KScreenHeight - NavBarHeight) { height = KScreenHeight - NavBarHeight + 1; } scrollView.contentSize = CGSizeMake(KScreenWidth, height); } - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ [self.view endEditing:YES]; } - (void)youpaifprofitAction{ // YOUPAILZProfitListVC *vc = [[YOUPAILZProfitListVC alloc] init]; // [self.navigationController pushViewController:vc animated:YES]; YOUPAIHRGuildDetailVC *vc = [YOUPAIHRGuildDetailVC new]; [self.navigationController pushViewController:vc animated:YES]; } - (void)youpaifselectMoney:(NSString*)str{ LZPickerWindow *vc = [[LZPickerWindow alloc] init]; vc.isTouchDismiss = YES; vc.delegate = self; [self TFPresentVC:vc completion:^{}]; vc.pickerView.dataSource = self; vc.pickerView.delegate = self; if (self.youpaipmoneyArray.count != 0) { self.youpaipselectedMoney = [NSString stringWithFormat:@"%@",self.youpaipmoneyArray[0]]; } } #pragma mark - PGPickerViewDataSource // returns the number of 'columns' to display. - (NSInteger)numberOfComponentsInPickerView:(PGPickerView *)pickerView{ return 1; } // returns the # of rows in each component.. - (NSInteger)pickerView:(PGPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ return self.youpaipmoneyArray.count; } - (NSString *)pickerView:(PGPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ return [NSString stringWithFormat:@"%@",self.youpaipmoneyArray[row]]; } #pragma mark - PGPickerViewDelegate - (void)pickerView:(PGPickerView *)pickerView title:(NSString *)title didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ self.youpaipselectedMoney = title; } #pragma mark - LZPickerWindowDelegate - (void)confirmClick{ NSString* str= self.youpaipselectedMoney; if (self.youpaipincome_money< [str integerValue]) { [ZCHUDHelper showTitle:LCStr(word10)];//@"提现金额不能大于收益的余额" }else{ self.youpaipmoneyLabel.text = str; [self youpaifverifyWithdrawBtn]; } } - (void)actionSheetPickerView:(IQActionSheetPickerView *)pickerView didSelectTitles:(NSArray *)titles{ if (pickerView.tag==1) { NSString* str= [titles lastObject]; if (self.youpaipincome_money< [str integerValue]) { [ZCHUDHelper showTitle:LCStr(word10)];//@"提现金额不能大于收益的余额" }else{ self.youpaipmoneyLabel.text = str; [self youpaifverifyWithdrawBtn]; } } } - (void)youpaifmonValueHandel:(UITapGestureRecognizer*)tap{ if (tap.state == UIGestureRecognizerStateEnded) { UILabel* lab = (UILabel*)tap.view; NSInteger num = [lab.text integerValue]; if (num>0) { [self youpaifselectMoney:lab.text]; }else{ [ZCHUDHelper showTitle:[NSString stringWithFormat:@"%@%zd",LCStr(word11),self.youpaipmin_money]];//可提现余额小于最小可提现金额 } } } - (void)youpaifapplyWithdraw{ if (self.youpaipaccount.length >0 && self.youpaipverify==1) { //账户已绑定 直接提现 [LCHttpHelper requestWithURLString:WithDrawApply parameters:@{@"money":self.youpaipmoneyLabel.text} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [ZCHUDHelper showTitle: LCStr(word19)];//提现已申请成功,请耐心等待 [self.navigationController popViewControllerAnimated:YES]; } }failure:^(NSError *error) { }]; }else{ //先绑定账户再提现 [LCHttpHelper requestWithURLString:WalletZFBBind parameters:@{@"card_account":self.youpaipaccountTextField.text,@"card_name":self.youpaipnameTextField.text} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [LCHttpHelper requestWithURLString:WithDrawApply parameters:@{@"money":self.youpaipmoneyLabel.text} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 [ZCHUDHelper showTitle:LCStr(word19)];//提现已申请成功,请耐心等待 [self.navigationController popViewControllerAnimated:YES]; } }failure:^(NSError *error) { }]; } }failure:^(NSError *error) { }]; } } -(void)textFieldDidEditing:(UITextField *)textField{ if ( [self.youpaipnameTextField.text isEqualToString:@""]||[self.youpaipaccountTextField.text isEqualToString:@""]||[self.youpaipmoneyLabel.text isEqualToString:@""]){ [self.youpaipwithdrawBtn setBackgroundImage:nil forState:(UIControlStateNormal)]; self.youpaipwithdrawBtn.userInteractionEnabled = NO; }else{ [self.youpaipwithdrawBtn setBackgroundImage:[LCTools ColorImage:self.youpaipwithdrawBtn.frame.size FromColors:@[HexColorFromRGB(0xFFD33F),HexColorFromRGB(0xF37A19)] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)]; self.youpaipwithdrawBtn.userInteractionEnabled = YES; } } #pragma mark - Request - (void)youpaifrequestWalleetInfo{ [LCHttpHelper requestWithURLString:WalletInit parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code==0) {//成功 NSString *incomeCoin = [[[dict objectForKey:@"data"]objectForKey:@"account"]objectForKey:@"income_coin"]; NSString *incomeMoney = [[[dict objectForKey:@"data"]objectForKey:@"account"]objectForKey:@"income_coin_money"]; self.youpaipprofitL.text = [NSString stringWithFormat:@"%@",incomeCoin]; self.youpaipprofitMoneyL.text = [NSString stringWithFormat:@"= %@元",incomeMoney]; } } failure:^(NSError *error) { }]; } @end