// // ReceiverRecordViewController.m // BuguLive // // Created by yy on 16/7/21. // Copyright © 2016年 xfg. All rights reserved. // #import "ReceiverRecordViewController.h" #import "RecordModel.h" #import "RecordTableViewCell.h" @interface ReceiverRecordViewController () { NetHttpsManager *_httpManager; NSMutableArray * recordArray; NSString *totalMoney; } @end @implementation ReceiverRecordViewController - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.hidden = YES; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor colorWithHexString:@"#F5F5F5"]; UIImageView * navView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationHeight)]; navView.image = [UIImage imageNamed:@"mine_navbg"]; navView.userInteractionEnabled = YES; [self.view addSubview:navView]; UIButton * backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [backBtn setImage:[UIImage imageNamed:@"com_arrow_vc_back"] forState:UIControlStateNormal]; backBtn.frame = CGRectMake(10, StatusBarHeight, 44, 44); [backBtn addTarget:self action:@selector(backLastVC) forControlEvents:UIControlEventTouchUpInside]; [navView addSubview:backBtn]; UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)]; titleLabel.centerX = SCREEN_WIDTH/2; titleLabel.centerY = backBtn.centerY; titleLabel.text = ASLocalizedString(@"提现记录"); titleLabel.textColor = UIColor.blackColor; titleLabel.font = [UIFont boldSystemFontOfSize:18]; titleLabel.textAlignment = NSTextAlignmentCenter; [navView addSubview:titleLabel]; // self.navigationItem.title =ASLocalizedString(@"提现记录"); // self.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithTarget:self action:@selector(backpProfitVC) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"]; _httpManager =[NetHttpsManager manager]; recordArray = [[NSMutableArray alloc]initWithCapacity:0]; [self loadReceiveNet]; } - (void)backLastVC { [self.navigationController popViewControllerAnimated:YES]; } - (void)creatTabel { UITableView *receiveTabel =[[UITableView alloc]initWithFrame:CGRectMake(0, NavigationHeight, kScreenW, kScreenH-NavigationHeight - SafeAreaBottomHeight) style:UITableViewStylePlain]; receiveTabel.delegate =self; receiveTabel.dataSource =self; receiveTabel.backgroundColor = UIColor.clearColor; [self.view addSubview:receiveTabel]; [receiveTabel setSeparatorStyle:UITableViewCellSeparatorStyleNone]; [receiveTabel registerNib:[UINib nibWithNibName:@"RecordTableViewCell" bundle:nil] forCellReuseIdentifier:@"Cell"]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; { return 1; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 50; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (recordArray.count>0) { return recordArray.count; } return 0; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return kRealValue(75); } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString * cellID = @"Cell"; RecordTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (cell == nil) { cell = [[RecordTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; } RecordModel *model =[recordArray objectAtIndex:indexPath.row]; cell.moneyLable.textColor = kAppGrayColor1; cell.recordStateLable.textColor =kAppGrayColor3; cell.titleLabel.text = ASLocalizedString(@"金币提现"); if ([model.is_pay isEqualToString:@"1"]) { cell.moneyLable.text =[NSString stringWithFormat:ASLocalizedString(@"%@"),model.money]; cell.timeLabel.text =model.create_time; cell.recordStateLable.text =ASLocalizedString(@"兑换中"); } else{ cell.moneyLable.text =[NSString stringWithFormat:ASLocalizedString(@"%@元"),model.money]; cell.timeLabel.text =model.pay_time; cell.recordStateLable.text =ASLocalizedString(@"兑换成功"); } return cell; } //添加标头中的内容 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { static NSString *headerSectionID = @"headerSectionID"; UITableViewHeaderFooterView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headerSectionID]; UILabel *label; if (headerView == nil) { headerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:headerSectionID]; label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, kScreenW-20, 50)]; label.text = [NSString stringWithFormat:ASLocalizedString(@"累计领取:%@元"),totalMoney]; label.font = [UIFont systemFontOfSize:18]; label.textAlignment =NSTextAlignmentCenter; label.textColor = UIColor.whiteColor; label.backgroundColor = [UIColor colorWithHexString:@"#FF985D"]; label.layer.cornerRadius = 10; label.layer.masksToBounds = YES; [headerView addSubview:label]; } return headerView; } #pragma marlk 返回 - (void)backpProfitVC { [self.navigationController popViewControllerAnimated:YES]; } #pragma marlk 请求领取记录 - (void)loadReceiveNet { NSMutableDictionary *parmDict = [NSMutableDictionary dictionary]; [parmDict setObject:@"user_center" forKey:@"ctl"]; [parmDict setObject:@"extract_record" forKey:@"act"]; [_httpManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) { if ([responseJson toInt:@"status"]==1) { totalMoney = [responseJson objectForKey:@"total_money"]; [recordArray removeAllObjects]; NSArray *listArr = [NSArray modelArrayWithClass:[RecordModel class] json:[responseJson objectForKey:@"list"]]; // NSMutableArray *listArray =[responseJson objectForKey:@"list"]; // if ([listArray isKindOfClass:[NSMutableArray class]]) { // if (listArray.count>0) { // for (NSDictionary *dic in listArray) { // RecordModel *model = [ RecordModel mj_objectWithKeyValues:dic]; // [recordArray addObject:model]; // } // // } // } [recordArray addObjectsFromArray:listArr]; [self creatTabel]; } else{ NSLog(ASLocalizedString(@"错误")); } } FailureBlock:^(NSError *error) { }]; } @end