//
//  ProductRechargeController.m
//  Open
//
//  Created by 雷俊博 on 2020/8/5.
//  Copyright © 2020 黄江涛 . All rights reserved.
//

#import "ProductRechargeController.h"
#import "RechargeTopView.h"
#import "RechargeInputView.h"
#import "UIView+frameAdjust.h"
#import "ProductPurchasePayWayView.h"
#import <YYLabel.h>
#import <YYText.h>
#import "RechargeSuccessController.h"
#import "SaveBankModel.h"

#import "SMSVerificationController.h"
#import "KBankListModel.h"
#import "BCOPAccAgreementModel.h"
#import "AgreementPresentView.h"



@interface ProductRechargeController ()<UITextFieldDelegate>

@property (nonatomic, strong)UIScrollView* scrollView;

@property (nonatomic, strong)RechargeTopView* topView;

@property (nonatomic, strong)RechargeInputView* valueView;

@property (nonatomic, assign)BOOL textIsEmpty;

@property (nonatomic, strong)UIButton* payBtn;

@property (nonatomic, strong)UIButton* xieyiBtn;

@property (nonatomic, strong)NSArray* agreementArray;

@end

@implementation ProductRechargeController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:0 target:nil action:nil];
    [self.navigationItem setBackBarButtonItem:bar];
    
    [GTCountSDK trackCountEvent:@"save_wudangProductRechargeCount" withArgs:@{}];//个推统计
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.scrollView];
    
    [self creatBottomView];
    
    //初始化
    self.textIsEmpty = YES;
    [self setButtonState];
    
    if (self.type == SaveFromTypeYinShu) {
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(refreshBalanceData) name:KKSBGETBalanceNotificationName object:nil];
    }else {
        [self getAllRechargeAgreementRequest];
    }
}

