修复消息页面部分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
@@ -44,7 +44,6 @@
#import "IfishUserObsever.h"
#import "QianDaoGiftView.h"
#import "IfishGoldAndExpTostView.h"
//#import "MineHeaderNewItemsCell.h"
#import "IfishMineGoldViewController.h"
#import "IifshMineDJViewController.h"
#import "WoDeRenWuViewController.h"
@@ -1,27 +0,0 @@
//
// MineHeaderNewItemsCell.h
// Ifish
//
// Created by imac on 17/3/13.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol MineHeaderItemsDelegate <NSObject>
-(void)tapDengjiAction;
-(void)tapGoldAction;
-(void)tapRenWuAction;
@end
@interface MineHeaderNewItemsCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *levlellabel;
@property (weak, nonatomic) IBOutlet UILabel *goldLabel;
@property (weak, nonatomic) IBOutlet UILabel *taskNumber;
@property (weak, nonatomic) IBOutlet UILabel *dengJi;
@property (weak, nonatomic) IBOutlet UILabel *jinBi;
@property (weak, nonatomic) IBOutlet UILabel *renWu;
@property (nonatomic,assign) id<MineHeaderItemsDelegate> itemsDelegate;
-(void)loadCellData;
@property (nonatomic,strong) UIView *redpontView;
@end
@@ -1,113 +0,0 @@
//
// MineHeaderNewItemsCell.m
// Ifish
//
// Created by imac on 17/3/13.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "MineHeaderNewItemsCell.h"
@implementation MineHeaderNewItemsCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
UITapGestureRecognizer *tapDengji=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dengjiAction)];
UITapGestureRecognizer *tapDengji2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dengjiAction2)];
[self.dengJi addGestureRecognizer:tapDengji];
[self.levlellabel addGestureRecognizer:tapDengji2];
UITapGestureRecognizer *tapgold=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGoldAction)];
[self.goldLabel addGestureRecognizer:tapgold];
UITapGestureRecognizer *tapgold2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGoldAction2)];
[self.jinBi addGestureRecognizer:tapgold2];
UITapGestureRecognizer *tapRenWu=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRenWuAction)];
UITapGestureRecognizer *tapRenWu2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRenWuAction2)];
[self.renWu addGestureRecognizer:tapRenWu];
[self.taskNumber addGestureRecognizer:tapRenWu2];
}
-(void)layoutSubviews{
if (!self.redpontView) {
self.redpontView = [[UIView alloc] init];
NSString *renwu= @"我的任务";
CGSize size = [renwu sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}];
self.redpontView.frame = CGRectMake(CGRectGetWidth(self.renWu.frame)/2 + size.width/2, 4, 8, 8);
self.redpontView.backgroundColor = RGB(252, 89, 89);
self.redpontView.layer.masksToBounds = YES;
self.redpontView.layer.cornerRadius = 4.0;
[self addSubview:self.redpontView];
[self.renWu bringSubviewToFront:self.redpontView];
}
}
-(void)loadCellData{
IfishUserAsset *userAsset =[dataContorl getAllIfishUserAsset];
self.levlellabel.text = [NSString stringWithFormat:@"LV%@",userAsset.gradeNum];
self.goldLabel.text = [NSString stringWithFormat:@"%ld",(long)userAsset.goldValue];
NSInteger undoneCount = [IfishHelperUtils getUnDoneTaskCount];
self.taskNumber.text = [NSString stringWithFormat:@"%ld",undoneCount];
self.redpontView.hidden = undoneCount ==0? YES : NO;
if (undoneCount==0) {
[[NSNotificationCenter defaultCenter] postNotificationName:IFISHTASK_HAVEDONEALL object:nil];
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)dengjiAction
{
if (self.itemsDelegate) {
[self.itemsDelegate tapDengjiAction];
}
}
-(void)dengjiAction2
{
if (self.itemsDelegate) {
[self.itemsDelegate tapDengjiAction];
}
}
-(void)tapGoldAction
{
if (self.itemsDelegate) {
[self.itemsDelegate tapGoldAction];
}
}
-(void)tapGoldAction2
{
if (self.itemsDelegate) {
[self.itemsDelegate tapGoldAction];
}
}
-(void)tapRenWuAction
{
if (self.itemsDelegate) {
[self.itemsDelegate tapRenWuAction];
}
}
-(void)tapRenWuAction2
{
if (self.itemsDelegate) {
[self.itemsDelegate tapRenWuAction];
}
}
@end
@@ -1,89 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="MineHeaderNewItemsCell" id="KGk-i7-Jjw" customClass="MineHeaderNewItemsCell">
<rect key="frame" x="0.0" y="0.0" width="375" height="60"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="375" height="59.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="等级" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="O45-QR-cHa">
<rect key="frame" x="21" y="0.0" width="82" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9wv-Em-ymJ">
<rect key="frame" x="8" y="29" width="108" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.9882352941176471" green="0.85098039215686272" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="277777" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YNL-Tj-AKG">
<rect key="frame" x="134" y="29" width="105" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.98823529409999999" green="0.85098039219999999" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UFF-ah-s4k">
<rect key="frame" x="257" y="29" width="110" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.98823529409999999" green="0.85098039219999999" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lAB-ez-ZeT">
<rect key="frame" x="124" y="13" width="2" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.047058823529411764" green="0.46274509803921571" blue="0.85098039215686272" alpha="0.69555004222972971" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uhm-GO-5Ke">
<rect key="frame" x="247" y="13" width="2" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.047058823530000002" green="0.46274509800000002" blue="0.85098039219999999" alpha="0.69555004220000005" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="我的任务" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hah-cc-Hgz">
<rect key="frame" x="271" y="0.0" width="82" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.98823529409999999" green="0.85098039219999999" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="金币" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="B6H-GU-HKz">
<rect key="frame" x="134" y="0.0" width="105" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<color key="backgroundColor" red="0.039215686270000001" green="0.41960784309999999" blue="0.7725490196" alpha="1" colorSpace="calibratedRGB"/>
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
<connections>
<outlet property="dengJi" destination="O45-QR-cHa" id="LfW-VK-4g0"/>
<outlet property="goldLabel" destination="YNL-Tj-AKG" id="ogk-kt-ySC"/>
<outlet property="jinBi" destination="B6H-GU-HKz" id="CS2-5L-R8c"/>
<outlet property="levlellabel" destination="9wv-Em-ymJ" id="bTK-L1-Xe0"/>
<outlet property="renWu" destination="Hah-cc-Hgz" id="gtx-WH-xHK"/>
<outlet property="taskNumber" destination="UFF-ah-s4k" id="DPn-Bh-Vxz"/>
</connections>
<point key="canvasLocation" x="25.5" y="52"/>
</tableViewCell>
</objects>
</document>
@@ -17,6 +17,7 @@ Strong UIButton *bgBtn;
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self loadSubViews];
}
return self;
@@ -159,6 +160,8 @@ Strong UIButton *bgBtn;
self.bgBtn.selected = YES;
}else
{
self.bgBtn.selected = NO;
self.deleteBtn.selected = NO;
self.deleteBtn.hidden = !isShowDelte;
self.bgBtn.hidden = !isShowDelte;
}
@@ -55,7 +55,9 @@ Assign BOOL isShowDelete;//是否显示删除按钮
Strong MessageAlertView *comboxView;
Strong UIView *deleteView;
Strong UIButton *deleteBtn;
Strong UIAlertController *alertController;
Strong UIAlertAction *okAction;
Strong UIAlertAction *cancelAction;
@end
extern BOOL launchedByNotification;
@implementation IfishMessageViewController
@@ -157,23 +159,24 @@ extern BOOL launchedByNotification;
[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];
[self.deleteView addSubview:self.deleteBtn];
UIButton *allDeleteBtn = InitObject(UIButton);
[allDeleteBtn setTitle:@"全选" forState:UIControlStateNormal];
[allDeleteBtn setTitle:@"取消" forState:UIControlStateSelected];
[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.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);
make.top.height.mas_equalTo(self.deleteView);
}];
[allDeleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(self.deleteBtn);
make.top.width.height.mas_equalTo(self.deleteBtn);
make.left.mas_equalTo(self.deleteBtn.mas_right);
}];
@@ -185,9 +188,7 @@ extern BOOL launchedByNotification;
make.left.mas_equalTo(kSizeFrom750(30));
make.right.mas_equalTo(-kSizeFrom750(30));
make.height.mas_equalTo(ONE_PIXEL_SIZE);
}];
}
#pragma mark --buttonClick
-(void)deleBtnClick:(UIButton *)sender{
@@ -196,7 +197,7 @@ extern BOOL launchedByNotification;
[SVProgressHUD showInfoWithStatus:@"请先选择要删除的消息"];
}else{
//调用删除接口,删除选中的消息内容
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"确认删除选中消息么" preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"确认删除所有选中消息么" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"cancel Action");
}];
@@ -210,16 +211,22 @@ extern BOOL launchedByNotification;
}
}
-(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];
if (!sender.selected) {//全选
//全部为选中状态
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];
}
}
}else{//取消全选
[self.deleteArray removeAllObjects];
self.isDelteAll = NO;
self.deleteBtn.selected = NO;
}
sender.selected = !sender.selected;
[self.tableView reloadData];
}
#pragma mark --comboxView显示与隐藏
@@ -259,20 +266,7 @@ extern BOOL launchedByNotification;
-(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];
}
}
self.pushId = @"";
UserModel*userModel=[dataContorl getUserInfo];
NSDictionary *reqDic = @{@"pushId":self.pushId,
@"userId":userModel.userId,
@@ -284,28 +278,21 @@ extern BOOL launchedByNotification;
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];
}
NSMutableArray *newMessageArray = InitObject(NSMutableArray);
NSMutableArray *oldMessageArray = InitObject(NSMutableArray);
for (int i=0; i<dataArray.count; i++) {
PushmessageModel *cacheModel = [PushmessageModel yy_modelWithJSON:[dataArray objectAtIndex:i]];
[cacheModel getCellHeight];
[self.messageArray addObject:cacheModel];
PushmessageModel *messageModel = [PushmessageModel yy_modelWithJSON:[dataArray objectAtIndex:i]];
[messageModel getCellHeight];
if ([messageModel.isRead integerValue]==1) {//未读消息
[newMessageArray addObject:messageModel];
}else{
[oldMessageArray addObject:messageModel];
}
}
[self.dataSource addObject:newMessageArray];
[self.dataSource addObject:oldMessageArray];
}
[self.dataSource addObject:self.messageArray];
[self.dataSource addObject:self.oldMessageArr];
[self.tableView reloadData];
@@ -314,7 +301,63 @@ extern BOOL launchedByNotification;
}];
}
//删除接口
//发送已读记录
-(void)postReadMessageRequestWithIndexPath:(NSIndexPath *)indexPath{
UserModel*userModel=[dataContorl getUserInfo];
PushmessageModel *model = [[self.dataSource objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
if([model.isRead integerValue]==1)//未读消息
{
NSMutableDictionary *deleteDic = InitObject(NSMutableDictionary);
[deleteDic setValue:model.pushId forKey:@"pushId"];
NSDictionary *reqDic = @{@"userId":userModel.userId,
@"pushId":model.pushId
};
[[AFNOHeaderHttpTool sharedInstance] postRequestWihtUrl:Push_Message_Readed params:reqDic success:^(NSDictionary *successDic) {
NSString *result = [successDic objectForKey:RESPONSE_CODE];
if ([result integerValue]==kReqSuccess) {
//已读
}else{
}
} failure:^(NSDictionary *errorDic) {
}];
}
}
//单独删除某一条消息
-(void)deleteSingleMessageWithIndex:(NSIndexPath *)indexPath{
UserModel*userModel=[dataContorl getUserInfo];
PushmessageModel *model = [[self.dataSource objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
NSMutableDictionary *deleteDic = InitObject(NSMutableDictionary);
[deleteDic setValue:model.pushId forKey:@"pushId"];
NSDictionary *reqDic = @{@"userId":userModel.userId,
@"pushIds":[CommonUtils arrayToJSONString:@[deleteDic]]
};
[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.dataSource objectAtIndex:indexPath.section] removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
// //刷新页面
// [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);
// }];
}];
}
//删除接口(多选删除)
-(void)deleteMessage{
UserModel*userModel=[dataContorl getUserInfo];
NSMutableArray *deleteArray = InitObject(NSMutableArray);
@@ -333,43 +376,19 @@ extern BOOL launchedByNotification;
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];
for (int i=0;i< self.dataSource.count;i++) {
NSArray *arr = [self.dataSource objectAtIndex:i];
NSMutableArray *newArray = InitObject(NSMutableArray);
for (int j=0; j<arr.count; j++) {
PushmessageModel *model = [arr objectAtIndex:j];
if ([self.deleteArray containsObject:model.pushId]) {
}else{
[newArray addObject:model];
}
}
[self.dataSource setObject:newArray atIndexedSubscript:i];
}
[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;
@@ -498,25 +517,24 @@ extern BOOL launchedByNotification;
//
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
// [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];
dispatch_async(dispatch_get_main_queue(), ^{
[self postReadMessageRequestWithIndexPath:indexPath];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"确认删除该消息么" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"cancel Action");
}];
WEAK_SELF;
UIAlertAction *delteActicon = [UIAlertAction actionWithTitle:@"删除" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[weakSelf deleteSingleMessageWithIndex:indexPath];
}];
[alertController addAction:cancelAction];
[alertController addAction:delteActicon];
[weakSelf presentViewController:alertController animated:YES completion:nil];
});
}
-(void)viewWillAppear:(BOOL)animated{
@@ -21,6 +21,8 @@
Copy NSString *phoneType;
//推送类型
Copy NSString *jpushStatus;
Copy NSString *isRead;//1、未读 0 已读
//创建时间
@property(nonatomic,copy) NSString *createTime;
//设备id
@@ -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];