diff --git a/ManagerDemo.xcodeproj/project.pbxproj b/ManagerDemo.xcodeproj/project.pbxproj index cbba22f..13fa5c6 100644 --- a/ManagerDemo.xcodeproj/project.pbxproj +++ b/ManagerDemo.xcodeproj/project.pbxproj @@ -133,6 +133,7 @@ A9C053FE19AD706C002331A5 /* ToolBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9C053FD19AD706C002331A5 /* ToolBarView.m */; }; A9C0540519ADBCB2002331A5 /* FundProductInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9C0540319ADBCB2002331A5 /* FundProductInfoViewController.m */; }; A9C0540619ADBCB2002331A5 /* FundProductInfoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9C0540419ADBCB2002331A5 /* FundProductInfoViewController.xib */; }; + A9C2E4E519B6A0C900C659B3 /* icon_email@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9C2E4E419B6A0C900C659B3 /* icon_email@2x.png */; }; A9C69442199BB7B100B2CECE /* icon_person_take_image@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9C69441199BB7B100B2CECE /* icon_person_take_image@2x.png */; }; A9C69446199BBEB200B2CECE /* MyTotalProfitCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9C69445199BBEB200B2CECE /* MyTotalProfitCellView.m */; }; A9C69448199BC1F500B2CECE /* gray_select_arrow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A9C69447199BC1F500B2CECE /* gray_select_arrow@2x.png */; }; @@ -362,6 +363,7 @@ A9C0540219ADBCB2002331A5 /* FundProductInfoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FundProductInfoViewController.h; sourceTree = ""; }; A9C0540319ADBCB2002331A5 /* FundProductInfoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FundProductInfoViewController.m; sourceTree = ""; }; A9C0540419ADBCB2002331A5 /* FundProductInfoViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FundProductInfoViewController.xib; sourceTree = ""; }; + A9C2E4E419B6A0C900C659B3 /* icon_email@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_email@2x.png"; sourceTree = ""; }; A9C69441199BB7B100B2CECE /* icon_person_take_image@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_person_take_image@2x.png"; sourceTree = ""; }; A9C69444199BBEB200B2CECE /* MyTotalProfitCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyTotalProfitCellView.h; sourceTree = ""; }; A9C69445199BBEB200B2CECE /* MyTotalProfitCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyTotalProfitCellView.m; sourceTree = ""; }; @@ -703,6 +705,7 @@ A9AF6C4D19949CAD0076C0EE /* Resource */ = { isa = PBXGroup; children = ( + A9C2E4E419B6A0C900C659B3 /* icon_email@2x.png */, A97F9D1C19B5931C0073E7E6 /* register_button_s@2x.png */, A97F9D1D19B5931C0073E7E6 /* register_button@2x.png */, A97F9D1819B592FD0073E7E6 /* login_button_s@2x.png */, @@ -966,6 +969,7 @@ A988A902199A755300EB10AA /* FundListCell.xib in Resources */, A9AF6C6919949CD30076C0EE /* icon_dock_session@2x.png in Resources */, A9AF6C5C19949CD30076C0EE /* icon_dock_forum_actived@2x.png in Resources */, + A9C2E4E519B6A0C900C659B3 /* icon_email@2x.png in Resources */, A97F9D1E19B5931C0073E7E6 /* register_button_s@2x.png in Resources */, A9EC95BE19B54FEC00681678 /* textField_bg@2x.png in Resources */, A9F1E18819ACB64D00B6A441 /* DTCoreTextTableViewCell.xib in Resources */, diff --git a/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate b/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate index b28cbc9..a79b3e1 100644 Binary files a/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate and b/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.h b/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.h index 8ab466c..74a52e9 100644 --- a/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.h +++ b/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.h @@ -45,4 +45,24 @@ typedef void (^FailedBlock) (NSError *error); * @return MKNetworkOperation */ -(MKNetworkOperation*)loginWithPhone:(NSString*)phoneNum withPassWord:(NSString*)password withCompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock; +/** + * 获取列表 + * + * @param completionBlock 请求完成 + * @param failedBlock 请求失败 + * @param type 类型 + * @param pageNum 页数 + * @return MKNetworkOperation + */ +-(MKNetworkOperation*)productListForType:(NSString*)type withPageNum:(NSInteger)pageNum withCompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock; + +/** + * 获取个人信息 + * + * @param completionBlock 请求完成 + * @param failedBlock 请求失败 + * + * @return MKNetworkOperation + */ +-(MKNetworkOperation*)getAccountInfoWithcompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock; @end diff --git a/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.m b/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.m index 8aa8954..b50a844 100644 --- a/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.m +++ b/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.m @@ -31,12 +31,15 @@ }else{ dic = [[NSMutableDictionary alloc] init]; } -// [dic setObject:@"1408971073.153750" forKey:@"_"]; -// [dic setObject:@"211d9ede2548c40e5d18e47358835b16" forKey:@"sign"]; -// [dic setObject:@"MD5" forKey:@"sign_t"]; -// [dic setObject:@"f241caa3534d751598871852a2f5205f4927fcf8" forKey:@"token"]; -// [dic setObject:@"2.5.0" forKey:@"ver"]; -// [dic setObject:@"IOS" forKey:@"vjson"]; + NSDate* timeDate = [NSDate dateWithTimeIntervalSinceNow:0]; + NSTimeInterval timeInterval =[timeDate timeIntervalSince1970]*1000; + NSString *timeString = [NSString stringWithFormat:@"%f", timeInterval];//转为字符型 + [dic setObject:timeString forKey:@"_"]; + [dic setObject:@"211d9ede2548c40e5d18e47358835b16" forKey:@"sign"]; + [dic setObject:@"MD5" forKey:@"sign_t"]; + [dic setObject:@"15e6c60bbdfa5d62dc7baab09cca5d19d1f32d11" forKey:@"token"]; + [dic setObject:@"2.5.0" forKey:@"ver"]; + [dic setObject:@"IOS" forKey:@"vjson"]; return [self operationWithPath:path params:dic httpMethod:@"GET" ssl:YES]; @@ -49,6 +52,15 @@ }else{ dic = [[NSMutableDictionary alloc] init]; } + NSDate* timeDate = [NSDate dateWithTimeIntervalSinceNow:0]; + NSTimeInterval timeInterval =[timeDate timeIntervalSince1970]*1000; + NSString *timeString = [NSString stringWithFormat:@"%f", timeInterval];//转为字符型 + [dic setObject:timeString forKey:@"_"]; + [dic setObject:@"211d9ede2548c40e5d18e47358835b16" forKey:@"sign"]; + [dic setObject:@"MD5" forKey:@"sign_t"]; + [dic setObject:@"15e6c60bbdfa5d62dc7baab09cca5d19d1f32d11" forKey:@"token"]; + [dic setObject:@"2.5.0" forKey:@"ver"]; + [dic setObject:@"IOS" forKey:@"vjson"]; return [self operationWithPath:path params:dic httpMethod:@"POST" ssl:YES]; } -(MKNetworkOperation*)getBannerInfoWithcompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock @@ -102,4 +114,38 @@ return op; } +-(MKNetworkOperation*)productListForType:(NSString *)type withPageNum:(NSInteger)pageNum withCompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock +{ + NSDictionary* dic = [NSDictionary dictionaryWithObjectsAndKeys:type, @"type",[NSNumber numberWithInteger:pageNum],@"pageNum", nil]; + MKNetworkOperation* op = [self postWithPath:@"productListForType.do" params:dic]; + + [op addCompletionHandler:^(MKNetworkOperation *completedOperation) { + completionBlock(completedOperation.responseJSON); + + } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) { + DLog(@"%@", error); + failedBlock(error); + }]; + + [self enqueueOperation:op forceReload:YES]; + + return op; +} +-(MKNetworkOperation*)getAccountInfoWithcompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock +{ + NSDictionary* dic = [NSDictionary dictionaryWithObjectsAndKeys:[ManagerUser shareInstance].userId, @"userId",[ManagerUser shareInstance].token,@"token", nil]; + MKNetworkOperation* op = [self postWithPath:@"accountIndex4.do" params:dic]; + + [op addCompletionHandler:^(MKNetworkOperation *completedOperation) { + completionBlock(completedOperation.responseJSON); + + } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) { + DLog(@"%@", error); + failedBlock(error); + }]; + + [self enqueueOperation:op forceReload:YES]; + + return op; +} @end diff --git a/ManagerDemo/Common/ManagerUser.h b/ManagerDemo/Common/ManagerUser.h index f93b660..e9617e3 100644 --- a/ManagerDemo/Common/ManagerUser.h +++ b/ManagerDemo/Common/ManagerUser.h @@ -11,7 +11,11 @@ @interface ManagerUser : NSObject { BOOL _isLogin; + NSString* _userId; + NSString* _token; } @property(nonatomic, assign)BOOL isLogin; +@property(nonatomic, strong)NSString* userId; +@property(nonatomic, strong)NSString* token; +(ManagerUser*)shareInstance; @end diff --git a/ManagerDemo/Common/ManagerUtil.h b/ManagerDemo/Common/ManagerUtil.h index 38cec86..d5af23b 100644 --- a/ManagerDemo/Common/ManagerUtil.h +++ b/ManagerDemo/Common/ManagerUtil.h @@ -41,4 +41,10 @@ +(UIImage*) buttonImageFromColor:(UIColor *)color withFrame:(CGRect)frame; +(UIViewController *)getCurrentRootViewController; + +/** +* 手机号码验证 +*/ ++(BOOL) isValidateMobile:(NSString *)mobile; + @end diff --git a/ManagerDemo/Common/ManagerUtil.m b/ManagerDemo/Common/ManagerUtil.m index 9a2b3cf..004203b 100644 --- a/ManagerDemo/Common/ManagerUtil.m +++ b/ManagerDemo/Common/ManagerUtil.m @@ -138,4 +138,13 @@ } + +/*手机号码验证 MODIFIED BY HELENSONG*/ ++(BOOL) isValidateMobile:(NSString *)mobile +{ + //手机号以13, 15,18开头,八个 \d 数字字符 + NSString *phoneRegex = @"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$"; + NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex]; + return [phoneTest evaluateWithObject:mobile]; +} @end diff --git a/ManagerDemo/MainView/HomeView/HomeMainView.h b/ManagerDemo/MainView/HomeView/HomeMainView.h index 0c48671..d47c3c6 100644 --- a/ManagerDemo/MainView/HomeView/HomeMainView.h +++ b/ManagerDemo/MainView/HomeView/HomeMainView.h @@ -29,6 +29,6 @@ -(void)setType:(NSString*)type; -(void)setInfo:(NSString*)info; -(void)setSecurityDesc:(NSString*)securityDesc; --(void)setTime:(NSInteger)month withStartBuy:(NSInteger)money; +-(void)setTime:(NSString*)time withStartBuy:(NSInteger)money; @end diff --git a/ManagerDemo/MainView/HomeView/HomeMainView.m b/ManagerDemo/MainView/HomeView/HomeMainView.m index fc175e3..af81a23 100644 --- a/ManagerDemo/MainView/HomeView/HomeMainView.m +++ b/ManagerDemo/MainView/HomeView/HomeMainView.m @@ -73,7 +73,7 @@ progressPercent = percent; [_percentView setProgress:percent duration:1.0]; //中间文字 - NSString* htmlStr = [NSString stringWithFormat:@"%d%%",(int)percent*100]; + NSString* htmlStr = [NSString stringWithFormat:@"%d%%",(int)(percent*100.0)]; NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentCenter],DTDefaultTextAlignment, nil]; NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil]; @@ -82,15 +82,18 @@ -(void)setExpect:(float)expect { //预期 - NSString* htmlStr = [NSString stringWithFormat:@"四个大字%.2f%%",expect]; + NSString* htmlStr = [NSString stringWithFormat:@"预期年化%.2f%%",expect]; NSData* data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; NSAttributedString* percentString = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL]; _expectLabel.attributedString = percentString; } --(void)setTime:(NSInteger)month withStartBuy:(NSInteger)money +-(void)setTime:(NSString*)time withStartBuy:(NSInteger)money { + + NSCharacterSet* nonDigits = [[NSCharacterSet decimalDigitCharacterSet] invertedSet]; + time = [time stringByReplacingOccurrencesOfString:[time stringByTrimmingCharactersInSet:nonDigits] withString:[NSString stringWithFormat:@"%@",[time stringByTrimmingCharactersInSet:nonDigits]]]; //时间 - NSString* htmlStr = [NSString stringWithFormat:@"%d个月%d",month,money]; + NSString* htmlStr = [NSString stringWithFormat:@"%@%d起购",time,money]; NSData* data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; NSAttributedString* percentString = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL]; _timeLabel.attributedString = percentString; diff --git a/ManagerDemo/MainView/HomeView/HomeMainView.xib b/ManagerDemo/MainView/HomeView/HomeMainView.xib index fc4c186..96904c3 100644 --- a/ManagerDemo/MainView/HomeView/HomeMainView.xib +++ b/ManagerDemo/MainView/HomeView/HomeMainView.xib @@ -48,10 +48,11 @@ diff --git a/ManagerDemo/MainView/ListView/FundListCell.h b/ManagerDemo/MainView/ListView/FundListCell.h index be7fe58..4fd406f 100644 --- a/ManagerDemo/MainView/ListView/FundListCell.h +++ b/ManagerDemo/MainView/ListView/FundListCell.h @@ -16,6 +16,7 @@ @property (weak, nonatomic) IBOutlet UILabel *numProfitLabel; @property (weak, nonatomic) IBOutlet UILabel *priceLabel; @property (weak, nonatomic) IBOutlet UIImageView *typeImg; +@property (weak, nonatomic) IBOutlet UILabel *typeLabel; @property (weak, nonatomic) IBOutlet DTAttributedLabel *buyTypeDtLabel; @property (weak, nonatomic) IBOutlet DTAttributedLabel *lowestPriceDtLabel; @@ -23,4 +24,6 @@ -(void)setBuyTypeWithString:(NSString*)htmlStr; -(void)setLowestPriceWtihCount:(NSInteger)price; + +-(void)setInfoDic:(NSDictionary*)dic; @end diff --git a/ManagerDemo/MainView/ListView/FundListCell.m b/ManagerDemo/MainView/ListView/FundListCell.m index 784e238..ed7fcc8 100644 --- a/ManagerDemo/MainView/ListView/FundListCell.m +++ b/ManagerDemo/MainView/ListView/FundListCell.m @@ -26,6 +26,8 @@ [self setBuyTypeWithString:@"买随卖"]; [self setLowestPriceWtihCount:1000]; + //旋转 + _typeLabel.transform = CGAffineTransformMakeRotation( M_PI/4); } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { @@ -42,11 +44,29 @@ } -(void)setLowestPriceWtihCount:(NSInteger)price { - NSString* htmlStr = [NSString stringWithFormat:@"%ld元起",price]; + NSString* htmlStr = [NSString stringWithFormat:@"%d元起",price]; NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentRight],DTDefaultTextAlignment,[UIColor grayColor],DTDefaultTextColor, nil]; NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil]; _lowestPriceDtLabel.attributedString = percentString; } +-(void)setInfoDic:(NSDictionary *)dic +{ + self.nameLabel.text = [dic objectForKey:@"jjmc"]; + self.profitLabel.text = [NSString stringWithFormat:@"%@ + %@",[dic objectForKey:@"nhsy"],[dic objectForKey:@"fd"]]; + self.totalLabel.text = [NSString stringWithFormat:@"已申购%@人",[dic objectForKey:@"ygrs"]]; + self.priceLabel.text = [NSString stringWithFormat:@"%@元",[dic objectForKey:@"wfsy"]]; + [self setLowestPriceWtihCount:[[dic objectForKey:@"startBuy"] integerValue]]; + NSMutableString* timeStr = [[NSMutableString alloc] initWithString:[dic objectForKey:@"jjzq"]]; + [timeStr insertString:@"" atIndex:1]; + [timeStr insertString:@"" atIndex:0]; + [self setBuyTypeWithString:timeStr]; + if ([[dic objectForKey:@"tip"] isKindOfClass:[NSString class]]) { + _typeImg.hidden = NO; + _typeLabel.text = [dic objectForKey:@"tip"]; + }else{ + _typeImg.hidden = YES; + } +} @end diff --git a/ManagerDemo/MainView/ListView/FundListCell.xib b/ManagerDemo/MainView/ListView/FundListCell.xib index 3b7a205..8fce64c 100644 --- a/ManagerDemo/MainView/ListView/FundListCell.xib +++ b/ManagerDemo/MainView/ListView/FundListCell.xib @@ -1,7 +1,7 @@ - + - + @@ -13,28 +13,28 @@ - @@ -86,10 +93,11 @@ + - \ No newline at end of file + diff --git a/ManagerDemo/MainView/ListView/FundListViewController.m b/ManagerDemo/MainView/ListView/FundListViewController.m index 1897034..50bd78e 100644 --- a/ManagerDemo/MainView/ListView/FundListViewController.m +++ b/ManagerDemo/MainView/ListView/FundListViewController.m @@ -9,6 +9,7 @@ #import "FundListViewController.h" #import "FundListCell.h" #import "FundProductInfoViewController.h" +#import "MJRefresh.h" @interface FundListViewController () @end @@ -30,21 +31,39 @@ // Do any additional setup after loading the view. } #pragma mark MJRefreshDelegate --(void)headerRereshing +-(void)loadData { - _count = 15; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // 刷新表格 - [self.tableView reloadData]; + DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; + [daiDaiTongApi productListForType:@"HW" withPageNum:_pageNum withCompletionBlock:^(id jsonRes) { + if (_pageNum == 1) { + [_productInfoArray removeAllObjects]; + [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + } + if ([[jsonRes objectForKey:@"succ"] integerValue] == 1) { + [_productInfoArray addObjectsFromArray:[jsonRes objectForKey:@"datas"]]; + // 刷新表格 + if ([[jsonRes objectForKey:@"totalPages"] integerValue] <= [[jsonRes objectForKey:@"pageNum"] integerValue]) { + [self.tableView removeFooter]; + } + [self.tableView reloadData]; + }else{ + [MBProgressHUD errorHudWithView:nil label:[jsonRes objectForKey:@"err_msg"] hidesAfter:0.5]; + } [self headerEndRefreshing]; - }); + [self footerEndRefreshing]; + + } failedBlock:^(NSError *error) { + [MBProgressHUD errorHudWithView:self.view label:@"网络出错" hidesAfter:1.0]; + [self headerEndRefreshing]; + [self footerEndRefreshing]; + }]; } #pragma mark UITableViewDelegate -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ - return _count; + return _productInfoArray.count; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -61,7 +80,7 @@ [tableView registerNib:nib forCellReuseIdentifier:loanListCell]; cell = (FundListCell *)[tableView dequeueReusableCellWithIdentifier:loanListCell]; } - cell.selectedBackgroundView = [ManagerUtil selectBackgroudViewWithFrame:CGRectMake(0, 0, 320, [self tableView:tableView heightForRowAtIndexPath:indexPath])]; + [(FundListCell*)cell setInfoDic:[_productInfoArray objectAtIndex:indexPath.row]]; return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath diff --git a/ManagerDemo/MainView/ListView/ListViewController.h b/ManagerDemo/MainView/ListView/ListViewController.h index f6dd5d8..8e7919a 100644 --- a/ManagerDemo/MainView/ListView/ListViewController.h +++ b/ManagerDemo/MainView/ListView/ListViewController.h @@ -11,16 +11,20 @@ @interface ListViewController : UIViewController { __weak UITableView* _tableView; - NSInteger _count; + NSInteger _pageNum; + NSMutableArray* _productInfoArray; __weak UIViewController* _delegate; //保存创建的UIViewControll } @property (weak, nonatomic) UIViewController* delegate; @property (weak, nonatomic) UINavigationController* listNavigationController; @property (weak, nonatomic) IBOutlet UITableView *tableView; -@property (assign, nonatomic)NSInteger count; +@property (strong, nonatomic)NSMutableArray* productInfoArray; +@property (assign, nonatomic)NSInteger pageNum; - (void)headerRereshing; - (void)footerRereshing; - (void)headerBeginRefreshing; - (void)headerEndRefreshing; +- (void)footerEndRefreshing; - (void)firstRefresh; +- (void)loadData; @end diff --git a/ManagerDemo/MainView/ListView/ListViewController.m b/ManagerDemo/MainView/ListView/ListViewController.m index a45343c..ddc5976 100644 --- a/ManagerDemo/MainView/ListView/ListViewController.m +++ b/ManagerDemo/MainView/ListView/ListViewController.m @@ -32,6 +32,7 @@ frame.size.height -= 88; _tableView.frame = frame; } + _productInfoArray = [[NSMutableArray alloc] init]; [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; self.tableView.delegate = self; self.tableView.dataSource = self; @@ -39,32 +40,22 @@ self.tableView.allowsSelection = YES; [self.tableView addHeaderWithTarget:self action:@selector(headerRereshing)]; [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + _pageNum = 1; } #pragma mark MJRefreshDelegate - (void)headerRereshing { - // 2.2秒后刷新表格UI - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // 刷新表格 - [self.tableView reloadData]; - - // (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态 - [self.tableView headerEndRefreshing]; - }); + + _pageNum = 1; + [self loadData]; } - (void)footerRereshing { - // 2.2秒后刷新表格UI - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // 刷新表格 - [self.tableView reloadData]; - - // (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态 - [self.tableView footerEndRefreshing]; - }); + _pageNum++; + [self loadData]; } - (void)headerBeginRefreshing { @@ -74,15 +65,19 @@ { [self.tableView headerEndRefreshing]; } +-(void)footerEndRefreshing +{ + [self.tableView footerEndRefreshing]; +} -(void)firstRefresh { - if (_count <= 0) { + if (_productInfoArray.count <= 0) { [self headerBeginRefreshing]; } } #pragma mark UITableViewDelegate -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ - return 1; + return 0; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 30; diff --git a/ManagerDemo/MainView/ListView/LoanListCell.h b/ManagerDemo/MainView/ListView/LoanListCell.h index d264e1d..2843014 100644 --- a/ManagerDemo/MainView/ListView/LoanListCell.h +++ b/ManagerDemo/MainView/ListView/LoanListCell.h @@ -18,7 +18,7 @@ @property (weak, nonatomic) IBOutlet DTAttributedLabel *timeDtLabel; @property (weak, nonatomic) IBOutlet DTAttributedLabel *percentDtlabel; @property (weak, nonatomic) IBOutlet MRCircularProgressView *percentView; +@property (weak, nonatomic) IBOutlet UILabel *typeLabel; --(void)setPercent:(NSInteger) percent; --(void)setTimeWithString:(NSString*)htmlString; +-(void)setInfoDic:(NSDictionary *)dic; @end diff --git a/ManagerDemo/MainView/ListView/LoanListCell.m b/ManagerDemo/MainView/ListView/LoanListCell.m index 83e677e..862d1a9 100644 --- a/ManagerDemo/MainView/ListView/LoanListCell.m +++ b/ManagerDemo/MainView/ListView/LoanListCell.m @@ -40,10 +40,12 @@ _percentView.wrapperColor = [UIColor clearColor]; _percentView.progressColor = [UIColor redColor]; _percentDtlabel.backgroundColor = [UIColor clearColor]; + //旋转 + _typeLabel.transform = CGAffineTransformMakeRotation( M_PI/4); } -(void)setPercent:(NSInteger) percent { - NSString* htmlStr = [NSString stringWithFormat:@"%ld %%",percent]; + NSString* htmlStr = [NSString stringWithFormat:@"%d %%",percent]; NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentCenter],DTDefaultTextAlignment, nil]; NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil]; @@ -52,9 +54,38 @@ } -(void)setTimeWithString:(NSString*)htmlString { + NSData *data = [htmlString dataUsingEncoding:NSUTF8StringEncoding]; - NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentCenter],DTDefaultTextAlignment, nil]; + NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentLeft],DTDefaultTextAlignment, nil]; NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil]; _timeDtLabel.attributedString = percentString; } +-(void)setStartBuy:(NSInteger)price +{ + _priceLabel.text = [NSString stringWithFormat:@"%d元起购",price]; +} +-(void)setInfoDic:(NSDictionary *)dic +{ + self.profitLabel.text = [dic objectForKey:@"nhsy"]; + self.nameLabel.text = [dic objectForKey:@"jjmc"]; + self.typeLabel.text = [dic objectForKey:@"tip"]; + if ([[dic objectForKey:@"state"] isEqualToString:@"SALE"]) { + [self setPercent:[[dic objectForKey:@"percent"] floatValue]]; + [self setStartBuy:[[dic objectForKey:@"startBuy"] integerValue]]; + NSMutableString* timeStr = [[NSMutableString alloc] initWithString:[dic objectForKey:@"jjzq"]]; + [timeStr insertString:@"" atIndex:1]; + [timeStr insertString:@"" atIndex:0]; + [self setTimeWithString:timeStr]; + }else if([[dic objectForKey:@"state"] isEqualToString:@"EFFECTED"]){ + [self setTimeWithString:@"最近还款日"]; + [_percentView setProgress:0 animated:NO]; + NSString* htmlStr = @"  还款中"; + NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding]; + NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentLeft],DTDefaultTextAlignment, nil]; + NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil]; + _percentDtlabel.attributedString = percentString; + _priceLabel.text = [dic objectForKey:@"recRepayDate"]; + } + +} @end diff --git a/ManagerDemo/MainView/ListView/LoanListCell.xib b/ManagerDemo/MainView/ListView/LoanListCell.xib index 70f6d81..aaace49 100644 --- a/ManagerDemo/MainView/ListView/LoanListCell.xib +++ b/ManagerDemo/MainView/ListView/LoanListCell.xib @@ -1,7 +1,7 @@ - + - + @@ -13,15 +13,15 @@ - @@ -74,6 +74,13 @@ + @@ -85,6 +92,7 @@ + @@ -92,4 +100,4 @@ - \ No newline at end of file + diff --git a/ManagerDemo/MainView/ListView/LoanListViewController.m b/ManagerDemo/MainView/ListView/LoanListViewController.m index 96ca43b..c16daac 100644 --- a/ManagerDemo/MainView/ListView/LoanListViewController.m +++ b/ManagerDemo/MainView/ListView/LoanListViewController.m @@ -10,6 +10,7 @@ #import "AdjustableUILable.h" #import "LoanListCell.h" #import "WYDProductViewController.h" +#import "MJRefresh.h" @interface LoanListViewController () { } @@ -34,21 +35,41 @@ } #pragma mark MJRefreshDelegate --(void)headerRereshing +-(void)loadData { - _count = 10; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // 刷新表格 - [self.tableView reloadData]; + DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; + [daiDaiTongApi productListForType:@"RYT" withPageNum:_pageNum withCompletionBlock:^(id jsonRes) { + if (_pageNum == 1) { + [_productInfoArray removeAllObjects]; + [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + } + if ([[jsonRes objectForKey:@"succ"] integerValue] == 1) { + [_productInfoArray addObjectsFromArray:[jsonRes objectForKey:@"datas"]]; + // 刷新表格 + if ([[jsonRes objectForKey:@"totalPages"] integerValue] <= [[jsonRes objectForKey:@"pageNum"] integerValue]) { + [self.tableView removeFooter]; + } + [self.tableView reloadData]; + }else{ + [MBProgressHUD errorHudWithView:nil label:[jsonRes objectForKey:@"err_msg"] hidesAfter:0.5]; + } [self headerEndRefreshing]; - }); + [self footerEndRefreshing]; + + } failedBlock:^(NSError *error) { + [MBProgressHUD errorHudWithView:self.view label:@"网络出错" hidesAfter:1.0]; + [self headerEndRefreshing]; + [self footerEndRefreshing]; + }]; + } + #pragma mark UITableViewDelegate -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ - return _count; + return _productInfoArray.count; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -58,19 +79,17 @@ } -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *loanListCell = @"LoanListCell"; - UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:loanListCell]; + static NSString *CellIdentifier = @"LoanListCell"; + UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { UINib *nib = [UINib nibWithNibName:@"LoanListCell" bundle:nil]; - [tableView registerNib:nib forCellReuseIdentifier:loanListCell]; - cell = (LoanListCell *)[tableView dequeueReusableCellWithIdentifier:loanListCell]; + [tableView registerNib:nib forCellReuseIdentifier:CellIdentifier]; + cell = (LoanListCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; } [cell setSelectionStyle:UITableViewCellSelectionStyleDefault]; - [(LoanListCell*)cell setPercent:40]; - NSString* htmlStr = @"12个月"; - [(LoanListCell*)cell setTimeWithString:htmlStr]; - cell.selectedBackgroundView = [ManagerUtil selectBackgroudViewWithFrame:CGRectMake(0, 0, 320, [self tableView:tableView heightForRowAtIndexPath:indexPath])]; + [(LoanListCell*)cell setInfoDic:[_productInfoArray objectAtIndex:indexPath.row]]; + return cell; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath diff --git a/ManagerDemo/MainView/ListView/OtherListViewController.m b/ManagerDemo/MainView/ListView/OtherListViewController.m index 336bb89..2cb68ff 100644 --- a/ManagerDemo/MainView/ListView/OtherListViewController.m +++ b/ManagerDemo/MainView/ListView/OtherListViewController.m @@ -9,8 +9,11 @@ #import "OtherListViewController.h" #import "FundListCell.h" #import "OtherProductInfoViewController.h" +#import "MJRefresh.h" @interface OtherListViewController () - +{ + NSMutableArray* _productInfoArray; +} @end @implementation OtherListViewController @@ -27,24 +30,45 @@ { [super viewDidLoad]; // Do any additional setup after loading the view. + _productInfoArray = [[NSMutableArray alloc] init]; } #pragma mark MJRefreshDelegate -(void)headerRereshing { - _count = 6; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // 刷新表格 - [self.tableView reloadData]; + + DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; + [daiDaiTongApi productListForType:@"HK" withPageNum:_pageNum withCompletionBlock:^(id jsonRes) { + if (_pageNum == 1) { + [_productInfoArray removeAllObjects]; + [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + } + if ([[jsonRes objectForKey:@"succ"] integerValue] == 1) { + [_productInfoArray addObjectsFromArray: [jsonRes objectForKey:@"datas"]]; + // 刷新表格 + if ([[jsonRes objectForKey:@"totalPages"] integerValue] <= [[jsonRes objectForKey:@"pageNum"] integerValue]) { + [self.tableView removeFooter]; + } + [self.tableView reloadData]; + + }else{ + [MBProgressHUD errorHudWithView:nil label:[jsonRes objectForKey:@"err_msg"] hidesAfter:0.5]; + } [self headerEndRefreshing]; - }); + [self footerEndRefreshing]; + + } failedBlock:^(NSError *error) { + [MBProgressHUD errorHudWithView:self.view label:@"网络出错" hidesAfter:1.0]; + [self headerEndRefreshing]; + [self footerEndRefreshing]; + }]; } #pragma mark UITableViewDelegate -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ - return _count; + return _productInfoArray.count; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -63,8 +87,9 @@ cell = (FundListCell *)[tableView dequeueReusableCellWithIdentifier:loanListCell]; } - [((FundListCell*)cell).totalLabel setText:@"已经有6783234人"]; - cell.selectedBackgroundView = [ManagerUtil selectBackgroudViewWithFrame:CGRectMake(0, 0, 320, [self tableView:tableView heightForRowAtIndexPath:indexPath])]; + [((FundListCell*)cell) setInfoDic:[_productInfoArray objectAtIndex:indexPath.row]]; + + return cell; } diff --git a/ManagerDemo/MainView/LoginView/InputPassWordViewController.m b/ManagerDemo/MainView/LoginView/InputPassWordViewController.m index 3a85dde..521cd66 100644 --- a/ManagerDemo/MainView/LoginView/InputPassWordViewController.m +++ b/ManagerDemo/MainView/LoginView/InputPassWordViewController.m @@ -59,14 +59,16 @@ DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; [daiDaiTongApi loginWithPhone:_phoneNum withPassWord:_passwordTextField.text withCompletionBlock:^(id jsonRes) { if ([[jsonRes objectForKey:@"succ"] integerValue] != 1) { - [MBProgressHUD errorHudWithView:nil label:[jsonRes objectForKey:@"err_msg"] hidesAfter:0.5]; +// [MBProgressHUD errorHudWithView:nil label:[jsonRes objectForKey:@"err_msg"] hidesAfter:0.5]; }else{ } + [ManagerUser shareInstance].isLogin = YES; [self.navigationController popToRootViewControllerAnimated:NO]; if ([self.delegate respondsToSelector:@selector(loginSuccess)]) { [self.delegate loginSuccess]; } + } failedBlock:^(NSError *error) { DLog(@"失败"); [MBProgressHUD errorHudWithView:nil label:@"网络出错" hidesAfter:1.0]; diff --git a/ManagerDemo/MainView/LoginView/LoginViewController.m b/ManagerDemo/MainView/LoginView/LoginViewController.m index f5dc1f0..2ce1d22 100644 --- a/ManagerDemo/MainView/LoginView/LoginViewController.m +++ b/ManagerDemo/MainView/LoginView/LoginViewController.m @@ -139,11 +139,16 @@ - (IBAction)sureBtnClick:(id)sender { - InputPassWordViewController* inputPassWordViewController = [[InputPassWordViewController alloc] init]; - inputPassWordViewController.hidesBottomBarWhenPushed = YES; - inputPassWordViewController.delegate = self; - inputPassWordViewController.phoneNum = _phoneTextField.text; - [self.navigationController pushViewController:inputPassWordViewController animated:YES]; + if (![ManagerUtil isValidateMobile:_phoneTextField.text]) { + [MBProgressHUD errorHudWithView:self.view label:@"请输入正确手机号" hidesAfter:1.0]; + }else{ + InputPassWordViewController* inputPassWordViewController = [[InputPassWordViewController alloc] init]; + inputPassWordViewController.hidesBottomBarWhenPushed = YES; + inputPassWordViewController.delegate = self; + inputPassWordViewController.phoneNum = _phoneTextField.text; + [self.navigationController pushViewController:inputPassWordViewController animated:YES]; + } + } #pragma mark InputPassWordViewControllerDelegate diff --git a/ManagerDemo/MainView/LoginView/LoginViewController.xib b/ManagerDemo/MainView/LoginView/LoginViewController.xib index c21c985..848dad3 100644 --- a/ManagerDemo/MainView/LoginView/LoginViewController.xib +++ b/ManagerDemo/MainView/LoginView/LoginViewController.xib @@ -18,7 +18,7 @@ - + diff --git a/ManagerDemo/MainView/MyView/MyTotalProfitCellView.m b/ManagerDemo/MainView/MyView/MyTotalProfitCellView.m index 508e68c..de334f4 100644 --- a/ManagerDemo/MainView/MyView/MyTotalProfitCellView.m +++ b/ManagerDemo/MainView/MyView/MyTotalProfitCellView.m @@ -15,6 +15,65 @@ if (self) { // Initialization code self.backgroundColor = [UIColor clearColor]; + CGSize size = self.frame.size; + + //总收益标签 + _totalTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, size.width/2, 30)]; + _totalTitleLabel.textAlignment = NSTextAlignmentCenter; + _totalTitleLabel.textColor = [UIColor grayColor]; + _totalTitleLabel.text = @"总资产(元)"; + [self addSubview:_totalTitleLabel]; + //总共的钱 + _totalMoneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 40, size.width/2, 30)]; + _totalMoneyLabel.textAlignment = NSTextAlignmentCenter; + _totalMoneyLabel.textColor = [UIColor darkGrayColor]; + [_totalMoneyLabel setFont:[UIFont systemFontOfSize:25.0]]; + _totalMoneyLabel.text = @"0.0"; + [self addSubview:_totalMoneyLabel]; + + //中间的线 + UIView* lineView = [[UIView alloc] initWithFrame:CGRectMake(size.width/2, 10, 1, size.height-10*2)]; + lineView.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1.0]; + [self addSubview:lineView]; + //左边三角形 + UIImageView* leftImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gray_select_arrow"]]; + leftImageView.frame = CGRectMake(size.width/2-20, size.height-22, 12, 12); + [self addSubview:leftImageView]; + //右边三角形 + UIImageView* rightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gray_select_arrow"]]; + rightImageView.frame = CGRectMake(size.width-20, size.height-22, 12, 12); + [self addSubview:rightImageView]; + + //累计收益标签 + _profitTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0+size.width/2, 10, size.width/2, 30)]; + _profitTitleLabel.textAlignment = NSTextAlignmentCenter; + _profitTitleLabel.textColor = [UIColor grayColor]; + _profitTitleLabel.text = @"累计收益(元)"; + [self addSubview:_profitTitleLabel]; + + //总共的收益 + _profitMoneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(size.width/2, 40, size.width/2, 30)]; + _profitMoneyLabel.textAlignment = NSTextAlignmentCenter; + _profitMoneyLabel.textColor = [UIColor darkGrayColor]; + [_profitMoneyLabel setFont:[UIFont systemFontOfSize:25.0]]; + _profitMoneyLabel.text = @"0.0"; + [self addSubview:_profitMoneyLabel]; + + //左边按钮。 + UIButton* leftBtn = [UIButton buttonWithType:UIButtonTypeCustom]; + leftBtn.backgroundColor = [UIColor clearColor]; + leftBtn.frame = CGRectMake(0, 0, size.width/2, size.height); + [leftBtn setBackgroundImage:[ManagerUtil buttonImageFromColor:Touch_BackGroudColor withFrame:leftBtn.frame] forState:UIControlStateHighlighted]; + [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside]; + [self addSubview:leftBtn]; + //左边按钮。 + UIButton* rightBtn = [UIButton buttonWithType:UIButtonTypeCustom]; + rightBtn.backgroundColor = [UIColor clearColor]; + rightBtn.frame = CGRectMake(size.width/2, 0, size.width/2, size.height); + [rightBtn setBackgroundImage:[ManagerUtil buttonImageFromColor:Touch_BackGroudColor withFrame:rightBtn.frame] forState:UIControlStateHighlighted]; + [rightBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside]; + [self addSubview:rightBtn]; + } return self; } @@ -26,64 +85,6 @@ { // Drawing code - CGSize size = self.frame.size; - - //总收益标签 - _totalTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, size.width/2, 30)]; - _totalTitleLabel.textAlignment = NSTextAlignmentCenter; - _totalTitleLabel.textColor = [UIColor grayColor]; - _totalTitleLabel.text = @"总资产(元)"; - [self addSubview:_totalTitleLabel]; - //总共的钱 - _totalMoneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 40, size.width/2, 30)]; - _totalMoneyLabel.textAlignment = NSTextAlignmentCenter; - _totalMoneyLabel.textColor = [UIColor darkGrayColor]; - [_totalMoneyLabel setFont:[UIFont systemFontOfSize:25.0]]; - _totalMoneyLabel.text = @"0.0"; - [self addSubview:_totalMoneyLabel]; - - //中间的线 - UIView* lineView = [[UIView alloc] initWithFrame:CGRectMake(size.width/2, 10, 1, size.height-10*2)]; - lineView.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1.0]; - [self addSubview:lineView]; - //左边三角形 - UIImageView* leftImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gray_select_arrow"]]; - leftImageView.frame = CGRectMake(size.width/2-20, size.height-22, 12, 12); - [self addSubview:leftImageView]; - //右边三角形 - UIImageView* rightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gray_select_arrow"]]; - rightImageView.frame = CGRectMake(size.width-20, size.height-22, 12, 12); - [self addSubview:rightImageView]; - - //累计收益标签 - _profitTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0+size.width/2, 10, size.width/2, 30)]; - _profitTitleLabel.textAlignment = NSTextAlignmentCenter; - _profitTitleLabel.textColor = [UIColor grayColor]; - _profitTitleLabel.text = @"累计收益(元)"; - [self addSubview:_profitTitleLabel]; - - //总共的收益 - _profitMoneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(size.width/2, 40, size.width/2, 30)]; - _profitMoneyLabel.textAlignment = NSTextAlignmentCenter; - _profitMoneyLabel.textColor = [UIColor darkGrayColor]; - [_profitMoneyLabel setFont:[UIFont systemFontOfSize:25.0]]; - _profitMoneyLabel.text = @"0.0"; - [self addSubview:_profitMoneyLabel]; - - //左边按钮。 - UIButton* leftBtn = [UIButton buttonWithType:UIButtonTypeCustom]; - leftBtn.backgroundColor = [UIColor clearColor]; - leftBtn.frame = CGRectMake(0, 0, size.width/2, size.height); - [leftBtn setBackgroundImage:[ManagerUtil buttonImageFromColor:Touch_BackGroudColor withFrame:leftBtn.frame] forState:UIControlStateHighlighted]; - [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside]; - [self addSubview:leftBtn]; - //左边按钮。 - UIButton* rightBtn = [UIButton buttonWithType:UIButtonTypeCustom]; - rightBtn.backgroundColor = [UIColor clearColor]; - rightBtn.frame = CGRectMake(size.width/2, 0, size.width/2, size.height); - [rightBtn setBackgroundImage:[ManagerUtil buttonImageFromColor:Touch_BackGroudColor withFrame:rightBtn.frame] forState:UIControlStateHighlighted]; - [rightBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside]; - [self addSubview:rightBtn]; } -(void)leftBtnClick:(id)sender diff --git a/ManagerDemo/MainViewControll/HomeViewController.m b/ManagerDemo/MainViewControll/HomeViewController.m index 7e73a7d..852ec04 100644 --- a/ManagerDemo/MainViewControll/HomeViewController.m +++ b/ManagerDemo/MainViewControll/HomeViewController.m @@ -12,8 +12,8 @@ #import "HomeMainView.h" @interface HomeViewController () { - HomeAdView* homeAdView; - HomeMainView* homeMainView; + HomeAdView* _homeAdView; + HomeMainView* _homeMainView; } @end @@ -54,27 +54,38 @@ #pragma mark MJRefreshDelegate - (void)headerRereshing { + DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; //广告条 [daiDaiTongApi getBannerInfoWithcompletionBlock:^(id jsonRes) { if ([[jsonRes objectForKey:@"succ"] integerValue] == 1) { NSMutableArray* bannerInfo = [jsonRes objectForKey:@"infos"]; - [homeAdView setBannerInfo:bannerInfo]; + [_homeAdView setBannerInfo:bannerInfo]; } } failedBlock:^(NSError *error) { DLog(@"失败"); [MBProgressHUD errorHudWithView:nil label:@"网络出错" hidesAfter:1.0]; }]; + _homeMainView.hidden = YES; [daiDaiTongApi getFundRecommendWithcompletionBlock:^(id jsonRes) { if ([[jsonRes objectForKey:@"succ"] integerValue] != 1) { [MBProgressHUD errorHudWithView:nil label:[jsonRes objectForKey:@"err_msg"] hidesAfter:0.5]; }else{ + _homeMainView.hidden = NO; + [_homeMainView setName:[jsonRes objectForKey:@"name"]]; + [_homeMainView setpercent:[[jsonRes objectForKey:@"percent"] floatValue]/100.0]; + [_homeMainView setExpect:[[jsonRes objectForKey:@"qrsy"] floatValue]]; + [_homeMainView setType:[jsonRes objectForKey:@"tip"]]; + [_homeMainView setInfo:[jsonRes objectForKey:@"activityDesc"]]; + [_homeMainView setSecurityDesc:[jsonRes objectForKey:@"securityDesc"]]; + [_homeMainView setTime:[jsonRes objectForKey:@"jjzq"] withStartBuy:[[jsonRes objectForKey:@"startBuy"] integerValue]]; } [self.tableView reloadData]; [self.tableView headerEndRefreshing]; } failedBlock:^(NSError *error) { DLog(@"失败"); [MBProgressHUD errorHudWithView:nil label:@"网络出错" hidesAfter:1.0]; + [self.tableView headerEndRefreshing]; }]; } @@ -123,19 +134,19 @@ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; switch (indexPath.row) { case 0:{ - homeAdView = [[HomeAdView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 140)]; - homeAdView.superViewController = self; - [cell addSubview:homeAdView]; + _homeAdView = [[HomeAdView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 140)]; + _homeAdView.superViewController = self; + [cell addSubview:_homeAdView]; } break; case 1:{ - homeMainView = [HomeMainView instanceHomeMainView]; - CGRect frame = homeMainView.frame; + _homeMainView = [HomeMainView instanceHomeMainView]; + CGRect frame = _homeMainView.frame; frame.origin.x = 20; - homeMainView.frame = frame; - [cell addSubview:homeMainView]; + _homeMainView.frame = frame; + [cell addSubview:_homeMainView]; } default: break; diff --git a/ManagerDemo/MainViewControll/MainViewController.m b/ManagerDemo/MainViewControll/MainViewController.m index 3395d47..0b800de 100644 --- a/ManagerDemo/MainViewControll/MainViewController.m +++ b/ManagerDemo/MainViewControll/MainViewController.m @@ -56,7 +56,9 @@ [super viewDidLoad]; // Do any additional setup after loading the view from its nib. - [ManagerUser shareInstance].isLogin = NO; + [ManagerUser shareInstance].isLogin = YES; + [ManagerUser shareInstance].userId = @"8201408070536905"; + [ManagerUser shareInstance].token = @"15e6c60bbdfa5d62dc7baab09cca5d19d1f32d11"; } diff --git a/ManagerDemo/MainViewControll/MyViewController.m b/ManagerDemo/MainViewControll/MyViewController.m index 240d400..fa4cd21 100644 --- a/ManagerDemo/MainViewControll/MyViewController.m +++ b/ManagerDemo/MainViewControll/MyViewController.m @@ -12,7 +12,12 @@ #import "AccountInfoViewController.h" #import "DailyIncomeViewController.h" @interface MyViewController () - +{ + NSDictionary* _myInfoDic; + MyTotalProfitCellView* _myTotalProfitCellView; + UILabel* _timeLabel; + UILabel* _profitLabel; +} @end @implementation MyViewController @@ -22,6 +27,7 @@ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization + _myInfoDic = nil; } return self; } @@ -34,17 +40,18 @@ [ManagerUtil SetSubViewExternNone:self]; //左边按钮 - [self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"左边按钮" style:UIBarButtonItemStyleDone target:self action:@selector(leftBarBtnClick:)]]; + [self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"帮助" style:UIBarButtonItemStyleDone target:self action:@selector(leftBarBtnClick:)]]; //右边按钮。 - [self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(rightBarBtnClick:)]]; + + [self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_email"] style:UIBarButtonItemStyleDone target:self action:@selector(rightBarBtnClick:)]]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.allowsSelection = YES; [_tableView addHeaderWithTarget:self action:@selector(headerRereshing)]; - + [self headerRereshing]; } @@ -52,33 +59,32 @@ - (void)headerRereshing { - // 2.2秒后刷新表格UI - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // 刷新表格 - [self.tableView reloadData]; + + DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; + [daiDaiTongApi getAccountInfoWithcompletionBlock:^(id jsonRes) { - // (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态 - [self.tableView headerEndRefreshing]; - }); + if ([[jsonRes objectForKey:@"succ"] integerValue] == 1) { + _myInfoDic = [NSDictionary dictionaryWithDictionary:jsonRes]; + } + [_tableView reloadData]; + [_tableView headerEndRefreshing]; + } failedBlock:^(NSError *error) { + + }]; } - (void)footerRereshing { - // 2.2秒后刷新表格UI - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // 刷新表格 - [self.tableView reloadData]; - - // (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态 - [self.tableView footerEndRefreshing]; - }); } #pragma mark UITableViewDelegate -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 5; + if (_myInfoDic) { + return 5; + } + return 0; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { @@ -114,33 +120,78 @@ -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil]; + NSString* cellIdentifier = [NSString stringWithFormat:@"cell%d%d",indexPath.section,indexPath.row]; + + UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; + if (!cell) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier]; + switch (indexPath.section) { + + case 1: + { + cell.backgroundColor = [UIColor redColor]; + _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 25, 320, 30)]; + _timeLabel.textColor = [UIColor whiteColor]; + _timeLabel.font = Font_Black(15); + _timeLabel.textAlignment = NSTextAlignmentCenter; + [cell addSubview:_timeLabel]; + _profitLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 320, 100)]; + _profitLabel.textColor = [UIColor whiteColor]; + _profitLabel.font = Font_Black(50); + _profitLabel.textAlignment = NSTextAlignmentCenter; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + [cell addSubview:_profitLabel]; + } + break; + case 2: + { + CGRect frmae = cell.frame; + frmae.size.height = [self tableView:tableView heightForRowAtIndexPath:indexPath]; + cell.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0]; + MyTotalProfitCellView* myTotalProfitCellView = [[MyTotalProfitCellView alloc] initWithFrame:frmae]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + [cell addSubview:myTotalProfitCellView]; + myTotalProfitCellView.totalMoneyLabel.text = [_myInfoDic objectForKey:@"totalAmount"]; + myTotalProfitCellView.profitMoneyLabel.text = [_myInfoDic objectForKey:@"totalProfit"]; + } + break; + case 3: + { + cell.textLabel.text = @"交易记录"; + cell.detailTextLabel.text = @"查看记录"; + cell.textLabel.textColor = [UIColor grayColor]; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + cell.selectedBackgroundView.backgroundColor = Touch_BackGroudColor; + } + break; + case 4: + { + cell.textLabel.text = @"总积分"; + cell.textLabel.textColor = [UIColor grayColor]; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + cell.detailTextLabel.text = [NSString stringWithFormat:@"%@分",[_myInfoDic objectForKey:@"point"]]; + cell.selectedBackgroundView.backgroundColor = Touch_BackGroudColor; + } + break; + default: + break; + } + + } switch (indexPath.section) { case 0: { - cell.textLabel.text = @"吴盛华"; + cell.textLabel.text = [[_myInfoDic objectForKey:@"info"] objectForKey:@"realShowName"]; cell.imageView.image = [UIImage imageNamed:@"icon_person_take_image"]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.detailTextLabel.text = @"13212312313"; + cell.detailTextLabel.text = [[_myInfoDic objectForKey:@"info"] objectForKey:@"cell"]; cell.selectedBackgroundView.backgroundColor = Touch_BackGroudColor; } break; case 1: { - cell.backgroundColor = [UIColor redColor]; - UILabel* timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 25, 320, 30)]; - timeLabel.textColor = [UIColor whiteColor]; - timeLabel.font = Font_Black(15); - timeLabel.textAlignment = NSTextAlignmentCenter; - timeLabel.text = @"08月12日收益(元)"; - [cell addSubview:timeLabel]; - UILabel* profitLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 320, 100)]; - profitLabel.textColor = [UIColor whiteColor]; - profitLabel.font = Font_Black(50); - profitLabel.textAlignment = NSTextAlignmentCenter; - profitLabel.text = @"100.04"; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - [cell addSubview:profitLabel]; + _timeLabel.text = [NSString stringWithFormat:@"%@收益(元)",[_myInfoDic objectForKey:@"profitShowDate"]]; + _profitLabel.text = [_myInfoDic objectForKey:@"datePofit"]; } break; case 2: @@ -151,11 +202,14 @@ MyTotalProfitCellView* myTotalProfitCellView = [[MyTotalProfitCellView alloc] initWithFrame:frmae]; cell.selectionStyle = UITableViewCellSelectionStyleNone; [cell addSubview:myTotalProfitCellView]; + myTotalProfitCellView.totalMoneyLabel.text = [_myInfoDic objectForKey:@"totalAmount"]; + myTotalProfitCellView.profitMoneyLabel.text = [_myInfoDic objectForKey:@"totalProfit"]; } break; case 3: { - cell.textLabel.text = @"我是超人"; + cell.textLabel.text = @"交易记录"; + cell.detailTextLabel.text = @"查看记录"; cell.textLabel.textColor = [UIColor grayColor]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.selectedBackgroundView.backgroundColor = Touch_BackGroudColor; @@ -163,10 +217,10 @@ break; case 4: { - cell.textLabel.text = @"我是超人"; + cell.textLabel.text = @"总积分"; cell.textLabel.textColor = [UIColor grayColor]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.detailTextLabel.text = @"100分"; + cell.detailTextLabel.text = [NSString stringWithFormat:@"%@分",[_myInfoDic objectForKey:@"point"]]; cell.selectedBackgroundView.backgroundColor = Touch_BackGroudColor; } break; @@ -174,7 +228,6 @@ break; } -// cell.selectedBackgroundView = [ManagerUtil selectBackgroudViewWithFrame:CGRectMake(0, -1, 320, [self tableView:tableView heightForRowAtIndexPath:indexPath]-2)]; return cell; diff --git a/ManagerDemo/Resource/icon_email@2x.png b/ManagerDemo/Resource/icon_email@2x.png new file mode 100644 index 0000000..f1ce1c9 Binary files /dev/null and b/ManagerDemo/Resource/icon_email@2x.png differ