- (void)creatBottomView {
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight - 148 * WIDTHRADIU, ScreenWidth, 148 * WIDTHRADIU)];
    view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view];
    
    
    UIButton* xieyiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [xieyiBtn addTarget:self action:@selector(xieyiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [xieyiBtn setImage:[UIImage imageNamed:@"xieyi_unselected"] forState:UIControlStateNormal];
    self.xieyiBtn = xieyiBtn;
    
    
    UIColor *color = [UIColor colorWithHex:0xcccccc];
    NSDictionary *attributes = @{NSFontAttributeName:[UIFont fontWithName:@"PingFangSC-Regular" size:12], NSForegroundColorAttributeName: color};
    
    NSMutableAttributedString *text1 = [[NSMutableAttributedString alloc] initWithString:@"我已阅读相关协议，理解其内容并承担相关风险" attributes:attributes];
    //设置高亮色和点击事件
    [text1 yy_setTextHighlightRange:[[text1 string] rangeOfString:@"相关协议"] color:[UIColor colorWithHex:0x137ef6] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
        NSLog(@"点击了《用户协议》");
        
        if (!self.agreementArray) {
            [self getAllRechargeAgreementRequest];
        }else{
            [AgreementPresentView showBankListWithVC:self type:AgreementPresentViewTypeBiCai bankArray:self.agreementArray block:^(BCSubModel*  _Nonnull model) {
                NSString* name = model.agreementTitle;
                NSString* url = model.agreementUrl;
                [self jumpToWebVCWithUrl:url title:name];
            }];
        }
       
    }];
    
    YYLabel* lb_xieyi = [YYLabel new];
    lb_xieyi.attributedText = text1;
    lb_xieyi.textAlignment = NSTextAlignmentLeft;
   
    //确认充值
    UIButton* payBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    payBtn.backgroundColor = [UIColor colorWithHex:0x137ef6];
    [payBtn setTitle:@"充值" forState:UIControlStateNormal];
    [payBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    payBtn.layer.cornerRadius = 5;
    [payBtn addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:payBtn];
    
    self.payBtn = payBtn;
    
    //提示
    YYLabel *label = [YYLabel new];
    [view addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset( cl_kNavigationBarHeight > 64 ? -20 * WIDTHRADIU  : 0);
        make.left.mas_equalTo(10 * WIDTHRADIU);
        make.width.mas_equalTo(ScreenWidth - 20 * WIDTHRADIU);
        //make.height.mas_equalTo(15);
    }];
    
    
    [payBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(label.mas_top).offset( - 10 * WIDTHRADIU);
        make.left.mas_equalTo(10 * WIDTHRADIU);
        make.width.mas_equalTo(ScreenWidth - 20 * WIDTHRADIU);
        make.height.offset(45);
    }];
    
    
    if (self.type == SaveFromTypeBiCai) {
        [view addSubview:xieyiBtn];
        [view addSubview:lb_xieyi];
        
        [xieyiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(payBtn.mas_top).offset(-10 * WIDTHRADIU);
            make.left.offset(0);
            make.width.offset(40 * WIDTHRADIU);
            make.height.offset(30 * WIDTHRADIU);
        }];
        
        [lb_xieyi mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(xieyiBtn.mas_right).offset(8 * WIDTHRADIU);
            make.right.offset(-10 * WIDTHRADIU);
            make.centerY.equalTo(xieyiBtn);
        }];
        
        
    }else if (self.type == SaveFromTypeYinShu) {
    }
    
    
   
    
    
    
   
   
    
    if (self.type == SaveFromTypeYinShu) {
        //1. 创建属性字符串。
       UIColor *color = [UIColor colorWithHex:0x808080];
        NSDictionary *attributes = @{NSFontAttributeName:[UIFont fontWithName:@"PingFangSC-Regular" size:12], NSForegroundColorAttributeName: color};
        
        NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"如有疑问，请联系银行客服" attributes:attributes];
        //设置高亮色和点击事件
        [text yy_setTextHighlightRange:[[text string] rangeOfString:@"请联系银行客服"] color:[UIColor colorWithHex:0x137ef6] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
            NSLog(@"点击了《用户协议》");
            NSLog(@"打电话");
            NSString *callPhone = @"telprompt:400-686-8707";
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
        }];
        
        label.attributedText = text;
    }else if (self.type == SaveFromTypeBiCai) {
       
        
        
        //1. 创建属性字符串。
       UIColor *color = [UIColor colorWithHex:0x808080];
        NSDictionary *attributes = @{NSFontAttributeName:[UIFont fontWithName:@"PingFangSC-Regular" size:12], NSForegroundColorAttributeName: color};
        
        NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"如有疑问，请联系银行客服" attributes:attributes];
        //设置高亮色和点击事件
        [text yy_setTextHighlightRange:[[text string] rangeOfString:@"请联系银行客服"] color:[UIColor colorWithHex:0x137ef6] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
            NSLog(@"点击了《用户协议》");
            NSLog(@"打电话");
            if (self.bcInfoModel.custServiceHotLine.count !=0) {
                NSString *callPhone = [NSString stringWithFormat:@"telprompt:%@",self.bcInfoModel.custServiceHotLine[0]];
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
            }else{
                [Tools showMessage:@"暂无客服电话"];
            }
            
        }];
        
        label.attributedText = text;
    }
    
    label.textAlignment = NSTextAlignmentCenter;
    
}

#pragma mark - 比财充值协议
- (void)getAllRechargeAgreementRequest
{
    NSString* url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipYinShuConfig],BCQueryRechargeAgreementsRequest];
    NSMutableDictionary *params = [NetworkPublicParams getBCPublicParams];
    [params setObject:[getPeopleID PeopleIphoneNmber] forKey:@"loginPhoneNum"];
    [params setObject:self.bcInfoModel.orgId forKey:@"orgId"];
    
    NSLog(@"比财充值协议url:%@",url);
    NSLog(@"params:%@",params);
    
    
    [NetworkRequest Post6:url Params:params Success:^(id _Nonnull objc) {
        NSLog(@"objc:%@",objc);
        NSString *state = [NSString stringWithFormat:@"%@",objc[@"state"]];
        NSString *describe = [NSString stringWithFormat:@"%@",objc[@"describe"]];
        if ([state isEqualToString:@"200"]) {
            self.agreementArray = [BCSubModel mj_objectArrayWithKeyValuesArray:objc[@"result"][@"agreementList"]];
            
            
            
            
        }else{
            [self alertShow:describe];
        }

    } Failure:^(NSError* error) {
        
        NSLog(@"error:%@",error);
        
        [Tools showMessage:@"网络出小差了,请稍后重试"];
        
    }];
}

#pragma mark - 通知绑定方法
- (void)refreshBalanceData
{
    [self getPayAccountInfoRequest];
}

