You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.2 KiB

//
// ChatListViewController.m
// tongxin
//
// Created by ecell on 2023/7/13.
// Copyright © 2023 xTT. All rights reserved.
//
#import "ChatListViewController.h"
#import "CommonTableView.h"
#import "ChatViewController.h"
#import "ChatListTableViewCell.h"
#import "ChatListModel.h"
@interface ChatListViewController ()
@property (nonatomic ,strong) CommonTableView *listTable;
@end
@implementation ChatListViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.zx_navTitle = @"微聊";
self.view.backgroundColor = tabViewBG;
// Do any additional setup after loading the view.
[self.view addSubview:self.listTable];
[self.listTable mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view).offset(iPhoneX_NavHeight);
make.left.right.equalTo(self.view);
make.bottom.equalTo(self.view.mas_bottom);
}];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self getModelList];
}
- (CommonTableView *)listTable
{
if (!_listTable)
{
_listTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:87 cellRow:0 isAdaptive:NO isLine:YES commonCell:ChatListTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) {
ChatListTableViewCell *cell = (ChatListTableViewCell *)cells;
//[UICommon tableView:self->_homeTable willDisplayCell:cell forRowAtIndexPath:indexPath cellCoutn:self.myDataSource.count sizeH:0];
cell.listModel = self.myDataSource[indexPath.row];
// if (indexPath.row == 0)
// [UICommon setExtraCellLineHidden:cell];
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) {
ChatListModel *model = self.myDataSource[indexPath.row];
ChatViewController *vc = [[ChatViewController alloc] init];
vc.zx_navTitle = model.groupid ? @"家庭群聊" : model.name;
vc.chatType = model.groupid ? 222: 111;
if (model.groupid)
{
Circle *infoCircle = [[Circle alloc] init];
infoCircle.groupid = model.groupid;
infoCircle.creator = model.creator;
infoCircle.members = model.members;
infoCircle.devices = model.devices;
infoCircle.msgNum = model.msgNum;
vc.infoCircle = infoCircle;
}
else
{
Circle *infoCircle = [[Circle alloc] init];
vc.imei = model.imei;
vc.infoCircle = infoCircle;
}
[self.navigationController pushViewController:vc animated:YES];
} DidscrollView:^(UIScrollView * _Nonnull scrollView) {
}];
_listTable.backgroundColor = KKClearColor;
[UICommon setTavleViewlink:_listTable distance:15];
}
return _listTable;
}
/// 获取用户所有单聊和群聊信息
- (void)getModelList
{
WEAKSELF
[cUser.cDevice GetChatGroupsWithSuccess:^(id responseObject) {
weakSelf.myDataSource = [NSMutableArray new];
NSArray *groupArr = responseObject[@"groupDataList"];
NSArray *singleArr = responseObject[@"singleDataList"];
for (NSDictionary *dic in singleArr)
{
ChatListModel *model = [ChatListModel yy_modelWithJSON:dic];
[weakSelf.myDataSource addObject:model];
}
for (NSDictionary *dic in groupArr)
{
ChatListModel *model = [ChatListModel yy_modelWithJSON:dic];
[weakSelf.myDataSource addObject:model];
}
weakSelf.listTable.cellRow = weakSelf.myDataSource.count;
[weakSelf.listTable reloadData];
} failure:^(NSError *error) {
}];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end