EarnestAmountVC.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // PaymentAmountVC.m
  3. // IBOSSmini
  4. //
  5. // Created by guan hong hou on 2018/2/1.
  6. // Copyright © 2018年 elongtian. All rights reserved.
  7. //
  8. #import "EarnestAmountVC.h"
  9. @interface EarnestAmountVC ()
  10. @end
  11. @implementation EarnestAmountVC
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. [self loadNavStyle];
  15. [self initUI];
  16. }
  17. -(void)loadNavStyle
  18. {
  19. //右边
  20. UIButton *btnAdd = [UIButton buttonWithType:UIButtonTypeCustom];
  21. [btnAdd addTarget:self action:@selector(submitData)
  22. forControlEvents:UIControlEventTouchUpInside];
  23. btnAdd.frame = CGRectMake(0, 0,60,14);
  24. [btnAdd setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  25. btnAdd.titleLabel.font=[UIFont systemFontOfSize:16];
  26. [btnAdd setTitle:@"确定" forState:UIControlStateNormal];
  27. UIBarButtonItem *menubtnAdd = [[UIBarButtonItem alloc] initWithCustomView:btnAdd];
  28. self.navigationItem.title=@"请选择";
  29. self.navigationItem.rightBarButtonItem = menubtnAdd;
  30. //返回
  31. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  32. [button setBackgroundImage:[UIImage imageNamed:@"icon_back"]
  33. forState:UIControlStateNormal];
  34. [button addTarget:self action:@selector(goBack)
  35. forControlEvents:UIControlEventTouchUpInside];
  36. button.frame = CGRectMake(0, 0, 15, 18);
  37. UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
  38. self.navigationItem.leftBarButtonItem = menuButton;
  39. }
  40. -(void)submitData{
  41. [self.view endEditing:YES];
  42. if([self.paymentDelegate respondsToSelector:@selector(showEarnestInfo:)])
  43. {
  44. [self.paymentDelegate showEarnestInfo:_earnestList];
  45. }
  46. [self.navigationController popViewControllerAnimated:YES];
  47. }
  48. -(void)initUI{
  49. _vTableView = [[UITableView alloc]
  50. initWithFrame:CGRectMake(0,
  51. 0,
  52. self.view.frame.size.width,
  53. self.view.frame.size.height)];
  54. _vTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  55. _vTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
  56. _vTableView.backgroundColor = [UIColor whiteColor];
  57. _vTableView.delegate = self;
  58. _vTableView.dataSource=self;
  59. [self.view addSubview:_vTableView];
  60. if(_earnestList!=nil&&_earnestList.count>0){
  61. [_vTableView reloadData];
  62. }
  63. }
  64. #pragma mark - tableView回调
  65. /**
  66. 单元格cell个数
  67. @param tableView <#tableView description#>
  68. @param section <#section description#>
  69. @return <#return value description#>
  70. */
  71. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  72. {
  73. return [_earnestList count];
  74. }
  75. /**
  76. <#Description#>
  77. @param tableView <#tableView description#>
  78. @return <#return value description#>
  79. */
  80. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  81. return 1;
  82. }
  83. /**
  84. 高度
  85. @param tableView <#tableView description#>
  86. @param indexPath <#indexPath description#>
  87. @return <#return value description#>
  88. */
  89. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  90. return 81 ;
  91. }
  92. /**
  93. 每个单元格cell
  94. @param tableView <#tableView description#>
  95. @param indexPath <#indexPath description#>
  96. @return <#return value description#>
  97. */
  98. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  99. {
  100. static NSString *cellIdentifier = @"EarnestCell";
  101. EarnestCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
  102. cell=[[EarnestCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  103. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  104. cell.cellIndex=indexPath.row;
  105. cell.delegate=self;
  106. EarnestModel *earnestModel = [_earnestList objectAtIndex:indexPath.row];
  107. [cell parseEarnestInfo:earnestModel];
  108. return cell;
  109. }
  110. -(void)updateEarnestInfo:(EarnestCell*)cell{
  111. NSString *earnestSumValue= cell.txtEarnestSum.text;
  112. if(earnestSumValue==nil||[earnestSumValue isEqualToString:@""]){
  113. earnestSumValue=@"0";
  114. }
  115. EarnestModel *earnestModel = [_earnestList objectAtIndex:cell.cellIndex];
  116. earnestModel.earnestSum=earnestSumValue;
  117. _earnestList[cell.cellIndex]=earnestModel;
  118. [_vTableView reloadData];
  119. }
  120. - (void)goBack
  121. {
  122. [self.navigationController popViewControllerAnimated:YES];
  123. }
  124. - (void)didReceiveMemoryWarning {
  125. [super didReceiveMemoryWarning];
  126. }
  127. @end