#pragma mark - 获取支付账户信息
- (void)getPayAccountInfoRequest
{
    NSString* url = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipYinShuConfig],YSGETAccountInfoRequest];
    
    SaveAccountSubUserInfoModel*infoModel = self.infoModel.SUBPACKS[0];
    
    NSDictionary*params = @{
        @"accNo": infoModel.CARDNBR
    };
    
    NSLog(@"银数账户查询余额url:%@",url);
    NSLog(@"params:%@",params);
    
    [KKLoadingAnimationView show];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    NSString *strHeader = [NSString stringWithFormat:@"IOS#%@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];
    NSLog(@"strHeader:%@",strHeader);
    [manager.requestSerializer setValue:strHeader forHTTPHeaderField:@"User-Agent"];
       
    [manager POST:url parameters:params headers:nil progress:^(NSProgress * _Nonnull uploadProgress) {
       
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
       [KKLoadingAnimationView dismiss];
       NSLog(@"responseObject:%@",responseObject);
        NSString*state = [NSString stringWithFormat:@"%@",responseObject[@"state"]];
        NSString* result = [NSString stringWithFormat:@"%@",responseObject[@"result"]];
        NSString*describe = [NSString stringWithFormat:@"%@",responseObject[@"describe"]];
        if ([state isEqualToString:@"200"]) {
            NSDictionary*dic = [Tools dencode:result];
            NSLog(@"result:%@",[Tools dencode:result]);
            self.cardModel = [SaveAccountCardInfo mj_objectWithKeyValues:dic];
            [self refreshPayViewData];
        }else{
            NSDictionary*dic = [Tools dictionaryWithJsonString:describe];
            NSLog(@"describe:%@",dic);
            NSString*code = nil;
            NSString*message = nil;
            if (![Tools isBlankString:[NSString stringWithFormat:@"%@",dic[@"code"]]]) {
                code = [NSString stringWithFormat:@"%@",dic[@"code"]];
            }else if (![Tools isBlankString:[NSString stringWithFormat:@"%@",dic[@"RETCODE"]]]){
                code = [NSString stringWithFormat:@"%@",dic[@"RETCODE"]];
            }
            
            if (code) {
                message = [KBankErrorCode showErrorMessageWithErrorCode:code];
                
                if (message) {
                    [SVProgressHUD showErrorWithStatus:message];
                }else{
                    [SVProgressHUD showErrorWithStatus:@"系统错误"];
                }
            }else{
                [SVProgressHUD showErrorWithStatus:@"系统错误"];
            }
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
       [KKLoadingAnimationView dismiss];
       NSLog(@"error:%@",error);
        [SVProgressHUD showInfoWithStatus:@"网络异常"];
    }];
}

#pragma mark - 刷新数据
- (void)refreshPayViewData
{
    [self.topView setMoneyWithMoney:[NSString stringWithFormat:@"%.2f",self.cardModel.AVAIL_BAL.doubleValue]];
}
#pragma mark - UITextFieldDelegate
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    NSMutableString * changedString=[[NSMutableString alloc] initWithString:textField.text];
    [changedString replaceCharactersInRange:range withString:string];
  
    NSString * str = [NSString stringWithFormat:@"%@%@",textField.text,string];
    //匹配以0开头的数字
    NSPredicate * predicate0 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",@"^[0][0-9]+$"];
    //匹配两位小数、整数
    NSPredicate * predicate1 = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",@"(\\+|\\-)?(([0]|(0[.]\\d{0,3}))|([1-9]\\d{0,7}(([.]\\d{0,0})?)))?"];
    BOOL sucess = ![predicate0 evaluateWithObject:str] && [predicate1 evaluateWithObject:str] &&[self validateNumber:string] ? YES : NO;
    
    
    if (sucess) {
        if (changedString.length == 0) {
             self.textIsEmpty = YES;
         }else{
             self.textIsEmpty = NO;
         }

        // 实时监测文本框的编辑状态
         [self setButtonState];
    }
    
    return sucess;
}


- (BOOL)validateNumber:(NSString*)number {
    BOOL res = YES;
    NSCharacterSet* tmpSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
    int i = 0;
    while (i < number.length) {
        NSString * string = [number substringWithRange:NSMakeRange(i, 1)];
        NSRange range = [string rangeOfCharacterFromSet:tmpSet];
        if (range.length == 0) {
            res = NO;
            break;
        }
        i++;
    }
    return res;
}

#pragma mark - 刷新按钮状态
- (void)setButtonState {
    if (self.textIsEmpty == NO) {
        self.payBtn.userInteractionEnabled = YES;
        self.payBtn.alpha = 1;
    } else {
        self.payBtn.userInteractionEnabled = NO;
        self.payBtn.alpha = 0.5;
    }
}

