ReceiverRecordViewController.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. //
  2. // ReceiverRecordViewController.m
  3. // BuguLive
  4. //
  5. // Created by yy on 16/7/21.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "ReceiverRecordViewController.h"
  9. #import "RecordModel.h"
  10. #import "RecordTableViewCell.h"
  11. @interface ReceiverRecordViewController ()<UITableViewDelegate,UITableViewDataSource>
  12. {
  13. NetHttpsManager *_httpManager;
  14. NSMutableArray * recordArray;
  15. NSString *totalMoney;
  16. }
  17. @end
  18. @implementation ReceiverRecordViewController
  19. - (void)viewWillAppear:(BOOL)animated {
  20. [super viewWillAppear:animated];
  21. self.navigationController.navigationBar.hidden = YES;
  22. }
  23. - (void)viewDidLoad
  24. {
  25. [super viewDidLoad];
  26. self.view.backgroundColor = [UIColor colorWithHexString:@"#F5F5F5"];
  27. UIImageView * navView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationHeight)];
  28. navView.image = [UIImage imageNamed:@"mine_navbg"];
  29. navView.userInteractionEnabled = YES;
  30. [self.view addSubview:navView];
  31. UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  32. [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal];
  33. backBtn.frame = CGRectMake(10, StatusBarHeight, 44, 44);
  34. [backBtn addTarget:self action:@selector(backLastVC) forControlEvents:UIControlEventTouchUpInside];
  35. [navView addSubview:backBtn];
  36. UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
  37. titleLabel.centerX = SCREEN_WIDTH/2;
  38. titleLabel.centerY = backBtn.centerY;
  39. titleLabel.text = ASLocalizedString(@"提现记录");
  40. titleLabel.textColor = UIColor.blackColor;
  41. titleLabel.font = [UIFont boldSystemFontOfSize:18];
  42. titleLabel.textAlignment = NSTextAlignmentCenter;
  43. [navView addSubview:titleLabel];
  44. // self.navigationItem.title =ASLocalizedString(@"提现记录");
  45. // self.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithTarget:self action:@selector(backpProfitVC) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  46. _httpManager =[NetHttpsManager manager];
  47. recordArray = [[NSMutableArray alloc]initWithCapacity:0];
  48. [self loadReceiveNet];
  49. }
  50. - (void)backLastVC {
  51. [self.navigationController popViewControllerAnimated:YES];
  52. }
  53. - (void)creatTabel
  54. {
  55. UITableView *receiveTabel =[[UITableView alloc]initWithFrame:CGRectMake(0, NavigationHeight, kScreenW, kScreenH-NavigationHeight - SafeAreaBottomHeight) style:UITableViewStylePlain];
  56. receiveTabel.delegate =self;
  57. receiveTabel.dataSource =self;
  58. receiveTabel.backgroundColor = UIColor.clearColor;
  59. [self.view addSubview:receiveTabel];
  60. [receiveTabel setSeparatorStyle:UITableViewCellSeparatorStyleNone];
  61. [receiveTabel registerNib:[UINib nibWithNibName:@"RecordTableViewCell" bundle:nil] forCellReuseIdentifier:@"Cell"];
  62. }
  63. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
  64. {
  65. return 1;
  66. }
  67. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  68. {
  69. return 50;
  70. }
  71. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  72. {
  73. if (recordArray.count>0) {
  74. return recordArray.count;
  75. }
  76. return 0;
  77. }
  78. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  79. {
  80. return kRealValue(75);
  81. }
  82. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  83. {
  84. static NSString * cellID = @"Cell";
  85. RecordTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  86. if (cell == nil) {
  87. cell = [[RecordTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  88. }
  89. RecordModel *model =[recordArray objectAtIndex:indexPath.row];
  90. cell.moneyLable.textColor = kAppGrayColor1;
  91. cell.recordStateLable.textColor =kAppGrayColor3;
  92. cell.titleLabel.text = ASLocalizedString(@"金币提现");
  93. if ([model.is_pay isEqualToString:@"1"]) {
  94. cell.moneyLable.text =[NSString stringWithFormat:ASLocalizedString(@"%@"),model.money];
  95. cell.timeLabel.text =model.create_time;
  96. cell.recordStateLable.text =ASLocalizedString(@"兑换中");
  97. }
  98. else{
  99. cell.moneyLable.text =[NSString stringWithFormat:ASLocalizedString(@"%@元"),model.money];
  100. cell.timeLabel.text =model.pay_time;
  101. cell.recordStateLable.text =ASLocalizedString(@"兑换成功");
  102. }
  103. return cell;
  104. }
  105. //添加标头中的内容
  106. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  107. {
  108. static NSString *headerSectionID = @"headerSectionID";
  109. UITableViewHeaderFooterView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headerSectionID];
  110. UILabel *label;
  111. if (headerView == nil) {
  112. headerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:headerSectionID];
  113. label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, kScreenW-20, 50)];
  114. label.text = [NSString stringWithFormat:ASLocalizedString(@"累计领取:%@元"),totalMoney];
  115. label.font = [UIFont systemFontOfSize:18];
  116. label.textAlignment =NSTextAlignmentCenter;
  117. label.textColor = UIColor.whiteColor;
  118. label.backgroundColor = [UIColor colorWithHexString:@"#FF985D"];
  119. label.layer.cornerRadius = 10;
  120. label.layer.masksToBounds = YES;
  121. [headerView addSubview:label];
  122. }
  123. return headerView;
  124. }
  125. #pragma marlk 返回
  126. - (void)backpProfitVC
  127. {
  128. [self.navigationController popViewControllerAnimated:YES];
  129. }
  130. #pragma marlk 请求领取记录
  131. - (void)loadReceiveNet
  132. {
  133. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  134. [parmDict setObject:@"user_center" forKey:@"ctl"];
  135. [parmDict setObject:@"extract_record" forKey:@"act"];
  136. [_httpManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  137. {
  138. if ([responseJson toInt:@"status"]==1) {
  139. totalMoney = [responseJson objectForKey:@"total_money"];
  140. [recordArray removeAllObjects];
  141. NSArray *listArr = [NSArray modelArrayWithClass:[RecordModel class] json:[responseJson objectForKey:@"list"]];
  142. // NSMutableArray *listArray =[responseJson objectForKey:@"list"];
  143. // if ([listArray isKindOfClass:[NSMutableArray class]]) {
  144. // if (listArray.count>0) {
  145. // for (NSDictionary *dic in listArray) {
  146. // RecordModel *model = [ RecordModel mj_objectWithKeyValues:dic];
  147. // [recordArray addObject:model];
  148. // }
  149. //
  150. // }
  151. // }
  152. [recordArray addObjectsFromArray:listArr];
  153. [self creatTabel];
  154. }
  155. else{
  156. NSLog(ASLocalizedString(@"错误"));
  157. }
  158. } FailureBlock:^(NSError *error)
  159. {
  160. }];
  161. }
  162. @end