1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
//
// WithdrawalViewController.m
// Lighting
//
// Created by 曹云霄 on 16/8/26.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "WithdrawalViewController.h"
#import "WithdrawalTableViewCell.h"
#import "WithdrawalTableViewController.h"
@interface WithdrawalViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetDelegate,DZNEmptyDataSetSource>
@property (weak, nonatomic) IBOutlet UITableView *withdrawalTableView;
/**
* 上传参数
*/
@property (nonatomic,strong) RsApplyBillRequest *model;
/**
* 数据源
*/
@property (nonatomic,strong) NSMutableArray *resultArray;
/**
* 总页数
*/
@property (nonatomic,assign) NSInteger totalPage;
@end
@implementation WithdrawalViewController
#pragma mark - lazy
- (RsApplyBillRequest *)model
{
if (!_model) {
_model = [[RsApplyBillRequest alloc]init];
DataPage *page = [[DataPage alloc]init];
page.page = ONE;
page.rows = KROWS;
_model.page = page;
_model.employeeId = [Shoppersmanager manager].shoppers.employee.fid;
}
return _model;
}
- (NSMutableArray *)resultArray
{
if (!_resultArray) {
_resultArray = [NSMutableArray array];
}
return _resultArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.withdrawalTableView.tableFooterView = [UIView new];
[self setupRefreshing];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.withdrawalTableView.mj_header beginRefreshing];
}
#pragma mark - 设置刷新
- (void)setupRefreshing
{
WS(weakSelf);
MjRefreshHeaderCustom *headerRefresh = [MjRefreshHeaderCustom headerWithRefreshingBlock:^{
weakSelf.model.page.page = ONE;
[weakSelf.withdrawalTableView.mj_footer resetNoMoreData];
[weakSelf getDatasAction:YES];
}];
headerRefresh.stateLabel.hidden = YES;
headerRefresh.lastUpdatedTimeLabel.hidden = YES;
self.withdrawalTableView.mj_header = headerRefresh;
MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
if (++ weakSelf.model.page.page > weakSelf.totalPage) {
[weakSelf.withdrawalTableView.mj_footer endRefreshingWithNoMoreData];
}else
{
[weakSelf getDatasAction:NO];
}
}];
footer.automaticallyHidden = YES;
self.withdrawalTableView.mj_footer = footer;
}
#pragma mark - 获取提现进度
- (void)getDatasAction:(BOOL)isRemoveAll
{
WS(weakSelf);
[XBLoadingView showHUDViewWithDefaultWithView:self.view];
[HTTP networkRequestWithURL:SERVERREQUESTURL(WITHDRAWALPROGRESS) withRequestType:ZERO withParameter:self.model withReturnValueBlock:^(id returnValue) {
weakSelf.withdrawalTableView.emptyDataSetSource = weakSelf;
weakSelf.withdrawalTableView.emptyDataSetDelegate = weakSelf;
[weakSelf endRefreshingForTableView:weakSelf.withdrawalTableView];
[XBLoadingView hideHUDViewWithDefaultWithView:weakSelf.view];
if (RESULT(returnValue)) {
if (isRemoveAll) {
[weakSelf.resultArray removeAllObjects];
}
RsApplyBillResponse *result = [[RsApplyBillResponse alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
weakSelf.totalPage = result.totalpages;
for (TOApplyBillEntity *entity in result.list) {
[weakSelf.resultArray addObject:entity];
}
[weakSelf.withdrawalTableView reloadData];
}else
{
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
}withFailureBlock:^(NSError *error) {
[weakSelf endRefreshingForTableView:weakSelf.withdrawalTableView];
[XBLoadingView hideHUDViewWithDefaultWithView:weakSelf.view];
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
}
#pragma mark - <UITableViewDataSource,UITableViewDelegate>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
WithdrawalTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WithdrawalTableViewCell" forIndexPath:indexPath];
TOApplyBillEntity *entity = self.resultArray[indexPath.row];
cell.entity = entity;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.resultArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 70;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
WithdrawalTableViewController *paymentsDetailsVC = [[[self class] getMainStoryboardClass] instantiateViewControllerWithIdentifier:@"WithdrawalTableViewController"];
paymentsDetailsVC.model = self.resultArray[indexPath.row];
[self.navigationController pushViewController:paymentsDetailsVC animated:YES];
}
#pragma mark - 释放
- (void)dealloc
{
[Notification removeObserver:self];
}
#pragma mark -友好界面
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
return kNoDataImage;
}
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView
{
return YES;
}
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
return [[NSAttributedString alloc]initWithString:@"暂无数据" attributes:nil];
}
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView
{
return 64;
}
@end