Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
@@ -0,0 +1,17 @@
//
// MineGoldModel.h
// Ifish
//
// Created by imac on 17/3/15.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MineGoldModel : NSObject
@property(nonatomic,copy) NSString *titleName;
@property(nonatomic,copy) NSString *creatTime;
@property(nonatomic,copy) NSString *goldValue;
-(instancetype)initWithDict:(NSDictionary *)dict;
@end
@@ -0,0 +1,22 @@
//
// MineGoldModel.m
// Ifish
//
// Created by imac on 17/3/15.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "MineGoldModel.h"
@implementation MineGoldModel
-(instancetype)initWithDict:(NSDictionary *)dict
{
self.titleName = [dict objectForKey:@"ramark"];
self.creatTime = [dict objectForKey:@"createTime"];
self.goldValue = [dict objectForKey:@"value"];
return self;
}
@end
@@ -0,0 +1,26 @@
//
// MineGoldCustomViewCell.h
// Ifish
//
// Created by imac on 17/3/15.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MineGoldModel.h"
//typedef NS_ENUM(NSInteger, MineGoldCellType){
// MineGoldCellTypeIn = 0,
// MineGoldCellTypeOut
//};
@interface MineGoldCustomViewCell : UITableViewCell
//@property (nonatomic) MineGoldCellType cellType;
@property (weak, nonatomic) IBOutlet UILabel *remaklabel;
@property (weak, nonatomic) IBOutlet UILabel *creatTime;
@property (weak, nonatomic) IBOutlet UILabel *goldlabel;
-(void)loadLeftTabCellData:(MineGoldModel*)model;
-(void)loadRightTabCellData:(MineGoldModel*)model;
@end
@@ -0,0 +1,44 @@
//
// MineGoldCustomViewCell.m
// Ifish
//
// Created by imac on 17/3/15.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "MineGoldCustomViewCell.h"
@implementation MineGoldCustomViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
-(void)loadLeftTabCellData:(MineGoldModel*)model
{
self.remaklabel.text = model.titleName;
self.creatTime.text = model.creatTime;
self.goldlabel.textColor = RGB(255, 115, 92);
self.goldlabel.text = [NSString stringWithFormat:@"%@",model.goldValue];
}
-(void)loadRightTabCellData:(MineGoldModel*)model
{
self.remaklabel.text = model.titleName;
self.creatTime.text = model.creatTime;
self.goldlabel.textColor = RGB(0, 185, 239);
self.goldlabel.text = [NSString stringWithFormat:@"%@",model.goldValue];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="MineGoldCustomViewCell" rowHeight="49" id="KGk-i7-Jjw" customClass="MineGoldCustomViewCell">
<rect key="frame" x="0.0" y="0.0" width="375" height="49"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="375" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FfJ-f1-kHg">
<rect key="frame" x="15" y="8" width="31" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="16" id="XCW-ZP-ZVK"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HbL-zE-nF2">
<rect key="frame" x="15" y="28" width="160" height="15"/>
<constraints>
<constraint firstAttribute="width" constant="160" id="Wfn-Zm-tYp"/>
<constraint firstAttribute="height" constant="15" id="a9z-eN-Msk"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="160" id="lFJ-qQ-luS"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2fz-WC-IbM">
<rect key="frame" x="0.0" y="48" width="375" height="1"/>
<color key="backgroundColor" red="0.8666666666666667" green="0.8666666666666667" blue="0.8666666666666667" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="GrW-Gs-fbL"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hAk-AF-0fz">
<rect key="frame" x="283" y="17" width="77" height="15"/>
<constraints>
<constraint firstAttribute="width" constant="77" id="1e8-ZW-Eg9"/>
<constraint firstAttribute="height" constant="15" id="ES3-9q-CUZ"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="topMargin" secondItem="FfJ-f1-kHg" secondAttribute="top" id="1EB-Fc-DoN"/>
<constraint firstAttribute="bottom" secondItem="2fz-WC-IbM" secondAttribute="bottom" id="C2f-3J-wVQ"/>
<constraint firstItem="2fz-WC-IbM" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="L1h-sz-kHI"/>
<constraint firstAttribute="trailingMargin" secondItem="hAk-AF-0fz" secondAttribute="trailing" constant="7" id="S9X-ci-eqK"/>
<constraint firstAttribute="trailing" secondItem="2fz-WC-IbM" secondAttribute="trailing" id="Uhh-PO-FXe"/>
<constraint firstAttribute="bottomMargin" secondItem="HbL-zE-nF2" secondAttribute="bottom" constant="-2" id="aEF-Ny-OgK"/>
<constraint firstItem="FfJ-f1-kHg" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="7" id="csc-L4-0dQ"/>
<constraint firstItem="hAk-AF-0fz" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="eVh-bi-hAw"/>
<constraint firstItem="HbL-zE-nF2" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" constant="7" id="fHh-7L-few"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="creatTime" destination="HbL-zE-nF2" id="dJ0-uy-3m0"/>
<outlet property="goldlabel" destination="hAk-AF-0fz" id="FIL-Dd-ERB"/>
<outlet property="remaklabel" destination="FfJ-f1-kHg" id="fMS-b1-HXB"/>
</connections>
<point key="canvasLocation" x="25.5" y="51.5"/>
</tableViewCell>
</objects>
</document>
@@ -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
@@ -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