339 lines
13 KiB
Objective-C
339 lines
13 KiB
Objective-C
//
|
|
// IifshMineDJViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 17/2/28.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "IifshMineDJViewController.h"
|
|
#import "DengJiView0Cell.h"
|
|
|
|
#import "DengJiShuoMingViewCell.h"
|
|
#import "DengJiShuoMingViewTopCell.h"
|
|
#import "DengJiShuoMingViewBootomCell.h"
|
|
|
|
#import "JingYanValueViewCell.h"
|
|
#import "JingYanvalueTopViewCell.h"
|
|
#import "JingYanValueBootomViewCell.h"
|
|
#import "MineDengJi.h"
|
|
#import "JingYanValuelist.h"
|
|
#import "IfishDatabaseManager.h"
|
|
@interface IifshMineDJViewController ()<UITableViewDelegate,UITableViewDataSource>
|
|
@property(nonatomic,strong)UITableView *tableView;
|
|
//等级说明
|
|
@property(nonatomic,strong)NSMutableArray *lvDescripArr;
|
|
//如何获取经验值
|
|
@property(nonatomic,strong)NSMutableArray *lvExpWayArr;
|
|
|
|
@end
|
|
|
|
@implementation IifshMineDJViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
_lvExpWayArr = [[NSMutableArray alloc] init];
|
|
_lvDescripArr = [[NSMutableArray alloc] init];
|
|
|
|
[self addTitleViewWithTitle:@"我的等级"];
|
|
// Do any additional setup after loading the view.
|
|
[self creatTab];
|
|
|
|
[self getDataArr];
|
|
|
|
}
|
|
|
|
-(void)getDataArr{
|
|
|
|
NSString *filePath = [[NSBundle mainBundle]pathForResource:@"degJiGuize" ofType:@"json"];
|
|
NSData *data = [[NSData alloc]initWithContentsOfFile:filePath];
|
|
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
|
|
|
|
NSDictionary *datadic = [dic objectForKey:@"data"];
|
|
NSArray*levelListArr = [datadic objectForKey:@"grades"];
|
|
for (NSDictionary *gradesdict in levelListArr ) {
|
|
MineDengJi *model = [[MineDengJi alloc]initWithDictionary:gradesdict];
|
|
[_lvDescripArr addObject:model];
|
|
}
|
|
|
|
NSArray *leveExpArr = [datadic objectForKey:@"gradeRules"];
|
|
for (NSDictionary *dictRules in leveExpArr ) {
|
|
JingYanValuelist *model = [[JingYanValuelist alloc]initWithDictionary:dictRules];
|
|
[_lvExpWayArr addObject:model];
|
|
}
|
|
|
|
[self.tableView reloadData];
|
|
|
|
// __weak typeof (self) weakself = self;
|
|
// NSString *userId = [dataContorl dataControlGetUserIdInfo];
|
|
// [AFHttpTool getLevelRuleInfo:userId success:^(id response) {
|
|
// NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
|
// if ([reDic[@"result"] isEqualToString:@"100"]){
|
|
// NSDictionary *dataDic =reDic[@"data"];
|
|
// NSArray*levelListArr =dataDic[@"grades"];
|
|
// for (NSDictionary *dic in levelListArr) {
|
|
// MineDengJi *dengJi = [[MineDengJi alloc] init];
|
|
// dengJi.levelCode = dic[@"gradeNum"];
|
|
// dengJi.levelName = dic[@"gradeName"];
|
|
// dengJi.maxValue = dic[@"maxValue"];
|
|
// dengJi.minValue = dic[@"minValue"];
|
|
// dengJi.remark = dic[@"gradeRemark"];
|
|
// [_lvDescripArr addObject:dengJi];
|
|
// }
|
|
// NSArray *leveExpArr = dataDic[@"gradeRules"];
|
|
// for (NSDictionary *dic in leveExpArr) {
|
|
// JingYanValuelist *jingYan = [[JingYanValuelist alloc] init];
|
|
// jingYan.addType = dic[@"addType"];
|
|
// jingYan.addValue = dic[@"addValue"];
|
|
// jingYan.ruleName = dic[@"ruleName"];
|
|
// jingYan.ruleRemark = dic[@"ruleRemark"];
|
|
// jingYan.ruleType = dic[@"ruleType"];
|
|
//
|
|
// [_lvExpWayArr addObject:jingYan];
|
|
// }
|
|
// [weakself.tableView reloadData];
|
|
//
|
|
// }else{
|
|
// [weakself.view makeToast:@"获取信息失败"];
|
|
// }
|
|
//
|
|
// } failure:^(NSError *err) {
|
|
// [weakself.view makeToast:@"请求异常"];
|
|
// NSLog(@"%@",err);
|
|
// }];
|
|
|
|
}
|
|
|
|
-(void)creatTab{
|
|
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStyleGrouped];
|
|
self.tableView.delegate = self;
|
|
self.tableView.dataSource = self;
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
self.tableView.showsVerticalScrollIndicator = NO;
|
|
self.tableView.backgroundColor = JWUIColorFromRGB(0xf2f2f2);
|
|
[self.view addSubview:self.tableView];
|
|
}
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
if (section == 1) {
|
|
return [_lvDescripArr count] +2;
|
|
}else if (section == 2){
|
|
return [_lvExpWayArr count] +2;;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
|
return 3;
|
|
}
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
//
|
|
NSInteger cout1 = [_lvDescripArr count] ;
|
|
NSInteger cout2 = [_lvExpWayArr count] ;
|
|
|
|
if (indexPath.section ==0) {
|
|
return self.view.frame.size.width * 0.65;
|
|
}else if (indexPath.section ==1){
|
|
//return self.view.frame.size.width * 0.49;
|
|
if (indexPath.row ==0) {
|
|
return 15;
|
|
}else if (indexPath.row>=1&&indexPath.row<=cout1){
|
|
return 25;
|
|
}else if (indexPath.row == (cout1 + 1)){
|
|
return 22;
|
|
}
|
|
}else if (indexPath.section ==2){
|
|
if (indexPath.row ==0) {
|
|
return 15;
|
|
}else if (indexPath.row>=1&&indexPath.row<=cout2){
|
|
return 25;
|
|
}else if (indexPath.row==(cout2 + 1)){
|
|
return 33;
|
|
}
|
|
}
|
|
//return self.view.frame.size.width * 0.28;
|
|
|
|
return 0;
|
|
}
|
|
|
|
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
NSInteger cout1 = [_lvDescripArr count] ;
|
|
NSInteger cout2 = [_lvExpWayArr count] ;
|
|
if (indexPath.section ==0) {
|
|
DengJiView0Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"DengJiView0Cell"];
|
|
if(cell==nil){
|
|
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"DengJiView0Cell" owner:self options:nil]lastObject];
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
[cell loadCellDataWith:_lvDescripArr];
|
|
return cell;
|
|
}else if (indexPath.section ==1){
|
|
|
|
if (indexPath.section ==1 && indexPath.row == 0) {
|
|
DengJiShuoMingViewTopCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DengJiShuoMingViewTopCell"];
|
|
if(cell==nil){
|
|
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"DengJiShuoMingViewTopCell" owner:self options:nil]lastObject];
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
return cell;
|
|
|
|
}else if (indexPath.section ==1 && indexPath.row >=1&&indexPath.row<=cout1){
|
|
DengJiShuoMingViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DengJiShuoMingViewCell"];
|
|
if(cell==nil){
|
|
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"DengJiShuoMingViewCell" owner:self options:nil]lastObject];
|
|
}
|
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
MineDengJi *model =_lvDescripArr[indexPath.row -1];
|
|
[cell loadCelldata:model];
|
|
return cell;
|
|
}else if (indexPath.section ==1 && indexPath.row == (cout1 + 1)){
|
|
DengJiShuoMingViewBootomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DengJiShuoMingViewBootomCell"];
|
|
if(cell==nil){
|
|
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"DengJiShuoMingViewBootomCell" owner:self options:nil]lastObject];
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
return cell;
|
|
}
|
|
|
|
}else if (indexPath.section ==2){
|
|
if (indexPath.row ==0) {
|
|
|
|
JingYanvalueTopViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"JingYanvalueTopViewCell"];
|
|
if(cell==nil){
|
|
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"JingYanvalueTopViewCell" owner:self options:nil]lastObject];
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
return cell;
|
|
|
|
}else if (indexPath.row >=1&&indexPath.row<=cout2){
|
|
JingYanValueViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"JingYanValueViewCell"];
|
|
if(cell==nil){
|
|
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"JingYanValueViewCell" owner:self options:nil]lastObject];
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
JingYanValuelist *list = _lvExpWayArr[indexPath.row -1];
|
|
[cell loadCellWithJingYan:list];
|
|
return cell;
|
|
|
|
}else if (indexPath.row ==(cout2+1)){
|
|
|
|
JingYanValueBootomViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"JingYanValueBootomViewCell"];
|
|
if(cell==nil){
|
|
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"JingYanValueBootomViewCell" owner:self options:nil]lastObject];
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
return cell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil;
|
|
}
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|
|
|
CGFloat H = self.view.frame.size.width * 0.093;
|
|
if (section ==0) {
|
|
|
|
return 5;
|
|
}else if (section ==1){
|
|
|
|
return 10 + H;
|
|
}
|
|
|
|
return H;
|
|
}
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
|
|
|
return 0.01f;
|
|
}
|
|
|
|
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|
CGFloat H = self.view.frame.size.width * 0.093;
|
|
if (section ==1) {
|
|
UIView *back = [[UIView alloc] init];
|
|
back.frame = CGRectMake(0,0, self.view.frame.size.width, H + 10);
|
|
|
|
UIView *headerback = [[UIView alloc] init];
|
|
headerback.frame = CGRectMake(0, 10, self.view.frame.size.width, H);
|
|
headerback.backgroundColor = [UIColor whiteColor];
|
|
[back addSubview:headerback];
|
|
|
|
UIImageView *img =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rank_iocn_explain"]];
|
|
img.frame = CGRectMake(15, H - 7 - 13, 13, 13);
|
|
[headerback addSubview:img];
|
|
|
|
UILabel *shuomingLabel =[[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(img.frame) + 5,CGRectGetMinY(img.frame),100, 13)];
|
|
shuomingLabel.text = @"等级说明";
|
|
shuomingLabel.textColor = RGB(153, 153, 153);
|
|
shuomingLabel.font = [UIFont systemFontOfSize:12];
|
|
[headerback addSubview:shuomingLabel];
|
|
|
|
UIView *lineView = [[UIView alloc] init];
|
|
lineView.frame = CGRectMake(0,CGRectGetHeight(headerback.frame)-1, self.view.frame.size.width, 1);
|
|
lineView.backgroundColor = JWUIColorFromRGB(0xf2f2f2);
|
|
[headerback addSubview:lineView];
|
|
|
|
return back;
|
|
|
|
}else if (section ==2){
|
|
UIView *headerback = [[UIView alloc] init];
|
|
headerback.frame = CGRectMake(0,0, self.view.frame.size.width, H);
|
|
headerback.backgroundColor = [UIColor whiteColor];
|
|
|
|
UIImageView *img =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rank_iocn_assist"]];
|
|
img.frame = CGRectMake(15, H - 7 - 13, 13, 13);
|
|
[headerback addSubview:img];
|
|
|
|
UILabel *shuomingLabel =[[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(img.frame) + 5,CGRectGetMinY(img.frame),100, 13)];
|
|
shuomingLabel.text = @"如何获取经验值?";
|
|
shuomingLabel.textColor = RGB(153, 153, 153);
|
|
shuomingLabel.font = [UIFont systemFontOfSize:12];
|
|
[headerback addSubview:shuomingLabel];
|
|
|
|
UIView *lineView = [[UIView alloc] init];
|
|
lineView.frame = CGRectMake(0,CGRectGetHeight(headerback.frame)-1, self.view.frame.size.width, 1);
|
|
lineView.backgroundColor = JWUIColorFromRGB(0xf2f2f2);
|
|
[headerback addSubview:lineView];
|
|
|
|
return headerback;
|
|
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
[super viewWillAppear:animated];
|
|
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
/*
|
|
#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
|