|
@@ -18,6 +18,12 @@
|
|
|
#import "YCMenuView.h"
|
|
|
#import "MailModel.h"
|
|
|
#import "MailListDetailVC.h"
|
|
|
+#import "MailAddUserSearch.h"
|
|
|
+#import "MailListByZuCell.h"
|
|
|
+#import "ChineseString.h"
|
|
|
+#import "MailEditVC.h"
|
|
|
+#import "MailListMoveVC.h"
|
|
|
+#import "MailGroupVC.h"
|
|
|
|
|
|
@interface MailListVC ()<UITableViewDelegate,UITableViewDataSource>
|
|
|
@property (weak, nonatomic) IBOutlet UIView *HeadView;
|
|
@@ -28,6 +34,9 @@
|
|
|
@property (strong,nonatomic) NSMutableArray *taskActionArray;
|
|
|
@property (strong,nonatomic) NSMutableArray *historyDataSourceArray;
|
|
|
@property (nonatomic, strong) AddressBookGroupModel *groupModel;
|
|
|
+@property (strong,nonatomic) NSMutableArray *pinyinArray;
|
|
|
+@property (strong,nonatomic) NSMutableArray *nameArray;
|
|
|
+@property (strong,nonatomic) NSMutableArray *cusNameArray;
|
|
|
@end
|
|
|
|
|
|
@implementation MailListVC
|
|
@@ -48,9 +57,13 @@
|
|
|
}
|
|
|
return _taskActionArray;
|
|
|
}
|
|
|
+- (void)viewWillAppear:(BOOL)animated
|
|
|
+{
|
|
|
+ [super viewWillAppear:animated];
|
|
|
+ [self getData];
|
|
|
+}
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
- [self getData];
|
|
|
self.fd_prefersNavigationBarHidden = YES;
|
|
|
self.view.backgroundColor = RGB(255, 255, 255);
|
|
|
[self.HeadView addSubview:self.SearchView];
|
|
@@ -124,14 +137,18 @@
|
|
|
});
|
|
|
} failure:^(NSError * _Nonnull error) {
|
|
|
REMOVESHOW
|
|
|
- // SHOWERROR([ZYCTool handerResultData:error]);
|
|
|
+ SHOWERROR([ZYCTool handerResultData:error]);
|
|
|
}];
|
|
|
} cancle:^{
|
|
|
}] show];
|
|
|
}else if ([@"加联系人" isEqualToString:action.title]){
|
|
|
-
|
|
|
+ MailAddUserSearch * vc = [[MailAddUserSearch alloc] init];
|
|
|
+ [weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
}else if ([@"批量编辑" isEqualToString:action.title]){
|
|
|
-
|
|
|
+ MailEditVC * vc = [MailEditVC initMailEditVC];
|
|
|
+ vc.dataArray = weakSelf.cusNameArray.mutableCopy;
|
|
|
+ vc.pinyinArray = weakSelf.pinyinArray.mutableCopy;
|
|
|
+ [weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
}else if ([@"扫一扫" isEqualToString:action.title]){
|
|
|
|
|
|
}
|
|
@@ -151,80 +168,133 @@
|
|
|
|
|
|
#pragma Mark 左滑按钮 iOS8以上
|
|
|
- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos){// delete action
|
|
|
- MailModel * model = self.dataSourceArray[indexPath.section];
|
|
|
- MailSubModel * smodel = model.Items[indexPath.row];
|
|
|
- switch (model.TypeId) {
|
|
|
- case MailListCusType:
|
|
|
- {
|
|
|
- WEAKSELF
|
|
|
- UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
|
|
|
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
|
|
|
- UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
|
|
- SHOWLOADING
|
|
|
- [[HttpManager sharedHttpManager] DeleteUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,AddressBookGroup_Get_Delete,(long)smodel.Id] parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
|
|
|
-
|
|
|
- REMOVESHOW
|
|
|
- STRONGSELF
|
|
|
- [strongSelf getData];
|
|
|
-
|
|
|
- } failure:^(NSError * _Nonnull error) {
|
|
|
- REMOVESHOW
|
|
|
+ if (indexPath.section <= (self.dataSourceArray.count - 1)) {
|
|
|
+ MailModel * model = self.dataSourceArray[indexPath.section];
|
|
|
+ MailSubModel * smodel = model.Items[indexPath.row];
|
|
|
+ switch (model.TypeId) {
|
|
|
+ case MailListCusType:
|
|
|
+ {
|
|
|
+ WEAKSELF
|
|
|
+ UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
|
|
|
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:(UIAlertControllerStyleAlert)];
|
|
|
+ UIAlertAction * sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+ SHOWLOADING
|
|
|
+ [[HttpManager sharedHttpManager] DeleteUrl:[NSString stringWithFormat:@"%@%@%ld",BaseUrl,AddressBookGroup_Get_Delete,(long)smodel.Id] parameters:@{} responseStyle:DATA success:^(id _Nonnull responseObject) {
|
|
|
+ REMOVESHOW
|
|
|
+ [weakSelf getData];
|
|
|
+ } failure:^(NSError * _Nonnull error) {
|
|
|
+ REMOVESHOW
|
|
|
+ }];
|
|
|
+ }];
|
|
|
+ UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [tableView reloadData];
|
|
|
+ });
|
|
|
+ }];
|
|
|
+ [alert addAction:sureAction];
|
|
|
+ [alert addAction:cancelAction];
|
|
|
+ [weakSelf presentViewController:alert animated:YES completion:^{
|
|
|
+
|
|
|
}];
|
|
|
}];
|
|
|
- UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
|
-
|
|
|
+ action1.backgroundColor = RGB(255, 59, 47);
|
|
|
+ UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"重命名" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
|
|
|
+ [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"重命名通讯录" changeStr:smodel.Name confirm:^(NSString * _Nonnull groupName) {
|
|
|
+ SHOWLOADING
|
|
|
+ [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,AddressBookGroup_Update_Post] parameters:@{@"GroupName":groupName,@"AddressBookGroupId":@(smodel.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
|
|
|
+ REMOVESHOW
|
|
|
+ STRONGSELF
|
|
|
+ [strongSelf getData];
|
|
|
+ } failure:^(NSError * _Nonnull error) {
|
|
|
+ REMOVESHOW
|
|
|
+ }];
|
|
|
+ } cancle:^{
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [tableView reloadData];
|
|
|
+ });
|
|
|
+ }] show];
|
|
|
}];
|
|
|
- [alert addAction:sureAction];
|
|
|
- [alert addAction:cancelAction];
|
|
|
- [weakSelf presentViewController:alert animated:YES completion:^{
|
|
|
+ action2.backgroundColor = RGB(255, 149, 3);
|
|
|
+ UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1,action2]];
|
|
|
+ actions.performsFirstActionWithFullSwipe = NO;
|
|
|
+ return actions;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[]];
|
|
|
+ actions.performsFirstActionWithFullSwipe = NO;
|
|
|
+ return actions;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ WEAKSELF
|
|
|
+ NSArray * array = self.cusNameArray[indexPath.section - self.dataSourceArray.count];
|
|
|
+ SelectModel * model = array[indexPath.row];
|
|
|
+ UIContextualAction *action1 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"删除" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
|
|
|
+ UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+
|
|
|
+ UIAlertAction *ok = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [tableView reloadData];
|
|
|
+ });
|
|
|
+ }];
|
|
|
+ [ok setValue:k9 forKey:@"_titleTextColor"];
|
|
|
+ UIAlertAction *noOk = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
+ [[HttpManager sharedHttpManager] DeleteUrl:Host(API_APP_User_Friends) parameters:@{@"UserIds":@[@(model.Id)]} responseStyle:DATA success:^(id _Nonnull responseObject) {
|
|
|
+ [weakSelf getData];
|
|
|
+ } failure:^(NSError * _Nonnull error) {
|
|
|
|
|
|
}];
|
|
|
}];
|
|
|
- action1.backgroundColor = RGB(255, 59, 47);
|
|
|
- UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"重命名" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
|
|
|
- [[ShowNewGroupAlert initShowNewGroupAlertWithTitle:@"重命名通讯录" changeStr:smodel.Name confirm:^(NSString * _Nonnull groupName) {
|
|
|
- SHOWLOADING
|
|
|
- [[HttpManager sharedHttpManager] POSTUrl:[NSString stringWithFormat:@"%@%@",BaseUrl,AddressBookGroup_Update_Post] parameters:@{@"GroupName":groupName,@"AddressBookGroupId":@(smodel.Id)} responseStyle:DATA success:^(id _Nonnull responseObject) {
|
|
|
- REMOVESHOW
|
|
|
- STRONGSELF
|
|
|
- [strongSelf getData];
|
|
|
- } failure:^(NSError * _Nonnull error) {
|
|
|
- REMOVESHOW
|
|
|
- }];
|
|
|
- } cancle:^{
|
|
|
- }] show];
|
|
|
-
|
|
|
-
|
|
|
- }];
|
|
|
- action2.backgroundColor = RGB(255, 149, 3);
|
|
|
- UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1,action2]];
|
|
|
- actions.performsFirstActionWithFullSwipe = NO;
|
|
|
- return actions;
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- {
|
|
|
- UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[]];
|
|
|
- actions.performsFirstActionWithFullSwipe = NO;
|
|
|
- return actions;
|
|
|
- }
|
|
|
- break;
|
|
|
+ [alertVC addAction:ok];
|
|
|
+ [alertVC addAction:noOk];
|
|
|
+ [weakSelf presentViewController:alertVC animated:YES completion:nil];
|
|
|
+ }];
|
|
|
+ action1.backgroundColor = RGB(255, 59, 47);
|
|
|
+ UIContextualAction *action2 = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"移动" handler:^(UIContextualAction * _Nonnull action,__kindof UIView * _Nonnull sourceView,void (^ _Nonnull completionHandler)(BOOL)) {
|
|
|
+ MailListMoveVC * vc = [MailListMoveVC initMailListMoveVC];
|
|
|
+ vc.selectArray = @[@(model.Id)];
|
|
|
+ vc.IsRoot = YES;
|
|
|
+ vc.moveBlock = ^{
|
|
|
+ [weakSelf getData];
|
|
|
+ };
|
|
|
+ [weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
+ }];
|
|
|
+ action2.backgroundColor = UIColorHex(#3D95EE);
|
|
|
+ UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[action1,action2]];
|
|
|
+ actions.performsFirstActionWithFullSwipe = NO;
|
|
|
+ return actions;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
|
|
- return self.dataSourceArray.count;
|
|
|
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|
|
+{
|
|
|
+ return self.dataSourceArray.count + self.pinyinArray.count;
|
|
|
}
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
- MailModel * model = self.dataSourceArray[section];
|
|
|
- return model.Items.count;
|
|
|
+ if (section <= (self.dataSourceArray.count - 1)) {
|
|
|
+ MailModel * model = self.dataSourceArray[section];
|
|
|
+ return model.Items.count;
|
|
|
+ }else{
|
|
|
+ NSArray *array = [self.cusNameArray objectAtIndex:(section - self.dataSourceArray.count)];
|
|
|
+ return [array count];
|
|
|
+ }
|
|
|
+}
|
|
|
+#pragma mark - section右侧index数组
|
|
|
+-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
|
|
|
+ return self.pinyinArray;
|
|
|
+}
|
|
|
+//点击右侧索引表项时调用 索引与section的对应关系
|
|
|
+- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
|
|
|
+ return index + self.dataSourceArray.count;
|
|
|
}
|
|
|
-
|
|
|
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|
|
- MailModel * model = self.dataSourceArray[section];
|
|
|
+ WS(weakSelf);
|
|
|
UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
|
|
|
[headerView setBackgroundColor:UIColorHex(0xF5F6F8)];
|
|
|
UILabel *sectionTitle = [[UILabel alloc] init];
|
|
@@ -236,127 +306,154 @@
|
|
|
sectionTitle.font = [UIFont systemFontOfSize:12];
|
|
|
sectionTitle.textColor = RGB(153, 153, 153);
|
|
|
sectionTitle.textAlignment = NSTextAlignmentLeft;
|
|
|
- WS(weakSelf);
|
|
|
- sectionTitle.text = model.Name;
|
|
|
- if (model.TypeId == MailListCusType) {
|
|
|
- UIImageView * imagV = [UIImageView new];
|
|
|
- imagV.image = IMG(@"create_mlist");
|
|
|
- UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
|
|
|
- MailListSortVC * vc = [MailListSortVC initMailListSortVC];
|
|
|
- vc.dataArray = model.Items;
|
|
|
- vc.sortBlock = ^{
|
|
|
- [weakSelf getData];
|
|
|
- };
|
|
|
- [weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
- }];
|
|
|
- [headerView addGestureRecognizer:tap];
|
|
|
- headerView.userInteractionEnabled = YES;
|
|
|
- [headerView addSubview:imagV];
|
|
|
- [imagV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.mas_equalTo(sectionTitle.mas_right).offset(8);
|
|
|
- make.centerY.mas_equalTo(headerView);
|
|
|
- }];
|
|
|
+ if (section <= (self.dataSourceArray.count - 1)) {
|
|
|
+ MailModel * model = self.dataSourceArray[section];
|
|
|
+ switch (model.TypeId) {
|
|
|
+ case MailListCusType:
|
|
|
+ {
|
|
|
+ sectionTitle.text = model.Name;
|
|
|
+ UIImageView * imagV = [UIImageView new];
|
|
|
+ imagV.image = IMG(@"create_mlist");
|
|
|
+ UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
|
|
|
+ MailListSortVC * vc = [MailListSortVC initMailListSortVC];
|
|
|
+ vc.dataArray = model.Items;
|
|
|
+ [weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
+ }];
|
|
|
+ [headerView addGestureRecognizer:tap];
|
|
|
+ headerView.userInteractionEnabled = YES;
|
|
|
+ [headerView addSubview:imagV];
|
|
|
+ [imagV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.mas_equalTo(sectionTitle.mas_right).offset(8);
|
|
|
+ make.centerY.mas_equalTo(headerView);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case MailListUserType:
|
|
|
+ {
|
|
|
+ sectionTitle.text = @"";
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ sectionTitle.text = model.Name;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ NSString *returnStr = [self.pinyinArray objectAtIndex:(section - self.dataSourceArray.count)];
|
|
|
+ sectionTitle.text = returnStr;
|
|
|
}
|
|
|
-// switch (section) {
|
|
|
-// case 0:
|
|
|
-// {
|
|
|
-// sectionTitle.text = @"单位通讯录";
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// case 1:
|
|
|
-// {
|
|
|
-// sectionTitle.text = @"系统通讯录";
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// default:
|
|
|
-// {
|
|
|
-// UIImageView * imagV = [UIImageView new];
|
|
|
-// imagV.image = IMG(@"create_mlist");
|
|
|
-// UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id _Nonnull sender) {
|
|
|
-// MailListSortVC * vc = [MailListSortVC initMailListSortVC];
|
|
|
-// vc.dataArray = [NSMutableArray arrayWithArray:weakSelf.dataSourceArray[section]];
|
|
|
-// vc.sortBlock = ^{
|
|
|
-// [weakSelf getData];
|
|
|
-// };
|
|
|
-// [weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
-// }];
|
|
|
-// [headerView addGestureRecognizer:tap];
|
|
|
-// headerView.userInteractionEnabled = YES;
|
|
|
-// [headerView addSubview:imagV];
|
|
|
-// [imagV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
-// make.left.mas_equalTo(sectionTitle.mas_right).offset(8);
|
|
|
-// make.centerY.mas_equalTo(headerView);
|
|
|
-// }];
|
|
|
-// sectionTitle.text = @"自建通讯录";
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// }
|
|
|
return headerView;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|
|
- MailModel * model = self.dataSourceArray[section];
|
|
|
- if (model.TypeId == MailListUserType) {
|
|
|
- return 0.01f;
|
|
|
- }
|
|
|
return 30.f;
|
|
|
}
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
- return [MailListCell configCell0Height];
|
|
|
+ if (indexPath.section <= (self.dataSourceArray.count - 1)) {
|
|
|
+ MailModel * model = self.dataSourceArray[indexPath.section];
|
|
|
+ switch (model.TypeId) {
|
|
|
+ case MailListUserType:
|
|
|
+ {
|
|
|
+ return [MailListByZuCell configCell0Height];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ return [MailListCell configCell0Height];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return [MailListByZuCell configCell0Height];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
- MailListCell *cell = [MailListCell configCell0:tableView indexPath:indexPath];
|
|
|
- MailModel * model = self.dataSourceArray[indexPath.section];
|
|
|
- MailSubModel * sModel = [model.Items objectAtIndex:indexPath.row];
|
|
|
- [cell setDataModel:sModel];
|
|
|
- return cell;
|
|
|
+ if (indexPath.section <= (self.dataSourceArray.count - 1)) {
|
|
|
+ MailModel * model = self.dataSourceArray[indexPath.section];
|
|
|
+ MailListCell *cell = [MailListCell configCell0:tableView indexPath:indexPath];
|
|
|
+ MailSubModel * sModel = [model.Items objectAtIndex:indexPath.row];
|
|
|
+ [cell setDataModel:sModel];
|
|
|
+ return cell;
|
|
|
+ }else{
|
|
|
+ NSArray * array = self.cusNameArray[indexPath.section - self.dataSourceArray.count];
|
|
|
+ SelectModel * smodel = [array objectAtIndex:indexPath.row];
|
|
|
+ MailListByZuCell *cell = [MailListByZuCell configCell0:tableView indexPath:indexPath];
|
|
|
+ cell.cell0TitleLabel.text = smodel.UserName;
|
|
|
+ [cell.cell0ImgView sd_setImageWithURL:[NSURL URLWithString:smodel.AvatarUrl] placeholderImage:[UIImage imageNamed:@"chatmsg_list_testuser_img"]];
|
|
|
+ return cell;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
|
- MailListCell *cell = [tableView cellForRowAtIndexPath:indexPath];
|
|
|
- MailListByZuVC *vc = [MailListByZuVC initMailListByZuVC];
|
|
|
- vc.notChangeSearchColor = self.notSearchChangeColor;
|
|
|
- vc.isSelectPeople = self.isSelectPeople;
|
|
|
- vc.isChat = self.isChat;
|
|
|
- vc.isShow = self.isShow;
|
|
|
- vc.isCheck = self.isCheck;
|
|
|
- vc.UserIds = self.UserIds;
|
|
|
- vc.isReturn = self.isReturn;
|
|
|
- vc.sendModel = self.sendModel;
|
|
|
- vc.titleStr = cell.cell0TitleLabel.text;
|
|
|
- MailModel * model = self.dataSourceArray[indexPath.section];
|
|
|
- MailSubModel * sModel = [model.Items objectAtIndex:indexPath.row];
|
|
|
- switch (model.TypeId) {
|
|
|
- case MailListDesType:
|
|
|
- {
|
|
|
- vc.indexId = sModel.Id;
|
|
|
- vc.pageType = MailListByZuPageType_Sys;
|
|
|
- [self.navigationController pushViewController:vc animated:YES];
|
|
|
- }
|
|
|
- break;
|
|
|
- case MailListCusType:
|
|
|
- {
|
|
|
- vc.indexId = sModel.Id;
|
|
|
- vc.pageType = MailListByZuPageType_custom;
|
|
|
- [self.navigationController pushViewController:vc animated:YES];
|
|
|
- }
|
|
|
- break;
|
|
|
- case MailListSysType:
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- {
|
|
|
- MailListDetailVC * userVC = [MailListDetailVC initMailListDetailVC];
|
|
|
- userVC.indexId = sModel.Id;
|
|
|
- [self.navigationController pushViewController:userVC animated:YES];
|
|
|
+ if (indexPath.section <= (self.dataSourceArray.count - 1)) {
|
|
|
+ MailModel * model = self.dataSourceArray[indexPath.section];
|
|
|
+ MailListByZuVC *vc = [MailListByZuVC initMailListByZuVC];
|
|
|
+ vc.notChangeSearchColor = self.notSearchChangeColor;
|
|
|
+ vc.isSelectPeople = self.isSelectPeople;
|
|
|
+ vc.isChat = self.isChat;
|
|
|
+ vc.isShow = self.isShow;
|
|
|
+ vc.isCheck = self.isCheck;
|
|
|
+ vc.UserIds = self.UserIds;
|
|
|
+ vc.isReturn = self.isReturn;
|
|
|
+ vc.sendModel = self.sendModel;
|
|
|
+ vc.titleStr = model.Name;
|
|
|
+ switch (model.TypeId) {
|
|
|
+ case MailListDesType:
|
|
|
+ {
|
|
|
+ MailSubModel * sModel = [model.Items objectAtIndex:indexPath.row];
|
|
|
+ vc.indexId = sModel.Id;
|
|
|
+ vc.pageType = MailListByZuPageType_Sys;
|
|
|
+ [self.navigationController pushViewController:vc animated:YES];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case MailListCusType:
|
|
|
+ {
|
|
|
+ MailSubModel * sModel = [model.Items objectAtIndex:indexPath.row];
|
|
|
+ vc.indexId = sModel.Id;
|
|
|
+ vc.titleStr = sModel.Name;
|
|
|
+ vc.pageType = MailListByZuPageType_custom;
|
|
|
+ [self.navigationController pushViewController:vc animated:YES];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case MailListSysType:
|
|
|
+ {
|
|
|
+ MailSubModel * sModel = [model.Items objectAtIndex:indexPath.row];
|
|
|
+ switch (sModel.TypeValue) {
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ MailGroupVC * vc = [[MailGroupVC alloc] init];
|
|
|
+ [self.navigationController pushViewController:vc animated:YES];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
- break;
|
|
|
+ }else{
|
|
|
+ NSArray * array = self.cusNameArray[indexPath.section - self.dataSourceArray.count];
|
|
|
+ SelectModel * sModel = [array objectAtIndex:indexPath.row];
|
|
|
+ MailListDetailVC * userVC = [MailListDetailVC initMailListDetailVC];
|
|
|
+ userVC.indexId = sModel.Id;
|
|
|
+ [self.navigationController pushViewController:userVC animated:YES];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -373,10 +470,21 @@
|
|
|
MailModel * model = [MailModel modelWithDictionary:dict];
|
|
|
[weakSelf.dataSourceArray addObject:model];
|
|
|
}
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- [weakSelf.tableView reloadData];
|
|
|
- });
|
|
|
}
|
|
|
+ NSMutableArray * mArray = [NSMutableArray array];
|
|
|
+ if ([responseObject[@"FriendUsers"] isKindOfClass:[NSArray class]]) {
|
|
|
+ NSArray * array = responseObject[@"FriendUsers"];
|
|
|
+ MailModel * model = [[MailModel alloc] init];
|
|
|
+ model.TypeId = 0;
|
|
|
+ for (NSDictionary * dict in array) {
|
|
|
+ SelectModel * umodel = [[SelectModel alloc] initDict:dict];
|
|
|
+ umodel.SourceId = umodel.UserId;
|
|
|
+ umodel.SourceType = 0;
|
|
|
+ umodel.SourceName = umodel.UserName;
|
|
|
+ [mArray addObject:umodel];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ [weakSelf resetDataSource:mArray];
|
|
|
} failure:^(NSError * _Nonnull error) {
|
|
|
REMOVESHOW
|
|
|
}];
|
|
@@ -420,4 +528,49 @@
|
|
|
}
|
|
|
return _groupModel;
|
|
|
}
|
|
|
+- (NSMutableArray *)cusNameArray
|
|
|
+{
|
|
|
+ if (!_cusNameArray) {
|
|
|
+ _cusNameArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ return _cusNameArray;
|
|
|
+}
|
|
|
+-(void)resetDataSource:(NSMutableArray *)sArray
|
|
|
+{
|
|
|
+ WS(weakSelf);
|
|
|
+ [self.cusNameArray removeAllObjects];
|
|
|
+ self.pinyinArray = [[NSMutableArray alloc] init];
|
|
|
+ self.nameArray = [[NSMutableArray alloc] init];
|
|
|
+ if (sArray.count > 0) {
|
|
|
+ NSMutableArray *stringsToSort = [[NSMutableArray alloc] init];
|
|
|
+ for(int i = 0;i < [sArray count];i++){
|
|
|
+ SelectModel * smodel = [sArray objectAtIndex:i];
|
|
|
+ NSString * str = [NSString stringWithFormat:@"%@UserId%ld",smodel.UserName,(long)smodel.UserId];
|
|
|
+ [stringsToSort addObject:str];
|
|
|
+ }
|
|
|
+ self.pinyinArray = [ChineseString IndexArray:stringsToSort];
|
|
|
+ self.nameArray = [ChineseString LetterSortArray:stringsToSort];
|
|
|
+ [self.nameArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+ NSMutableArray * subAddArray = [NSMutableArray array];
|
|
|
+ for (NSString * string in obj) {
|
|
|
+ NSInteger flag = 0;
|
|
|
+ BOOL isAdd = NO;
|
|
|
+ for (NSInteger i = 0; i < sArray.count; i ++) {
|
|
|
+ SelectModel * smodel = [sArray objectAtIndex:i];
|
|
|
+ if ([string containsString:[NSString stringWithFormat:@"UserId%ld",smodel.UserId]]) {
|
|
|
+ [subAddArray addObject:smodel];
|
|
|
+ isAdd = YES;
|
|
|
+ flag = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (subAddArray.count > 0) {
|
|
|
+ [weakSelf.cusNameArray addObject:subAddArray];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [weakSelf.tableView reloadData];
|
|
|
+ });
|
|
|
+}
|
|
|
@end
|