提交
This commit is contained in:
@@ -57,14 +57,19 @@
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
-(void)getPriceData{
|
||||
MJWeakSelf
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[QXMineNetwork roomWaterDetailWithRoomId:self.room_id start_time:self.startTime end_time:self.endTime page:self.page type:self.type successBlock:^(QXRoomDetailModel * _Nonnull model) {
|
||||
weakSelf.headerView.model = model;
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.dict removeAllObjects];
|
||||
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
NSLog(@"⚠️ self has been deallocated, skipping hide operation");
|
||||
return;
|
||||
}
|
||||
strongSelf.headerView.model = model;
|
||||
if (strongSelf.page == 1) {
|
||||
[strongSelf.dict removeAllObjects];
|
||||
}
|
||||
|
||||
NSArray *arr = [weakSelf.dict allKeys];
|
||||
NSArray *arr = [strongSelf.dict allKeys];
|
||||
for (QXRoomWaterModel*md in model.list) {
|
||||
BOOL haveKey = NO;
|
||||
for (NSString *s in arr) {
|
||||
@@ -75,10 +80,10 @@
|
||||
}
|
||||
if (!haveKey) {
|
||||
// key没有包含某个日期,设置日期的流水json
|
||||
[weakSelf.dict setObject:[md yy_modelToJSONString] forKey:md.time];
|
||||
[strongSelf.dict setObject:[md yy_modelToJSONString] forKey:md.time];
|
||||
}else{
|
||||
//有包含某个日期,先取出之前已有的数据
|
||||
NSString *json = [weakSelf.dict objectForKey:md.time];
|
||||
NSString *json = [strongSelf.dict objectForKey:md.time];
|
||||
//转换为模型
|
||||
QXRoomWaterModel *m = [QXRoomWaterModel yy_modelWithJSON:json];
|
||||
//旧数据
|
||||
@@ -88,10 +93,10 @@
|
||||
//赋值于历史数据
|
||||
m.list = newArr;
|
||||
// 重新设置键值对
|
||||
[weakSelf.dict setObject:[m yy_modelToJSONString] forKey:md.time];
|
||||
[strongSelf.dict setObject:[m yy_modelToJSONString] forKey:md.time];
|
||||
}
|
||||
}
|
||||
NSArray *keys = [weakSelf.dict.allKeys sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
|
||||
NSArray *keys = [strongSelf.dict.allKeys sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
|
||||
// NSString *s1 = obj1;
|
||||
// NSString *s2 = obj2;
|
||||
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
|
||||
@@ -110,18 +115,23 @@
|
||||
return NSOrderedSame;
|
||||
}
|
||||
}];
|
||||
self.allDateArray = [NSMutableArray arrayWithArray:keys];
|
||||
[weakSelf.tableView reloadData];
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
strongSelf.allDateArray = [NSMutableArray arrayWithArray:keys];
|
||||
[strongSelf.tableView reloadData];
|
||||
[strongSelf.tableView.mj_header endRefreshing];
|
||||
if (model.list.count == 0) {
|
||||
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
strongSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
[strongSelf.tableView.mj_footer endRefreshing];
|
||||
}
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg);
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
__strong typeof(weakSelf) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
showToast(msg);
|
||||
[strongSelf.tableView.mj_header endRefreshing];
|
||||
[strongSelf.tableView.mj_footer endRefreshing];
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user