修复消息页面部分bug

This commit is contained in:
wbzhan
2019-05-27 16:41:39 +08:00
parent 25c051d5f1
commit 8e027e82c9
16 changed files with 355 additions and 546 deletions
@@ -118,7 +118,6 @@ Assign NSInteger messageCount;//消息个数
//dispatch_queue_t queue = dispatch_queue_create("com.privateQueue",NULL);
dispatch_async(dispatch_get_main_queue(), ^{
[self getMessageData];
[self getMoreUserData];
[self initBannerData];
[self loadGoodsData];
@@ -136,34 +135,23 @@ Assign NSInteger messageCount;//消息个数
}
-(void)getMessageData{
//获取未读消息个数
-(void)getMessageCount{
NSDictionary *resalutDic = [CommonUtils getCacheDataWithKey:Cache_Message];
NSString *pushId = @"";
if (resalutDic==nil) {
pushId = @"";
}else{
NSArray *dataArray = [resalutDic objectForKey:@"data"];
PushmessageModel *model = [PushmessageModel yy_modelWithJSON:dataArray.firstObject];
pushId = model.pushId;
}
UserModel*userModel=[dataContorl getUserInfo];
NSDictionary *reqDic = @{@"pushId":pushId,
@"userId":userModel.userId,
@"firstResult":@(0),
@"pageSize":@(999)
NSDictionary *reqDic = @{@"userId":userModel.userId
};
[[AFNOHeaderHttpTool sharedInstance] postRequestWihtUrl:Push_Message_Url params:reqDic success:^(NSDictionary *successDic) {
[[AFNOHeaderHttpTool sharedInstance] postRequestWihtUrl:Push_Message_UnReadCount params:reqDic success:^(NSDictionary *successDic) {
NSString *totalCount = [successDic objectForKey:@"total"];
if ([totalCount integerValue]>0) {
//有新消息
self.messageCount = [totalCount integerValue];
[self setRedViewData];
}else{
NSString *result = [successDic objectForKey:RESPONSE_CODE];
NSDictionary *dic = [successDic objectForKey:RESPONSE_DATA];
if ([result integerValue]==kReqSuccess) {
NSString *count = [dic objectForKey:@"messageNoReadCount"];
self.messageCount = [count integerValue];
}
[self setRedViewData];
} failure:^(NSDictionary *errorDic) {
}];
@@ -605,7 +593,7 @@ Assign NSInteger messageCount;//消息个数
_mesglabel.textAlignment = NSTextAlignmentCenter;
_mesglabel.backgroundColor = [UIColor redColor];
[navMeaasageBtn addSubview:_mesglabel];
_mesglabel.font = [UIFont boldSystemFontOfSize:10];
_mesglabel.font = [UIFont systemFontOfSize:10];
// [self setRedViewData];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
@@ -623,8 +611,10 @@ Assign NSInteger messageCount;//消息个数
-(void)setRedViewData{
// NSInteger count = [[[NIMSDK sharedSDK] conversationManager] allUnreadCount];
if (self.messageCount> 0) {
if(self.messageCount>=100){
_mesglabel.frame = RECT(self.mesglabel.frame.origin.x, self.mesglabel.frame.origin.y, 24, 16);
}
_mesglabel.text = [NSString stringWithFormat:@"%ld",(long)self.messageCount];
_mesglabel.hidden = NO;
}else{
@@ -723,14 +713,15 @@ Assign NSInteger messageCount;//消息个数
[super viewWillAppear:animated];
self.navigationController.navigationBar.translucent = YES;
//设置透明导航栏
[self.navigationController
.navigationBar setClearNav];
[self.navigationController.navigationBar setClearNav];
[self scrollViewDidScroll:self.tableView];
//内容置顶
//[self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
[self refreshUI];
//刷新消息数
[self setRedViewData];
[self getMessageCount];
}
-(void)refreshUI{
@@ -1067,6 +1058,7 @@ Assign NSInteger messageCount;//消息个数
CGFloat rowH=TabContentHeaght*0.068;
UIView*view=[[UIView alloc] initWithFrame:CGRectMake(0,0, kScreenSize.width, rowH)];
view.userInteractionEnabled = YES;
view.backgroundColor = [UIColor whiteColor];
CGFloat Space =kScreenSize.width*0.063;
CGFloat ImgW =kScreenSize.width*0.056;
@@ -1079,18 +1071,12 @@ Assign NSInteger messageCount;//消息个数
UIButton *addbtn =[UIButton buttonWithType:UIButtonTypeCustom];
CGFloat Space2 =kScreenSize.width*0.031;
addbtn.frame = CGRectMake(CGRectGetMaxX(headImg.frame) + Space2 -3,1,200,rowH -2);
NSDictionary *attributes=@{ NSFontAttributeName:[UIFont systemFontOfSize:15],
NSForegroundColorAttributeName:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1] ,
};
NSAttributedString *str= [[NSAttributedString alloc] initWithString:@"添加设备" attributes:attributes];
[addbtn setAttributedTitle:str forState:UIControlStateNormal];
[addbtn setTitleColor:RGB(153, 153, 153) forState:UIControlStateNormal];
[addbtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
[addbtn setTitle:@"添加设备" forState:UIControlStateNormal];
addbtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
//[addbtn setBackgroundColor:[UIColor redColor]];
[addbtn addTarget:self action:@selector(addBtnAction) forControlEvents:UIControlEventTouchUpInside];
[addbtn addTarget:self action:@selector(addBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:addbtn];
return view;
@@ -1111,7 +1097,7 @@ Assign NSInteger messageCount;//消息个数
#pragma mark- 添加设备
-(void)addBtnAction{
-(void)addBtnAction:(UIButton *)sender{
[self pushWiFiConnectVC];