Initial commit
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// IfishMineGoldViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/3/14.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ClearNavBaseViewController.h"
|
||||
|
||||
@interface IfishMineGoldViewController : ClearNavBaseViewController
|
||||
|
||||
@end
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
//
|
||||
// IfishMineGoldViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/3/14.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "IfishMineGoldViewController.h"
|
||||
#import "IifshSegmentView.h"
|
||||
#import "MineGoldModel.h"
|
||||
#import "MineGoldCustomViewCell.h"
|
||||
@interface IfishMineGoldViewController ()<IfishSegmentViewDelegate,UITableViewDelegate,UITableViewDataSource>
|
||||
|
||||
@property (nonatomic,strong) UITableView *leftTabView;
|
||||
@property (nonatomic,strong) NSMutableArray *leftDataArr;
|
||||
@property (nonatomic) NSInteger totalIn;
|
||||
@property (nonatomic,strong) UITableView *rightTabView;
|
||||
@property (nonatomic,strong) NSMutableArray *rightDataArr;
|
||||
@property (nonatomic) NSInteger totalOut;
|
||||
|
||||
@end
|
||||
|
||||
@implementation IfishMineGoldViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
[self addTitleViewWithTitle:@"我的金币"];
|
||||
_leftDataArr = [[NSMutableArray alloc] init];
|
||||
_rightDataArr = [[NSMutableArray alloc] init];
|
||||
self.view.backgroundColor = RGB(242, 242, 242);
|
||||
[self creatSubViews];
|
||||
[self getLeftData];
|
||||
[self loadRightData];
|
||||
}
|
||||
|
||||
|
||||
-(void)creatSubViews
|
||||
{
|
||||
UIImageView *imagView = [[UIImageView alloc] init];
|
||||
imagView.frame = CGRectMake(0, 0, self.view.frame.size.width, 136*KWidth_Scale + 64);
|
||||
imagView.image = [UIImage imageNamed:@"gold_background"];
|
||||
[self.view addSubview:imagView];
|
||||
UIImageView *goldImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gold_iocn"]];
|
||||
CGFloat ImgW = 53*KWidth_Scale;
|
||||
goldImg.frame = CGRectMake(self.view.frame.size.width/2 - ImgW/2, 20*KWidth_Scale + 64 , ImgW, ImgW);
|
||||
[self.view addSubview:goldImg];
|
||||
[self.view bringSubviewToFront:goldImg];
|
||||
|
||||
UILabel *goldLabe = [[UILabel alloc] init];
|
||||
goldLabe.frame = CGRectMake(0, CGRectGetMaxY(goldImg.frame) + 14*KWidth_Scale, self.view.frame.size.width, 20);
|
||||
IfishUserAsset *userAsset = [dataContorl getAllIfishUserAsset];
|
||||
NSString *goldStr= [NSString stringWithFormat:@"金币 %ld",(long)userAsset.goldValue];
|
||||
NSMutableAttributedString * attributestr= [[NSMutableAttributedString alloc] initWithString:goldStr];
|
||||
[attributestr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0, goldStr.length)];
|
||||
[attributestr addAttribute:NSForegroundColorAttributeName value:RGB(245.0, 204.0, 46.0) range:NSMakeRange(0, 2)];
|
||||
goldLabe.textAlignment = NSTextAlignmentCenter;
|
||||
goldLabe.font = [UIFont systemFontOfSize:15];
|
||||
goldLabe.textColor = [UIColor whiteColor];
|
||||
goldLabe.attributedText = attributestr;
|
||||
[self.view addSubview:goldLabe];
|
||||
|
||||
|
||||
IifshSegmentView *seg = [[IifshSegmentView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(imagView.frame), self.view.frame.size.width, 44*KWidth_Scale)];
|
||||
seg.segDelegate = self;
|
||||
[seg initleftTitle:@"获取记录" addRightTitle:@"支出记录" isSelectStyle:NO];
|
||||
[self.view addSubview:seg];
|
||||
|
||||
CGFloat tabH = self.view.frame.size.height - CGRectGetMaxY(seg.frame);
|
||||
_leftTabView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(seg.frame), self.view.frame.size.width, tabH) style:UITableViewStylePlain];
|
||||
_leftTabView.hidden = NO;
|
||||
_leftTabView.delegate = self;
|
||||
_leftTabView.dataSource = self;
|
||||
_leftTabView.bounces = NO;
|
||||
_leftTabView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[self.view addSubview:_leftTabView];
|
||||
|
||||
_rightTabView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(seg.frame), self.view.frame.size.width, tabH) style:UITableViewStylePlain];
|
||||
_rightTabView.hidden = YES;
|
||||
_rightTabView.delegate =self;
|
||||
_rightTabView.dataSource = self;
|
||||
_rightTabView.bounces = NO;
|
||||
_rightTabView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[self.view addSubview:_rightTabView];
|
||||
|
||||
}
|
||||
|
||||
-(void)getLeftData{
|
||||
|
||||
NSString *userid =[dataContorl dataControlGetUserIdInfo];
|
||||
__weak typeof (self)weakSelf = self;
|
||||
[AFHttpTool goldValueRecord:userid firstResult:0 pageSize:20 success:^(id response) {
|
||||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
NSString *result=reDic[@"result"];
|
||||
_totalIn = [[reDic objectForKey:@"total"] integerValue];
|
||||
if ([result isEqualToString:@"100"]) {
|
||||
NSArray *data= reDic[@"data"];
|
||||
for (NSDictionary *dic in data) {
|
||||
MineGoldModel *mode =[[MineGoldModel alloc] initWithDict:dic];
|
||||
[_leftDataArr addObject:mode];
|
||||
|
||||
}
|
||||
[_leftTabView reloadData];
|
||||
|
||||
}else{
|
||||
[weakSelf.view makeToast:@"请求失败"];
|
||||
}
|
||||
|
||||
} failure:^(NSError *err) {
|
||||
[weakSelf.view makeToast:@"请求异常"];
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(void)loadRightData{
|
||||
NSString *userid =[dataContorl dataControlGetUserIdInfo];
|
||||
__weak typeof (self)weakSelf = self;
|
||||
[AFHttpTool goldExpendRecord:userid firstResult:0 pageSize:20 success:^(id response) {
|
||||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
NSString *result=reDic[@"result"];
|
||||
_totalOut = [[reDic objectForKey:@"total"] integerValue];
|
||||
if ([result isEqualToString:@"100"]) {
|
||||
NSArray *data= reDic[@"data"];
|
||||
for (NSDictionary *dic in data) {
|
||||
MineGoldModel *mode =[[MineGoldModel alloc] initWithDict:dic];
|
||||
[_rightDataArr addObject:mode];
|
||||
}
|
||||
|
||||
[weakSelf.rightTabView reloadData];
|
||||
|
||||
}else{
|
||||
|
||||
[weakSelf.view makeToast:@"请求失败"];
|
||||
}
|
||||
|
||||
} failure:^(NSError *err) {
|
||||
[weakSelf.view makeToast:@"请求异常"];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)segmentSelectAtIndext:(NSInteger)index
|
||||
{
|
||||
switch (index) {
|
||||
case 0:
|
||||
{
|
||||
_rightTabView.hidden = YES;
|
||||
_leftTabView.hidden = NO;
|
||||
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
_leftTabView.hidden = YES;
|
||||
_rightTabView.hidden = NO;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
NSInteger rowcount = tableView ==_leftTabView? _leftDataArr.count:_rightDataArr.count;
|
||||
return rowcount;
|
||||
|
||||
}
|
||||
|
||||
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
|
||||
UITableViewCell *cell =nil;
|
||||
cell = tableView ==_leftTabView? [self leftTab:tableView cellForRowAtIndexPath:indexPath] : [self rightTab:tableView cellForRowAtIndexPath:indexPath];
|
||||
|
||||
return cell;
|
||||
}
|
||||
//获取记录
|
||||
-(UITableViewCell *)leftTab:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MineGoldCustomViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"MineGoldCustomViewCell"];
|
||||
if (cell==nil) {
|
||||
cell= [[[NSBundle mainBundle]loadNibNamed:@"MineGoldCustomViewCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
//cell.cellType = MineGoldCellTypeIn;
|
||||
MineGoldModel *model =_leftDataArr[indexPath.row];
|
||||
[cell loadLeftTabCellData:model];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
|
||||
}
|
||||
|
||||
//支出记录
|
||||
-(UITableViewCell *)rightTab:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MineGoldCustomViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"MineGoldCustomViewCell"];
|
||||
if (cell==nil) {
|
||||
cell= [[[NSBundle mainBundle]loadNibNamed:@"MineGoldCustomViewCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
//cell.cellType = MineGoldCellTypeOut;
|
||||
MineGoldModel *model =_rightDataArr[indexPath.row];
|
||||
[cell loadRightTabCellData:model];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
|
||||
}
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
return 49*KWidth_Scale;
|
||||
|
||||
}
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||||
|
||||
return 10;
|
||||
|
||||
}
|
||||
|
||||
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||||
|
||||
UIView *view = [[UIView alloc] init];
|
||||
view.backgroundColor = RGB(242, 242, 242);
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
|
||||
[super didReceiveMemoryWarning];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
#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
|
||||
Reference in New Issue
Block a user