Commit f7270c2c authored by admin's avatar admin

修复首页搜索无数据页面 口碑报告选择商场bug 下载pdf附件

parent 57e30e56
...@@ -2292,7 +2292,7 @@ ...@@ -2292,7 +2292,7 @@
CreatedOnToolsVersion = 7.0.1; CreatedOnToolsVersion = 7.0.1;
SystemCapabilities = { SystemCapabilities = {
com.apple.BackgroundModes = { com.apple.BackgroundModes = {
enabled = 1; enabled = 0;
}; };
com.apple.Push = { com.apple.Push = {
enabled = 0; enabled = 0;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define kAnnounceContentCell @"AnnoContentTableViewCell" #define kAnnounceContentCell @"AnnoContentTableViewCell"
#define kAttachmentTableViewCell @"AttachmentTableViewCell" #define kAttachmentTableViewCell @"AttachmentTableViewCell"
@interface AnnoDetailViewController ()<UITableViewDataSource, UITableViewDelegate, UIDocumentInteractionControllerDelegate> @interface AnnoDetailViewController ()<UITableViewDataSource, UITableViewDelegate, UIDocumentInteractionControllerDelegate, UIAlertViewDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) AnnounceDetailHeadView *headerView; @property (nonatomic, strong) AnnounceDetailHeadView *headerView;
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
docController.delegate = self;//设置代理 docController.delegate = self;//设置代理
[docController presentPreviewAnimated:YES]; [docController presentPreviewAnimated:YES];
} else { } else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"文件不存在,请先下载在查看!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"文件不存在,请下载后再查看!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show]; [alert show];
} }
} }
...@@ -177,19 +177,27 @@ ...@@ -177,19 +177,27 @@
//已完成下载 //已完成下载
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"下载成功"); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"下载成功!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[self.tableView reloadData]; alert.tag = 66690;
[alert show];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"下载失败");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"下载失败!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
}]; }];
[operation start]; [operation start];
} }
} }
- (void)didReceiveMemoryWarning { #pragma mark - UIAlertViewDelegate
[super didReceiveMemoryWarning]; -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
// Dispose of any resources that can be recreated. {
if (alertView.tag == 66690) {
if (buttonIndex == 0) {
[self.tableView reloadData];
}
}
} }
#pragma mark - UITableView Delegate/DataSource #pragma mark - UITableView Delegate/DataSource
......
...@@ -132,13 +132,18 @@ ...@@ -132,13 +132,18 @@
{ {
NSString *nameStr = @""; NSString *nameStr = @"";
_uuidArray = [NSMutableArray array]; _uuidArray = [NSMutableArray array];
if (array.count == 0) {
_storeName = @"全部";
} else {
for (TreeNodeModel *model in array) { for (TreeNodeModel *model in array) {
nameStr = [nameStr stringByAppendingString:[NSString stringWithFormat:@"%@,", model.name]]; nameStr = [nameStr stringByAppendingString:[NSString stringWithFormat:@"%@,", model.name]];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:model.uuid , @"store_uuid", model.code , @"store_code", model.name , @"store_name", nil]; NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:model.uuid , @"store_uuid", model.code , @"store_code", model.name , @"store_name", nil];
[_uuidArray addObject:dict]; [_uuidArray addObject:dict];
} }
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
_storeName = nameStr; _storeName = nameStr;
}
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} }
......
...@@ -43,6 +43,14 @@ ...@@ -43,6 +43,14 @@
self.view.backgroundColor = kFootViewBackGroundColor; self.view.backgroundColor = kFootViewBackGroundColor;
// UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 20)];
// [rightButton setTitle:@"全部重置" forState:UIControlStateNormal];
// [rightButton addTarget:self action:@selector(resetClick:) forControlEvents:UIControlEventTouchUpInside];
// [rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
// rightButton.titleLabel.font = [UIFont systemFontOfSize:15];
// UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
// self.navigationItem.rightBarButtonItem = rightButtonItem;
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)]; UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]]; [customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"选择商场"]; [customLab setText:@"选择商场"];
...@@ -69,6 +77,11 @@ ...@@ -69,6 +77,11 @@
} }
- (void)resetClick:(UIButton *)sender
{
}
- (void)sureClick:(UIButton *)sender - (void)sureClick:(UIButton *)sender
{ {
if (_delegate && [_delegate respondsToSelector:@selector(deliverWithArray:)]) { if (_delegate && [_delegate respondsToSelector:@selector(deliverWithArray:)]) {
...@@ -91,10 +104,8 @@ ...@@ -91,10 +104,8 @@
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":@(999) @"pageSize":@(999)
}; };
NSLog(@"url = %@", url);
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; [MBProgressHUD showHUDAddedTo:self.view animated:YES];
[httpClient queryLowerOrgsWithParameters:parameters completion:^(id response, NSError *error) { [httpClient queryLowerOrgsWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"查询下级组织 reponse = %@,error = %@", response, error);
NSDictionary *data = response[@"data"]; NSDictionary *data = response[@"data"];
NSArray *dataArray = data[@"records"]; NSArray *dataArray = data[@"records"];
NSMutableArray *oneTree = [NSMutableArray array]; NSMutableArray *oneTree = [NSMutableArray array];
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#import "CommentView.h" #import "CommentView.h"
#import <MBProgressHUD.h> #import <MBProgressHUD.h>
#import "CommentModel.h" #import "CommentModel.h"
#import "CommonFunc.h"
#import <UIImageView+WebCache.h> #import <UIImageView+WebCache.h>
#import <UIButton+WebCache.h> #import <UIButton+WebCache.h>
...@@ -41,6 +42,8 @@ ...@@ -41,6 +42,8 @@
@property (nonatomic, copy) NSString *pictureUuid; @property (nonatomic, copy) NSString *pictureUuid;
@property (nonatomic, strong) NSMutableArray *imageNameArray;
@end @end
@implementation PictureStoryViewController @implementation PictureStoryViewController
...@@ -55,6 +58,7 @@ ...@@ -55,6 +58,7 @@
[super viewDidLoad]; [super viewDidLoad];
self.picTextArray = [NSMutableArray array]; self.picTextArray = [NSMutableArray array];
self.imageNameArray = [NSMutableArray array];
self.view.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = [UIColor whiteColor];
self.automaticallyAdjustsScrollViewInsets = NO; self.automaticallyAdjustsScrollViewInsets = NO;
...@@ -76,7 +80,6 @@ ...@@ -76,7 +80,6 @@
NSString *url = [NSString stringWithFormat:@"%@%@%@?userUuid=%@", kRedStarURL, kPicturePraiseDetailURL, self.uuid, user_uuid]; NSString *url = [NSString stringWithFormat:@"%@%@%@?userUuid=%@", kRedStarURL, kPicturePraiseDetailURL, self.uuid, user_uuid];
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; [MBProgressHUD showHUDAddedTo:self.view animated:YES];
HttpClient *http = [[HttpClient alloc] initWithUrl:url]; HttpClient *http = [[HttpClient alloc] initWithUrl:url];
__block PictureStoryViewController *weakSelf = self;
[http getPicturePraiseDetailWithCompletion:^(id response, NSError *error) { [http getPicturePraiseDetailWithCompletion:^(id response, NSError *error) {
NSLog(@"图说口碑详情 res ===%@, error = %@", response, error); NSLog(@"图说口碑详情 res ===%@, error = %@", response, error);
...@@ -99,14 +102,51 @@ ...@@ -99,14 +102,51 @@
[_picTextArray addObject:picText]; [_picTextArray addObject:picText];
} }
weakSelf.tableView.delegate = self; // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
weakSelf.tableView.dataSource = self; // [self reloadPictureText:_picTextArray];
// });
self.tableView.delegate = self;
self.tableView.dataSource = self;
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
}]; }];
} }
- (void)reloadPictureText:(NSMutableArray *)picTextArray
{
if (picTextArray.count == 0) {
return;
}
for (int i = 0; i < picTextArray.count; i++) {
PicTextModel *picText = picTextArray[i];
if (picText.fileName.length != 0) {
NSURL *imageURL = [NSURL URLWithString:picText.fileUrl];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
NSString *imageName = picText.fileName;
[_imageNameArray addObject:imageName];
// 获取沙盒目录
NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *fullPath = [cachePath stringByAppendingPathComponent:imageName];
// 将图片写入文件
[imageData writeToFile:fullPath atomically:NO];
}
}
dispatch_async(dispatch_get_main_queue(), ^{
[_tableView reloadData];
});
}
- (void)setupNav - (void)setupNav
{ {
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)]; UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
...@@ -326,10 +366,16 @@ ...@@ -326,10 +366,16 @@
cell = [[PictureTextTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kPictureTextTableCell]; cell = [[PictureTextTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kPictureTextTableCell];
} }
NSURL *imageUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", kRedStarURL ,picText.fileUrl]]; NSURL *imageUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", kRedStarURL ,picText.fileUrl]];
UIImage *defaultImage = [UIImage imageNamed:@"default_pic"];
// defaultImage = [defaultImage resizableImageWithCapInsets:UIEdgeInsetsMake(38, 85, 22, 85) resizingMode:UIImageResizingModeStretch];
[cell.bigImageView sd_setImageWithURL:imageUrl placeholderImage:defaultImage];
// [cell.bigImageView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"default_pic"]]; // [cell.bigImageView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"default_pic"]];
[cell.bigImageView sd_setImageWithURL:imageUrl]; // [cell.bigImageView sd_setImageWithURL:imageUrl];
NSLog(@"cell.size = %@", NSStringFromCGSize(cell.bigImageView.image.size));
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
[cell.bigImageView addGestureRecognizer:tap]; [cell.bigImageView addGestureRecognizer:tap];
...@@ -341,6 +387,20 @@ ...@@ -341,6 +387,20 @@
} }
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
// if (_imageNameArray.count == 0) {
// cell.bigImageView.image = [UIImage imageNamed:@"default_pic"];
// } else {
// // 获取沙盒目录
// NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
// NSString *fullPath = [cachePath stringByAppendingPathComponent:_imageNameArray[0]];
// UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
// cell.bigImageView.image = image;
// //[cell ];
// }
return cell; return cell;
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#define SELECTED_VIEW_CONTROLLER_TAG 39998 #define SELECTED_VIEW_CONTROLLER_TAG 39998
@interface SOPViewController () <GroupTabBarDelegate, SOPTableViewDelegate, UITableViewDelegate, UITableViewDataSource, UIDocumentInteractionControllerDelegate> @interface SOPViewController () <UIAlertViewDelegate,GroupTabBarDelegate, SOPTableViewDelegate, UITableViewDelegate, UITableViewDataSource, UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) GroupTabBar *groupTabBar; @property (nonatomic, strong) GroupTabBar *groupTabBar;
@property (nonatomic, strong) NSArray *titleArray; @property (nonatomic, strong) NSArray *titleArray;
...@@ -256,7 +256,9 @@ ...@@ -256,7 +256,9 @@
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = paths.lastObject; NSString *path = paths.lastObject;
[self downloadFileURL:[NSString stringWithFormat:@"%@%@", kRedStarURL, atta.fileUrl] savePath:path fileName:atta.fileName]; NSString *fileName = [NSString stringWithFormat:@"%@", atta.fileName];
fileName = [fileName stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
[self downloadFileURL:[NSString stringWithFormat:@"%@%@", kRedStarURL, atta.fileUrl] savePath:path fileName:fileName];
} }
- (void)downloadFileURL:(NSString *)aUrl savePath:(NSString *)aSavePath fileName:(NSString *)aFileName - (void)downloadFileURL:(NSString *)aUrl savePath:(NSString *)aSavePath fileName:(NSString *)aFileName
...@@ -276,8 +278,11 @@ ...@@ -276,8 +278,11 @@
if (![fileManager fileExistsAtPath:aSavePath]) { if (![fileManager fileExistsAtPath:aSavePath]) {
[fileManager createDirectoryAtPath:aSavePath withIntermediateDirectories:YES attributes:nil error:nil]; [fileManager createDirectoryAtPath:aSavePath withIntermediateDirectories:YES attributes:nil error:nil];
} }
NSLog(@"aurlllll === %@", aUrl);
//下载附件 //下载附件
aUrl = [aUrl stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSLog(@"aurlllll === %@", aUrl);
NSURL *url = [[NSURL alloc] initWithString:aUrl]; NSURL *url = [[NSURL alloc] initWithString:aUrl];
NSURLRequest *request = [NSURLRequest requestWithURL:url]; NSURLRequest *request = [NSURLRequest requestWithURL:url];
...@@ -290,10 +295,15 @@ ...@@ -290,10 +295,15 @@
//已完成下载 //已完成下载
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"下载成功"); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"下载成功!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[self.tableView reloadData]; alert.tag = 66690;
[alert show];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"下载失败"); NSLog(@"error ==== %@", error);
[self.tableView reloadData];
[self closeRedView];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"下载失败!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
}]; }];
[operation start]; [operation start];
...@@ -404,6 +414,17 @@ ...@@ -404,6 +414,17 @@
{ {
[self.navigationController dismissViewControllerAnimated:YES completion:nil]; [self.navigationController dismissViewControllerAnimated:YES completion:nil];
} }
#pragma mark - UIAlertViewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag == 66690) {
if (buttonIndex == 0) {
[self.tableView reloadData];
}
}
}
#pragma mark - UITableView Delegate/DataSource #pragma mark - UITableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{ {
......
...@@ -72,9 +72,8 @@ ...@@ -72,9 +72,8 @@
[super viewDidLoad]; [super viewDidLoad];
self.allTitleArray = [NSArray arrayWithObjects:@"口碑巡检", @"选择范围", @"统计方式" ,nil]; self.allTitleArray = [NSArray arrayWithObjects:@"口碑巡检", @"选择范围", @"统计方式" ,nil];
self.uuidArray = [NSMutableArray array];
self.titleArray = [NSMutableArray array]; self.titleArray = [NSMutableArray array];
self.uuidArray = [NSMutableArray array];
self.tableView.delegate = self; self.tableView.delegate = self;
self.tableView.dataSource = self; self.tableView.dataSource = self;
...@@ -302,12 +301,17 @@ ...@@ -302,12 +301,17 @@
- (void)deliverWithArray:(NSMutableArray *)array - (void)deliverWithArray:(NSMutableArray *)array
{ {
NSString *nameStr = @""; NSString *nameStr = @"";
self.uuidArray = [NSMutableArray array];
if (array.count == 0) {
_selectName = @"全部";
} else {
for (TreeNodeModel *model in array) { for (TreeNodeModel *model in array) {
nameStr = [nameStr stringByAppendingString:[NSString stringWithFormat:@"%@,", model.name]]; nameStr = [nameStr stringByAppendingString:[NSString stringWithFormat:@"%@,", model.name]];
[_uuidArray addObject:model.uuid]; [_uuidArray addObject:model.uuid];
} }
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
_selectName = nameStr; _selectName = nameStr;
}
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#import "QuestionViewController.h" #import "QuestionViewController.h"
#import "HomeCellItem.h" #import "HomeCellItem.h"
#import "NoDataView.h"
#import "PictureTableCell.h" #import "PictureTableCell.h"
#define kHomePictureListCell @"homePictureListCell" #define kHomePictureListCell @"homePictureListCell"
...@@ -59,6 +60,7 @@ ...@@ -59,6 +60,7 @@
@property (nonatomic, strong) NSMutableArray *taskListDataArray; // 问题与知识 @property (nonatomic, strong) NSMutableArray *taskListDataArray; // 问题与知识
@property (nonatomic, strong) NSMutableArray *allRankListArray; @property (nonatomic, strong) NSMutableArray *allRankListArray;
@property (nonatomic, strong) NSMutableArray *allPraiseListArray; @property (nonatomic, strong) NSMutableArray *allPraiseListArray;
@property (nonatomic, strong) NoDataView *noDataView;
@end @end
...@@ -67,7 +69,9 @@ ...@@ -67,7 +69,9 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.sectionArray = [NSMutableArray array]; self.view.backgroundColor = [UIColor whiteColor];
self.sectionArray = [NSMutableArray arrayWithObjects:@"口碑报告",@"商场风采", @"问题知识",@"口碑巡检",nil];
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)]; UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
[customLab setTextColor:[UIColor whiteColor]]; [customLab setTextColor:[UIColor whiteColor]];
...@@ -100,20 +104,25 @@ ...@@ -100,20 +104,25 @@
if ([permissions containsObject:@"500201"]) { if ([permissions containsObject:@"500201"]) {
[self requestRankingList]; [self requestRankingList];
} else {
[_sectionArray removeObject:@"口碑报告"];
} }
[self requestPicturePraise]; [self requestPicturePraise];
if ([permissions containsObject:@"500501"] || [permissions containsObject:@"500502"]) { if ([permissions containsObject:@"500501"] || [permissions containsObject:@"500502"]) {
[self requestQuestionList]; [self requestQuestionList];
}else {
[_sectionArray removeObject:@"问题知识"];
} }
if ([permissions containsObject:@"500101"] || [permissions containsObject:@"500102"]) { if ([permissions containsObject:@"500101"] || [permissions containsObject:@"500102"]) {
[self requestInspectList]; [self requestInspectList];
}else {
[_sectionArray removeObject:@"口碑巡检"];
} }
self.allRankListArray = [NSMutableArray array]; self.allRankListArray = [NSMutableArray array];
self.taskListDataArray = [NSMutableArray array]; self.taskListDataArray = [NSMutableArray array];
self.allQuestionArray = [NSMutableArray array]; self.allQuestionArray = [NSMutableArray array];
...@@ -175,22 +184,199 @@ ...@@ -175,22 +184,199 @@
} }
#pragma mark - 请求数据
//- (void)requestRankingList
//{
//
// NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL];
// HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
// NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
//
// NSDictionary *parameters = @{@"keyword":self.customStr,
// @"praiseUuid":@"",
// @"statisMode":@(0),
// @"pageNumber":@(0),
// @"pageSize":pageSize
// };
//
// [httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
// NSLog(@"口碑报告response = %@", response);
// NSDictionary *dataDict = response[@"data"];
// NSArray *dataArray = dataDict[@"records"];
//
// NSMutableArray *tgArray = [NSMutableArray array];
//
// for (NSDictionary *ListDict in dataArray) {
// RankListModel *rankList = [RankListModel rankListModelWithDict:ListDict];
// [tgArray addObject:rankList];
// }
// _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;
// }
// }
// if (_allRankListArray.count != 0) {
// [_sectionArray addObject:@"口碑报告"];
// }
// [self.tableView reloadData];
// [MBProgressHUD hideHUDForView:self.view animated:YES];
//
//
//
// }];
//}
//
//- (NSArray *)sortRankListWithRankListArray:(NSMutableArray *)allRanking
//{
// NSArray *sortedArray = [allRanking sortedArrayUsingComparator:^NSComparisonResult(RankListModel *p1, RankListModel *p2){
// //return [p2.score compare:p1.score];
// return [@(p2.score) compare:@(p1.score)];
//
// }];
// return sortedArray;
//}
//
//
//
//- (void)requestInspectList
//{
//
// NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
// NSLog(@"uuuurl = %@", url);
// HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
// NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
//
// NSDictionary *parameters = @{@"keyword":self.customStr,
// @"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
// @"queryOrders":@[@{@"field":@"lastModifyInfo", @"direction":@"desc"}],
// @"pageNumber":@(0),
// @"pageSize":pageSize
// };
// NSLog(@"parrrrr = %@", parameters);
// [httpCilent getInspectListWithParameters:parameters completion:^(id response, NSError *error) {
//
// NSLog(@"巡检列表%@", response);
// NSLog(@"error = %@", error);
// NSDictionary *dataDict = response[@"data"];
// NSArray *dataArray = dataDict[@"records"];
// for (NSDictionary *dict in dataArray) {
// TaskListModel *taskList = [[TaskListModel alloc] init];
// [taskList setValuesForKeysWithDictionary:dict];
// [_taskListDataArray addObject:taskList];
// }
// if (_taskListDataArray.count != 0) {
// [_sectionArray addObject:@"口碑巡检"];
// }
// [self.tableView reloadData];
// [MBProgressHUD hideHUDForView:self.view animated:YES];
//
// }];
//
//}
//
//- (void)requestQuestionList
//{
// // 初始化数组
// // 请求地址
// NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
// NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
// NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
// NSDictionary *parameters = @{@"keyword":self.customStr,
// @"user":user_uuid,
// @"scope":@"all",
// @"pageNumber":@(0),
// @"pageSize":pageSize
// };
// // 发起请求
// HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
// //
//
// // 请求问题列表
// [httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) {
// NSDictionary *dataDict = (NSDictionary *)response[@"data"];
// NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"];
// NSLog(@"问题与知识列表recods = %@", response);
// NSLog(@"error = %@", error);
// for (NSDictionary *questionDict in recordsDict) {
// QuestionModel *question = [[QuestionModel alloc] init];
// [question setValuesForKeysWithDictionary:questionDict];
// [_allQuestionArray addObject:question];
// }
// if (_allQuestionArray.count != 0) {
// [_sectionArray addObject:@"问题知识"];
// }
// [self.tableView reloadData];
//
// [MBProgressHUD hideHUDForView:self.view animated:YES];
// }];
//}
//
//- (void)requestPicturePraise
//{
//
// // 请求地址
// NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQueryPicturePraiseURL];
// NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
// NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
//
// NSDictionary *parameters = @{
// @"keyword":self.customStr,
// @"scope":@"all",
// @"user":user_uuid,
// @"type":@"store",
// @"pageNumber":@(0),
// @"pageSize":pageSize
// };
//
// // 发起请求
// HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
// [MBProgressHUD showHUDAddedTo:self.view animated:YES];
//
// // 请求问题列表
// [httpClient queryPicturePraiseWithParameters:parameters completion:^(id response, NSError *error) {
// NSLog(@"图说口碑 response = %@ error = %@" , response, error);
// NSDictionary *dataDict = response[@"data"];
// NSArray *dataArray = dataDict[@"records"];
// NSMutableArray *tempArray = [NSMutableArray array];
// for (NSDictionary *dict in dataArray) {
// PictureListModel *picList = [[PictureListModel alloc] init];
// [picList setValuesForKeysWithDictionary:dict];
// [tempArray addObject:picList];
// }
// _allPraiseListArray = tempArray;
// if (_allPraiseListArray.count != 0) {
// [_sectionArray addObject:@"商场风采"];
// }
// [self.tableView reloadData];
// [MBProgressHUD hideHUDForView:self.view animated:YES];
// }];
//
//}
#pragma mark - 请求数据 #pragma mark - 请求数据
- (void)requestRankingList - (void)requestRankingList
{ {
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL]; NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kRankingListURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url]; HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"]; NSDictionary *parameters = @{@"praiseUuid":@"",
@"keyword":self.customStr,
NSDictionary *parameters = @{@"keyword":self.customStr,
@"praiseUuid":@"",
@"statisMode":@(0), @"statisMode":@(0),
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":pageSize @"pageSize":@(3)
}; };
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) { [httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
// [self requestPicturePraise];
NSLog(@"口碑报告response = %@", response); NSLog(@"口碑报告response = %@", response);
NSDictionary *dataDict = response[@"data"]; NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"]; NSArray *dataArray = dataDict[@"records"];
...@@ -212,10 +398,24 @@ ...@@ -212,10 +398,24 @@
rank.index = rank.score == prevRank.score ? prevRank.index: i + 1; rank.index = rank.score == prevRank.score ? prevRank.index: i + 1;
} }
} }
if (_allRankListArray.count != 0) { if (_allRankListArray.count == 0) {
[_sectionArray addObject:@"口碑报告"]; [_sectionArray removeObject:@"口碑报告"];
}
if (_sectionArray.count == 0) {
if (_tableView) {
[_tableView removeFromSuperview];
_tableView = nil;
}
self.noDataView.backgroundColor = [UIColor whiteColor];
} else {
if (_noDataView) {
[_noDataView removeFromSuperview];
_noDataView = nil;
} }
[self.tableView reloadData]; [self.tableView reloadData];
}
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
...@@ -239,32 +439,46 @@ ...@@ -239,32 +439,46 @@
{ {
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL]; NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
NSLog(@"uuuurl = %@", url);
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url]; HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{@"keyword":self.customStr,
NSDictionary *parameters = @{
@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"], @"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":@[@{@"field":@"lastModifyInfo", @"direction":@"desc"}], @"queryOrders":@[@{@"field":@"lastModifyInfo", @"direction":@"desc"}],
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":pageSize @"keyword":self.customStr,
@"pageSize":@(2)
}; };
NSLog(@"parrrrr = %@", parameters);
[httpCilent getInspectListWithParameters:parameters completion:^(id response, NSError *error) { [httpCilent getInspectListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"巡检列表%@", response); NSLog(@"巡检列表%@", response);
NSLog(@"error = %@", error); NSLog(@"error = %@", error);
NSDictionary *dataDict = response[@"data"]; NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"]; NSArray *dataArray = dataDict[@"records"];
NSMutableArray *tempArray = [NSMutableArray array];
for (NSDictionary *dict in dataArray) { for (NSDictionary *dict in dataArray) {
TaskListModel *taskList = [[TaskListModel alloc] init]; TaskListModel *taskList = [[TaskListModel alloc] init];
[taskList setValuesForKeysWithDictionary:dict]; [taskList setValuesForKeysWithDictionary:dict];
[_taskListDataArray addObject:taskList]; [tempArray addObject:taskList];
}
_taskListDataArray = [NSMutableArray arrayWithArray:tempArray];
if (_taskListDataArray.count == 0) {
[_sectionArray removeObject:@"口碑巡检"];
} }
if (_taskListDataArray.count != 0) { if (_sectionArray.count == 0) {
[_sectionArray addObject:@"口碑巡检"]; if (_tableView) {
[_tableView removeFromSuperview];
_tableView = nil;
}
self.noDataView.backgroundColor = [UIColor whiteColor];
} else {
if (_noDataView) {
[_noDataView removeFromSuperview];
_noDataView = nil;
} }
[self.tableView reloadData]; [self.tableView reloadData];
}
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
}]; }];
...@@ -277,33 +491,48 @@ ...@@ -277,33 +491,48 @@
// 请求地址 // 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL]; NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"]; NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"]; // 请求参数
NSDictionary *parameters = @{@"keyword":self.customStr, NSDictionary *parameters = @{@"user":user_uuid,
@"user":user_uuid,
@"scope":@"all", @"scope":@"all",
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":pageSize @"keyword":self.customStr,
@"pageSize":@(2)
}; };
// 发起请求 // 发起请求
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr]; HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
//
// 请求问题列表 // 请求问题列表
[httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) { [httpClient getQuestionListWithParameters:parameters completion:^(id response, NSError *error) {
// [self requestInspectList];
NSDictionary *dataDict = (NSDictionary *)response[@"data"]; NSDictionary *dataDict = (NSDictionary *)response[@"data"];
NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"]; NSDictionary *recordsDict = (NSDictionary *)dataDict[@"records"];
NSLog(@"问题与知识列表recods = %@", response); NSLog(@"问题与知识列表recods = %@", response);
NSLog(@"error = %@", error); NSLog(@"error = %@", error);
NSMutableArray *tempArray = [NSMutableArray array];
for (NSDictionary *questionDict in recordsDict) { for (NSDictionary *questionDict in recordsDict) {
QuestionModel *question = [[QuestionModel alloc] init]; QuestionModel *question = [[QuestionModel alloc] init];
[question setValuesForKeysWithDictionary:questionDict]; [question setValuesForKeysWithDictionary:questionDict];
[_allQuestionArray addObject:question]; [tempArray addObject:question];
} }
if (_allQuestionArray.count != 0) { _allQuestionArray = [NSMutableArray arrayWithArray:tempArray];
[_sectionArray addObject:@"问题知识"]; if (_allQuestionArray.count == 0) {
[_sectionArray removeObject:@"问题知识"];
}
if (_sectionArray.count == 0) {
if (_tableView) {
[_tableView removeFromSuperview];
_tableView = nil;
}
self.noDataView.backgroundColor = [UIColor whiteColor];
} else {
if (_noDataView) {
[_noDataView removeFromSuperview];
_noDataView = nil;
} }
[self.tableView reloadData]; [self.tableView reloadData];
}
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
}]; }];
} }
...@@ -314,15 +543,13 @@ ...@@ -314,15 +543,13 @@
// 请求地址 // 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQueryPicturePraiseURL]; NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQueryPicturePraiseURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"]; NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{ NSDictionary *parameters = @{
@"keyword":self.customStr,
@"scope":@"all", @"scope":@"all",
@"user":user_uuid, @"user":user_uuid,
@"type":@"store", @"type":@"store",
@"keyword":self.customStr,
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":pageSize @"pageSize":@(2)
}; };
// 发起请求 // 发起请求
...@@ -331,7 +558,7 @@ ...@@ -331,7 +558,7 @@
// 请求问题列表 // 请求问题列表
[httpClient queryPicturePraiseWithParameters:parameters completion:^(id response, NSError *error) { [httpClient queryPicturePraiseWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"图说口碑 response = %@ error = %@" , response, error); // [self requestQuestionList];
NSDictionary *dataDict = response[@"data"]; NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"]; NSArray *dataArray = dataDict[@"records"];
NSMutableArray *tempArray = [NSMutableArray array]; NSMutableArray *tempArray = [NSMutableArray array];
...@@ -340,11 +567,23 @@ ...@@ -340,11 +567,23 @@
[picList setValuesForKeysWithDictionary:dict]; [picList setValuesForKeysWithDictionary:dict];
[tempArray addObject:picList]; [tempArray addObject:picList];
} }
_allPraiseListArray = tempArray; _allPraiseListArray = [NSMutableArray arrayWithArray:tempArray];
if (_allPraiseListArray.count != 0) { if (_allPraiseListArray.count == 0) {
[_sectionArray addObject:@"商场风采"]; [_sectionArray removeObject:@"商场风采"];
}
if (_sectionArray.count == 0) {
if (_tableView) {
[_tableView removeFromSuperview];
_tableView = nil;
}
self.noDataView.backgroundColor = [UIColor whiteColor];
} else {
if (_noDataView) {
[_noDataView removeFromSuperview];
_noDataView = nil;
} }
[self.tableView reloadData]; [self.tableView reloadData];
}
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
}]; }];
...@@ -422,7 +661,7 @@ ...@@ -422,7 +661,7 @@
} }
RankListModel *rankList = _allRankListArray[indexPath.row - 1]; RankListModel *rankList = _allRankListArray[indexPath.row - 1];
cell.rankList = rankList; cell.rankList = rankList;
cell.gradeImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", rankList.index+ 1]]; cell.gradeImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"medal_0%d", rankList.index]];
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
} }
...@@ -642,6 +881,30 @@ ...@@ -642,6 +881,30 @@
} }
return _tableView; return _tableView;
} }
- (NoDataView *)noDataView
{
if (!_noDataView) {
_noDataView = [[NoDataView alloc] init];
_noDataView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:_noDataView];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:45];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_noDataView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _noDataView;
}
/* /*
#pragma mark - Navigation #pragma mark - Navigation
......
...@@ -32,10 +32,6 @@ ...@@ -32,10 +32,6 @@
<key>NSAllowsArbitraryLoads</key> <key>NSAllowsArbitraryLoads</key>
<true/> <true/>
</dict> </dict>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key> <key>UIRequiredDeviceCapabilities</key>
......
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