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
//
// IntegralDetailsViewController.m
// Lighting
//
// Created by 曹云霄 on 2016/11/21.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "IntegralDetailsViewController.h"
#import "IntegralDetailsTableViewCell.h"
#import "prizeDetailsTableViewCell.h"
#import "PrizeExchangeDetailsViewController.h"
@interface IntegralDetailsViewController ()<UITableViewDelegate,UITableViewDataSource>
/**
数据源
*/
@property (nonatomic,strong) NSMutableArray *datasArray;
/**
顶部约束
*/
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topConstraint;
@end
@implementation IntegralDetailsViewController
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.tableView.mj_header beginRefreshing];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self uiConfigAction];
}
#pragma mark - UI
- (void)uiConfigAction
{
self.tableView.rowHeight = (self.cellType == PrizeTableView)?90:70;
if (self.cellType == PrizeTableView) {
self.topConstraint.constant = NavigationHeight;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.backgroundColor = RGB(237, 238, 239, 1);
}
}
#pragma mark -加载数据
- (void)loadWebDataSource
{
WS(weakSelf);
if (self.pullPageIndex == ONE) {
[self.datasArray removeAllObjects];
}
switch (weakSelf.cellType) {
case IntrgralTableView:
{
[self queryIntegralDetailsCompleted:^(RsScoreDetails *result) {
[weakSelf endRefresh:EndRefreshNotData];
}];
}
break;
case PrizeTableView:
{
[weakSelf queryPrizeDetailsCompleted:^(RsPrizeBillResponse *result) {
[weakSelf endRefresh:EndRefreshNotData];
}];
}
break;
default:
break;
}
}
#pragma mark - 查询积分明细
- (void)queryIntegralDetailsCompleted:(void(^)(RsScoreDetails *result))completed
{
WS(weakSelf);
[XBLoadingView showHUDViewWithDefault];;
NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(INTEGRALQUERY),[Shoppersmanager manager].shoppers.employee.fid];
[HTTP networkWithDictionaryRequestWithURL:url withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
if (RESULT(returnValue)) {
RsScoreDetails *integralDatas = [[RsScoreDetails alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
completed(integralDatas);
[weakSelf.datasArray addObjectsFromArray:integralDatas.recoreds];
if (weakSelf.returnIntegralDetailsBlock) {
weakSelf.returnIntegralDetailsBlock(integralDatas);
}
}else {
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
[weakSelf.tableView reloadData];
}withFailureBlock:^(NSError *error) {
[weakSelf endRefresh:EndRefreshDefault];
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
}
#pragma mark - 查询兑奖明细
- (void)queryPrizeDetailsCompleted:(void(^)(RsPrizeBillResponse *result))completed
{
WS(weakSelf);
NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(ALLEXCHANGERECORD),[Shoppersmanager manager].shoppers.employee.fid];
[HTTP networkWithDictionaryRequestWithURL:url withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
if (RESULT(returnValue)) {
RsPrizeBillResponse *integralDatas = [[RsPrizeBillResponse alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
completed(integralDatas);
[weakSelf.datasArray addObjectsFromArray:integralDatas.bills];
}else {
[XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
}
[weakSelf.tableView reloadData];
} withFailureBlock:^(NSError *error) {
[weakSelf endRefresh:EndRefreshDefault];
[XBLoadingView showHUDViewWithText:error.localizedDescription];
}];
}
#pragma mark - <UITableViewDataSource,UITableViewDelegate>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (self.cellType) {
case IntrgralTableView:
{
IntegralDetailsTableViewCell *integralCell = [tableView dequeueReusableCellWithIdentifier:@"IntegralDetailsTableViewCell" forIndexPath:indexPath];
integralCell.integralEntity = self.datasArray[indexPath.row];
integralCell.selectionStyle = UITableViewCellSelectionStyleNone;
return integralCell;
}
break;
case PrizeTableView:
{
prizeDetailsTableViewCell *prizeCell = [tableView dequeueReusableCellWithIdentifier:@"prizeDetailsTableViewCell" forIndexPath:indexPath];
prizeCell.prizeListModel = self.datasArray[indexPath.row];
prizeCell.backgroundColor = [UIColor clearColor];
return prizeCell;
}
break;
default:
break;
}
return nil;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.datasArray.count;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (self.cellType) {
case PrizeTableView:
{
PrizeExchangeDetailsViewController *exchangeDetails = [PrizeExchangeDetailsViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_GUIDEINTERGRAL];
RsPrizeBill *bill = self.datasArray[indexPath.row];
exchangeDetails.isDelivery = ![bill.bill.state isEqualToString:TOPRIZEBILLENTITYSTATE_REQUESTED];
exchangeDetails.prizeBillNumber = bill.bill.billnumber;
[self pushViewController:exchangeDetails animated:YES];
}
break;
default:
break;
}
}
#pragma mark - lazy
- (NSMutableArray *)datasArray
{
if (!_datasArray) {
_datasArray = [NSMutableArray array];
}
return _datasArray;
}
@end