123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- //
- // SourceGroupSearchVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/1/17.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "ReplayMeSearchVC.h"
- #import "ReplayMeCell.h"
- #import "ReplyModel.h"
- @interface ReplayMeSearchVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) NSMutableArray *listArray;
- @end
- @implementation ReplayMeSearchVC
- - (NSMutableArray *)listArray
- {
- if (!_listArray) {
- _listArray = [NSMutableArray array];
- }
- return _listArray;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- self.view.backgroundColor = RGB(255, 255, 255);
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- // [self.topNavSearch setBarPlaceholder:@"姓名/手机号/邮箱"];
- self.historySearchType = HistorySearchType_Reply;
- [self addObserver:self forKeyPath:@"searchText" options:NSKeyValueObservingOptionNew context:nil];
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (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:text];
- }
- }
- - (void)getData:(NSString *)searchKey
- {
- [self.listArray removeAllObjects];
- WS(weakSelf);
- NSDictionary * paraDict = @{@"KeyWord":searchKey,
- @"TypeValue":self.IsReplyMe ? @(1) : @(0),
- };
- SHOWLOADING
- [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Reply_List) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) {
- REMOVESHOW
- if ([responseObject isKindOfClass:[NSDictionary class]]) {
- for (NSDictionary * dict in responseObject[@"Item"]) {
- ReplyModel * model = [ReplyModel modelWithDictionary:dict];
- [weakSelf.listArray addObject:model];
- }
- }
- dispatch_async(dispatch_get_main_queue(), ^{
- [weakSelf.tableView reloadData];
- });
- } failure:^(NSError * _Nonnull error) {
- REMOVESHOW
- }];
- }
- #pragma mark - UITableViewDelegate
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return self.listArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return UITableViewAutomaticDimension;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- ReplyModel * model = [self.listArray objectAtIndex:indexPath.row];
- if (model.IsComment) {
- ReplayMeCell * cell = [ReplayMeCell configCell0:tableView indexPath:indexPath];
- cell.redV.hidden = YES;
- [cell setDataCommentModel:model searchText:self.searchText];
- return cell;
- }else{
- ReplayMeCell * cell = [ReplayMeCell configCell1:tableView indexPath:indexPath];
- cell.redV.hidden = YES;
- [cell setDataModel:model searchText:self.searchText];
- return cell;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- ReplyModel * model = [self.listArray objectAtIndex:indexPath.row];
- MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC];
- vc.type = model.TypeValue;
- vc.Id = model.Id;
- [self.navigationController pushViewController:vc animated:YES];
- }
- @end
|