Commit 94c9f6e5 authored by admin's avatar admin

修复首页 搜索 排名列表崩溃的bug

parent 04e044ce
...@@ -112,4 +112,7 @@ ...@@ -112,4 +112,7 @@
// 获取口碑列表 // 获取口碑列表
#define kQueryShortPraiseURL @"redstar-server/rest/praise/query_short?userUuid=" #define kQueryShortPraiseURL @"redstar-server/rest/praise/query_short?userUuid="
// 获取下级组织
#define kQueryLowerOrgsURL @"redstar-server/rest/organization/queryLowerOrgs"
#endif /* Url_h */ #endif /* Url_h */
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
if (!_checkBoxButton) { if (!_checkBoxButton) {
_checkBoxButton = [[CheckBoxButton alloc] init]; _checkBoxButton = [[CheckBoxButton alloc] init];
[_checkBoxButton setTitleColor:kLightBlack forState:UIControlStateNormal]; [_checkBoxButton setTitleColor:kLightBlack forState:UIControlStateNormal];
// [_checkBoxButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected]; [_checkBoxButton setTitleColor:kSelectStoreColor forState:UIControlStateSelected];
_checkBoxButton.titleLabel.font = [UIFont systemFontOfSize:17.0]; _checkBoxButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
_checkBoxButton.translatesAutoresizingMaskIntoConstraints = NO; _checkBoxButton.translatesAutoresizingMaskIntoConstraints = NO;
[_checkBoxButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal]; [_checkBoxButton setImage:[UIImage imageNamed:@"uncheck_box"] forState:UIControlStateNormal];
......
...@@ -14,5 +14,4 @@ ...@@ -14,5 +14,4 @@
@property (nonatomic, strong) CheckBoxButton *checkBoxButton; @property (nonatomic, strong) CheckBoxButton *checkBoxButton;
@property (nonatomic, strong) UIImageView *iconImageView; @property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) ProvinceModel *provinceModel; @property (nonatomic, strong) ProvinceModel *provinceModel;
@end @end
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
_checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0); _checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_checkBoxButton.imageView.contentMode = UIViewContentModeRight; _checkBoxButton.imageView.contentMode = UIViewContentModeRight;
_checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft; _checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft;
[_checkBoxButton addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_checkBoxButton]; [self.contentView addSubview:_checkBoxButton];
// 顶端 // 顶端
...@@ -45,10 +44,6 @@ ...@@ -45,10 +44,6 @@
} }
return _checkBoxButton; return _checkBoxButton;
} }
- (void)click:(CheckBoxButton *)sender
{
sender.selected = !sender.selected;
}
- (UIImageView *)iconImageView - (UIImageView *)iconImageView
{ {
......
...@@ -81,7 +81,6 @@ ...@@ -81,7 +81,6 @@
_checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0); _checkBoxButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
_checkBoxButton.imageView.contentMode = UIViewContentModeRight; _checkBoxButton.imageView.contentMode = UIViewContentModeRight;
_checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft; _checkBoxButton.titleLabel.contentMode = UIViewContentModeLeft;
[_checkBoxButton addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_checkBoxButton]; [self.contentView addSubview:_checkBoxButton];
// 顶端 // 顶端
...@@ -102,10 +101,6 @@ ...@@ -102,10 +101,6 @@
} }
return _checkBoxButton; return _checkBoxButton;
} }
- (void)click:(CheckBoxButton *)sender
{
sender.selected = !sender.selected;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#import "SelectStoreHeadView.h" #import "SelectStoreHeadView.h"
#import "CheckBoxButton.h" #import "CheckBoxButton.h"
#import "HttpClient.h"
@interface SelectStoreViewController () <RATreeViewDelegate, RATreeViewDataSource> @interface SelectStoreViewController () <RATreeViewDelegate, RATreeViewDataSource>
@property (nonatomic, strong) RATreeView *treeView; @property (nonatomic, strong) RATreeView *treeView;
@property (nonatomic, strong) NSMutableArray *allAreaData; @property (nonatomic, strong) NSMutableArray *allAreaData;
...@@ -64,6 +66,8 @@ ...@@ -64,6 +66,8 @@
[self.treeView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])]; [self.treeView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])];
self.treeView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.treeView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.treeView reloadData]; [self.treeView reloadData];
[self requestQueryLowerOrgs];
} }
- (void)doBack:(id)sender - (void)doBack:(id)sender
...@@ -71,9 +75,18 @@ ...@@ -71,9 +75,18 @@
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES];
} }
- (void)didReceiveMemoryWarning { - (void)requestQueryLowerOrgs
[super didReceiveMemoryWarning]; {
// Dispose of any resources that can be recreated. NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQueryLowerOrgsURL];
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:url];
NSDictionary *parameters = @{@"path":@"",
@"pageNumber":@(0),
@"pageSize":@(10)
};
[httpClient queryLowerOrgsWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"查询下级组织 reponse = %@,error = %@", response, error);
}];
} }
- (void)loadData - (void)loadData
...@@ -107,27 +120,51 @@ ...@@ -107,27 +120,51 @@
} }
#pragma mark - TreeView Cell Click
- (void)areaClick:(CheckBoxButton *)sender - (void)areaClick:(CheckBoxButton *)sender
{ {
sender.selected = !sender.selected; sender.selected = !sender.selected;
NSLog(@"ender.title= %@", sender.titleLabel.text);
SelectAreaTableCell *cell = (SelectAreaTableCell *)sender.superview.superview; SelectAreaTableCell *cell = (SelectAreaTableCell *)sender.superview.superview;
NSArray *provinceArray = cell.areaModel.provinceArray; id item = [_treeView itemForCell:cell];
AreaModel *area = cell.areaModel;
if (sender.selected) { if (sender.selected) {
for (ProvinceModel *pro in area.provinceArray) {
for (ProvinceModel *proVin in provinceArray) { pro.isChoose = YES;
proVin.isChoose = YES;
} }
[sender setTitleColor:kLightBlack forState:UIControlStateNormal];
} else { } else {
for (ProvinceModel *proVin in provinceArray) { for (ProvinceModel *pro in area.provinceArray) {
proVin.isChoose = NO; pro.isChoose = NO;
} }
[sender setTitleColor:kSelectStoreColor forState:UIControlStateNormal]; }
[_treeView reloadRowsForItems:@[item] withRowAnimation:RATreeViewRowAnimationNone];
// [_treeView expandRowForItem:item withRowAnimation:RATreeViewRowAnimationNone];
//[_treeView expandRowForItem:item expandChildren:YES withRowAnimation:RATreeViewRowAnimationFade];
}
- (void)provinceClick:(CheckBoxButton *)sender
{
sender.selected = !sender.selected;
SelectProvinceTableCell *cell = (SelectProvinceTableCell *)sender.superview.superview;
ProvinceModel *province = cell.provinceModel;
if (sender.selected) {
for (StoreModel *store in province.storeArray) {
store.isChoose = YES;
}
} else {
for (StoreModel *store in province.storeArray) {
store.isChoose = NO;
}
} }
[_treeView reloadRows]; //[_treeView reloadData];
} }
- (void)storeClick:(CheckBoxButton *)sender
{
sender.selected = !sender.selected;
}
#pragma mark - RAtreeView Delegate/DataSource #pragma mark - RAtreeView Delegate/DataSource
- (NSInteger)treeView:(RATreeView *)treeView numberOfChildrenOfItem:(id)item - (NSInteger)treeView:(RATreeView *)treeView numberOfChildrenOfItem:(id)item
...@@ -171,8 +208,8 @@ ...@@ -171,8 +208,8 @@
SelectAreaTableCell *cell = [self.treeView dequeueReusableCellWithIdentifier:kSelectAreaTableCell]; SelectAreaTableCell *cell = [self.treeView dequeueReusableCellWithIdentifier:kSelectAreaTableCell];
cell.areaModel = data; cell.areaModel = data;
[cell.checkBoxButton setTitle:data.name forState:UIControlStateNormal]; [cell.checkBoxButton setTitle:data.name forState:UIControlStateNormal];
[cell.checkBoxButton addTarget:self action:@selector(areaClick:) forControlEvents:UIControlEventTouchUpInside];
cell.iconImageView.image = [UIImage imageNamed:@"arrow_down"]; cell.iconImageView.image = [UIImage imageNamed:@"arrow_down"];
[cell.checkBoxButton addTarget:self action:@selector(areaClick:) forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
} else if (level == 1) { } else if (level == 1) {
...@@ -185,17 +222,17 @@ ...@@ -185,17 +222,17 @@
cell.checkBoxButton.selected = NO; cell.checkBoxButton.selected = NO;
} }
[cell.checkBoxButton setTitle:data.name forState:UIControlStateNormal]; [cell.checkBoxButton setTitle:data.name forState:UIControlStateNormal];
[cell.checkBoxButton addTarget:self action:@selector(provinceClick:) forControlEvents:UIControlEventTouchUpInside];
cell.iconImageView.image = [UIImage imageNamed:@"grey-trilateral_down"]; cell.iconImageView.image = [UIImage imageNamed:@"grey-trilateral_down"];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
} else { } else {
StoreModel *data = item; StoreModel *data = item;
SelectStoreTableCell *cell = [self.treeView dequeueReusableCellWithIdentifier:kSelectStoreTableCell]; SelectStoreTableCell *cell = [self.treeView dequeueReusableCellWithIdentifier:kSelectStoreTableCell];
cell.storeModel = data; cell.storeModel = data;
[cell.checkBoxButton setTitle:data.name forState:UIControlStateNormal]; [cell.checkBoxButton setTitle:data.name forState:UIControlStateNormal];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.checkBoxButton addTarget:self action:@selector(storeClick:) forControlEvents:UIControlEventTouchUpInside];
return cell; return cell;
} }
} }
......
...@@ -498,10 +498,10 @@ ...@@ -498,10 +498,10 @@
if (!_rankDetailHeaderView) { if (!_rankDetailHeaderView) {
_rankDetailHeaderView = [[RankDetailHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 298)]; _rankDetailHeaderView = [[RankDetailHeaderView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 298)];
if (self.indexRow < 3) { if (self.indexRow < 3) {
NSString *imageName = [NSString stringWithFormat:@"medal_0%ld", (long)(_indexRow + 1)]; NSString *imageName = [NSString stringWithFormat:@"medal_0%ld", (long)(_indexRow)];
_rankDetailHeaderView.rankDetailView.gradeImageView.image = [UIImage imageNamed:imageName]; _rankDetailHeaderView.rankDetailView.gradeImageView.image = [UIImage imageNamed:imageName];
} else { } else {
NSString *rankStr = [NSString stringWithFormat:@"第 %ld 名", (long)(_indexRow + 1)]; NSString *rankStr = [NSString stringWithFormat:@"第 %ld 名", (long)(_indexRow)];
NSMutableAttributedString *rankAttr = [[NSMutableAttributedString alloc] initWithString:rankStr]; NSMutableAttributedString *rankAttr = [[NSMutableAttributedString alloc] initWithString:rankStr];
[rankAttr addAttributes:@{NSForegroundColorAttributeName:kRankHeadTitleTextColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,1)]; [rankAttr addAttributes:@{NSForegroundColorAttributeName:kRankHeadTitleTextColor,NSFontAttributeName:[UIFont systemFontOfSize:14.0f]} range:NSMakeRange(0,1)];
[rankAttr addAttributes:@{NSForegroundColorAttributeName:kGradeNumberTextColor} range:NSMakeRange(1,rankStr.length - 2)]; [rankAttr addAttributes:@{NSForegroundColorAttributeName:kGradeNumberTextColor} range:NSMakeRange(1,rankStr.length - 2)];
......
...@@ -95,7 +95,6 @@ ...@@ -95,7 +95,6 @@
_pickRow = 0; _pickRow = 0;
[self requestShortPraise]; [self requestShortPraise];
[self requestRankingList];
self.shoppingLabel.text = @"商场名称"; self.shoppingLabel.text = @"商场名称";
self.scoreLabel.text = @"总分"; self.scoreLabel.text = @"总分";
...@@ -116,12 +115,12 @@ ...@@ -116,12 +115,12 @@
} }
#pragma mark - Private Methods #pragma mark - Private Methods
- (void)requestRankingList - (void)requestRankingListWithPraiseUuid:(NSString *)praiseUuid
{ {
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL]; NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url]; HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSDictionary *parameters = @{@"praiseUuid":@"5a7417015147f8eb0151482b2359005b", NSDictionary *parameters = @{@"praiseUuid":praiseUuid,
@"statisMode":@(0), @"statisMode":@(0),
}; };
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; [MBProgressHUD showHUDAddedTo:self.view animated:YES];
...@@ -179,6 +178,13 @@ ...@@ -179,6 +178,13 @@
self.tableView.dataSource = self; self.tableView.dataSource = self;
[self.tableView reloadData]; [self.tableView reloadData];
} }
if (_titleArray.count == 0) {
return ;
} else {
NSDictionary *paDict = _titleArray[0];
[self requestRankingListWithPraiseUuid:paDict[@"uuid"]];
}
}]; }];
} }
...@@ -454,7 +460,6 @@ ...@@ -454,7 +460,6 @@
rankDetailVC.uuid = rankList.uuid; rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid; rankDetailVC.store_uuid = rankList.store_uuid;
rankDetailVC.storeAddress = rankList.storeAddress; rankDetailVC.storeAddress = rankList.storeAddress;
NSLog(@"storeAddress = %@", rankList.storePictures);
rankDetailVC.storePictures = rankList.storePictures; rankDetailVC.storePictures = rankList.storePictures;
[self.navigationController pushViewController:rankDetailVC animated:YES]; [self.navigationController pushViewController:rankDetailVC animated:YES];
} }
......
...@@ -130,6 +130,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2); ...@@ -130,6 +130,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
} }
[[NSUserDefaults standardUserDefaults] setObject:_titleArray forKey:@"function"]; [[NSUserDefaults standardUserDefaults] setObject:_titleArray forKey:@"function"];
NSLog(@"-title = =%@", _titleArray);
// 初始化容器 // 初始化容器
// self.btnTitleArray = [NSArray arrayWithObjects:@"在线抽查", @"口碑巡检",@"口碑标准",@"图说口碑",@"问题知识",@"口碑排名",@"查看抽查", nil]; // self.btnTitleArray = [NSArray arrayWithObjects:@"在线抽查", @"口碑巡检",@"口碑标准",@"图说口碑",@"问题知识",@"口碑排名",@"查看抽查", nil];
...@@ -293,19 +294,16 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2); ...@@ -293,19 +294,16 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL]; NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url]; HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSDictionary *parameters = @{ NSDictionary *parameters = @{@"praiseUuid":@"5a7417015157efa6015158f52be8004e",
@"queryOrders":@[@{@"direction":@"asc"}], @"statisMode":@(0),
@"pageNumber":@(0),
@"pageSize":@(3)
}; };
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) { [httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"口碑排名response = %@", response); NSLog(@"口碑排名response = %@", response);
NSLog(@"error = %@", error);
if ([(NSArray *)response[@"data"] count] == 0) { if ([(NSArray *)response[@"data"] count] == 0) {
return; return;
} }
NSDictionary *dataDict = response[@"data"]; NSArray *dataArray = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
NSMutableArray *tgArray = [NSMutableArray array]; NSMutableArray *tgArray = [NSMutableArray array];
...@@ -314,6 +312,17 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2); ...@@ -314,6 +312,17 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
[tgArray addObject:rankList]; [tgArray addObject:rankList];
} }
_allRankListArray = (NSMutableArray *)[self sortRankListWithRankListArray:tgArray]; _allRankListArray = (NSMutableArray *)[self sortRankListWithRankListArray:tgArray];
for (int i = 0 ; i < _allRankListArray.count; i++) {
RankListModel *rank = _allRankListArray[i];
if (i == 0) {
rank.index = i + 1;
} else {
RankListModel *prevRank = _allRankListArray[i-1];
rank.index = rank.score == prevRank.score ? prevRank.index: i + 1;
}
}
[self.tableView reloadData]; [self.tableView reloadData];
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
...@@ -550,27 +559,6 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2); ...@@ -550,27 +559,6 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
} else { } else {
return 0; return 0;
} }
// if (_titleArray.count == 5) {
// if (section == 0) {
// return _taskListDataArray.count;
// } else {
// return _allQuestionArray.count;
// }
// } else {
//
// if (section == 0) {
// return _taskListDataArray.count;
//
// } else if (section == 1 ) {
// return _allRankListArray.count + 1;
//
// } else {
// return _allQuestionArray.count;
//
// }
// }
} }
...@@ -608,8 +596,9 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2); ...@@ -608,8 +596,9 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
if (!cell) { if (!cell) {
cell = [[RankingListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeRankingListCell]; cell = [[RankingListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeRankingListCell];
} }
cell.rankList = _allRankListArray[indexPath.row - 1]; RankListModel *rankList = _allRankListArray[indexPath.row - 1];
cell.gradeImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", (int)indexPath.row]]; cell.rankList = rankList;
cell.gradeImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", rankList.index]];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
} }
...@@ -650,7 +639,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2); ...@@ -650,7 +639,7 @@ typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
} else if ([titleArray[indexPath.section] isEqualToString:@"口碑排名"] && indexPath.section == s2) { } else if ([titleArray[indexPath.section] isEqualToString:@"口碑排名"] && indexPath.section == s2) {
RankListModel *rankList = _allRankListArray[indexPath.row - 1]; RankListModel *rankList = _allRankListArray[indexPath.row - 1];
RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init]; RankDetailViewController *rankDetailVC = [[RankDetailViewController alloc] init];
rankDetailVC.indexRow = indexPath.row - 1; rankDetailVC.indexRow = rankList.index;
rankDetailVC.uuid = rankList.uuid; rankDetailVC.uuid = rankList.uuid;
rankDetailVC.store_uuid = rankList.store_uuid; rankDetailVC.store_uuid = rankList.store_uuid;
rankDetailVC.storeAddress = rankList.storeAddress; rankDetailVC.storeAddress = rankList.storeAddress;
......
...@@ -64,7 +64,8 @@ ...@@ -64,7 +64,8 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
NSMutableArray *titleArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"function"]; //NSMutableArray *titleArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"function"];
NSArray *titleArray = [NSArray arrayWithObjects:@"口碑巡检",@"口碑排名",@"问题知识", nil];
self.titleArray = [NSMutableArray arrayWithArray:titleArray]; self.titleArray = [NSMutableArray arrayWithArray:titleArray];
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)]; UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
...@@ -215,24 +216,33 @@ ...@@ -215,24 +216,33 @@
NSString *url1 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL]; NSString *url1 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL];
HttpClient *httpCilent1 = [[HttpClient alloc] initWithUrl:url1]; HttpClient *httpCilent1 = [[HttpClient alloc] initWithUrl:url1];
NSDictionary *parameters1 = @{ NSDictionary *parameters1 = @{
@"keyword":self.customStr, @"praiseUuid":@"5a7417015157efa6015158f52be8004e",
@"queryOrders":@[@{@"direction":@"asc"}], @"statisMode":@(0),
@"pageNumber":@(0), @"keyword":self.customStr
@"pageSize":@(10) };
};
__block SearchViewController *weakSelf = self;
[httpCilent1 getRankingListWithParameters:parameters1 completion:^(id response, NSError *error) { [httpCilent1 getRankingListWithParameters:parameters1 completion:^(id response, NSError *error) {
NSLog(@"口碑排名response = %@", response); NSLog(@"口碑排名response = %@", response);
NSDictionary *dataDict = response[@"data"]; if ([(NSArray *)response[@"data"] count] == 0) {
NSArray *dataArray = dataDict[@"records"]; return;
}
NSArray *dataArray = response[@"data"];
NSMutableArray *rankTempArr = [NSMutableArray array]; NSMutableArray *rankTempArr = [NSMutableArray array];
for (NSDictionary *ListDict in dataArray) { for (NSDictionary *ListDict in dataArray) {
RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict]; RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
[rankTempArr addObject:rankList]; [rankTempArr addObject:rankList];
} }
weakSelf.allRankListArray = rankTempArr; _allRankListArray = (NSMutableArray *)[self sortRankListWithRankListArray:rankTempArr];
for (int i = 0 ; i < _allRankListArray.count; i++) {
RankListModel *rank = _allRankListArray[i];
if (i == 0) {
rank.index = i + 1;
} else {
RankListModel *prevRank = _allRankListArray[i-1];
rank.index = rank.score == prevRank.score ? prevRank.index: i + 1;
}
}
if (_allRankListArray.count != 0) { if (_allRankListArray.count != 0) {
if (![_titleArray containsObject:@"口碑排名"]) { if (![_titleArray containsObject:@"口碑排名"]) {
...@@ -246,6 +256,14 @@ ...@@ -246,6 +256,14 @@
} }
- (NSArray *)sortRankListWithRankListArray:(NSMutableArray *)allRanking
{
NSArray *sortedArray = [allRanking sortedArrayUsingComparator:^NSComparisonResult(RankListModel *p1, RankListModel *p2){
return [p2.score compare:p1.score];
}];
return sortedArray;
}
- (void)requestAllQuestion - (void)requestAllQuestion
{ {
NSString *url2 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL]; NSString *url2 = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
...@@ -351,8 +369,9 @@ ...@@ -351,8 +369,9 @@
if (!cell) { if (!cell) {
cell = [[RankingListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeRankingListCell]; cell = [[RankingListCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kHomeRankingListCell];
} }
cell.rankList = _allRankListArray[indexPath.row - 1]; RankListModel *rankList = _allRankListArray[indexPath.row - 1];
cell.gradeImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", (int)indexPath.row]]; cell.rankList = rankList;
cell.gradeImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", rankList.index]];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
} }
......
...@@ -119,4 +119,7 @@ typedef void (^completionBlock) (id response, NSError *error); ...@@ -119,4 +119,7 @@ typedef void (^completionBlock) (id response, NSError *error);
// 获取口碑列表 // 获取口碑列表
- (void)queryShortPraiseWithCompletion:(completionBlock)completion; - (void)queryShortPraiseWithCompletion:(completionBlock)completion;
// 查询下级参数
- (void)queryLowerOrgsWithParameters:(id)parameters completion:(completionBlock)completion;
@end @end
...@@ -407,4 +407,14 @@ ...@@ -407,4 +407,14 @@
}]; }];
} }
//
- (void)queryLowerOrgsWithParameters:(id)parameters completion:(completionBlock)completion
{
[self postParameters:parameters completion:^(id response, NSError *error) {
if (completion) {
completion (response, error);
}
}];
}
@end @end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment