// // KXMainDetailViewController.m // QBCS // // Created by kuxuan on 2017/6/6. // Copyright © 2017年 kuxuan. All rights reserved. // #import "KXMainDetailViewController.h" #import "KXMainDetailModel.h" #import "KXMainDetailThreeView.h" #import "KXMainDetailTableViewCell.h" #import "KXQuesViewController.h" #import "KXSelectTableViewCell.h" #import "KXWebDetailViewController.h" #import "KXLogginViewController.h" #import "KXUpDownButton.h" #import "KXRecommendView.h" #import "KXMainPageViewModel.h" #import "KXLittleLogginView.h" @interface KXMainDetailViewController () { UIView *_headerView; UIView *_footerView; KXMainDetailModel *_detailModel; UITextField *_amountTF; UIButton *_dateButton; NSArray *_titleArray; NSArray *_detailImageArr; UIView *_selectView; KXUpDownButton *_updownButton; BOOL _isSpread; KXRecommendView *_recommendView; UIButton *_applyButton; } @property (nonatomic,strong)UITableView *tableView; @property (nonatomic,strong)UITableView *selectTableView; @property (nonatomic,strong)MBProgressHUD *hud; @end @implementation KXMainDetailViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. _titleArray=@[@"申请条件",@"所需资料",@"详细说明"]; _detailImageArr = @[@"main_detail_term",@"main_detail_data",@"main_detail_explain"]; _isSpread = NO; if (self.enterSource == nil) { self.enterSource = @""; } [self createNavigation]; [self requestData]; } -(void)createNavigation { self.name = self.titleString; [self addLeftBarButtonItemWithImageName:@"main_back" title:nil target:self selector:@selector(pop)]; if (_detailModel.customer_service_number.length) { [self addRightBarButtonItemWithImageName:@"main_detail_phone" target:self selector:@selector(phone) redDot:NO]; } } -(void)pop { if (self.isPresent == YES) { [self.navigationController dismissViewControllerAnimated:YES completion:nil]; } else{ [self.navigationController popViewControllerAnimated:YES]; } } -(void)phone { NSString *phoneNumber = [NSString stringWithFormat:@"tel:%@",_detailModel.customer_service_number]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"%@客服电话",_detailModel.name] message:_detailModel.customer_service_number preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { }]]; [alert addAction:[UIAlertAction actionWithTitle:@"呼叫" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:phoneNumber]]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]]; } }]]; [self presentViewController:alert animated:YES completion:nil]; } -(void)setBottomView { UIView *bottomView=[[UIView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-62-NavHeight-safeBottomHeight, SCREEN_WIDTH, 62)]; [self.view addSubview:bottomView]; _applyButton=[UIButton buttonWithType:UIButtonTypeCustom]; _applyButton.layer.cornerRadius=3; _applyButton.layer.masksToBounds=YES; _applyButton.frame=CGRectMake(LEADING_SPACE, 8, SCREEN_WIDTH-2*LEADING_SPACE, 46); [_applyButton setBackgroundColor:[UIColor baseColor]]; [_applyButton setTitle:@"立即申请" forState:UIControlStateNormal]; [_applyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [_applyButton addTarget:self action:@selector(applyAction) forControlEvents:UIControlEventTouchUpInside]; [bottomView addSubview:_applyButton]; BOOL isEnable = [_detailModel.status integerValue] == 1? YES:NO; if(isEnable == NO) { [_applyButton setBackgroundColor:[UIColor grayColor]]; [_applyButton setTitle:@"已下架" forState:UIControlStateNormal]; [_applyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; _applyButton.enabled = NO; } } -(void)applyAction { // _applyButton.enabled = NO; NSString *urlString=[NSString stringWithFormat:@"%@/user/personalCenter",URL]; [KXHTTP post:urlString params:nil success:^(id json) { NSString *username= [[NSUserDefaults standardUserDefaults]valueForKey:USER_NAME]; if (!username) { KXLittleLogginView *littleView = [[KXLittleLogginView alloc]initWithFrame:self.view.bounds]; littleView.delegate = self; [self.view addSubview:littleView]; _applyButton.enabled = YES; }else{ NSInteger markCount = [[NSUserDefaults standardUserDefaults] integerForKey:KXMARK_CLICKCOUNT]; if (!markCount) { markCount = 0; } markCount ++; [[NSUserDefaults standardUserDefaults] setInteger:markCount forKey:KXMARK_CLICKCOUNT]; [[NSUserDefaults standardUserDefaults] synchronize]; [MobClick event:@"applyClick"]; NSString *urlString=[NSString stringWithFormat:@"%@/user/addapply",URL]; [KXHTTP post:urlString params:@{@"product_id":self.detailID,@"periods":_dateButton.titleLabel.text,@"money":_amountTF.text} success:^(id json) { NSDictionary *dict = @{@"entersource":self.enterSource}; [MobClick event:@"applyAction" attributes:dict]; KXWebDetailViewController *web=[[KXWebDetailViewController alloc]init]; web.webStr = json[@"url"]; web.titleStr = self.name; web.product_id = self.detailID; web.product_apply_id = json[@"product_apply_id"]; [self.navigationController pushViewController:web animated:YES]; _applyButton.enabled = YES; } failure:^(NSError *error) { _applyButton.enabled = YES; }]; } } failure:^(NSError *error) { _applyButton.enabled = YES; }]; } -(void)requestData { //[self.hud showAnimated:YES]; NSString *urlString=[NSString stringWithFormat:@"%@/product/detail",URL]; [KXHTTP post:urlString params:@{@"id":self.detailID,@"enter_source":self.enterSource} success:^(id json) { [self.hud hide:YES]; _detailModel=[KXMainDetailModel yy_modelWithJSON:json]; [self createHeaderView]; [self setBottomView]; [self setupSelectView]; [self createNavigation]; } failure:^(NSError *error) { [self.hud hide:YES]; }]; } -(void)createHeaderView { _headerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 373)]; _headerView.backgroundColor=[UIColor KXColorWithRed:239 green:239 blue:244]; UIView *topView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 168)]; topView.backgroundColor=[UIColor whiteColor]; [_headerView addSubview:topView]; UIImageView *headImageView=[[UIImageView alloc]initWithFrame:CGRectMake(14, 19, 50, 50)]; [headImageView sd_setImageWithURL:[NSURL URLWithString:_detailModel.icon] placeholderImage:[UIImage imageNamed:@"placeholder_square"] options:SDWebImageRefreshCached]; headImageView.layer.cornerRadius=8; headImageView.layer.masksToBounds=YES; [topView addSubview:headImageView]; UILabel *nameLabel=[[UILabel alloc]initWithFrame:CGRectMake(78, 19, 200, 20)]; nameLabel.textColor=[UIColor titleColor]; nameLabel.font=FONT_SYS(18); nameLabel.text=_detailModel.name; [topView addSubview:nameLabel]; UILabel *applyLabel=[[UILabel alloc]initWithFrame:CGRectMake(78, 55, 130, 15)]; applyLabel.textColor=[UIColor detailTitleColor]; applyLabel.font=FONT_SYS(12); applyLabel.text=[NSString stringWithFormat:@"%@人申请成功",_detailModel.applicants]; [topView addSubview:applyLabel]; UILabel *ratelabel=[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-130, 55, 40, 15)]; ratelabel.textColor=[UIColor detailTitleColor]; ratelabel.font=FONT_SYS(12); ratelabel.text=@"成功率"; [topView addSubview:ratelabel]; for (int i=0; i<5; i++) { UIImageView *starImageView=[[UIImageView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH-90)+16*i, 55, 14, 14)]; if (i<_detailModel.star.intValue) { starImageView.image=[UIImage imageNamed:@"main_star_highlight"]; }else{ starImageView.image=[UIImage imageNamed:@"main_star_normal"]; } [topView addSubview:starImageView]; } UIView *toplineView = [[UIView alloc] initWithFrame:CGRectMake(15, 87, SCREEN_WIDTH-30, 1)]; toplineView.backgroundColor = [UIColor KXColorWithHex:0xeeeeee]; [topView addSubview:toplineView]; NSArray *topTitleArr = @[@"额度",@"期限",@"参考月利率"]; NSString *quotaStr = [NSString stringWithFormat:@"%@-%@",_detailModel.upper_amount,_detailModel.lower_amount]; NSString *segStr = _detailModel.term; NSString *topMonthRateStr = [NSString stringWithFormat:@"%.2f%@",_detailModel.monthly_rate.floatValue,@"%"]; NSArray *topDetailArr = @[quotaStr,segStr,topMonthRateStr]; for (NSInteger i =0; i<3; i++) { UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(i*(SCREEN_WIDTH/3), 107, SCREEN_WIDTH/3, 17)]; label.font = FONT_SYS(12); label.textColor = [UIColor KXColorWithHex:0x666666]; label.textAlignment = NSTextAlignmentCenter; label.text = topTitleArr[i]; [topView addSubview:label]; UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(i*(SCREEN_WIDTH/3), 130, SCREEN_WIDTH/3, 20)]; label2.font = FONT_SYS(14); label2.textColor = [UIColor titleColor]; label2.textAlignment = NSTextAlignmentCenter; label2.text = topDetailArr[i]; [topView addSubview:label2]; } UIView *middleView=[[UIView alloc]initWithFrame:CGRectMake(0, 174, SCREEN_WIDTH, 215)]; middleView.backgroundColor=[UIColor whiteColor]; [_headerView addSubview:middleView]; UILabel *quotaLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 31, 30*SCREEN_MUTI, 15)]; quotaLabel.textColor=[UIColor KXColorWithHex:0x666666]; quotaLabel.font=FONT_SYS(14); quotaLabel.text=@"金额"; [middleView addSubview:quotaLabel]; UILabel *amountLabel=[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-44, 31, 15, 15)]; amountLabel.text=@"元"; amountLabel.font=FONT_SYS(14); amountLabel.textColor=[UIColor KXColorWithHex:0x666666]; [middleView addSubview:amountLabel]; _amountTF=[[UITextField alloc]initWithFrame:CGRectMake(45, 24, SCREEN_WIDTH-90,28)]; _amountTF.font=FONT_SYS(20); _amountTF.textColor = [UIColor baseColor]; _amountTF.text=_detailModel.upper_amount.stringValue; _amountTF.textAlignment=NSTextAlignmentCenter; _amountTF.returnKeyType=UIReturnKeyDone; _amountTF.keyboardType=UIKeyboardTypeNumberPad; _amountTF.delegate=self; [middleView addSubview:_amountTF]; UIView *amountLine = [[UIView alloc] initWithFrame:CGRectMake(15, 62, SCREEN_WIDTH-30, 1)]; amountLine.backgroundColor = [UIColor KXColorWithHex:0xeeeeee]; [middleView addSubview:amountLine]; UILabel *segLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 80, Fitsize(30), 20)]; segLabel.textColor=[UIColor KXColorWithHex:0x666666]; segLabel.font=FONT_SYS(14); segLabel.text=@"期限"; [middleView addSubview:segLabel]; _dateButton=[UIButton buttonWithType:UIButtonTypeCustom]; _dateButton.frame=CGRectMake(45, 73, SCREEN_WIDTH-90, 28); NSDictionary *dict=_detailModel.loan_period[0]; NSString *month = dict[@"k"]; [_dateButton setTitle:month forState:UIControlStateNormal]; [_dateButton setTitleColor:[UIColor baseColor] forState:UIControlStateNormal]; _dateButton.titleLabel.font=FONT_SYS(20); [_dateButton addTarget:self action:@selector(chooseDate) forControlEvents:UIControlEventTouchUpInside]; [middleView addSubview:_dateButton]; UIButton *daterightBtn = [UIButton buttonWithType:UIButtonTypeCustom]; daterightBtn.frame =CGRectMake(SCREEN_WIDTH-60, 80, 60, 15); [daterightBtn setImage:[UIImage imageNamed:@"main_detail_down"] forState:UIControlStateNormal]; [daterightBtn setTitle:[dict[@"v"] substringWithRange:NSMakeRange([dict[@"v"] length]-1, 1)] forState:UIControlStateNormal]; [daterightBtn setTitleColor:[UIColor KXColorWithHex:0x666666] forState:UIControlStateNormal]; daterightBtn.titleLabel.font=FONT_SYS(14); [daterightBtn addTarget:self action:@selector(chooseDate) forControlEvents:UIControlEventTouchUpInside]; [middleView addSubview:daterightBtn]; [self setImageToRight:daterightBtn]; UIView *dateLine = [[UIView alloc] initWithFrame:CGRectMake(15, 111, SCREEN_WIDTH-30, 1)]; dateLine.backgroundColor = [UIColor KXColorWithHex:0xeeeeee]; [middleView addSubview:dateLine]; UILabel *bottomLeftLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 128, 120, 20)]; bottomLeftLabel.font = FONT_SYS(14); bottomLeftLabel.textColor = [UIColor KXColorWithHex:0x666666]; bottomLeftLabel.text = @"最快放款时间"; [middleView addSubview:bottomLeftLabel]; UILabel *bottomRightLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-75, 128, 60, 20)]; bottomRightLabel.font = FONT_SYS(14); bottomRightLabel.textAlignment = NSTextAlignmentRight; bottomRightLabel.textColor = [UIColor KXColorWithHex:0x666666]; bottomRightLabel.text = [NSString stringWithFormat:@"%@",[[self calculateSumMoney] objectAtIndex:2]]; [middleView addSubview:bottomRightLabel]; UILabel *bottomMidLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 164, SCREEN_WIDTH, 22)]; bottomMidLabel.font = FONT_SYS(16); bottomMidLabel.textColor = [UIColor detailTitleColor]; bottomMidLabel.textAlignment = NSTextAlignmentCenter; bottomMidLabel.text = [NSString stringWithFormat:@"预计还款总额%@",[[self calculateSumMoney] objectAtIndex:0]]; bottomMidLabel.tag = 12345; [middleView addSubview:bottomMidLabel]; [self createFooterView]; [self createTableView]; } -(void)setupSelectView { _selectView=[[UIView alloc]initWithFrame:self.view.bounds]; _selectView.hidden=YES; _selectView.backgroundColor=[UIColor colorWithWhite:0 alpha:0.5]; [self.view addSubview:_selectView]; self.selectTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT-220-64, SCREEN_WIDTH, 220) style:UITableViewStylePlain]; self.selectTableView.backgroundColor=[UIColor KXColorWithRed:239 green:239 blue:244]; self.selectTableView.separatorStyle=UITableViewCellSeparatorStyleNone; [self.selectTableView registerClass:[KXSelectTableViewCell class] forCellReuseIdentifier:@"select"]; self.selectTableView.tableFooterView=[[UIView alloc]init]; self.selectTableView.delegate = self; self.selectTableView.dataSource = self; [_selectView addSubview:self.selectTableView]; } -(void)tapAction:(UITapGestureRecognizer *)tap { _selectView.hidden=YES; } -(NSArray *)calculateSumMoney { NSInteger amount=_amountTF.text.integerValue; NSInteger date=[_dateButton.titleLabel.text integerValue]; float rate; NSString *rateString; if ([_detailModel.show_day isEqualToString:@"参考月利率"]) { rate=_detailModel.monthly_rate.floatValue/100; rateString=[NSString stringWithFormat:@"%.2f%@",_detailModel.monthly_rate.floatValue,@"%"]; }else{ rate=_detailModel.day_rate.floatValue/100; rateString=[NSString stringWithFormat:@"%.2f%@",_detailModel.day_rate.floatValue,@"%"]; } NSArray *detailArray=@[[NSString stringWithFormat:@"%.2f元",amount*date*rate+amount],rateString,_detailModel.lend_time]; return detailArray; } -(void)chooseDate { _selectView.hidden=NO; } //设置图片居右 -(void)setImageToRight:(UIButton *)btn { NSDictionary *attribute = @{NSFontAttributeName:btn.titleLabel.font}; //获取文本的宽度 CGFloat btnWidth = [btn.titleLabel.text boundingRectWithSize:CGSizeMake(0, 15) options:\ NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size.width; //通过调节文本和图片的内边距到达目的 btn.imageEdgeInsets = UIEdgeInsetsMake(0, btnWidth+4, 0, -btnWidth); [btn setTitleEdgeInsets:UIEdgeInsetsMake(0, -btn.imageView.image.size.width-3, 0, btn.imageView.image.size.width)]; } -(void)createTableView { self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-NavHeight-62-safeBottomHeight) style:UITableViewStylePlain]; self.tableView.backgroundColor=[UIColor KXColorWithRed:239 green:239 blue:244]; self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone; [self.tableView registerClass:[KXMainDetailTableViewCell class] forCellReuseIdentifier:@"detail"]; self.tableView.tableHeaderView=_headerView; self.tableView.tableFooterView=_footerView; self.tableView.delegate = self; self.tableView.dataSource = self; [self.view addSubview:self.tableView]; } - (void)createFooterView { _footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 75 + 90*SCREEN_MUTI)]; _footerView.backgroundColor=[UIColor KXColorWithRed:239 green:239 blue:244]; _updownButton = [[KXUpDownButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 45)]; [_updownButton addTarget:self action:@selector(upAndDownAction:) forControlEvents:UIControlEventTouchUpInside]; [_footerView addSubview:_updownButton]; UILabel *sameMoreLabel = [[UILabel alloc]initWithFrame:CGRectMake(14, 45, 300, 30)]; sameMoreLabel.text = @"同时申请这些产品的贷款通过率更高哦~"; sameMoreLabel.font = FONT_SYS(14); sameMoreLabel.textColor = [UIColor KXColorWithHex:0x666666]; [_footerView addSubview:sameMoreLabel]; _recommendView = [[KXRecommendView alloc]initWithFrame:CGRectMake(0, 75, SCREEN_WIDTH, 90*SCREEN_MUTI)]; _recommendView.delegate = self; [_footerView addSubview:_recommendView]; [KXMainPageViewModel recommendData:@{@"id":self.detailID} data:^(NSArray *dataSource) { _recommendView.dataSource = dataSource; }]; } - (void)upAndDownAction:(KXUpDownButton *)btn { if (_isSpread == NO) { _isSpread = YES; btn.imageView.image = [UIImage imageWithCGImage:btn.imageView.image.CGImage scale:1 orientation:UIImageOrientationDown]; [self.tableView reloadData]; btn.titleLabel.text = @"收起"; }else{ _isSpread = NO; btn.imageView.image = [UIImage imageWithCGImage:btn.imageView.image.CGImage scale:1 orientation:UIImageOrientationUp]; [self.tableView reloadData]; btn.titleLabel.text = @"查看更多"; } } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if ([tableView isEqual:self.selectTableView]) { return 1; }else{ if (_isSpread == YES) { return 3; }else{ return 0; } } } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if ([tableView isEqual:self.selectTableView]) { return _detailModel.loan_period.count; }else{ return 1; } } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if ([tableView isEqual:self.selectTableView]) { KXSelectTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"select"]; if (!cell) { cell=[[KXSelectTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"select"]; } NSDictionary *dict=_detailModel.loan_period[indexPath.row]; cell.backgroundColor=[UIColor whiteColor]; cell.selectionStyle=UITableViewCellSelectionStyleNone; cell.detailStr=dict[@"v"]; return cell; }else{ KXMainDetailTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"detail"]; if (!cell) { cell=[[KXMainDetailTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"detail"]; } cell.selectionStyle=UITableViewCellSelectionStyleNone; cell.nameLabel.text=_titleArray[indexPath.section]; cell.ImageView.image = [UIImage imageNamed:_detailImageArr[indexPath.section]]; NSMutableAttributedString * attrStr = [[NSMutableAttributedString alloc] initWithData:[_detailModel.req_list[indexPath.section] dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil]; if (indexPath.section!=2) { cell.contentLabel.text=_detailModel.req_list[indexPath.section]; }else{ cell.contentLabel.attributedText=attrStr; } if (indexPath.section == 0) { cell.lineLabel.hidden = YES; } cell.contentLabel.font=FONT_SYS(14); cell.contentLabel.textColor=[UIColor titleColor]; return cell; } } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { if ([tableView isEqual:self.selectTableView]) { return 45; }else{ if (indexPath.section!=2) { NSMutableAttributedString *att=[[NSMutableAttributedString alloc]initWithString:_detailModel.req_list[indexPath.section]]; [att addAttribute:NSFontAttributeName value:FONT_SYS(14) range:NSMakeRange(0, [_detailModel.req_list[indexPath.section] length]-1)]; CGRect rect=[att boundingRectWithSize:CGSizeMake(SCREEN_WIDTH-28, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading context:nil]; return rect.size.height+65; }else{ NSMutableAttributedString * attrStr = [[NSMutableAttributedString alloc] initWithData:[_detailModel.req_list[indexPath.section] dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil]; [attrStr addAttribute:NSFontAttributeName value:FONT_SYS(14) range:NSMakeRange(0, [attrStr length]-1)]; CGRect rect = [attrStr boundingRectWithSize:CGSizeMake(SCREEN_WIDTH-28, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin context:nil]; return rect.size.height+65; } } } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if ([tableView isEqual:self.selectTableView]) { NSDictionary *dict=_detailModel.loan_period[indexPath.row]; NSString *dateStr = dict[@"k"]; [_dateButton setTitle:dateStr forState:UIControlStateNormal]; [self setImageToRight:_dateButton]; _selectView.hidden=YES; KXMainDetailThreeView *threeView=[_headerView viewWithTag:888]; threeView.detailLabel.text=[[self calculateSumMoney] objectAtIndex:0]; UILabel *label = [_headerView viewWithTag:12345]; label.text = [NSString stringWithFormat:@"预计还款总额%@",[[self calculateSumMoney] objectAtIndex:0]]; } } #pragma mark -----------UITextFieldDelagate--------------- -(void)textFieldDidBeginEditing:(UITextField *)textField { textField.text=@""; } -(void)textFieldDidEndEditing:(UITextField *)textField reason:(UITextFieldDidEndEditingReason)reason { // if (textField.text.integerValue>_detailModel.lower_amount.integerValue) { // textField.text=_detailModel.lower_term.stringValue; // } // if (textField.text.integerValue<_detailModel.upper_amount.integerValue) { // textField.text=_detailModel.upper_amount.stringValue; // } KXMainDetailThreeView *threeView=[_headerView viewWithTag:888]; threeView.detailLabel.text=[[self calculateSumMoney] objectAtIndex:0]; UILabel *label = [_headerView viewWithTag:12345]; label.text = [NSString stringWithFormat:@"预计还款总额%@",[[self calculateSumMoney] objectAtIndex:0]]; } -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { return YES; } #pragma mark ----------------KXRecommendViewDelegate------------------- -(void)recmmendViewClickWithId:(NSString *)ID name:(NSString *)name { [MobClick event:@"detailListClick"]; KXMainDetailViewController *detail=[[KXMainDetailViewController alloc]init]; detail.detailID=ID; detail.titleString=name; detail.enterSource = @"detailList"; [self.navigationController pushViewController:detail animated:YES]; } #pragma mark =======================KXLittleLogginViewDelegate================ - (void)littleLogginViewSuccess { NSString *urlString=[NSString stringWithFormat:@"%@/user/addapply",URL]; [KXHTTP post:urlString params:@{@"product_id":self.detailID,@"periods":_dateButton.titleLabel.text,@"money":_amountTF.text} success:^(id json) { KXWebDetailViewController *web=[[KXWebDetailViewController alloc]init]; web.webStr=_detailModel.link; web.titleStr = self.name; web.product_id = self.detailID; web.product_apply_id = json[@"product_apply_id"]; [self.navigationController pushViewController:web animated:YES]; } failure:^(NSError *error) { }]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { _selectView.hidden=YES; } -(MBProgressHUD *)hud { if (!_hud) { _hud=[[MBProgressHUD alloc]initWithView:self.view]; _hud.labelText=@"加载中..."; [self.view addSubview:_hud]; } return _hud; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)gotoMainDetail { NSLog(@"gotoMainDetail"); } /* #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