#pragma mark - public methods
-(id)getXiblWithClassName:(NSString *)className
{
    return [[NSBundle mainBundle]loadNibNamed:className owner:self options:nil].lastObject;
}

#pragma mark - 跳转web页面
- (void)jumpToWebVCWithUrl:(NSString *)url title:(NSString *)title
{
    if (self.type == SaveFromTypeYinShu) {
        
        url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        
    }else if (self.type == SaveFromTypeBiCai) {
        
        NSArray* urlArray = [url componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"?"]];
        url = nil;
        
        for (int i = 0; i < urlArray.count; i++) {
            if (i == 0) {
                url = urlArray[0];
            }else{
                if (i == (urlArray.count - 1)) {
                    url = [url stringByAppendingFormat:@"?%@",[urlArray[i] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
                }else{
                    url = [NSString stringWithFormat:@"%@?%@",url,urlArray[i]];
                }
            }
        }
        
    }
    
    WebVC * vc = [WebVC new];
    vc.title= title;
    vc.url = url;
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}


#pragma mark - event response
- (void)payBtnClick:(UIButton *)sender
{
    
    if (self.type == SaveFromTypeYinShu) {
        [GTCountSDK trackCountEvent:@"save_rechargeSMSCount" withArgs:@{}];
        
        SMSVerificationController*vc = [SMSVerificationController new];
        vc.title = @"充值短信验证";
        vc.infoModel = self.infoModel;
        vc.amount = self.valueView.tf_count.text;
        vc.type = SMSSendTypeRecharge;
        [self.navigationController pushViewController:vc animated:YES];
        return;
    }else if (self.type == SaveFromTypeBiCai) {
        if (self.xieyiBtn.selected == NO) {
            [Tools showMessage:@"充值前请先同意充值协议"];
            return;
        }
        
        SMSVerificationController*vc = [SMSVerificationController new];
        vc.title = @"充值短信验证";
        vc.bcAccountInfoModel = self.bcInfoModel;
        vc.amount = self.valueView.tf_count.text;
        vc.type = SMSSendTypeBCRecharge;
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}

- (void)xieyiBtnClick:(UIButton *)sender
{

    sender.selected = !sender.selected;
    
    if (sender.selected) {
        [sender setImage:[UIImage imageNamed:@"xieyi_selected"] forState:UIControlStateNormal];
    }else {
        [sender setImage:[UIImage imageNamed:@"xieyi_unselected"] forState:UIControlStateNormal];
    }
}

- (void)alertShow:(NSString *)msg
{
    if (@available(iOS 9.0,*)) {
        
        UIAlertController * alertV = [UIAlertController alertControllerWithTitle:@"提示" message:msg preferredStyle:UIAlertControllerStyleAlert];
        
        UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        
        [alertV addAction:confirm];
        
        [self presentViewController:alertV animated:YES completion:nil];
        
    }else{
        UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
        [alertV show];
    }
}


#pragma mark - 根据银行卡号判断银行名称
//根据卡号判断银行
- (NSString *)returnBankName:(NSString *)cardName {
    
    
    if (cardName.length < 6) {
        return @"";
    }
    NSString*bankName = [KBankListModel getBankNameWithStr:cardName];
    
    return bankName;
    
}

#pragma mark - getters
- (UIScrollView *)scrollView
{
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, cl_kNavigationBarHeight, ScreenWidth, ScreenHeight - cl_kNavigationBarHeight - 145 * WIDTHRADIU)];
        _scrollView.showsVerticalScrollIndicator = NO;
        //_scrollView.delegate = self;
        _scrollView.contentSize = CGSizeMake(ScreenWidth, 0);
        _scrollView.backgroundColor  = [UIColor colorWithHex:0xf4f4f4];
        
        //银行信息
        RechargeTopView* topView = [[RechargeTopView alloc]init];
        
        
        
        [_scrollView addSubview:topView];
        
        self.topView = topView;

        //充值金额
        RechargeInputView* valueView = [self getXiblWithClassName:@"RechargeInputView"];
        valueView.tf_count.delegate = self;
        [_scrollView addSubview:valueView];
        [valueView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(topView.mas_bottom).offset(0);
            make.left.mas_equalTo(0);
            make.width.mas_equalTo(ScreenWidth);
            make.height.mas_greaterThanOrEqualTo(50);
        }];
        
        self.valueView = valueView;


        //支付方式
        ProductPurchasePayWayView* payView = [self getXiblWithClassName:@"ProductPurchasePayWayView"];
        
        
        
        payView.rechargeBtn.hidden = YES;
        
        [_scrollView addSubview:payView];
        [payView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(valueView.mas_bottom);
            make.left.mas_equalTo(0);
            make.width.mas_equalTo(ScreenWidth);
            make.height.mas_greaterThanOrEqualTo(50);
        }];
        
        
       
        
        
        
        if (self.type == SaveFromTypeYinShu) {
            topView.lb_number.text = [NSString stringWithFormat:@"****  %@",[self.cardModel.CARDNBR substringFromIndex:self.cardModel.CARDNBR.length - 4]];
            
            [topView setMoneyWithMoney:[NSString stringWithFormat:@"%.2f",self.cardModel.AVAIL_BAL.doubleValue]];
            
            SaveAccountSubUserInfoModel*kModel = self.infoModel.SUBPACKS[0];
            
            NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"wdBankList"ofType:@"plist"];
            NSArray*array = [NSArray arrayWithContentsOfFile:plistPath];
            SaveBankModel*model = [SaveBankModel new];
            for (NSDictionary*dic in array) {
                if ([[self returnBankName:kModel.SIGCARD] isEqualToString:dic[@"bankName"]]) {
                    model = [SaveBankModel new];
                    model.bankName = dic[@"bankName"];
                    model.bankImage = dic[@"bankImage"];
                    model.orderMin = dic[@"orderMin"];
                    model.dMin = dic[@"dMin"];
                    break;
                }
            }
            
            payView.lb_bankName.text =[NSString stringWithFormat:@"%@(%@)",[self returnBankName:kModel.SIGCARD],[kModel.SIGCARD substringFromIndex:(kModel.SIGCARD.length - 4)]];
            if ([Tools isBlankString:model.orderMin]) {
                payView.lb_amount.text = @"单笔扣款限额1000万元,每日扣款限额1000万元";
            }else{
                payView.lb_amount.text = [NSString stringWithFormat:@"单笔扣款限额%@万元,每日扣款限额%@万元",model.orderMin,model.dMin];
            }
            
            if ([Tools isBlankString:model.bankImage]) {
                payView.icon.image = [UIImage imageNamed:@"bank_wudang"];
            }else{
                payView.icon.image = [UIImage imageNamed:model.bankImage];
            }
            

        }else if (self.type == SaveFromTypeBiCai) {
            topView.lb_mark.text = [self.bcInfoModel.orgName substringToIndex:1];
            topView.lb_bankName.text = self.bcInfoModel.orgName;
            topView.lb_number.text = [NSString stringWithFormat:@"****  %@",[self.bcInfoModel.bankElecAccountNum substringFromIndex:self.bcInfoModel.bankElecAccountNum.length - 4]];
            
            [topView setMoneyWithMoney:[NSString stringWithFormat:@"%.2f",self.bcInfoModel.balance.doubleValue]];
            
            
            valueView.tf_count.placeholder = [NSString stringWithFormat:@"充值%d元起",self.bcInfoModel.chargeMinLimitAmt.intValue];
            
            if (self.bcInfoModel.cardList.count > 0) {
                BCCardListModel *ccmodel = self.bcInfoModel.cardList[0];
                payView.lb_bankName.text =[NSString stringWithFormat:@"%@%@",ccmodel.bankName,ccmodel.lastFourCardNo];
                
                NSString *singleDes = nil;
                
                NSString *dayDesc = nil;
                
                if ([Tools isBlankString:ccmodel.bankCardQuotaDescDto.singleDedctDesc]) {
                    singleDes = @"单笔扣款无限额";
                }else{
                    singleDes = ccmodel.bankCardQuotaDescDto.singleDedctDesc;
                }
                
                if ([Tools isBlankString:ccmodel.bankCardQuotaDescDto.dayDedctDesc]) {
                    dayDesc = @"每日扣款无限额";
                }else{
                    dayDesc = ccmodel.bankCardQuotaDescDto.dayDedctDesc;
                }
                
                payView.lb_amount.text = [NSString stringWithFormat:@"%@,%@",singleDes,dayDesc];
                [payView.icon sd_setImageWithURL:[NSURL URLWithString:ccmodel.bankLogoUrl] completed:nil];
            }
           
        }
        //_scrollView.contentSize = CGSizeMake(ScreenWidth, topView.maxY + 10);
    }
    return _scrollView;
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter]removeObserver:self name:KKSBGETBalanceNotificationName object:nil];
}
/*
#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.
}
*/

@end
