1、变更推送为阿里云推,清除云信IM以及推送内容;

2、消息页面全新改版;
3、部分微小Bug修复
This commit is contained in:
wbzhan
2019-05-24 19:21:31 +08:00
parent c586949438
commit 25c051d5f1
1544 changed files with 17136 additions and 78376 deletions
@@ -8,17 +8,19 @@
#import "IfishMessageViewController.h"
#import "AFNetworking.h"
#import "IfishMassageViewCell.h"
#import "IfishMassageModel.h"
#import "PushmassageModel.h"
#import "IfishDatabaseManager.h"
#import "JHRefresh.h"
#import "IfishMessageViewCell.h"
//#import "IfishDatabaseManager.h"
//#import "JHRefresh.h"
#import "IfishNomassageView.h"
#import "PushMasssageWebViewController.h"
#import "ShareReportViewController.h"
#import "KanHuBaoGaoModel.h"
#import "PingfenModel.h"
//#import "PushMasssageWebViewController.h"
//#import "ShareReportViewController.h"
//#import "KanHuBaoGaoModel.h"
//#import "PingfenModel.h"
#import "AFNOHeaderHttpTool.h"
#import "MessageAlertView.h"
#import "SVProgressHUD.h"
#import "IfishUserAsset.h"
#import "YYCache.h"
@interface IfishMessageViewController ()<UITableViewDelegate,UITableViewDataSource>
{
BOOL _isRefreshing;
@@ -29,8 +31,9 @@
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong) NSMutableArray *pushMassageArr;
@property(nonatomic,strong) NSMutableArray *messageArray;//新消息
@property(nonatomic,strong) NSMutableArray *oldMessageArr;//旧消息
@property(nonatomic,strong) NSMutableArray *dataSource;//数据源
@property(nonatomic)BOOL isRefreshing;
@property(nonatomic)BOOL isLoadMore;
@@ -41,8 +44,18 @@
@property(nonatomic) int page;
Copy NSString *lastPushId;//最近一次推送的Id
@property(nonatomic,strong)NSDictionary*para;
Strong NSMutableArray *deleteArray;//将要删除字符串的id集合
Assign BOOL isDelteAll;//是否全选删除
Assign BOOL isShowDelete;//是否显示删除按钮
Strong MessageAlertView *comboxView;
Strong UIView *deleteView;
Strong UIButton *deleteBtn;
@end
extern BOOL launchedByNotification;
@implementation IfishMessageViewController
@@ -51,42 +64,191 @@ extern BOOL launchedByNotification;
[super viewDidLoad];
// Do any additional setup after loading the view.
self.pushMassageArr = [[NSMutableArray alloc] init];
// NSUserDefaults *userdefault = [NSUserDefaults standardUserDefaults];
// self.pushId = [userdefault valueForKey:@"PUSHID"];
self.isShowDelete = NO;
self.isDelteAll = NO;
self.titleString = @"消息";
[self.rightButton setImage:IMAGEBYENAME(@"message_more") forState:UIControlStateNormal];
[self.rightButton addTarget:self action:@selector(rightBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.tableView];
[self.view addSubview:self.comboxView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
[self.view addSubview:self.deleteView];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = item;
[self initTab];
[self getPushData];
[self getRequest];
}
-(NSMutableArray *)dataSource
{
if (!_dataSource) {
_dataSource = [[NSMutableArray alloc]init];
}
return _dataSource;
}
-(NSMutableArray *)messageArray
{
if (!_messageArray) {
_messageArray = [[NSMutableArray alloc]init];
}
return _messageArray;
}
-(NSMutableArray *)oldMessageArr
{
if (!_oldMessageArr) {
_oldMessageArr = [[NSMutableArray alloc]init];
}
return _oldMessageArr;
}
-(NSMutableArray *)deleteArray
{
if (!_deleteArray) {
_deleteArray = [[NSMutableArray alloc]init];
}
return _deleteArray;
}
-(UITableView*)tableView{
if (!_tableView) {
_tableView=[[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.dataSource=self;
_tableView.delegate=self;
_tableView.showsVerticalScrollIndicator=NO;
_tableView.backgroundColor = TABLE_BACKGROUD_COLOR;
}
return _tableView;
}
-(MessageAlertView *)comboxView{
if (!_comboxView) {
_comboxView = [[MessageAlertView alloc]initWithFrame:RECT(screen_width - kSizeFrom750(220), 0, kSizeFrom750(220), kSizeFrom750(90))];
_comboxView.transform = CGAffineTransformScale(self.comboxView.transform,0.01,0.01);
_comboxView.layer.position = CGPointMake(screen_width - kSizeFrom750(220)/2, 0);
_comboxView.layer.anchorPoint = CGPointMake(0.5, 0);
_comboxView.hidden = YES;
WEAK_SELF;
//点击删除
_comboxView.comboxBlock = ^(NSInteger tag) {
[weakSelf showComboxView:NO];
weakSelf.isShowDelete = YES;
[weakSelf.deleteView setHidden:NO];
[weakSelf.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(-kSizeFrom750(100));
}];
//刷新页面,显示删除按钮
[weakSelf.tableView reloadData];
};
}
return _comboxView;
}
-(UIView *)deleteView{
if (!_deleteView) {
_deleteView = [[UIView alloc]initWithFrame:RECT(0, screen_height - NavigationBarHeight - kSizeFrom750(100), screen_width, kSizeFrom750(100))];
_deleteView.backgroundColor = [UIColor whiteColor];
_deleteView.hidden = YES;
[self loadDelteSubViews];
}
return _deleteView;
}
-(void)loadDelteSubViews{
self.deleteBtn = InitObject(UIButton);
[self.deleteBtn setTitle:@"删除" forState:UIControlStateNormal];
[self.deleteBtn.titleLabel setFont:SYSTEMSIZE(34)];
[self.deleteBtn setTitleColor:RGB(178, 178, 178) forState:UIControlStateNormal];
[self.deleteBtn setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
[self.deleteBtn addTarget:self action:@selector(deleBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[_deleteView addSubview:self.deleteBtn];
UIButton *allDeleteBtn = InitObject(UIButton);
[allDeleteBtn setTitle:@"全选" forState:UIControlStateNormal];
[allDeleteBtn.titleLabel setFont:SYSTEMSIZE(34)];
[allDeleteBtn setTitleColor:RGB(4, 99, 201) forState:UIControlStateNormal];
[allDeleteBtn addTarget:self action:@selector(allDeleteBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[_deleteView addSubview:allDeleteBtn];
[self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.deleteView);
make.left.mas_equalTo(0);
make.width.mas_equalTo(screen_width/2);
make.height.mas_equalTo(self.deleteView);
}];
[allDeleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(self.deleteBtn);
make.left.mas_equalTo(self.deleteBtn.mas_right);
}];
UIView *line = [[UIView alloc]init];
line.backgroundColor = RGB(178, 178, 178);
[_deleteView addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.deleteView);
make.left.mas_equalTo(kSizeFrom750(30));
make.right.mas_equalTo(-kSizeFrom750(30));
make.height.mas_equalTo(ONE_PIXEL_SIZE);
}];
}
-(void)initTab{
if (self.tableView==nil) {
UITableView*table=[[UITableView alloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
table.dataSource=self;
table.delegate=self;
table.separatorStyle=UITableViewCellSeparatorStyleNone;
self.tableView=table;
self.tableView.showsVerticalScrollIndicator=NO;
self.tableView.backgroundColor = TABLE_BACKGROUD_COLOR;
[self.view addSubview:self.tableView];
[self.tableView registerNib:[UINib nibWithNibName:@"IfishMassageViewCell" bundle:nil] forCellReuseIdentifier:@"IfishMassageViewCell"];
// if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
//
// [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,-100, 0,0)];
// [self.tableView setSeparatorColor:TABLE_SEPRETLINE_COLOR];
// }
#pragma mark --buttonClick
-(void)deleBtnClick:(UIButton *)sender{
if (self.deleteArray.count==0) {
[SVProgressHUD showInfoWithStatus:@"请先选择要删除的消息"];
}else{
//调用删除接口,删除选中的消息内容
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"确认删除选中消息么" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"cancel Action");
}];
UIAlertAction *delteActicon = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"delete Action");
[self deleteMessage];
}];
[alertController addAction:cancelAction];
[alertController addAction:delteActicon];
[self presentViewController:alertController animated:YES completion:nil];
}
}
-(void)allDeleteBtnClick:(UIButton *)sender{
//全部为选中状态
self.isDelteAll = YES;
self.deleteBtn.selected = YES;
[self.deleteArray removeAllObjects];
for (NSArray *arr in self.dataSource) {
for (PushmessageModel *model in arr) {
[self.deleteArray addObject:model.pushId];
}
}
[self.tableView reloadData];
}
#pragma mark --comboxView显示与隐藏
-(void)rightBtnClick:(UIButton *)sender{
BOOL isHidden = self.comboxView.hidden;
if (isHidden) {
self.comboxView.hidden = NO;
}
[UIView animateWithDuration:0.3 animations:^{
self.comboxView.transform = CGAffineTransformScale(self.comboxView.transform,isHidden?100:0.01,isHidden?100:0.01);
} completion:^(BOOL finished) {
self.comboxView.hidden = !isHidden;
}];
}
-(void)showComboxView:(BOOL)isShow{
BOOL isHidden = self.comboxView.hidden;
if (isHidden) {
self.comboxView.hidden = NO;
}
[UIView animateWithDuration:0.3 animations:^{
self.comboxView.transform = CGAffineTransformScale(self.comboxView.transform,isHidden?100:0.01,isHidden?100:0.01);
} completion:^(BOOL finished) {
self.comboxView.hidden = !isHidden;
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
@@ -94,20 +256,157 @@ extern BOOL launchedByNotification;
#pragma mark - Table view data source
-(void)getRequest
{
[SVProgressHUD show];
NSDictionary *resalutDic = [CommonUtils getCacheDataWithKey:Cache_Message];
if (resalutDic==nil) {
self.pushId = @"";
}else{
NSArray *dataArray = [resalutDic objectForKey:@"data"];
PushmessageModel *model = [PushmessageModel yy_modelWithJSON:dataArray.firstObject];
self.pushId = model.pushId;
for (int i=0; i<dataArray.count; i++) {
PushmessageModel *cacheModel = [PushmessageModel yy_modelWithJSON:[dataArray objectAtIndex:i]];
[cacheModel getCellHeight];
[self.oldMessageArr addObject:cacheModel];
}
}
UserModel*userModel=[dataContorl getUserInfo];
NSDictionary *reqDic = @{@"pushId":self.pushId,
@"userId":userModel.userId,
@"firstResult":@(0),
@"pageSize":@(999)
};
[[AFNOHeaderHttpTool sharedInstance] postRequestWihtUrl:Push_Message_Url params:reqDic success:^(NSDictionary *successDic) {
NSString *totalCount = [successDic objectForKey:@"total"];
NSArray *dataArray = [successDic objectForKey:@"data"];
if ([totalCount integerValue]>0) {
//判断是否已经有缓存
NSDictionary *resalutDic = [CommonUtils getCacheDataWithKey:Cache_Message];
if (resalutDic!=nil) {
//原有缓存中的数据
NSArray *cacheDataArray = [resalutDic objectForKey:@"data"];
//新消息列表
NSMutableArray *newDataArray = [NSMutableArray arrayWithArray:dataArray];
[newDataArray addObjectsFromArray:cacheDataArray];
NSMutableDictionary *newDic = InitObject(NSMutableDictionary);
[newDic setObject:newDataArray forKey:@"data"];
[CommonUtils SetCacheDataWithObject:newDic WithPathName:Cache_Message];
}else{
[CommonUtils SetCacheDataWithObject:successDic WithPathName:Cache_Message];
}
for (int i=0; i<dataArray.count; i++) {
PushmessageModel *cacheModel = [PushmessageModel yy_modelWithJSON:[dataArray objectAtIndex:i]];
[cacheModel getCellHeight];
[self.messageArray addObject:cacheModel];
}
}
[self.dataSource addObject:self.messageArray];
[self.dataSource addObject:self.oldMessageArr];
[self.tableView reloadData];
} failure:^(NSDictionary *errorDic) {
}];
}
//删除接口
-(void)deleteMessage{
UserModel*userModel=[dataContorl getUserInfo];
NSMutableArray *deleteArray = InitObject(NSMutableArray);
for (int i=0; i<self.deleteArray.count; i++) {
NSString *pushId = [self.deleteArray objectAtIndex:i];
NSMutableDictionary *deleteDic = InitObject(NSMutableDictionary);
[deleteDic setValue:pushId forKey:@"pushId"];
[deleteArray addObject:deleteDic];
}
NSDictionary *reqDic = @{@"userId":userModel.userId,
@"pushIds":[CommonUtils arrayToJSONString:deleteArray]
};
[SVProgressHUD show];
[[AFNOHeaderHttpTool sharedInstance] postRequestWihtUrl:Push_Message_Delete_Url params:reqDic success:^(NSDictionary *successDic) {
NSString *result = [successDic objectForKey:RESPONSE_CODE];
if ([result integerValue]==kReqSuccess) {
self.deleteBtn.selected = NO;
NSDictionary *cacheDic = [CommonUtils getCacheDataWithKey:Cache_Message];
NSArray *cacheArray = [cacheDic objectForKey:@"data"];
NSMutableArray *newCacheArray = InitObject(NSMutableArray);
//从缓存中删除已经删除的消息
for (int i=0; i<cacheArray.count; i++) {
NSDictionary *dic = [cacheArray objectAtIndex:i];
NSString *cachePushId =[NSString stringWithFormat:@"%@",[dic objectForKey:@"pushId"]];
if ([self.deleteArray containsObject:cachePushId]) {
}else{
[newCacheArray addObject:dic];
}
}
[self.dataSource removeAllObjects];
NSMutableArray *newArray = InitObject(NSMutableArray);
NSMutableArray *oldArray = InitObject(NSMutableArray);
//从新消息列表中剔除
for (int i=0; i<self.messageArray.count; i++) {
PushmessageModel *model = [self.messageArray objectAtIndex:i];
if ([self.deleteArray containsObject:model.pushId]) {
}else{
[newArray addObject:model];
}
}
//从旧消息列表中剔除
for (int i=0; i<self.oldMessageArr.count; i++) {
PushmessageModel *model = [self.oldMessageArr objectAtIndex:i];
if ([self.deleteArray containsObject:model.pushId]) {
}else{
[oldArray addObject:model];
}
}
[self.dataSource addObject:newArray];
[self.dataSource addObject:oldArray];
[CommonUtils SetCacheDataWithObject:[NSDictionary dictionaryWithObjectsAndKeys:newCacheArray,@"data", nil] WithPathName:Cache_Message];
//走删除接口之后,清空删除内容数组
[self.deleteArray removeAllObjects];
self.isDelteAll = NO;
[self.deleteView setHidden:YES];
[self.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.view);
}];
self.isShowDelete = NO;
//刷新页面
[self.tableView reloadData];
[self.tableView scrollsToTop];
}else{
[SVProgressHUD showInfoWithStatus:@"删除失败"];
}
} failure:^(NSDictionary *errorDic) {
[SVProgressHUD showInfoWithStatus:@"删除失败"];
// self.deleteBtn.selected = NO;
// [self.deleteView setHidden:YES];
// [self.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
// make.bottom.mas_equalTo(self.view);
// }];
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
return self.dataSource.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.pushMassageArr.count;
return ((NSArray *)[self.dataSource objectAtIndex:section]).count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.pushMassageArr count] ==0) {
if (((NSArray *)[self.dataSource firstObject]).count ==0&&((NSArray *)[self.dataSource lastObject]).count==0) {
if (!self.nomassagView) {
self.nomassagView = [[IfishNomassageView alloc] initWithFrame:CGRectMake(0,self.view.frame.size.height/2 -40, kScreenSize.width, 80)];
@@ -131,390 +430,99 @@ extern BOOL launchedByNotification;
}
IfishMassageViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IfishMassageViewCell"];
static NSString *cellId = @"IfishMessageViewCell";
IfishMessageViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (cell==nil) {
cell=[[IfishMassageViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"IfishMassageViewCell"];
cell=[[IfishMessageViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
}
PushmessageModel *model = [[self.dataSource objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
PushmassageModel *model = [self.pushMassageArr objectAtIndex:indexPath.row];
cell.pushContent.text = model.massageBody;
cell.pushTitle.text = model.massageTitle;
cell.pushTimeLabel.text = model.createTime;
// cell.IconImage.image = [UIImage imageNamed:model.IconImage];
// 1.wendu_warn 2.remove_device3.qu_reply 4.offline_push
// * 5.remind_water 6 all_push
if ([model.massageType isEqualToString:@"wendu_warn"]) {
cell.userInteractionEnabled = NO;
cell.pushTypeImg.image = [UIImage imageNamed:@"ic_jpush_wendu"];
[cell loadInfoWithModel:model isShowDelete:self.isShowDelete isDeleteAll:self.isDelteAll];
WEAK_SELF;
cell.deleteBlock = ^(NSString *messageId, BOOL isDelete) {
if (isDelete) {
[weakSelf.deleteArray addObject:messageId];//添加到删除列表
}else{
[weakSelf.deleteArray removeObject:messageId];//从删除列表中清除
}
}else if ([model.massageType isEqualToString:@"remove_device"]){
cell.userInteractionEnabled = NO;
cell.pushTypeImg.image = [UIImage imageNamed:@"ic_jpush_msg"];
}else if ([model.massageType isEqualToString:@"qu_reply"]){
cell.userInteractionEnabled = NO;
cell.pushTypeImg.image = [UIImage imageNamed:@"ic_imchat_msg"];
}else if ([model.massageType isEqualToString:@"remind_water"]){
cell.userInteractionEnabled = NO;
cell.pushTypeImg.image = [UIImage imageNamed:@"ic_jpush_changewater"];
}else if ([model.massageType isEqualToString:@"offline_push"]){
cell.userInteractionEnabled = NO;
cell.pushTypeImg.image = [UIImage imageNamed:@"ic_jpush_offline"];
}else if ([model.massageType isEqualToString:@"all_push"]){
cell.userInteractionEnabled = YES;
cell.pushTypeImg.image = [UIImage imageNamed:@"ic_jpush_all_push"];
}else if ([model.massageType isEqualToString:@"review_push"]){
cell.userInteractionEnabled = NO;
cell.pushTypeImg.image = [UIImage imageNamed:@"ic_imchat_msg"];
}else if ([model.massageType isEqualToString:@"send_report"]){
cell.userInteractionEnabled = YES;
cell.pushTypeImg.image = [UIImage imageNamed:@"ic_jpush_all_push"];
}
if (self.deleteArray.count>0) {
self.deleteBtn.selected = YES;
}else
self.deleteBtn.selected = NO;
};
return cell;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (section==1) {
UIView *header = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screen_width, kSizeFrom750(90))];
header.backgroundColor = [UIColor whiteColor];
UILabel *headerLabel = [[UILabel alloc]init];
headerLabel.frame = CGRectMake(0, kSizeFrom750(30), screen_width, kSizeFrom750(30));
headerLabel.textColor = RGB(178, 178, 178);
headerLabel.textAlignment = NSTextAlignmentCenter;
headerLabel.text = @"···············以上为最新消息···············";
headerLabel.font = SYSTEMSIZE(30);
[header addSubview:headerLabel];
return header;
}else
return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section==1) {
return kSizeFrom750(90);
}else
return 0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 100;
if (self.dataSource.count!=0) {
PushmessageModel *model = [[self.dataSource objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
return model.cellHeight;
}
return 0;
}
//
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if ([self.pushMassageArr count] ==0) {
return;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
PushmassageModel *model = self.pushMassageArr[indexPath.row];
if ([model.massageType isEqualToString:@"all_push"]) {
PushMasssageWebViewController *webVC = [[PushMasssageWebViewController alloc] init];
webVC.pushlink = model.url;
webVC.pushtitle = model.massageTitle;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:webVC animated:YES];
self.hidesBottomBarWhenPushed = NO;
}else if ([model.massageType isEqualToString:@"send_report"]){
if (![model.reportId isKindOfClass:[NSNull class]] && ![model.url isKindOfClass:[NSNull class]]) {
[self kanHuBaoGaoXiangQingwithReportId:model.reportId addUrl:model.url];
}else{
[self.view makeToast:@"reportId 或 url 为空"];
}
}
}
//查询看护报告详情
-(void)kanHuBaoGaoXiangQingwithReportId:(NSString*)reportId addUrl:(NSString *)shareUrl{
[AFNOHeaderHttpTool getLookReportById:reportId success:^(id response) {
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
NSLog(@"result:%@",resultDic[@"result"]);
if ([resultDic[@"result"] isEqualToString:@"100"]) {
NSDictionary *dataDic = resultDic[@"data"];
ShareReportViewController *shareVC=[[ShareReportViewController alloc] init];
KanHuBaoGaoModel *bagM =[[KanHuBaoGaoModel alloc] init];
bagM.shareImg = dataDic[@"shareImg"];
bagM.timestamp = dataDic[@"timestamp"];
bagM.totalIndex = dataDic[@"totalIndex"];
bagM.baifenbi = dataDic[@"baifenbi"];
bagM.reportId = dataDic[@"reportId"];
shareVC.baGaoMod = bagM;
PingfenModel *PFMode1=[[PingfenModel alloc] init];
PFMode1.pingFenDesc = dataDic[@"index1Text"];
PFMode1.pingFenNumber = dataDic[@"index1"];
PingfenModel *PFMode2=[[PingfenModel alloc] init];
PFMode2.pingFenDesc = dataDic[@"index2Text"];
PFMode2.pingFenNumber = dataDic[@"index2"];
PingfenModel *PFMode3=[[PingfenModel alloc] init];
PFMode3.pingFenDesc = dataDic[@"index3Text"];
PFMode3.pingFenNumber = dataDic[@"index3"];
NSArray *pingfenArr=@[PFMode1,PFMode2,PFMode3];
shareVC.pinFenArr = pingfenArr;
NSString *suggesttrue=dataDic[@"suggestion"];
shareVC.suggesttrue = suggesttrue;
shareVC.shareUrl = shareUrl;
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:shareVC animated:YES];
self.hidesBottomBarWhenPushed = NO;
}else{
[self.view makeToast:@"看护报告详情查询失败"];
}
} failure:^(NSError *err) {
[self.view makeToast:@"请检查网络"];
// [tableView deselectRowAtIndexPath:indexPath animated:YES];
[self.deleteArray removeAllObjects];
[self.deleteView setHidden:YES];
[self.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.view);
}];
PushmessageModel *model = [[self.dataSource objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
[self.deleteArray addObject:model.pushId];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"确认删除该消息么" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"cancel Action");
}];
UIAlertAction *delteActicon = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"delete Action");
[self deleteMessage];
}];
[alertController addAction:cancelAction];
[alertController addAction:delteActicon];
[self presentViewController:alertController animated:YES completion:nil];
}
-(void)viewWillAppear:(BOOL)animated{
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(presentMassageView) name:@"PresentView" object:nil];
if ([self.pushMassageArr count] ==0) {
if (!self.nomassagView) {
self.nomassagView = [[IfishNomassageView alloc] initWithFrame:CGRectMake(0,self.view.frame.size.height/2 -40, kScreenSize.width, 80)];
[self.view addSubview:self.nomassagView];
}
self.nomassagView.hidden = NO;
self.tableView.scrollEnabled = NO;
}else{
if (self.nomassagView) {
[self.nomassagView removeFromSuperview];
self.nomassagView = nil;
}
self.nomassagView.hidden = YES;
self.tableView.scrollEnabled = YES;
}
[super viewWillAppear:animated];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault];
}
-(void)viewWillDisappear:(BOOL)animated{
//[[NSNotificationCenter defaultCenter] removeObserver:self name:@"PresentView" object:nil];
}
//收到通知刷新列表
-(void)presentMassageView{
//[self getPushData];
}
-(void)getPushData{
[self.pushMassageArr removeAllObjects];
[self creatReatRefreshView];
// 确保消息推送过来 更新 消息列表
AFHTTPRequestOperationManager*mannager=[AFHTTPRequestOperationManager manager];
mannager.responseSerializer=[AFHTTPResponseSerializer serializer];
UserModel*userModel = [[DataCenter defaultDtacenter] valueForKey:@"UserLogIn"];
NSDictionary *parameters= [[NSDictionary alloc] init];
parameters = @{ @"firstResult": @"0",
@"pageSize" : @"10",
@"userId":userModel.userId
};
[mannager POST:kGetPushListInf parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (responseObject) {
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
NSLog(@"*-*-*--*总共的条数%@",resultDic[@"total"]);
_total = resultDic[@"total"];
NSArray *arr = resultDic[@"data"];
for (NSDictionary *dict in arr) {
PushmassageModel *pushModel = [[PushmassageModel alloc] init];
pushModel.massageType = dict[@"pushType"];
pushModel.massageTitle = dict[@"pushTitle"];
pushModel.massageBody = dict[@"pushContext"];
pushModel.pushId = dict[@"pushId"];
pushModel.createTime = dict[@"createTime"];
pushModel.showName = dict[@"showName"];
pushModel.deviceId = dict[@"deviceId"];
pushModel.userId = dict [@"userId"];
pushModel.url = dict [@"pushLink"];
pushModel.reportId = dict[@"reportId"];
[self.pushMassageArr addObject:pushModel];
}
NSLog(@" _SecondDataCellArray %lu", (unsigned long)self.pushMassageArr.count);
[self.tableView reloadData];
[self endRefreshing];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[self endRefreshing];
}];
}
-(void)creatReatRefreshView{
__weak typeof (self)weskSelf=self;
// 下拉刷新
UserModel*userModel = [[DataCenter defaultDtacenter] valueForKey:@"UserLogIn"];
[weskSelf.tableView addRefreshHeaderViewWithAniViewClass:[JHRefreshAmazingAniView class] beginRefresh:^{
if (weskSelf.isRefreshing) {
return ;
}
weskSelf.isRefreshing=YES;
[self getPushData];
_page=0;
_para = @{ @"firstResult": @"0",
@"pageSize" : @"10",
@"userId":userModel.userId
};
[weskSelf addTaskWithDic:_para isRefresh:YES];
[self.tableView reloadData];
}];
//上拉加载更多
[weskSelf.tableView addRefreshFooterViewWithAniViewClass:[JHRefreshCommonAniView class] beginRefresh:^{
if (weskSelf.isLoadMore) {
return ;
}
weskSelf.isLoadMore=YES;
NSInteger pagecount =[_total integerValue]/10+1;
if (_page<pagecount-1) {
_page++;
NSInteger first=(NSInteger)_page*10;
NSString *firsStr=[NSString stringWithFormat:@"%ld",(long)first];
_para = @{ @"firstResult": firsStr,
@"pageSize" : @"10",
@"userId":userModel.userId
};
[weskSelf addTaskWithDic:_para isRefresh:NO];
}else{
[self endRefreshing];
[self.view makeToast:@"已无更多数据"];
}
}];
}
-(void)endRefreshing{
if (self.isRefreshing) {
self.isRefreshing=NO;
[self.tableView headerEndRefreshingWithResult:JHRefreshResultNone];
}
if (self.isLoadMore) {
self.isLoadMore=NO;
[self.tableView footerEndRefreshing];
}
}
-(void)addTaskWithDic:(NSDictionary *)para isRefresh:(BOOL)isRefresh{
if (isRefresh) {
[self.pushMassageArr removeAllObjects];
}
AFHTTPRequestOperationManager*mannager=[AFHTTPRequestOperationManager manager];
mannager.responseSerializer=[AFHTTPResponseSerializer serializer];
[mannager POST:kGetPushListInf parameters:para success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (responseObject) {
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
NSLog(@"*-*-*--*总共的条数%@",resultDic[@"total"]);
NSArray *arr = resultDic[@"data"];
for (NSDictionary *dict in arr) {
PushmassageModel *pushModel = [[PushmassageModel alloc] init];
pushModel.massageType = dict[@"pushType"];
pushModel.massageTitle = dict[@"pushTitle"];
pushModel.massageBody = dict[@"pushContext"];
pushModel.pushId = dict[@"pushId"];
pushModel.createTime = dict[@"createTime"];
pushModel.showName = dict[@"showName"];
pushModel.deviceId = dict[@"deviceId"];
pushModel.userId = dict [@"userId"];
pushModel.url = dict [@"pushLink"];
pushModel.reportId = dict[@"reportId"];
[self.pushMassageArr addObject:pushModel];
}
NSLog(@" _SecondDataCellArray %lu", (unsigned long)self.pushMassageArr.count);
[self.tableView reloadData];
[self endRefreshing];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[self endRefreshing];
}];
}
@end