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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//
// OrderRecordViewController.m
// Lighting
//
// Created by 曹云霄 on 2016/10/25.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "OrderRecordViewController.h"
#import "OrderdetailsViewController.h"
#import "OrderTableViewCell.h"
@interface OrderRecordViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
/**
* 记录总页数
*/
@property (nonatomic,assign) NSInteger totalPage;
/**
* 订单记录数据
*/
@property (nonatomic,strong) NSMutableArray *orderRecordArray;
/**
* 请求订单记录
*/
@property (nonatomic,strong) OrderFilter *orderRecordModel;
@end
@implementation OrderRecordViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self GetdatasAciton];
}
#pragma mark -获取数据
- (void)GetdatasAciton
{
WS(weakSelf);
//下拉刷新
MjRefreshHeaderCustom *headerRefresh = [MjRefreshHeaderCustom headerWithRefreshingBlock:^{
//购物袋
weakSelf.orderRecordModel.dp.page = 1;
[weakSelf.orderRecordTableView.mj_footer resetNoMoreData];
[weakSelf getGuideAllcustomerOrder:weakSelf.orderRecordModel isRemove:YES];
}];
headerRefresh.stateLabel.hidden = YES;
headerRefresh.lastUpdatedTimeLabel.hidden = YES;
self.orderRecordTableView.mj_header = headerRefresh;
//进入刷新状态
[self.orderRecordTableView.mj_header beginRefreshing];
//上拉加载
self.orderRecordTableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
[weakSelf.orderRecordTableView.mj_footer resetNoMoreData];
//购物袋
if (++ weakSelf.orderRecordModel.dp.page > weakSelf.totalPage) {
[weakSelf.orderRecordTableView.mj_footer endRefreshingWithNoMoreData];
}else
{
[weakSelf getGuideAllcustomerOrder:weakSelf.orderRecordModel isRemove:NO];
}
}];
self.orderRecordTableView.mj_footer.automaticallyHidden = YES;
self.orderRecordTableView.tableFooterView = [UIView new];
}
#pragma mark -获取客户订单数据
- (void)getGuideAllcustomerOrder:(OrderFilter *)allOrder isRemove:(BOOL)remove
{
[self CreateMBProgressHUDLoding];
WS(weakSelf);
[[NetworkRequestClassManager Manager] NetworkRequestWithURL:SERVERREQUESTURL(QUERYORDER) WithCallClass:weakSelf WithRequestType:0 WithParameter:allOrder WithReturnValueBlock:^(id returnValue) {
weakSelf.orderRecordTableView.emptyDataSetSource = weakSelf;
weakSelf.orderRecordTableView.emptyDataSetDelegate = weakSelf;
[weakSelf RemoveMBProgressHUDLoding];
[weakSelf endRefreshingForTableView:weakSelf.orderRecordTableView];
if ([returnValue[@"code"] isEqualToNumber:@0]) {
if (remove) {
[weakSelf.orderRecordArray removeAllObjects];
}
OrderResponse *Allorder = [[OrderResponse alloc]initWithDictionary:returnValue[@"data"] error:nil];
weakSelf.totalPage = [returnValue[@"data"][@"totalpages"] intValue];
for (OrderBill *model in Allorder.orderBillList) {
[weakSelf.orderRecordArray addObject:model];
}
[weakSelf.orderRecordTableView reloadData];
}else
{
[weakSelf ErrorMBProgressView:returnValue[@"message"]];
}
} WithErrorCodeBlock:^(id errorCodeValue) {
[weakSelf ErrorMBProgressView:NETWORK];
} WithFailureBlock:^(NSError *error) {
[weakSelf ErrorMBProgressView:error.localizedDescription];
}];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
OrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ordercell" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.model = [self.orderRecordArray objectAtIndex_opple:indexPath.row];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.orderRecordArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 200;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
OrderdetailsViewController *orderdetails = [[[self class] getMainStoryboardClass] instantiateViewControllerWithIdentifier:@"orderdetails"];
TOOrderEntity *model = (TOOrderEntity *)[[self.orderRecordArray objectAtIndex_opple:indexPath.row] order];
orderdetails.orderCode = model.orderNumber;
if ([model.orderState isEqualToString:@"006"] || [model.orderState isEqualToString:@"002"] || [model.orderState isEqualToString:@"003"]) {
orderdetails.isShowPrintButton = YES;
orderdetails.isShowPayButton = NO;
orderdetails.isShowHeaderView = YES;
orderdetails.isUserInteractionEnabled = NO;
} else if ([model.orderState isEqualToString:@"001"]) {//未付款
orderdetails.isShowPayButton = YES;
orderdetails.isShowPrintButton = NO;
orderdetails.isShowHeaderView = YES;
orderdetails.isUserInteractionEnabled = YES;
}else{
orderdetails.isShowHeaderView = NO;
}
//撤销、支付回调
WS(weakSelf);
[orderdetails setDelecteAndPayButtonBlock:^(NSInteger cellindex, NSString *orderSate) {
OrderBill *model = [weakSelf.orderRecordArray objectAtIndex_opple:cellindex];
model.order.orderState = orderSate;
NSIndexPath *indexapath = [NSIndexPath indexPathForRow:cellindex inSection:0];
[weakSelf.orderRecordTableView reloadRowsAtIndexPaths:@[indexapath] withRowAnimation:UITableViewRowAnimationNone];
}];
[self.navigationController pushViewController:orderdetails animated:YES];
}
#pragma mark - lazy
- (NSMutableArray *)orderRecordArray
{
if (_orderRecordArray == nil) {
_orderRecordArray = [NSMutableArray array];
}
return _orderRecordArray;
}
- (OrderFilter *)orderRecordModel
{
if (!_orderRecordModel) {
_orderRecordModel = [[OrderFilter alloc]init];
DataPage *Newpage = [[DataPage alloc]init];
Newpage.page = 1;
Newpage.rows = KROWS;
_orderRecordModel.dp = Newpage;
_orderRecordModel.consumerIdEquals = self.model.fid;
}
return _orderRecordModel;
}
#pragma mark -友好界面
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
return kNoDataImage;
}
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView
{
return [[NSAttributedString alloc]initWithString:@"暂无数据" attributes:nil];
}
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView
{
return YES;
}
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView
{
return 100;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end