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.
124 lines
4.3 KiB
124 lines
4.3 KiB
// |
|
// ShortMessageListViewController.m |
|
// tongxin |
|
// |
|
// Created by ecell on 2023/5/30. |
|
// Copyright © 2023 xTT. All rights reserved. |
|
// |
|
|
|
#import "ShortMessageListViewController.h" |
|
#import "ShortMessageListTableViewCell.h" |
|
#import "ShortMessageDetailsViewController.h" |
|
#import "CommonTableView.h" |
|
#import "SmSModel.h" |
|
#import "MJRefresh.h" |
|
|
|
@interface ShortMessageListViewController ()<DZNEmptyDataSetSource,DZNEmptyDataSetDelegate,CommonTableViewDelegate> |
|
|
|
@property (nonatomic ,strong) CommonTableView *listTable; |
|
@property (nonatomic ,assign) NSInteger page; |
|
|
|
|
|
@end |
|
|
|
@implementation ShortMessageListViewController |
|
|
|
- (void)viewDidLoad { |
|
[super viewDidLoad]; |
|
// Do any additional setup after loading the view. |
|
self.zx_navTitle = @"表端短信"; |
|
self.emptyText = @"未收到手表短信"; |
|
self.page = 0; |
|
[self.view addSubview:self.listTable]; |
|
[self.listTable mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.view); |
|
make.top.equalTo(self.view).offset(iPhoneX_NavHeight); |
|
make.bottom.equalTo(self.view.mas_bottom); |
|
}]; |
|
[self GetListModel]; |
|
} |
|
|
|
- (CommonTableView *)listTable |
|
{ |
|
if (!_listTable) |
|
{ |
|
_listTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:104 cellRow:0 isAdaptive:YES isLine:NO commonCell:ShortMessageListTableViewCell.class |
|
createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) { |
|
ShortMessageListTableViewCell *cell = (ShortMessageListTableViewCell *)cells; |
|
cell.smsModel = self.myDataSource[indexPath.row]; |
|
|
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) { |
|
ShortMessageDetailsViewController *vc = [[ShortMessageDetailsViewController alloc] init]; |
|
vc.smsModel = self.myDataSource[indexPath.row]; |
|
[self.navigationController pushViewController:vc animated:YES]; |
|
|
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) { |
|
|
|
}]; |
|
_listTable.isEditing = YES; |
|
_listTable.delegates = self; |
|
_listTable.backgroundColor = KKClearColor; |
|
_listTable.emptyDataSetSource = self; |
|
_listTable.emptyDataSetDelegate = self; |
|
WEAKSELF |
|
_listTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ |
|
weakSelf.page = 0; |
|
[weakSelf.myDataSource removeAllObjects]; |
|
[weakSelf GetListModel]; |
|
}]; |
|
_listTable.mj_footer = [MJRefreshFooter footerWithRefreshingBlock:^{ |
|
[weakSelf GetListModel]; |
|
}]; |
|
|
|
} |
|
return _listTable; |
|
} |
|
|
|
- (void)GetListModel |
|
{ |
|
WEAKSELF |
|
[cUser.cDevice getDevicesSmSList:self.page success:^(id responseObject) { |
|
NSArray *arr = responseObject[@"smsMessages"]; |
|
if (arr.count >= 20) |
|
weakSelf.page++; |
|
else |
|
[weakSelf.listTable.mj_footer endRefreshingWithNoMoreData]; |
|
[arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { |
|
SmSModel *model = [SmSModel yy_modelWithJSON:obj]; |
|
[weakSelf.myDataSource addObject:model]; |
|
}]; |
|
|
|
[weakSelf.listTable.mj_header endRefreshing]; |
|
[weakSelf.listTable.mj_footer endRefreshing]; |
|
NSLog(@"%@",weakSelf.myDataSource); |
|
weakSelf.listTable.cellRow = weakSelf.myDataSource.count; |
|
[weakSelf.listTable reloadData]; |
|
|
|
} failure:^(id faiObject) { |
|
|
|
}]; |
|
} |
|
|
|
- (void)CommTableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath |
|
{ |
|
WEAKSELF |
|
SmSModel *model = self.myDataSource[indexPath.row]; |
|
[cUser.cDevice deleteAndPostDevicesSmSList:model.id method:@"DELETE" success:^(id responseObject) { |
|
[weakSelf.myDataSource removeAllObjects]; |
|
[weakSelf GetListModel]; |
|
} failure:^(id faiObject) { |
|
|
|
}]; |
|
} |
|
|
|
/* |
|
#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
|
|
|