123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //
- // ChangeSchoolListViewController.m
- // jiaPei
- //
- // Created by 张嵘 on 2019/7/1.
- // Copyright © 2019 JCZ. All rights reserved.
- //
- #import "ChangeSchoolListViewController.h"
- #import "ChangeSchoolListCell.h"
- #import <MJRefresh.h>
- #import "ChangeSchoolListModel.h"
- #import "ChangeSchoolDetailViewController.h"
- #import "HolderView.h"
- @interface ChangeSchoolListViewController () <UITableViewDataSource, UITableViewDelegate>
- @property (nonatomic, readwrite, strong) NSMutableArray *dataArr;
- @property (nonatomic, readwrite, strong) HolderView *holderView;
- @end
- @implementation ChangeSchoolListViewController
- #pragma mark - Life Cycle
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self initUI];
- }
- #pragma mark - UITableViewDataSource And UITableViewDelegate
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return self.dataArr.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 1;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return kScreenWidth *0.45;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return 0.01;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- return 10;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- ChangeSchoolListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ChangeSchoolListCell"];
- ChangeSchoolListModel *changeSchoolListModel = self.dataArr[indexPath.section];
- cell.changeSchoolListModel = changeSchoolListModel;
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- ChangeSchoolDetailViewController *vc = [ChangeSchoolDetailViewController suspendChangeSchoolDetailPageVC];
- ChangeSchoolListModel *changeSchoolListModel = self.dataArr[indexPath.section];
- vc.changeSchoolListModel = changeSchoolListModel;
- [vc initWithUpResultBlock:^(BOOL isSuccess) {
- if (isSuccess) {
- [self.tableView.mj_header beginRefreshing];
- }
- }];
- [self navPushHideTabbarToVC:vc];
- }
- #pragma mark - Private Functions
- - (void)initUI {
- self.title = @"转校记录";
- [self configNavigationBar];
- [_tableView registerNib:[UINib nibWithNibName:@"ChangeSchoolListCell" bundle:nil] forCellReuseIdentifier:@"ChangeSchoolListCell"];
- _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
- [self getData];
- }];
- [_tableView.mj_header beginRefreshing];
-
- [self.holderView freshBlock:^{
- [self.tableView.mj_header beginRefreshing];
- }];
- [self.view addSubview:self.holderView];
- }
- /// 请求数据
- - (void)getData {
- NSMutableArray *arr = [NSMutableArray array];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
- [arr addPro:@"outId" Value:defUser.userDict[@"outId"]];
- [arr addPro:@"idcard" Value:defUser.sfzmhm];
-
- NSString *method = @"getZxInfoByStudent";
-
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
- _holderView.hidden = NO;
- [_tableView.mj_header endRefreshing];
- if (!root) {
- ShowMsgFailed();
- return;
- }
- if ([root[@"code"] isEqualToString:@"0"]) {
- if (self.dataArr.count > 0) {
- [self.dataArr removeAllObjects];
- }
- [self.dataArr addObjectsFromArray:[ChangeSchoolListModel modelArrayWithJSON:root[@"body"]]];
- [_tableView reloadData];
- _holderView.hidden = self.dataArr.count != 0;
- }else {
- if ([root[@"body"] isKindOfClass:[NSString class]]) {
- ShowMsg(root[@"body"]);
- }
- return;
- }
- }];
- }
- #pragma mark - Lazy Load
- - (NSMutableArray *)dataArr {
- if (!_dataArr) {
- _dataArr = [NSMutableArray array];
- }
- return _dataArr;
- }
- - (HolderView *)holderView {
- if (!_holderView) {
- _holderView = [[HolderView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNavOffSet - kSafeAreaBottomHeight)];
- }
- return _holderView;
- }
- @end
|