Commit 4d3c7d9d authored by admin's avatar admin

添加删除缓存

parent a1f3aa0c
......@@ -10,10 +10,10 @@
#define Url_h
// url 测试环境
//#define kRedStarURL @"http://218.244.151.129:7580/"
#define kRedStarURL @"http://218.244.151.129:7580/"
// 正式环境
#define kRedStarURL @"http://219.235.234.225:7580/"
// #define kRedStarURL @"http://219.235.234.225:7580/"
// 最新正式环境
// #define kRedStarURL @"http://219.235.234.212:7580/"
......
......@@ -12,6 +12,9 @@
@interface CategoryTableView ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) NSMutableArray *titleArray;
@property (nonatomic, strong) NSMutableArray *categoryArray;
@property (nonatomic, strong) NSMutableDictionary *questionDict;
@property (nonatomic, strong) NSString *cateStr;
@end
@implementation CategoryTableView
......@@ -37,42 +40,61 @@
- (void)setup
{
self.questionDict = [NSMutableDictionary dictionary];
[_questionDict setObject:[NSArray arrayWithObjects:@"15分钟退单",@"便民服务",@"基础管理",@"轻松购系统",@"营运物料",@"服务承诺",@"人员形象",@"全员服务",@"其他", nil] forKey:@"服务"];
[_questionDict setObject:[NSArray arrayWithObjects:@"导视系统",@"背景音乐",@"物料规范",@"儿童区",@"休息区",@"其他", nil] forKey:@"环境企划"];
[_questionDict setObject:[NSArray arrayWithObjects:@"基础环境",@"物料标识",@"停车场",@"卫生间",@"硬件改造",@"人员",@"其他", nil] forKey:@"环境物业"];
[_questionDict setObject:[NSArray arrayWithObjects:@"七折管理",@"价签物料",@"其他", nil] forKey:@"价格"];
[_questionDict setObject:[NSArray arrayWithObjects:@"绿色陈展",@"三年质保",@"其他", nil] forKey:@"质量"];
[_questionDict setObject:[NSArray arrayWithObjects:@"商户信用分类", nil] forKey:@"商户信用分类"];
[_questionDict setObject:[NSArray arrayWithObjects:@"审批、比价、采购", nil] forKey:@"审批比价采购"];
[_questionDict setObject:[NSArray arrayWithObjects:@"送货跟单", nil] forKey:@"送货跟单"];
[_questionDict setObject:[NSArray arrayWithObjects:@"指标", nil] forKey:@"指标"];
[_questionDict setObject:[NSArray arrayWithObjects:@"其他", nil] forKey:@"其他"];
self.delegate = self;
self.dataSource = self;
self.titleArray = [NSMutableArray array];
self.titleArray = [NSMutableArray arrayWithArray:[NSArray arrayWithObjects:@"15分钟退单",@"便民服务",@"基础管理",@"轻松购系统",@"营运物料",@"服务承诺",@"人员形象",@"全员服务",@"其他", nil]];
self.categoryArray = [NSMutableArray array];
NSInteger selectedIndex = 0;
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:selectedIndex inSection:0];
[self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
//注册通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadCurrentTableView:) name:kQuestionGroupNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadCurrentTableView:) name:kQuestionGroupNotification object:nil];
}
- (void)reloadCurrentTableView:(NSNotification *)notification
{
NSString *url = [NSString stringWithFormat:@"%@%@%@",kRedStarURL, kQuestionCategoryURL, notification.userInfo[@"groupName"]];
HttpClient *http = [[HttpClient alloc] initWithUrl:url];
[http getQuestionCategoryWithCompletion:^(id response, NSError *error) {
NSLog(@"分类categaory response= %@", response);
if (response[@"success"]) {
NSDictionary *dictData = response[@"data"];
NSArray *array = dictData[@"records"];
NSMutableArray *groupArray = [NSMutableArray array];
NSMutableArray *categoryArray = [NSMutableArray array];
for (NSDictionary *dict in array) {
NSString *category = [NSString stringWithFormat:@"%@", dict[@"name"]];
NSString *group = [NSString stringWithFormat:@"%@", dict[@"groupName"]];
[categoryArray addObject:category];
[groupArray addObject:group];
}
_titleArray = categoryArray;
_categoryArray = categoryArray;
[self reloadData];
}
}];
_cateStr = [NSString stringWithFormat:@"%@",notification.userInfo[@"groupName"]];
NSArray *selectArray = [NSArray arrayWithArray:[_questionDict objectForKey:_cateStr]];
_titleArray = [NSMutableArray arrayWithArray:selectArray];
[self reloadData];
// NSString *url = [NSString stringWithFormat:@"%@%@%@",kRedStarURL, kQuestionCategoryURL, notification.userInfo[@"groupName"]];
// url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
// HttpClient *http = [[HttpClient alloc] initWithUrl:url];
// [http getQuestionCategoryWithCompletion:^(id response, NSError *error) {
// NSLog(@"分类categaory response= %@", response);
// if (response[@"success"]) {
// NSDictionary *dictData = response[@"data"];
// NSArray *array = dictData[@"records"];
// NSMutableArray *groupArray = [NSMutableArray array];
// NSMutableArray *categoryArray = [NSMutableArray array];
// for (NSDictionary *dict in array) {
// NSString *category = [NSString stringWithFormat:@"%@", dict[@"name"]];
// NSString *group = [NSString stringWithFormat:@"%@", dict[@"groupName"]];
// [categoryArray addObject:category];
// [groupArray addObject:group];
//
// }
// _titleArray = categoryArray;
// _categoryArray = categoryArray;
// [self reloadData];
// }
// }];
}
- (void)dealloc
......@@ -104,10 +126,10 @@
// cell点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cateName = _categoryArray[indexPath.row];
// NSString *cateName = _categoryArray[indexPath.row];
NSString *group = _titleArray[indexPath.row];
if (_categroyDeleagte && [_categroyDeleagte respondsToSelector:@selector(categoryTableViewClick:GroupTitle:)]) {
[_categroyDeleagte categoryTableViewClick:cateName GroupTitle:group];
[_categroyDeleagte categoryTableViewClick:_cateStr GroupTitle:group];
}
}
......
......@@ -41,8 +41,10 @@
[self selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
NSMutableArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:@"groupTitle"];
self.titleArray = [NSMutableArray arrayWithArray:array];
// NSMutableArray *array = [[NSUserDefaults standardUserDefaults] objectForKey:@"groupTitle"];
// self.titleArray = [NSMutableArray arrayWithArray:array];
_titleArray = [NSMutableArray arrayWithObjects:@"服务", @"环境企划", @"环境物业",@"价格",@"质量",@"商户信用分类",@"审批比价采购",@"送货跟单",@"指标",@"其他", nil];
self.delegate = self;
self.dataSource = self;
}
......
......@@ -14,6 +14,8 @@
#import "AttachmentTableViewCell.h"
#import "AttachmentModel.h"
#import <MBProgressHUD.h>
#define kAttachmentTableCell @"sopAttachmentCell"
#define SELECTED_VIEW_CONTROLLER_TAG 39998
......@@ -277,17 +279,37 @@
[fileManager createDirectoryAtPath:aSavePath withIntermediateDirectories:YES attributes:nil error:nil];
}
//下载附件
NSLog(@"aaaurl === %@", aUrl);
aUrl = [aUrl stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSLog(@"aaaurl === %@", aUrl);
NSURL *url = [[NSURL alloc] initWithString:aUrl];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.inputStream = [NSInputStream inputStreamWithURL:url];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:fileName append:NO];
//下载进度控制
//下载进度控制
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
// 设置进度条进度
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeAnnularDeterminate;
// if (expectedContentLength > 0 && progressContentLength <= expectedContentLength)
// progress = (CGFloat) progressContentLength / expectedContentLength;
// else
// progress = (progressContentLength % 1000000l) / 1000000.0f;
CGFloat precent = totalBytesRead / totalBytesExpectedToRead;
hud.labelText = [NSString stringWithFormat:@"%f", precent];
NSLog(@"prrrrrrrrrrrrrr ==== %f", precent);
}];
//已完成下载
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
[self closeRedView];
......@@ -300,11 +322,12 @@
[self closeRedView];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"下载失败!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
[self.tableView reloadData];
}];
[operation start];
}
}
......
......@@ -172,37 +172,44 @@
- (void)addComment:(UIButton *)sender
{
NSArray *permissions = [[NSUserDefaults standardUserDefaults] objectForKey:@"permissions"];
// 口碑报告 商场风采 图说口碑 口碑标准 问题知识 口碑巡检
if (!_backGroundView) {
_backGroundView = [[UIView alloc] initWithFrame:self.view.bounds];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeBackGroundView)];
[_backGroundView addGestureRecognizer:tapGR];
}
if (!_commentView) {
_commentView = [[CommentView alloc] init];
_commentView.backgroundColor = [UIColor whiteColor];
if ([permissions containsObject:@"500202"]) {
if (!_backGroundView) {
_backGroundView = [[UIView alloc] initWithFrame:self.view.bounds];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeBackGroundView)];
[_backGroundView addGestureRecognizer:tapGR];
}
if (!_commentView) {
_commentView = [[CommentView alloc] init];
_commentView.backgroundColor = [UIColor whiteColor];
}
_commentView.contentTextView.text = @"";
_commentView.contentTextView.delegate = self;
[_commentView.quitBtn addTarget:self action:@selector(closeBackGroundView) forControlEvents:UIControlEventTouchUpInside];
[_commentView.sureBtn addTarget:self action:@selector(submitComment:) forControlEvents:UIControlEventTouchUpInside];
[self.view insertSubview:_backGroundView aboveSubview:_treeView];
[self.view insertSubview:_commentView aboveSubview:_backGroundView];
_backGroundView.alpha = 0;
_backGroundView.backgroundColor = [UIColor blackColor];
CGRect toFrame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight, kScreenWidth, kCommentViewHeight);
CGRect fromFrame = CGRectMake(0, kScreenHeight, kScreenWidth, kCommentViewHeight);
_commentView.frame = fromFrame;
[UIView animateWithDuration:0.3 animations:^{
_backGroundView.alpha = 0.6;
_commentView.frame = toFrame;
}];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您没有口碑报告的评论权限!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
}
_commentView.contentTextView.text = @"";
_commentView.contentTextView.delegate = self;
[_commentView.quitBtn addTarget:self action:@selector(closeBackGroundView) forControlEvents:UIControlEventTouchUpInside];
[_commentView.sureBtn addTarget:self action:@selector(submitComment:) forControlEvents:UIControlEventTouchUpInside];
[self.view insertSubview:_backGroundView aboveSubview:_treeView];
[self.view insertSubview:_commentView aboveSubview:_backGroundView];
_backGroundView.alpha = 0;
_backGroundView.backgroundColor = [UIColor blackColor];
CGRect toFrame = CGRectMake(0, self.view.frame.size.height - kCommentViewHeight, kScreenWidth, kCommentViewHeight);
CGRect fromFrame = CGRectMake(0, kScreenHeight, kScreenWidth, kCommentViewHeight);
_commentView.frame = fromFrame;
[UIView animateWithDuration:0.3 animations:^{
_backGroundView.alpha = 0.6;
_commentView.frame = toFrame;
}];
}
// 提交评论
......
......@@ -53,7 +53,7 @@
self.view.backgroundColor = kSectionBackGroundColor;
self.titleArray = [NSMutableArray arrayWithObjects:@"配置",@"关于",@"检查版本更新", nil];
self.titleArray = [NSMutableArray arrayWithObjects:@"配置",@"关于",@"检查版本更新",@"清除缓存",nil];
[self setupTableView];
......@@ -104,6 +104,29 @@
}
- (void)clear
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *cachPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
NSArray *files = [[NSFileManager defaultManager] subpathsAtPath:cachPath];
for (NSString *p in files) {
NSError *error;
NSString *path = [cachPath stringByAppendingPathComponent:p];
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
[[NSFileManager defaultManager] removeItemAtPath:path error:&error];
}
}
[self performSelectorOnMainThread:@selector(clearCacheSuccess) withObject:nil waitUntilDone:YES];
});
}
- (void)clearCacheSuccess
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"清除缓存成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alertView show];
}
#pragma mark - UIAlertViewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
......@@ -194,10 +217,12 @@
} else if (indexPath.row == 1) {
AboutMeViewController *about = [[AboutMeViewController alloc] init];
[self.navigationController pushViewController:about animated:YES];
} else {
} else if (indexPath.row == 0){
self.numberActionSheet = [[UIActionSheet alloc] initWithTitle:@"列表请求数量设置" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"10",@"20",@"30",@"40", @"50", nil];
[_numberActionSheet showInView:self.view];
} else {
[self clear];
}
}
......
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