Skip to content

Commit c268170

Browse files
committed
【iOS】当马币余额为0,并且没有过交易记录,马币页面显示不对
1 parent f81e2d3 commit c268170

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

Coding_iOS/Controllers/PointRecordsViewController.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ - (void)refreshMore{
8787
}
8888

8989
- (void)sendRequest{
90-
if (_curRecords.list.count <= 0) {
90+
if (_curRecords.list.count <= 0 && !_curRecords.points_left) {
9191
[self.view beginLoading];
9292
}
9393
__weak typeof(self) weakSelf = self;
@@ -100,15 +100,15 @@ - (void)sendRequest{
100100
[weakSelf.myTableView reloadData];
101101
weakSelf.myTableView.showsInfiniteScrolling = weakSelf.curRecords.canLoadMore;
102102
}
103-
[weakSelf.view configBlankPage:EaseBlankPageTypeView hasData:(weakSelf.curRecords.list.count > 0) hasError:(error != nil) reloadButtonBlock:^(id sender) {
103+
[weakSelf.view configBlankPage:EaseBlankPageTypeView hasData:(weakSelf.curRecords.list.count > 0 || weakSelf.curRecords.points_left) hasError:(error != nil) reloadButtonBlock:^(id sender) {
104104
[weakSelf refresh];
105105
}];
106106
}];
107107
}
108108

109109
#pragma mark Table M
110110
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
111-
return _curRecords.list.count <= 0? 0:2;
111+
return _curRecords.list.count <= 0? 1:2;
112112
}
113113
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
114114
return section == 0? 2: self.curRecords.list.count;
@@ -117,9 +117,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
117117

118118
if (indexPath.section == 0) {
119119
if (indexPath.row == 0) {
120-
PointRecord *record = [_curRecords.list firstObject];
121120
PointTopCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_PointTopCell forIndexPath:indexPath];
122-
cell.pointLeftStr = [NSString stringWithFormat:@"%.2f", record.points_left.floatValue];
121+
cell.pointLeftStr = _curRecords.points_left? [NSString stringWithFormat:@"%.2f", _curRecords.points_left.floatValue]: @"--";
123122
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:0 hasSectionLine:NO];
124123
return cell;
125124
}else{

Coding_iOS/Models/PointRecords.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
@property (readwrite, nonatomic, strong) NSDictionary *propertyArrayMap;
1616
@property (readwrite, nonatomic, strong) NSMutableArray *list;
1717

18+
@property (strong, nonatomic) NSNumber *points_left;
19+
1820
- (NSString *)toPath;
1921
- (NSDictionary *)toParams;
2022
- (void)configWithObj:(PointRecords *)records;

Coding_iOS/Models/PointRecords.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ - (instancetype)init
2222
}
2323
return self;
2424
}
25+
- (NSNumber *)points_left{
26+
if (!_points_left && _list.count > 0) {
27+
_points_left = [(PointRecord *)_list.firstObject points_left];
28+
}
29+
return _points_left;
30+
}
2531
- (NSString *)toPath{
2632
return @"api/point/records";
2733
}

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2412,7 +2412,16 @@ - (void)request_PointRecords:(PointRecords *)records andBlock:(void (^)(id data,
24122412

24132413
data = [data valueForKey:@"data"];
24142414
PointRecords *resultA = [NSObject objectOfClass:@"PointRecords" fromJSON:data];
2415-
block(resultA, nil);
2415+
if (!records.points_left) {
2416+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:@"api/point/points" withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
2417+
if (data) {
2418+
records.points_left = data[@"data"][@"points_left"];
2419+
}
2420+
block(resultA, nil);
2421+
}];
2422+
}else{
2423+
block(resultA, nil);
2424+
}
24162425
}else{
24172426
block(nil, error);
24182427
}

0 commit comments

Comments
 (0)