diff --git a/ManagerDemo.xcodeproj/project.pbxproj b/ManagerDemo.xcodeproj/project.pbxproj index 13fa5c6..d19a6f9 100644 --- a/ManagerDemo.xcodeproj/project.pbxproj +++ b/ManagerDemo.xcodeproj/project.pbxproj @@ -40,6 +40,13 @@ A93F8806199A077F00875287 /* OtherListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A93F87FF199A077F00875287 /* OtherListViewController.m */; }; A94FE51E199C9C3C00626DE5 /* MoveSocialCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = A94FE51D199C9C3C00626DE5 /* MoveSocialCellView.m */; }; A94FE520199C9C6800626DE5 /* MoveSocialCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = A94FE51F199C9C6800626DE5 /* MoveSocialCellView.xib */; }; + A95CEA3419B754A800D4605F /* MessageCenterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A95CEA3219B754A800D4605F /* MessageCenterViewController.m */; }; + A95CEA3519B754A800D4605F /* MessageCenterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A95CEA3319B754A800D4605F /* MessageCenterViewController.xib */; }; + A95CEA3919B755C000D4605F /* MessageCenterTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A95CEA3719B755C000D4605F /* MessageCenterTableViewCell.m */; }; + A95CEA3A19B755C000D4605F /* MessageCenterTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A95CEA3819B755C000D4605F /* MessageCenterTableViewCell.xib */; }; + A95CEA3C19B7667400D4605F /* icon_success@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A95CEA3B19B7667400D4605F /* icon_success@2x.png */; }; + A95CEA4019B766F400D4605F /* MessageDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A95CEA3E19B766F400D4605F /* MessageDetailViewController.m */; }; + A95CEA4119B766F400D4605F /* MessageDetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A95CEA3F19B766F400D4605F /* MessageDetailViewController.xib */; }; A96F2A7C199D008200608237 /* UIButton+Bootstrap.m in Sources */ = {isa = PBXBuildFile; fileRef = A96F2A7B199D008200608237 /* UIButton+Bootstrap.m */; }; A96F2A7F199D01C000608237 /* NSString+FontAwesome.m in Sources */ = {isa = PBXBuildFile; fileRef = A96F2A7E199D01C000608237 /* NSString+FontAwesome.m */; }; A97F9D1519B592E90073E7E6 /* get_ver_button_gry@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A97F9D1219B592E90073E7E6 /* get_ver_button_gry@2x.png */; }; @@ -231,6 +238,16 @@ A94FE51C199C9C3C00626DE5 /* MoveSocialCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoveSocialCellView.h; sourceTree = ""; }; A94FE51D199C9C3C00626DE5 /* MoveSocialCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MoveSocialCellView.m; sourceTree = ""; }; A94FE51F199C9C6800626DE5 /* MoveSocialCellView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MoveSocialCellView.xib; sourceTree = ""; }; + A95CEA3119B754A800D4605F /* MessageCenterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageCenterViewController.h; sourceTree = ""; }; + A95CEA3219B754A800D4605F /* MessageCenterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageCenterViewController.m; sourceTree = ""; }; + A95CEA3319B754A800D4605F /* MessageCenterViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MessageCenterViewController.xib; sourceTree = ""; }; + A95CEA3619B755C000D4605F /* MessageCenterTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageCenterTableViewCell.h; sourceTree = ""; }; + A95CEA3719B755C000D4605F /* MessageCenterTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageCenterTableViewCell.m; sourceTree = ""; }; + A95CEA3819B755C000D4605F /* MessageCenterTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MessageCenterTableViewCell.xib; sourceTree = ""; }; + A95CEA3B19B7667400D4605F /* icon_success@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon_success@2x.png"; sourceTree = ""; }; + A95CEA3D19B766F400D4605F /* MessageDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageDetailViewController.h; sourceTree = ""; }; + A95CEA3E19B766F400D4605F /* MessageDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageDetailViewController.m; sourceTree = ""; }; + A95CEA3F19B766F400D4605F /* MessageDetailViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MessageDetailViewController.xib; sourceTree = ""; }; A96F2A7A199D008200608237 /* UIButton+Bootstrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+Bootstrap.h"; sourceTree = ""; }; A96F2A7B199D008200608237 /* UIButton+Bootstrap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+Bootstrap.m"; sourceTree = ""; }; A96F2A7D199D01C000608237 /* NSString+FontAwesome.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+FontAwesome.h"; sourceTree = ""; }; @@ -705,6 +722,7 @@ A9AF6C4D19949CAD0076C0EE /* Resource */ = { isa = PBXGroup; children = ( + A95CEA3B19B7667400D4605F /* icon_success@2x.png */, A9C2E4E419B6A0C900C659B3 /* icon_email@2x.png */, A97F9D1C19B5931C0073E7E6 /* register_button_s@2x.png */, A97F9D1D19B5931C0073E7E6 /* register_button@2x.png */, @@ -831,6 +849,15 @@ A986269219B413D600FF9E2C /* DailyIncomeTableViewCell.h */, A986269319B413D600FF9E2C /* DailyIncomeTableViewCell.m */, A986269419B413D600FF9E2C /* DailyIncomeTableViewCell.xib */, + A95CEA3119B754A800D4605F /* MessageCenterViewController.h */, + A95CEA3219B754A800D4605F /* MessageCenterViewController.m */, + A95CEA3319B754A800D4605F /* MessageCenterViewController.xib */, + A95CEA3619B755C000D4605F /* MessageCenterTableViewCell.h */, + A95CEA3719B755C000D4605F /* MessageCenterTableViewCell.m */, + A95CEA3819B755C000D4605F /* MessageCenterTableViewCell.xib */, + A95CEA3D19B766F400D4605F /* MessageDetailViewController.h */, + A95CEA3E19B766F400D4605F /* MessageDetailViewController.m */, + A95CEA3F19B766F400D4605F /* MessageDetailViewController.xib */, ); path = MyView; sourceTree = ""; @@ -965,6 +992,7 @@ A986268B19B40AAC00FF9E2C /* SVWebViewController.bundle in Resources */, A9AF6C731994B5890076C0EE /* icon_bar_share@2x.png in Resources */, A97F9D1519B592E90073E7E6 /* get_ver_button_gry@2x.png in Resources */, + A95CEA3A19B755C000D4605F /* MessageCenterTableViewCell.xib in Resources */, A9EAA04019985EDE001A872A /* HomeMainView.xib in Resources */, A988A902199A755300EB10AA /* FundListCell.xib in Resources */, A9AF6C6919949CD30076C0EE /* icon_dock_session@2x.png in Resources */, @@ -1010,6 +1038,7 @@ A93F87821999BB1D00875287 /* red_line_and_shadow@2x.png in Resources */, A91C6D4019AB8E9C00AEBF4D /* p2c_alert@2x.png in Resources */, A9AF6C6019949CD30076C0EE /* icon_dock_mine_actived@2x.png in Resources */, + A95CEA3C19B7667400D4605F /* icon_success@2x.png in Resources */, A919056C19B0882E002575DF /* AccountInfoViewController.xib in Resources */, A9B2507019B4C75E003E8855 /* HelpCenterViewController.xib in Resources */, A9AF6C8F1994C5700076C0EE /* MJRefresh.bundle in Resources */, @@ -1029,6 +1058,7 @@ A97F9D1619B592E90073E7E6 /* get_ver_button_red_s@2x.png in Resources */, A9B2507519B4C796003E8855 /* HelpCenterTableViewCell.xib in Resources */, A919056119B02A83002575DF /* icon_color_name@2x.png in Resources */, + A95CEA3519B754A800D4605F /* MessageCenterViewController.xib in Resources */, A9AF6BF719947DD00076C0EE /* InfoPlist.strings in Resources */, A9AF6C761994B5890076C0EE /* icon_indicate_more_down@2x.png in Resources */, A919056319B02A8C002575DF /* icon_color_person@2x.png in Resources */, @@ -1043,6 +1073,7 @@ A986269119B411AA00FF9E2C /* DailyIncomeViewController.xib in Resources */, A97F9D2419B595550073E7E6 /* InputPassWordViewController.xib in Resources */, A9AF6C3E199486CA0076C0EE /* ProductListViewController.xib in Resources */, + A95CEA4119B766F400D4605F /* MessageDetailViewController.xib in Resources */, A986269619B413D600FF9E2C /* DailyIncomeTableViewCell.xib in Resources */, A9AF6C2F199483520076C0EE /* MainViewController.xib in Resources */, A9C69452199BD14D00B2CECE /* more_icon_3@2x.png in Resources */, @@ -1127,6 +1158,7 @@ A9B2506F19B4C75E003E8855 /* HelpCenterViewController.m in Sources */, A986269519B413D600FF9E2C /* DailyIncomeTableViewCell.m in Sources */, A986268A19B40AAC00FF9E2C /* SVModalWebViewController.m in Sources */, + A95CEA4019B766F400D4605F /* MessageDetailViewController.m in Sources */, A96F2A7F199D01C000608237 /* NSString+FontAwesome.m in Sources */, A9EAA035199857F5001A872A /* HomeMainView.m in Sources */, A919055619B02741002575DF /* AccountInfoViewController.m in Sources */, @@ -1143,7 +1175,9 @@ A97F9D2719B5974B0073E7E6 /* UIUnderlinedButton.m in Sources */, A9AF6BFD19947DD00076C0EE /* AppDelegate.m in Sources */, A9AF6C911994C5700076C0EE /* MJRefreshConst.m in Sources */, + A95CEA3419B754A800D4605F /* MessageCenterViewController.m in Sources */, A9AF6C931994C5700076C0EE /* MJRefreshHeaderView.m in Sources */, + A95CEA3919B755C000D4605F /* MessageCenterTableViewCell.m in Sources */, A9F1E18619ACB63100B6A441 /* DTCoreTextTableViewCell.m in Sources */, A9AF6BF919947DD00076C0EE /* main.m in Sources */, A90BEC05199DDACA00230242 /* WYDInfoHeadView.m in Sources */, diff --git a/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate b/ManagerDemo.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate index a79b3e1..1bc1aac 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 74a52e9..8418719 100644 --- a/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.h +++ b/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.h @@ -65,4 +65,34 @@ typedef void (^FailedBlock) (NSError *error); * @return MKNetworkOperation */ -(MKNetworkOperation*)getAccountInfoWithcompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock; + +/** + * 获取消息 + * + * @param completionBlock 请求完成 + * @param failedBlock 请求失败 + * @param pageNum 页数 + * @return MKNetworkOperation + */ +-(MKNetworkOperation*)getMsgwithPageNum:(NSInteger)pageNum withCompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock; + +/** + * 标记消息已读 + * + * @param completionBlock 请求完成 + * @param failedBlock 请求失败 + * + * @return MKNetworkOperation + */ +-(MKNetworkOperation*)readMsgWithcompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock; + +/** + * 读取消息详情 + * + * @param completionBlock 请求完成 + * @param failedBlock 请求失败 + * @param msgId 页数 + * @return MKNetworkOperation + */ +-(MKNetworkOperation*)getMsgDetailwithPageNum:(NSString*)msgId withCompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock; @end diff --git a/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.m b/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.m index b50a844..a423a90 100644 --- a/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.m +++ b/ManagerDemo/Common/DaiDaiTongApi/DaiDaiTongApi.m @@ -148,4 +148,55 @@ return op; } +-(MKNetworkOperation*)getMsgwithPageNum:(NSInteger)pageNum withCompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock +{ + NSDictionary* dic = [NSDictionary dictionaryWithObjectsAndKeys:[ManagerUser shareInstance].userId, @"userId",[ManagerUser shareInstance].token,@"token",[NSNumber numberWithInt:pageNum], @"pageNum", nil]; + MKNetworkOperation* op = [self postWithPath:@"msgquerypage.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*)readMsgWithcompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock +{ + NSDictionary* dic = [NSDictionary dictionaryWithObjectsAndKeys:[ManagerUser shareInstance].userId, @"userId",[ManagerUser shareInstance].token,@"token", nil]; + MKNetworkOperation* op = [self postWithPath:@"msgread.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*)getMsgDetailwithPageNum:(NSString *)msgId withCompletionBlock:(CompletionBlock)completionBlock failedBlock:(FailedBlock)failedBlock +{ + NSDictionary* dic = [NSDictionary dictionaryWithObjectsAndKeys:[ManagerUser shareInstance].userId, @"userId",[ManagerUser shareInstance].token,@"token", msgId, @"msgId", nil]; + MKNetworkOperation* op = [self postWithPath:@"msgdetailquery.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/MBProgressHUD/MBProgressHUD+Util.m b/ManagerDemo/Common/MBProgressHUD/MBProgressHUD+Util.m index 603e9ab..81c8814 100644 --- a/ManagerDemo/Common/MBProgressHUD/MBProgressHUD+Util.m +++ b/ManagerDemo/Common/MBProgressHUD/MBProgressHUD+Util.m @@ -32,8 +32,7 @@ static MBProgressHUD *activityHUD = nil; { view = [UIApplication sharedApplication].delegate.window; } - - + [MBProgressHUD hideAllHUDsForView:view animated:YES]; MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:view]; HUD.dimBackground = NO; HUD.animationType = MBProgressHUDAnimationFade; @@ -52,13 +51,13 @@ static MBProgressHUD *activityHUD = nil; view = [UIApplication sharedApplication].delegate.window; } - + [MBProgressHUD hideAllHUDsForView:view animated:YES]; MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:view]; HUD.dimBackground = NO; HUD.animationType = MBProgressHUDAnimationFade; [view addSubview:HUD]; - HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkmark"]]; + HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_success"]]; HUD.mode = MBProgressHUDModeCustomView; HUD.labelText = msg; [HUD show:YES]; diff --git a/ManagerDemo/Common/ManagerConstants.h b/ManagerDemo/Common/ManagerConstants.h index f45df7f..7e6d41e 100644 --- a/ManagerDemo/Common/ManagerConstants.h +++ b/ManagerDemo/Common/ManagerConstants.h @@ -36,4 +36,8 @@ * 点击的背景颜色 */ #define Touch_BackGroudColor [UIColor colorWithWhite:0.5 alpha:0.3] +/** + * 错误字符串 + */ +#define Net_Error_Str @"网络出错" #endif diff --git a/ManagerDemo/MainView/ListView/FundListViewController.m b/ManagerDemo/MainView/ListView/FundListViewController.m index 50bd78e..4bd42ef 100644 --- a/ManagerDemo/MainView/ListView/FundListViewController.m +++ b/ManagerDemo/MainView/ListView/FundListViewController.m @@ -35,11 +35,12 @@ { 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) { + if (_pageNum == 1) { + [_productInfoArray removeAllObjects]; + [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + } [_productInfoArray addObjectsFromArray:[jsonRes objectForKey:@"datas"]]; // 刷新表格 if ([[jsonRes objectForKey:@"totalPages"] integerValue] <= [[jsonRes objectForKey:@"pageNum"] integerValue]) { diff --git a/ManagerDemo/MainView/ListView/ListViewController.m b/ManagerDemo/MainView/ListView/ListViewController.m index ddc5976..a604985 100644 --- a/ManagerDemo/MainView/ListView/ListViewController.m +++ b/ManagerDemo/MainView/ListView/ListViewController.m @@ -46,8 +46,6 @@ #pragma mark MJRefreshDelegate - (void)headerRereshing { - - _pageNum = 1; [self loadData]; } diff --git a/ManagerDemo/MainView/ListView/LoanListViewController.m b/ManagerDemo/MainView/ListView/LoanListViewController.m index c16daac..1558bab 100644 --- a/ManagerDemo/MainView/ListView/LoanListViewController.m +++ b/ManagerDemo/MainView/ListView/LoanListViewController.m @@ -39,11 +39,12 @@ { 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) { + if (_pageNum == 1) { + [_productInfoArray removeAllObjects]; + [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + } [_productInfoArray addObjectsFromArray:[jsonRes objectForKey:@"datas"]]; // 刷新表格 if ([[jsonRes objectForKey:@"totalPages"] integerValue] <= [[jsonRes objectForKey:@"pageNum"] integerValue]) { diff --git a/ManagerDemo/MainView/ListView/OtherListViewController.m b/ManagerDemo/MainView/ListView/OtherListViewController.m index 2cb68ff..036e224 100644 --- a/ManagerDemo/MainView/ListView/OtherListViewController.m +++ b/ManagerDemo/MainView/ListView/OtherListViewController.m @@ -39,11 +39,12 @@ 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) { + if (_pageNum == 1) { + [_productInfoArray removeAllObjects]; + [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + } [_productInfoArray addObjectsFromArray: [jsonRes objectForKey:@"datas"]]; // 刷新表格 if ([[jsonRes objectForKey:@"totalPages"] integerValue] <= [[jsonRes objectForKey:@"pageNum"] integerValue]) { diff --git a/ManagerDemo/MainView/MyView/MessageCenterTableViewCell.h b/ManagerDemo/MainView/MyView/MessageCenterTableViewCell.h new file mode 100644 index 0000000..e7f2abc --- /dev/null +++ b/ManagerDemo/MainView/MyView/MessageCenterTableViewCell.h @@ -0,0 +1,23 @@ +// +// MessageCenterTableViewCell.h +// ManagerDemo +// +// Created by xmfish on 14-9-3. +// Copyright (c) 2014年 ash. All rights reserved. +// + +#import + +@interface MessageCenterTableViewCell : UITableViewCell +{ + NSString* _msgId; + NSInteger _msgState; +} +@property (strong, nonatomic)NSString* msgId; +@property (assign, nonatomic)NSInteger msgState; +@property (weak, nonatomic) IBOutlet UILabel *nameLabel; +@property (weak, nonatomic) IBOutlet UILabel *timeLabel; +@property (weak, nonatomic) IBOutlet UILabel *infoLabel; + + +@end diff --git a/ManagerDemo/MainView/MyView/MessageCenterTableViewCell.m b/ManagerDemo/MainView/MyView/MessageCenterTableViewCell.m new file mode 100644 index 0000000..b17c40a --- /dev/null +++ b/ManagerDemo/MainView/MyView/MessageCenterTableViewCell.m @@ -0,0 +1,27 @@ +// +// MessageCenterTableViewCell.m +// ManagerDemo +// +// Created by xmfish on 14-9-3. +// Copyright (c) 2014年 ash. All rights reserved. +// + +#import "MessageCenterTableViewCell.h" + +@implementation MessageCenterTableViewCell + +- (void)awakeFromNib +{ + // Initialization code + _msgId = @""; + _msgState = 0; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated +{ + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/ManagerDemo/MainView/MyView/MessageCenterTableViewCell.xib b/ManagerDemo/MainView/MyView/MessageCenterTableViewCell.xib new file mode 100644 index 0000000..e1dbb3c --- /dev/null +++ b/ManagerDemo/MainView/MyView/MessageCenterTableViewCell.xib @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ManagerDemo/MainView/MyView/MessageCenterViewController.h b/ManagerDemo/MainView/MyView/MessageCenterViewController.h new file mode 100644 index 0000000..206179a --- /dev/null +++ b/ManagerDemo/MainView/MyView/MessageCenterViewController.h @@ -0,0 +1,14 @@ +// +// MessageCenterViewController.h +// ManagerDemo +// +// Created by xmfish on 14-9-3. +// Copyright (c) 2014年 ash. All rights reserved. +// + +#import + +@interface MessageCenterViewController : UIViewController +@property (weak, nonatomic) IBOutlet UITableView *tableView; + +@end diff --git a/ManagerDemo/MainView/MyView/MessageCenterViewController.m b/ManagerDemo/MainView/MyView/MessageCenterViewController.m new file mode 100644 index 0000000..d16990c --- /dev/null +++ b/ManagerDemo/MainView/MyView/MessageCenterViewController.m @@ -0,0 +1,149 @@ +// +// MessageCenterViewController.m +// ManagerDemo +// +// Created by xmfish on 14-9-3. +// Copyright (c) 2014年 ash. All rights reserved. +// + +#import "MessageCenterViewController.h" +#import "MessageCenterTableViewCell.h" +#import "MessageDetailViewController.h" +#import "MJRefresh.h" +@interface MessageCenterViewController () +{ + NSMutableArray* _infoArray; + NSInteger _pageNum; +} +@end + +@implementation MessageCenterViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + _infoArray = [[NSMutableArray alloc] init]; + _pageNum = 1; + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. + + self.navigationItem.title = @"消息中心"; + _tableView.delegate = self; + _tableView.dataSource = self; + [self.tableView addHeaderWithTarget:self action:@selector(headerRereshing)]; + [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + + //右边按钮 + [self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"已读" style:UIBarButtonItemStyleDone target:self action:@selector(rightBarBtnClick:)]]; + self.navigationItem.rightBarButtonItem.tintColor = [UIColor grayColor]; + [self headerRereshing]; +} +#pragma mark UIBarButtonItem +-(void)rightBarBtnClick:(id)sender +{ + [MBProgressHUD hudWithView:self.view label:@"安全加载中"]; + DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; + [daiDaiTongApi readMsgWithcompletionBlock:^(id jsonRes) { + + if ([[jsonRes objectForKey:@"succ"] integerValue] == 1) { + [MBProgressHUD checkHudWithView:self.view label:@"已全部标记为已读" hidesAfter:0.5]; + }else{ + [MBProgressHUD errorHudWithView:nil label:[jsonRes objectForKey:@"err_msg"] hidesAfter:0.5]; + } + } failedBlock:^(NSError *error) { + [MBProgressHUD errorHudWithView:self.view label:Net_Error_Str hidesAfter:0.5]; + }]; +} +#pragma mark MJRefreshDelegate +- (void)headerRereshing +{ + _pageNum = 1; + [self loadData]; +} +- (void)footerRereshing +{ + + ++_pageNum; + [self loadData]; +} +-(void)loadData +{ + if (_infoArray.count == 0) { + _tableView.hidden = YES; + } + + DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; + [daiDaiTongApi getMsgwithPageNum:_pageNum withCompletionBlock:^(id jsonRes) { + if ([[jsonRes objectForKey:@"succ"] integerValue] == 1) { + + if (_pageNum == 1) { + [_infoArray removeAllObjects]; + [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + } + if ([[jsonRes objectForKey:@"totalPages"] integerValue] <= [[jsonRes objectForKey:@"pageNum"] integerValue]) { + [self.tableView removeFooter]; + } + [_infoArray addObjectsFromArray:[jsonRes objectForKey:@"infos"]]; + _tableView.hidden = NO; + }else{ + [MBProgressHUD errorHudWithView:nil label:[jsonRes objectForKey:@"err_msg"] hidesAfter:0.5]; + } + [self.tableView reloadData]; + [self.tableView footerEndRefreshing]; + [self.tableView headerEndRefreshing]; + } failedBlock:^(NSError *error) { + [MBProgressHUD errorHudWithView:self.view label:Net_Error_Str hidesAfter:0.5]; + [self.tableView footerEndRefreshing]; + [self.tableView headerEndRefreshing]; + }]; +} +-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return _infoArray.count; +} +-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return 80; +} +-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString* cellIdentifier = @"cell"; + MessageCenterTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; + if (!cell) { + UINib *nib = [UINib nibWithNibName:@"MessageCenterTableViewCell" bundle:nil]; + [tableView registerNib:nib forCellReuseIdentifier:cellIdentifier]; + cell = (MessageCenterTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; + } + cell.msgId = [[_infoArray objectAtIndex:indexPath.row] objectForKey:@"id"]; + cell.msgState = [[[_infoArray objectAtIndex:indexPath.row] objectForKey:@"state"] integerValue]; + cell.nameLabel.text = [[_infoArray objectAtIndex:indexPath.row] objectForKey:@"title"]; + cell.timeLabel.text = [[_infoArray objectAtIndex:indexPath.row] objectForKey:@"date"]; + cell.infoLabel.text = [[_infoArray objectAtIndex:indexPath.row] objectForKey:@"content"]; + return cell; +} +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + [tableView deselectRowAtIndexPath:indexPath animated:NO]; + MessageDetailViewController* messageDetailViewController = [[MessageDetailViewController alloc] init]; + messageDetailViewController.msgId = [[_infoArray objectAtIndex:indexPath.row] objectForKey:@"id"]; + [self.navigationController pushViewController:messageDetailViewController animated:YES]; +} +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/ManagerDemo/MainView/MyView/MessageCenterViewController.xib b/ManagerDemo/MainView/MyView/MessageCenterViewController.xib new file mode 100644 index 0000000..aedc764 --- /dev/null +++ b/ManagerDemo/MainView/MyView/MessageCenterViewController.xib @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ManagerDemo/MainView/MyView/MessageDetailViewController.h b/ManagerDemo/MainView/MyView/MessageDetailViewController.h new file mode 100644 index 0000000..7e60949 --- /dev/null +++ b/ManagerDemo/MainView/MyView/MessageDetailViewController.h @@ -0,0 +1,22 @@ +// +// MessageDetailViewController.h +// ManagerDemo +// +// Created by xmfish on 14-9-3. +// Copyright (c) 2014年 ash. All rights reserved. +// + +#import + +@interface MessageDetailViewController : UIViewController +{ + NSString* _msgId; +} +@property (strong, nonatomic) NSString* msgId; +@property (strong, nonatomic) IBOutlet UITableViewCell *msgTableCell; +@property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (weak, nonatomic) IBOutlet UILabel *msgNameLabel; +@property (weak, nonatomic) IBOutlet UILabel *msgTimeLabel; +@property (weak, nonatomic) IBOutlet UILabel *msgDetailLabel; + +@end diff --git a/ManagerDemo/MainView/MyView/MessageDetailViewController.m b/ManagerDemo/MainView/MyView/MessageDetailViewController.m new file mode 100644 index 0000000..44b46bd --- /dev/null +++ b/ManagerDemo/MainView/MyView/MessageDetailViewController.m @@ -0,0 +1,98 @@ +// +// MessageDetailViewController.m +// ManagerDemo +// +// Created by xmfish on 14-9-3. +// Copyright (c) 2014年 ash. All rights reserved. +// + +#import "MessageDetailViewController.h" + +@interface MessageDetailViewController () + +@end + +@implementation MessageDetailViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + _msgId = @""; + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view from its nib. + _tableView.delegate = self; + _tableView.dataSource = self; + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _msgDetailLabel.lineBreakMode = NSLineBreakByWordWrapping; + _msgDetailLabel.numberOfLines = 0; + CGRect frame = _msgDetailLabel.frame; + frame.size.height += 100; + _msgDetailLabel.frame = frame; + [self loadData]; +} +-(void)loadData +{ + [MBProgressHUD hudWithView:self.view label:@"安全加载中"]; + _tableView.hidden = YES; + DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; + [daiDaiTongApi getMsgDetailwithPageNum:_msgId withCompletionBlock:^(id jsonRes) { + if ([[jsonRes objectForKey:@"succ"] integerValue] == 1) { + _tableView.hidden = NO; + _msgNameLabel.text = [[jsonRes objectForKey:@"data"] objectForKey:@"title"]; + _msgTimeLabel.text = [[jsonRes objectForKey:@"data"] objectForKey:@"date"]; + _msgDetailLabel.text = [[jsonRes objectForKey:@"data"] objectForKey:@"content"]; + CGSize maximumSize = CGSizeMake(280, CGFLOAT_MAX); // 第一个参数是label的宽度,第二个参数是固定的宏定义,CGFLOAT_MAX + CGSize expectedLabelSize = [[[jsonRes objectForKey:@"data"] objectForKey:@"content"] sizeWithFont:_msgDetailLabel.font + constrainedToSize:maximumSize + lineBreakMode:NSLineBreakByWordWrapping]; + + CGRect newFrame = _msgDetailLabel.frame; + newFrame.size.height = expectedLabelSize.height; + + _msgDetailLabel.frame = newFrame; + CGRect frame = _msgTableCell.frame; + frame.size.height = 45 + _msgDetailLabel.frame.size.height; + _msgTableCell.frame = frame; + _msgDetailLabel.text = [[jsonRes objectForKey:@"data"] objectForKey:@"content"]; + + [_tableView reloadData]; + [MBProgressHUD hideHUDForView:self.view animated:YES]; + }else{ + [MBProgressHUD errorHudWithView:nil label:[jsonRes objectForKey:@"err_msg"] hidesAfter:0.5]; + } + } failedBlock:^(NSError *error) { + [MBProgressHUD errorHudWithView:self.view label:Net_Error_Str hidesAfter:0.5]; + }]; +} +#pragma mark UITableViewDelegate +-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return 1; +} +-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return _msgTableCell.frame.size.height; +} +-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return _msgTableCell; +} +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/ManagerDemo/MainView/MyView/MessageDetailViewController.xib b/ManagerDemo/MainView/MyView/MessageDetailViewController.xib new file mode 100644 index 0000000..17e7f77 --- /dev/null +++ b/ManagerDemo/MainView/MyView/MessageDetailViewController.xib @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ManagerDemo/MainViewControll/MoreViewController.m b/ManagerDemo/MainViewControll/MoreViewController.m index e2b6abb..aca36d8 100644 --- a/ManagerDemo/MainViewControll/MoreViewController.m +++ b/ManagerDemo/MainViewControll/MoreViewController.m @@ -10,6 +10,7 @@ #import "MoveSocialCellView.h" #import "ActivityCenterViewController.h" #import "HelpCenterViewController.h" +#import "MessageCenterViewController.h" @interface MoreViewController () @end @@ -185,11 +186,6 @@ default: break; } -// UIView* selectedBackgroudView = [ManagerUtil selectBackgroudViewWithFrame:CGRectMake(0, 0, 320, [self tableView:tableView heightForRowAtIndexPath:indexPath])]; -// CGFloat cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath]; -// [selectedBackgroudView addSubview:[ManagerUtil lineWithColor:[UIColor grayColor] withAlpha:0.3 withFrame:CGRectMake(0, 0, 1, cellHeight) ]]; -// [selectedBackgroudView addSubview:[ManagerUtil lineWithColor:[UIColor grayColor] withAlpha:0.3 withFrame:CGRectMake(tableView.frame.size.width-1, 0, 1, cellHeight)]]; -// cell.selectedBackgroundView = selectedBackgroudView; return cell; } @@ -204,6 +200,11 @@ activityCenterViewController.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:activityCenterViewController animated:YES]; } + if (indexPath.row == 1) { + MessageCenterViewController* messageCenterViewController = [[MessageCenterViewController alloc] init]; + messageCenterViewController.hidesBottomBarWhenPushed = YES; + [self.navigationController pushViewController:messageCenterViewController animated:YES]; + } if (indexPath.row == 2) { HelpCenterViewController* helpCenterViewController = [[HelpCenterViewController alloc] init]; helpCenterViewController.hidesBottomBarWhenPushed = YES; diff --git a/ManagerDemo/MainViewControll/MyViewController.m b/ManagerDemo/MainViewControll/MyViewController.m index fa4cd21..c738291 100644 --- a/ManagerDemo/MainViewControll/MyViewController.m +++ b/ManagerDemo/MainViewControll/MyViewController.m @@ -11,6 +11,7 @@ #import "MJRefresh.h" #import "AccountInfoViewController.h" #import "DailyIncomeViewController.h" +#import "MessageCenterViewController.h" @interface MyViewController () { NSDictionary* _myInfoDic; @@ -58,8 +59,6 @@ #pragma mark MJRefreshDelegate - (void)headerRereshing { - - DaiDaiTongApi* daiDaiTongApi = [DaiDaiTongApi shareInstance]; [daiDaiTongApi getAccountInfoWithcompletionBlock:^(id jsonRes) { @@ -69,7 +68,9 @@ [_tableView reloadData]; [_tableView headerEndRefreshing]; } failedBlock:^(NSError *error) { - + [MBProgressHUD errorHudWithView:self.view label:Net_Error_Str hidesAfter:0.5]; + [_tableView reloadData]; + [_tableView headerEndRefreshing]; }]; } @@ -148,11 +149,9 @@ 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]; + _myTotalProfitCellView = [[MyTotalProfitCellView alloc] initWithFrame:frmae]; cell.selectionStyle = UITableViewCellSelectionStyleNone; - [cell addSubview:myTotalProfitCellView]; - myTotalProfitCellView.totalMoneyLabel.text = [_myInfoDic objectForKey:@"totalAmount"]; - myTotalProfitCellView.profitMoneyLabel.text = [_myInfoDic objectForKey:@"totalProfit"]; + [cell addSubview:_myTotalProfitCellView]; } break; case 3: @@ -169,7 +168,6 @@ 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; @@ -196,32 +194,14 @@ 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; + _myTotalProfitCellView.totalMoneyLabel.text = [_myInfoDic objectForKey:@"totalAmount"]; + _myTotalProfitCellView.profitMoneyLabel.text = [_myInfoDic objectForKey:@"totalProfit"]; } 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: @@ -259,8 +239,9 @@ } -(void)rightBarBtnClick:(id)sender { - DLog(@"首页右边按钮"); - [_tableView headerBeginRefreshing]; + MessageCenterViewController* messageCenterViewController = [[MessageCenterViewController alloc] init]; + messageCenterViewController.hidesBottomBarWhenPushed = YES; + [self.navigationController pushViewController:messageCenterViewController animated:YES]; } - (void)didReceiveMemoryWarning { diff --git a/ManagerDemo/Resource/icon_success@2x.png b/ManagerDemo/Resource/icon_success@2x.png new file mode 100644 index 0000000..9956034 Binary files /dev/null and b/ManagerDemo/Resource/icon_success@2x.png differ