123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- //
- // SPSBWaitToDoViewController.m
- // 我的社保
- //
- // Created by shanp on 2021/6/22.
- //
- #import "SPSBWaitToDoViewController.h"
- #import "SPSBUIGeneralHeader.h"
- #import "UIViewController+SPSBNetworkManager.h"
- #import "SPSBRefreshHeader.h"
- #import "UIViewController+SPSBLoadDataStatus.h"
- #import "SPSBWaitToDoModel.h"
- #import "UITableView+SPSBDefault.h"
- #import "SPSBWaitToDoDetailsViewController.h"
- @interface SPSBWaitToDoTableViewCell : UITableViewCell {
- UILabel *_titleLabel;
- UILabel *_timeLabel;
- UILabel *_cityLabel;
- UILabel *_statusLabel;
- UIView *_tipsView;
- }
- @end
- @implementation SPSBWaitToDoTableViewCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (!self) return nil;
-
- self.contentView.backgroundColor = spsb_F5F5F5_color();
- UIView *bgView = UIView.new;
- bgView.backgroundColor = spsb_FFFFFF_color(1.f);
- [self.contentView addSubview:bgView];
- [bgView makeConstraints:^(JXHConstraintMaker *make) {
- make.top.and.leading.and.trailing.equalTo(0);
- make.height.equalTo(90);
- }];
- _titleLabel = [UILabel convenienceWithFont:spsb_font(17) text:nil textColor:spsb_333333_color()];
- [bgView addSubview:_titleLabel];
- [_titleLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(15);
- make.top.equalTo(20);
- }];
-
-
-
- _timeLabel = [UILabel convenienceWithFont:spsb_font(14) text:nil textColor:spsb_999999_color()];
- [bgView addSubview:_timeLabel];
- [_timeLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(15);
- make.bottom.equalTo(-20);
- }];
-
- _cityLabel = [UILabel convenienceWithFont:spsb_font(17) text:nil textColor:spsb_333333_color() textAlignment:NSTextAlignmentRight];
- [bgView addSubview:_cityLabel];
- [_cityLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(-33);
- make.centerY.equalTo(self->_titleLabel.centerY);
- make.leading.greaterThanOrEqualTo(self->_titleLabel.trailing).offset(10);
- }];
- [_cityLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
-
- _statusLabel = [UILabel convenienceWithFont:spsb_font(14) text:nil textColor:spsb_FF801A_color() textAlignment:NSTextAlignmentRight];
- [bgView addSubview:_statusLabel];
- [_statusLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(-33);
- make.centerY.equalTo(self->_timeLabel.centerY);
- }];
-
- _tipsView = UIView.new;
- _tipsView.backgroundColor = spsb_FF5E5E_color();
- [_tipsView setLayerCornerRadius:4 clipToBounds:false];
- [bgView addSubview:_tipsView];
- [_tipsView makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(self->_cityLabel.leading).offset(-6);
- make.centerY.equalTo(self->_titleLabel.centerY);
- make.size.equalTo(CGSizeMake(8, 8));
- }];
-
- UIImageView *arrow = [[UIImageView alloc] initWithImage:jxh_getImage(list_arrow)];
- [bgView addSubview:arrow];
- [arrow makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(-15);
- make.centerY.equalTo(self->_titleLabel.centerY);
- }];
-
- return self;
- }
- - (void)reloadData:(SPSBWaitToDoModel *)data {
- _titleLabel.text = data.spsb_source_name;
- _timeLabel.text = data.spsb_create_time;
- _cityLabel.text = data.spsb_city_name;
- switch ([data.spsb_flow_status integerValue]) {
- case 1: {
- _statusLabel.text = @"处理中";
- _statusLabel.textColor = spsb_FF801A_color();
- }
- break;
- case 2: {
- _statusLabel.text = @"已完成";
- _statusLabel.textColor = spsb_999999_color();
- }
- break;
-
- default: {
- _statusLabel.text = @"已关闭";
- _statusLabel.textColor = spsb_999999_color();
- }
- break;
- }
- _tipsView.hidden = [data.spsb_todo_flag integerValue] == 1 ? false : true;
- }
- @end
- @interface SPSBWaitToDoViewController () {
- NSArray<SPSBWaitToDoModel *> *_dataArray;
- bool _firstLoad;
- }
- @end
- @implementation SPSBWaitToDoViewController
- - (instancetype)init {
- self = [super initWithStyle:UITableViewStylePlain backgroundColor:SPSBTableViewBackgroundColorGray];
- if (!self) return nil;
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setupUI];
- _firstLoad = true;
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- if (_firstLoad) {
- _firstLoad = false;
- [self getDataWithTips:true];
- } else {
- [self getDataWithTips:false];
- }
- }
- #pragma mark - Action
- #pragma mark - Network Action
- - (void)getDataWithTips:(bool)tips {
- @weakify(self)
- [self networkUseMethod:SPSBNetworkMethodPOST loadingTips:tips ? @"正在加载": nil isLogin:true url:spsb_appUrl(SPSBUrlGetMaterialflowList) urlParameters:nil parameters:nil success:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- [self getDataSuccess:data];
- return @"";
- } failure:^NSString * _Nullable(NSError * _Nonnull error, id _Nullable data) {
- @strongify(self)
- [self getdataFailure:error];
- return @"加载失败";
- }];
- }
- - (void)getDataSuccess:(id)data {
- _dataArray = [SPSBWaitToDoModel getModelListWithArray:data[@"data"]];
- [self.tableView reloadData];
- if (_dataArray.count == 0) {
- self.tableView.backgroundColor = spsb_FFFFFF_color(1.f);
- [self.tableView setDefaultFootViewWithError:nil image:jxh_getImage(todo_qs) height:jxh_viewHeight(self.tableView) action:^{
- }];
- } else {
- self.tableView.backgroundColor = spsb_F5F5F5_color();
- [self.tableView removeDefaultFootView];
- }
- [self.tableView.mj_header endRefreshing];
- }
- - (void)getdataFailure:(NSError *)error {
- _dataArray = @[];
- [self.tableView reloadData];
- @weakify(self)
- self.tableView.backgroundColor = spsb_FFFFFF_color(1.f);
- [self.tableView setDefaultFootViewWithError:error image:jxh_getImage(todo_qs) height:jxh_viewHeight(self.tableView) action:^{
- @strongify(self)
- self.tableView.backgroundColor = spsb_F5F5F5_color();
- [self getDataWithTips:true];
- }];
- [self.tableView.mj_header endRefreshing];
- }
- #pragma mark - Delegate & DataSource
- static NSString * const reuseIdentifier = @"SPSBWaitToDoTableViewCell";
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- SPSBWaitToDoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
- if (!cell) {
- cell = [[SPSBWaitToDoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
- }
- [cell reloadData:_dataArray[indexPath.row]];
- return cell;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return _dataArray.count;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:false];
- SPSBWaitToDoDetailsViewController *vc = SPSBWaitToDoDetailsViewController.new;
- vc.spsb_data = _dataArray[indexPath.row];
- [self.navigationController pushViewController:vc animated:true];
- }
- #pragma mark - UI
- - (void)setupUI {
- self.title = @"待办事项";
- [self setupTableView];
- @weakify(self)
- self.tableView.mj_header = [SPSBRefreshHeader headerWithRefreshingBlock:^{
- @strongify(self)
- [self getDataWithTips:false];
- }];
- }
- - (void)setupTableView {
- self.tableView.rowHeight = 100.f;
- }
- @end
|