123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- //
- // ChatMsgTopSearchVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/4/8.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "ChatMsgTopSearchVC.h"
- #import "MailListByZuCell.h"
- #import "MailListDetailVC.h"
- @interface ChatMsgTopSearchVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, copy) NSMutableArray *listArray;
- @end
- @implementation ChatMsgTopSearchVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- self.view.backgroundColor = RGB(255, 255, 255);
- self.historySearchType = HistorySearchType_XinYuan;
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- self.historySearchType = HistorySearchType_XinYuan;
- [self addObserver:self forKeyPath:@"searchText" options:NSKeyValueObservingOptionNew context:nil];
- }
- - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
- {
- id obj = [change objectForKey:@"new"];
- NSString * text = @"";
- if ([obj isKindOfClass:[NSString class]]) {
- text = obj;
- }else{
- text = [obj stringValue];
- }
- if (text.length > 0) {
- [self getData];
- }
- }
- - (void)getData
- {
- NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
- [dict setObject:self.searchText forKey:@"Key"];
- WEAKSELF
- [self.listArray removeAllObjects];
- [[HttpManager sharedHttpManager] POSTWithUrl:AddressBookGroup_Search_Post parameters:dict success:^(id _Nonnull responseObject) {
- NSLog(@"搜索结果:%@",responseObject);
- for (NSDictionary *dic in responseObject) {
- SelectModel * model = [[SelectModel alloc] initDict:dic];
- [weakSelf.listArray addObject:model];
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- if (weakSelf.listArray.count > 0) {
- weakSelf.collectionView.hidden = YES;
- weakSelf.noDataView.hidden = YES;
- weakSelf.tableView.hidden = NO;
- [weakSelf.tableView reloadData];
- }else{
- weakSelf.noDataView.hidden = NO;
- weakSelf.collectionView.hidden = YES;
- weakSelf.tableView.hidden = YES;
- weakSelf.noDataL.text = @"暂无用户";
- }
- });
- } failure:^(NSError * _Nonnull error) {
- SHOWERROR([ZYCTool handerResultData:error])
-
- }];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return self.listArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return [MailListByZuCell configCell2Height];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- SelectModel * model = [self.listArray objectAtIndex:indexPath.row];
- MailListByZuCell *cell = [MailListByZuCell configCell2:tableView indexPath:indexPath];
- cell.cell0TitleLabel.text = model.UserName;
- cell.cell0DepartMentName.text = model.DepartmentName;
- [cell.cell0ImgView sd_setImageWithURL:[NSURL URLWithString:model.AvatarUrl] placeholderImage:IMG(@"chatmsg_list_testuser_img")];
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- SelectModel *model = [self.listArray objectAtIndex:indexPath.row];
- model.SourceName = model.UserName;
- model.SourceId = model.UserId;
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- MailListDetailVC *vc = [MailListDetailVC initMailListDetailVC];
- vc.indexId = model.UserId;
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (NSMutableArray *)listArray{
- if (!_listArray) {
- _listArray = [NSMutableArray new];
- }
- return _listArray;
- }
- @end
|