Commit 8db206be authored by AvatarC's avatar AvatarC

Merge branch 'develop' of https://git.oschina.net/gomoretech/RedstarIOS into develop_avatar

parents 64630bb5 17f1e76c
......@@ -95,6 +95,7 @@
84AD4F3D1BF4894D00BFB37C /* RankDetailView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84AD4F3C1BF4894D00BFB37C /* RankDetailView.m */; };
84AD4F3F1BF498A900BFB37C /* ranking.plist in Resources */ = {isa = PBXBuildFile; fileRef = 84AD4F3E1BF498A900BFB37C /* ranking.plist */; };
84AD4F461BF4A9E800BFB37C /* RankHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84AD4F451BF4A9E800BFB37C /* RankHeadView.m */; };
84B4765A1C2E4B37006C6488 /* PicCategoryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84B476591C2E4B37006C6488 /* PicCategoryViewController.m */; };
84BB16A21C191A7F00383A64 /* OnLineResultFootView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84BB16A11C191A7F00383A64 /* OnLineResultFootView.m */; };
84C9574D1BDB344900083584 /* UIBarButtonItem+Create.m in Sources */ = {isa = PBXBuildFile; fileRef = 84C9574A1BDB344900083584 /* UIBarButtonItem+Create.m */; };
84C9574E1BDB344900083584 /* UIView+Frame.m in Sources */ = {isa = PBXBuildFile; fileRef = 84C9574C1BDB344900083584 /* UIView+Frame.m */; };
......@@ -152,6 +153,7 @@
84ECCF181C01FA2600EA4960 /* QuestionDetailModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 84ECCF171C01FA2600EA4960 /* QuestionDetailModel.m */; };
84ECCF1B1C0210F000EA4960 /* CommentModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 84ECCF1A1C0210F000EA4960 /* CommentModel.m */; };
84ED5DD81BF2E64300A1BB6D /* ScreenView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84ED5DD71BF2E64300A1BB6D /* ScreenView.m */; };
84EE92771C2FFDEB000EF5BF /* AttachmentModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 84EE92761C2FFDEB000EF5BF /* AttachmentModel.m */; };
84F1669B1BE715E40061D350 /* ZanButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F1669A1BE715E40061D350 /* ZanButton.m */; };
84F30DA41BFC19F200CBAD13 /* RankListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F30DA31BFC19F200CBAD13 /* RankListModel.m */; };
84F57C461BEC388A00DDEEB1 /* CommentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F57C451BEC388A00DDEEB1 /* CommentView.m */; };
......@@ -359,6 +361,8 @@
84AD4F3E1BF498A900BFB37C /* ranking.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ranking.plist; sourceTree = "<group>"; };
84AD4F441BF4A9E800BFB37C /* RankHeadView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankHeadView.h; sourceTree = "<group>"; };
84AD4F451BF4A9E800BFB37C /* RankHeadView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankHeadView.m; sourceTree = "<group>"; };
84B476581C2E4B37006C6488 /* PicCategoryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PicCategoryViewController.h; sourceTree = "<group>"; };
84B476591C2E4B37006C6488 /* PicCategoryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PicCategoryViewController.m; sourceTree = "<group>"; };
84BB16A01C191A7F00383A64 /* OnLineResultFootView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OnLineResultFootView.h; sourceTree = "<group>"; };
84BB16A11C191A7F00383A64 /* OnLineResultFootView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OnLineResultFootView.m; sourceTree = "<group>"; };
84C957491BDB344900083584 /* UIBarButtonItem+Create.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIBarButtonItem+Create.h"; sourceTree = "<group>"; };
......@@ -474,6 +478,8 @@
84ECCF1A1C0210F000EA4960 /* CommentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentModel.m; sourceTree = "<group>"; };
84ED5DD61BF2E64300A1BB6D /* ScreenView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenView.h; sourceTree = "<group>"; };
84ED5DD71BF2E64300A1BB6D /* ScreenView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScreenView.m; sourceTree = "<group>"; };
84EE92751C2FFDEB000EF5BF /* AttachmentModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttachmentModel.h; sourceTree = "<group>"; };
84EE92761C2FFDEB000EF5BF /* AttachmentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AttachmentModel.m; sourceTree = "<group>"; };
84F166991BE715E40061D350 /* ZanButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZanButton.h; sourceTree = "<group>"; };
84F1669A1BE715E40061D350 /* ZanButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZanButton.m; sourceTree = "<group>"; };
84F30DA21BFC19F200CBAD13 /* RankListModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankListModel.h; sourceTree = "<group>"; };
......@@ -716,6 +722,7 @@
8426A4A71BDF0CD600E5FDF5 /* Picture */ = {
isa = PBXGroup;
children = (
84B476531C2E4B1C006C6488 /* PictureCategory */,
849A183D1C152CD400071600 /* AddPicture */,
8490C4C71BF9DEF0006B6569 /* PictureDetail */,
8490C4CB1BF9DEF0006B6569 /* PictureList */,
......@@ -1473,6 +1480,8 @@
children = (
849B2F751C0CABE6005D809F /* AnnounceDetailModel.h */,
849B2F761C0CABE6005D809F /* AnnounceDetailModel.m */,
84EE92751C2FFDEB000EF5BF /* AttachmentModel.h */,
84EE92761C2FFDEB000EF5BF /* AttachmentModel.m */,
);
path = Model;
sourceTree = "<group>";
......@@ -1599,6 +1608,47 @@
path = Model;
sourceTree = "<group>";
};
84B476531C2E4B1C006C6488 /* PictureCategory */ = {
isa = PBXGroup;
children = (
84B476541C2E4B1C006C6488 /* Cell */,
84B476551C2E4B1C006C6488 /* Model */,
84B476561C2E4B1C006C6488 /* View */,
84B476571C2E4B1C006C6488 /* ViewController */,
);
path = PictureCategory;
sourceTree = "<group>";
};
84B476541C2E4B1C006C6488 /* Cell */ = {
isa = PBXGroup;
children = (
);
path = Cell;
sourceTree = "<group>";
};
84B476551C2E4B1C006C6488 /* Model */ = {
isa = PBXGroup;
children = (
);
path = Model;
sourceTree = "<group>";
};
84B476561C2E4B1C006C6488 /* View */ = {
isa = PBXGroup;
children = (
);
path = View;
sourceTree = "<group>";
};
84B476571C2E4B1C006C6488 /* ViewController */ = {
isa = PBXGroup;
children = (
84B476581C2E4B37006C6488 /* PicCategoryViewController.h */,
84B476591C2E4B37006C6488 /* PicCategoryViewController.m */,
);
path = ViewController;
sourceTree = "<group>";
};
84C582E91BDDFACD00AF838D /* Cell */ = {
isa = PBXGroup;
children = (
......@@ -2390,6 +2440,7 @@
8473E3881C1BBFF600960257 /* InspectTaskDetailCell.m in Sources */,
84F57C9C1BECA73800DDEEB1 /* StarBar.m in Sources */,
84F57C4C1BEC785E00DDEEB1 /* AddQuestionViewController.m in Sources */,
84EE92771C2FFDEB000EF5BF /* AttachmentModel.m in Sources */,
84D2F5201C2D213400651EFB /* AttachmentTableViewCell.m in Sources */,
84C9729F1C1ADD17003A3276 /* PictureCommentTableCell.m in Sources */,
849A18461C152EBA00071600 /* AddPictureTableCell.m in Sources */,
......@@ -2432,6 +2483,7 @@
8480BEB21C143A4100E2F18F /* StateTableView.m in Sources */,
849B2F711C0CA22F005D809F /* AnnoContentTableViewCell.m in Sources */,
84A2270E1C229409002766DC /* RankPickView.m in Sources */,
84B4765A1C2E4B37006C6488 /* PicCategoryViewController.m in Sources */,
84D3E6021C04DA85001FF1DD /* InspectUpLoadFootView.m in Sources */,
84A673881C0B50B4000F828E /* OnLineCompleteViewController.m in Sources */,
8474C5991BE78BBC007DCF19 /* QuestionDetailCell.m in Sources */,
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "store_show@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "store_show@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "case_show@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "case_show@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "report_show@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "report_show@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "task_online@2x.png",
"filename" : "口碑巡检_功能一览@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_online@3x.png",
"filename" : "口碑巡检_功能一览@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "口碑巡检_功能一览@2x.png",
"filename" : "praise_report@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "口碑巡检_功能一览@3x.png",
"filename" : "praise_report@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "praise_standard@2x.png",
"filename" : "question_problem@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "praise_standard@3x.png",
"filename" : "question_problem@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "praise_image@2x.png",
"filename" : "praise_standard@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "praise_image@3x.png",
"filename" : "praise_standard@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "question_problem@2x.png",
"filename" : "praise_image@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "question_problem@3x.png",
"filename" : "praise_image@3x.png",
"scale" : "3x"
}
],
......
......@@ -6,12 +6,12 @@
},
{
"idiom" : "universal",
"filename" : "praise_report@2x.png",
"filename" : "stor_icon_big@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "praise_report@3x.png",
"filename" : "stor_icon_big@3x.png",
"scale" : "3x"
}
],
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "task_online@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "task_online@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "store_icon@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "store_icon@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -21,6 +21,8 @@
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
_window.backgroundColor = [UIColor whiteColor];
[_window makeKeyAndVisible];
[[NSUserDefaults standardUserDefaults] setObject:@(10) forKey:@"requestNumber"];
// 设置根控制器
LoginViewController *loginVC = [[LoginViewController alloc] init];
......
......@@ -14,21 +14,23 @@
{
if (!_nameBtn) {
_nameBtn = [[UIButton alloc] init];
_nameBtn.backgroundColor = [UIColor grayColor];
_nameBtn.translatesAutoresizingMaskIntoConstraints = NO;
[_nameBtn setTitleColor:kNavigationBarColor forState:UIControlStateNormal];
_nameBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
_nameBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
_nameBtn.layer.cornerRadius = 4.0;
[self.contentView addSubview:_nameBtn];
NSLayoutConstraint *lineViewTop = [NSLayoutConstraint constraintWithItem:_nameBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
[self.contentView addConstraint:lineViewTop];
NSLayoutConstraint *lineViewRight = [NSLayoutConstraint constraintWithItem:_nameBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:-20];
NSLayoutConstraint *lineViewRight = [NSLayoutConstraint constraintWithItem:_nameBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.downloadBtn attribute:NSLayoutAttributeLeft multiplier:1.0 constant:-10];
[self.contentView addConstraint:lineViewRight];
NSLayoutConstraint *lineViewBottom = [NSLayoutConstraint constraintWithItem:_nameBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5];
[self.contentView addConstraint:lineViewBottom];
NSLayoutConstraint *lineViewLeft = [NSLayoutConstraint constraintWithItem:_nameBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:10];
NSLayoutConstraint *lineViewLeft = [NSLayoutConstraint constraintWithItem:_nameBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
[self.contentView addConstraint:lineViewLeft];
NSLayoutConstraint *lineViewHeight = [NSLayoutConstraint constraintWithItem:_nameBtn attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35];
......@@ -42,22 +44,24 @@
{
if (!_downloadBtn) {
_downloadBtn = [[UIButton alloc] init];
_downloadBtn.backgroundColor = [UIColor grayColor];
_downloadBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
_downloadBtn.translatesAutoresizingMaskIntoConstraints = NO;
[_downloadBtn setTitle:@"下载" forState:UIControlStateNormal];
[_downloadBtn setTitle:@"已下载" forState:UIControlStateSelected];
_downloadBtn.layer.cornerRadius = 4.0;
[self.contentView addSubview:_downloadBtn];
NSLayoutConstraint *lineViewTop = [NSLayoutConstraint constraintWithItem:_downloadBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
NSLayoutConstraint *lineViewTop = [NSLayoutConstraint constraintWithItem:_downloadBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:8];
[self.contentView addConstraint:lineViewTop];
NSLayoutConstraint *lineViewRight = [NSLayoutConstraint constraintWithItem:_downloadBtn attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
[self.contentView addConstraint:lineViewRight];
NSLayoutConstraint *lineViewBottom = [NSLayoutConstraint constraintWithItem:_downloadBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5];
NSLayoutConstraint *lineViewBottom = [NSLayoutConstraint constraintWithItem:_downloadBtn attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-8];
[self.contentView addConstraint:lineViewBottom];
NSLayoutConstraint *lineViewLeft = [NSLayoutConstraint constraintWithItem:_downloadBtn attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:10];
[self.contentView addConstraint:lineViewLeft];
NSLayoutConstraint *lineViewWidth = [NSLayoutConstraint constraintWithItem:_downloadBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:80];
[self.contentView addConstraint:lineViewWidth];
}
return _downloadBtn;
}
......
//
// AttachmentModel.h
// redstar
//
// Created by admin on 15/12/27.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface AttachmentModel : NSObject
@property (nonatomic, strong) NSString *fileName;
@property (nonatomic, strong) NSString *fileUrl;
@end
//
// AttachmentModel.m
// redstar
//
// Created by admin on 15/12/27.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "AttachmentModel.h"
@implementation AttachmentModel
@end
......@@ -10,6 +10,7 @@
#import "AnnounceDetailHeadView.h"
#import "AnnoContentTableViewCell.h"
#import "AnnounceDetailFootView.h"
#import "AttachmentModel.h"
#import "HttpClient.h"
......@@ -17,14 +18,18 @@
#import "AttachmentTableViewCell.h"
#import <AFNetworking.h>
#define kAnnounceContentCell @"AnnoContentTableViewCell"
#define kAttachmentTableViewCell @"AttachmentTableViewCell"
@interface AnnoDetailViewController ()<UITableViewDataSource, UITableViewDelegate>
@interface AnnoDetailViewController ()<UITableViewDataSource, UITableViewDelegate, UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) AnnounceDetailHeadView *headerView;
@property (nonatomic, strong) AnnounceDetailFootView *footerView;
@property (nonatomic, strong) AnnounceDetailModel *annoDetail;
@property (nonatomic, strong) NSMutableArray *attachmentArray;
@end
@implementation AnnoDetailViewController
......@@ -33,6 +38,8 @@
{
[super viewDidLoad];
self.attachmentArray = [NSMutableArray array];
[self setNav];
[self requestAnnoDetail];
......@@ -50,6 +57,12 @@
AnnounceDetailModel *annoDetail = [AnnounceDetailModel announceDetailModelWithDict:dict];
_annoDetail = annoDetail;
for (NSDictionary *attachmentDict in _annoDetail.attachmentUrls) {
AttachmentModel *atta = [[AttachmentModel alloc] init];
[atta setValuesForKeysWithDictionary:attachmentDict];
[_attachmentArray addObject:atta];
}
self.tableView.delegate = self;
self.tableView.dataSource = self;
}];
......@@ -98,12 +111,80 @@
- (void)showFile:(UIButton *)sender
{
NSInteger row = sender.tag - 998473;
AttachmentModel *atta = _attachmentArray[row];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = paths.lastObject;
NSString *url = [NSString stringWithFormat:@"%@/%@", path, atta.fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:url]) {
UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:url]];//为该对象初始化一个加载路径
docController.delegate = self;//设置代理
[docController presentPreviewAnimated:YES];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"文件不存在,请先下载在查看!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
}
}
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
- (void)downloadFile:(UIButton *)sender
{
NSInteger row = sender.tag - 998473;
AttachmentModel *atta = _attachmentArray[row];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = paths.lastObject;
[self downloadFileURL:[NSString stringWithFormat:@"%@%@", kRedStarURL, atta.fileUrl] savePath:path fileName:atta.fileName];
}
- (void)downloadFileURL:(NSString *)aUrl savePath:(NSString *)aSavePath fileName:(NSString *)aFileName
{
NSFileManager *fileManager = [NSFileManager defaultManager];
//检查本地文件是否已存在
NSString *fileName = [NSString stringWithFormat:@"%@/%@", aSavePath, aFileName];
//检查附件是否存在
if ([fileManager fileExistsAtPath:fileName]) {
NSLog(@"存在了");
}else{
NSLog(@"不存在");
//创建附件存储目录
if (![fileManager fileExistsAtPath:aSavePath]) {
[fileManager createDirectoryAtPath:aSavePath withIntermediateDirectories:YES attributes:nil error:nil];
}
//下载附件
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 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"下载成功");
[self.tableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"下载失败");
}];
[operation start];
}
}
- (void)didReceiveMemoryWarning {
......@@ -112,15 +193,24 @@
}
#pragma mark - UITableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1 + _annoDetail.attachmentUrls.count;
if (section == 0) {
return 1;
} else {
return _attachmentArray.count;
}
}
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
if (indexPath.section == 0) {
AnnoContentTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kAnnounceContentCell];
if (!cell) {
cell = [[AnnoContentTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kAnnounceContentCell];
......@@ -139,21 +229,34 @@
if (!cell) {
cell = [[AttachmentTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kAttachmentTableViewCell];
}
NSDictionary *dict = _annoDetail.attachmentUrls[indexPath.row - 1];
NSString *name = dict[@"fileName"];
AttachmentModel *atta = _attachmentArray[indexPath.row];
NSString *name = atta.fileName;
[cell.nameBtn setTitle:name forState:UIControlStateNormal];
[cell.downloadBtn setTitle:@"下载" forState:UIControlStateNormal];
[cell.nameBtn addTarget:self action:@selector(showFile:) forControlEvents:UIControlEventTouchUpInside];
[cell.downloadBtn addTarget:self action:@selector(downloadFile:) forControlEvents:UIControlEventTouchUpInside];
cell.downloadBtn.tag = 998473 + indexPath.row;
cell.nameBtn.tag = 998473 + indexPath.row;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = paths.lastObject;
NSString *url = [NSString stringWithFormat:@"%@/%@", path, atta.fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:url]) {
cell.downloadBtn.selected = YES;
cell.downloadBtn.backgroundColor = [UIColor grayColor];
} else {
cell.downloadBtn.selected = NO;
cell.downloadBtn.backgroundColor = [UIColor colorWithRed:47 / 255.0 green:209/ 255.0 blue:92 / 255.0 alpha:1.0];
}
return cell;
}
}
- (UITableView *)tableView
{
if (!_tableView) {
......@@ -165,7 +268,6 @@
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 100.0;
_tableView.tableHeaderView = self.headerView;
_tableView.tableFooterView = self.footerView;
[_tableView registerClass:[AnnoContentTableViewCell class] forCellReuseIdentifier:kAnnounceContentCell];
[_tableView registerClass:[AttachmentTableViewCell class] forCellReuseIdentifier:kAttachmentTableViewCell];
[self.view addSubview:_tableView];
......@@ -198,8 +300,7 @@
- (AnnounceDetailFootView *)footerView
{
if (!_footerView) {
_footerView = [[AnnounceDetailFootView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 120)];
_footerView.backgroundColor = [UIColor whiteColor];
_footerView = [[AnnounceDetailFootView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)];
}
return _footerView;
}
......
......@@ -11,6 +11,8 @@
#import "RankingListViewController.h"
#import "PictureViewController.h"
#import "QuestionViewController.h"
#import "PicCategoryViewController.h"
#import "StandardViewController.h"
@interface FunctionViewController ()
@property (nonatomic, strong) UIView *lineView;
......@@ -50,12 +52,12 @@
#pragma mark - Private Methods
- (void)setup
{
[self.onLineSamplingBtn setTitle:@"口碑巡检" forState:UIControlStateNormal];
[self.wordOfMouthBtn setTitle:@"口碑排名" forState:UIControlStateNormal];
[self.standardBtn setTitle:@"问题与知识" forState:UIControlStateNormal];
[self.pictureBtn setTitle:@"图说口碑" forState:UIControlStateNormal];
[self.questionBtn setTitle:@"口碑标准" forState:UIControlStateNormal];
[self.rankBtn setTitle:@"在线抽查" forState:UIControlStateNormal];
[self.onLineSamplingBtn setTitle:@"口碑报告" forState:UIControlStateNormal];
[self.wordOfMouthBtn setTitle:@"商场风采" forState:UIControlStateNormal];
[self.standardBtn setTitle:@"图说口碑" forState:UIControlStateNormal];
[self.pictureBtn setTitle:@"口碑标准" forState:UIControlStateNormal];
[self.questionBtn setTitle:@"问题知识" forState:UIControlStateNormal];
[self.rankBtn setTitle:@"口碑巡检" forState:UIControlStateNormal];
//self.lineView.backgroundColor = kSeparateLineViewColor;
......@@ -71,18 +73,23 @@
InspectListViewController *inspectListVC = [[InspectListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:inspectListVC];
} else if ([item.titleLabel.text isEqualToString:@"口碑标准"]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"当前功能正在开发!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
return;
StandardViewController *standardVC = [[StandardViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:standardVC];
} else if ([item.titleLabel.text isEqualToString:@"图说口碑"]) {
PictureViewController *pictureVC = [[PictureViewController alloc] init];
PicCategoryViewController *pictureVC = [[PicCategoryViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:pictureVC];
} else if ([item.titleLabel.text isEqualToString:@"问题与知识"]) {
} else if ([item.titleLabel.text isEqualToString:@"问题知识"]) {
QuestionViewController *questionVC = [[QuestionViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:questionVC];
} else if ([item.titleLabel.text isEqualToString:@"口碑排名"]) {
} else if ([item.titleLabel.text isEqualToString:@"口碑报告"]) {
RankingListViewController *rankingListVC = [[RankingListViewController alloc] init];
nav = [[UINavigationController alloc] initWithRootViewController:rankingListVC];
} else if ([item.titleLabel.text isEqualToString:@"商场风采"]) {
PictureViewController *pic = [[PictureViewController alloc] init];
pic.come = @"首页";
pic.category = @"store";
nav = [[UINavigationController alloc] initWithRootViewController:pic];
} else {
return;
}
......
......@@ -105,9 +105,11 @@
HttpClient *http = [[HttpClient alloc] initWithUrl:[NSString stringWithFormat:@"%@%@", kRedStarURL, kStoreSportcheckURL]];
// 相关参数
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{@"userUuid":user_uuid,
@"pageNumber":@(0),
@"pageSize":@(10)
@"pageSize":pageSize
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[http getStoreSportCheckListWithParameters:parameters completion:^(id response, NSError *error) {
......@@ -155,9 +157,11 @@
HttpClient *http = [[HttpClient alloc] initWithUrl:[NSString stringWithFormat:@"%@%@", kRedStarURL, kStoreSportcheckURL]];
// 相关参数
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{@"userUuid":user_uuid,
@"pageNumber":@(_page),
@"pageSize":@(10)
@"pageSize":pageSize
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[http getStoreSportCheckListWithParameters:parameters completion:^(id response, NSError *error) {
......@@ -352,11 +356,13 @@
- (void)submitClick:(UIButton *)sender
{
HttpClient *http = [[HttpClient alloc] initWithUrl:[NSString stringWithFormat:@"%@%@", kRedStarURL, kStoreSportcheckURL]];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],@"userUuid",
@[],@"queryOrders",
@(0),@"pageNumber",
@(10),@"pageSize", nil];
pageSize,@"pageSize", nil];
if (_screenView.groupTabBar.selectNumber == 0) {
......@@ -541,9 +547,11 @@
// 相关参数
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{@"userUuid":user_uuid,
@"pageNumber":@(0),
@"pageSize":@(10),
@"pageSize":pageSize,
@"queryOrders":queryOrders
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
......
......@@ -108,11 +108,13 @@
- (void)requestSpotCheckList
{
HttpClient *http = [[HttpClient alloc] initWithUrl:[NSString stringWithFormat:@"%@%@", kRedStarURL, kManageSportcheckURL]];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
// 相关参数
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSDictionary *parameters = @{@"userUuid":user_uuid,
@"pageNumber":@(0),
@"pageSize":@(10)
@"pageSize":pageSize
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[http getManageSportCheckListWithParameters:parameters completion:^(id response, NSError *error) {
......@@ -161,9 +163,11 @@
HttpClient *http = [[HttpClient alloc] initWithUrl:[NSString stringWithFormat:@"%@%@", kRedStarURL, kManageSportcheckURL]];
// 相关参数
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{@"userUuid":user_uuid,
@"pageNumber":@(_page),
@"pageSize":@(10)
@"pageSize":pageSize
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[http getManageSportCheckListWithParameters:parameters completion:^(id response, NSError *error) {
......@@ -366,11 +370,13 @@
{
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kManageSportcheckURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],@"userUuid",
@[],@"queryOrders",
@(0),@"pageNumber",
@(10),@"pageSize", nil];
pageSize,@"pageSize", nil];
if (_screenView.groupTabBar.selectNumber == 0) {
......@@ -519,12 +525,12 @@
@"direction":@"asc"}];
}
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
// 相关参数
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSDictionary *parameters = @{@"userUuid":user_uuid,
@"pageNumber":@(_page),
@"pageSize":@(10),
@"pageSize":pageSize,
@"queryOrders":queryOrders
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
......
......@@ -9,5 +9,5 @@
#import <UIKit/UIKit.h>
@interface AddPictureViewController : UIViewController
@property (nonatomic, copy) NSString *category;
@end
//
// PicCategoryViewController.h
// redstar
//
// Created by admin on 15/12/26.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface PicCategoryViewController : UIViewController
@end
//
// PicCategoryViewController.m
// redstar
//
// Created by admin on 15/12/26.
// Copyright © 2015年 ZWF. All rights reserved.
//
#import "PicCategoryViewController.h"
#import "StandardTableViewCell.h"
#import "PictureViewController.h"
#define kPicCategoryTableViewCell @"picCategoryViewCell"
@interface PicCategoryViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *titleArray;
@property (nonatomic, strong) NSArray *detailTitleArray;
@end
@implementation PicCategoryViewController
- (void)viewDidLoad {
[super viewDidLoad];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.modalPresentationCapturesStatusBarAppearance = NO;
self.navigationController.navigationBar.translucent = NO;
}
[self setupNav];
self.titleArray = [NSArray arrayWithObjects:@"商场风采",@"优秀案例",@"巡店报告", nil];
self.detailTitleArray = [NSArray arrayWithObjects:@"SOP:标准作业程序",@"内部精品培训课程讲义资料...",@"专家讲师精品课程视频分享...", nil];
self.tableView.delegate = self;
self.tableView.dataSource = self;
}
- (void)setupNav
{
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"口碑标准"];
customLab.font = [UIFont boldSystemFontOfSize:19];
self.navigationItem.titleView = customLab;
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(0, 0, 30, 44);
[backBtn setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem = backItem;
}
-(void)doBack:(id)sender
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UItableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return _titleArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// StandardTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kPicCategoryTableViewCell];
// if (!cell) {
// cell = [[StandardTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kPicCategoryTableViewCell];
// }
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kPicCategoryTableViewCell];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kPicCategoryTableViewCell];
}
cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"pic_0%ld",(long)indexPath.section]];
cell.textLabel.text = [NSString stringWithFormat:@"%@", _titleArray[indexPath.section]];
cell.textLabel.font = [UIFont systemFontOfSize:18.0];
//cell.detailTitleLabel.text = [NSString stringWithFormat:@"%@", _detailTitleArray[indexPath.section]];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 100;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return CGFLOAT_MIN;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PictureViewController *sopVC = [[PictureViewController alloc] init];
sopVC.come = @"图说";
if (indexPath.section == 0) {
sopVC.category = @"store";
[self.navigationController pushViewController:sopVC animated:YES];
} else if (indexPath.section == 1) {
sopVC.category = @"casus";
[self.navigationController pushViewController:sopVC animated:YES];
} else {
sopVC.category = @"report";
[self.navigationController pushViewController:sopVC animated:YES];
}
}
#pragma mark - lazy laoding
- (UITableView *)tableView
{
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.showsVerticalScrollIndicator = NO;
_tableView.showsHorizontalScrollIndicator = NO;
_tableView.tableFooterView = [[UIView alloc] init];
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 300.0;
[self.view addSubview:_tableView];
[self.view insertSubview:_tableView atIndex:0];
NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
[self.view addConstraint:tableTop];
NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.view addConstraint:tableLeft];
NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
[self.view addConstraint:tableRight];
NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.view addConstraint:tableBottom];
}
return _tableView;
}
@end
......@@ -10,6 +10,9 @@
@interface PictureTextTableCell : UITableViewCell
@property (nonatomic, strong) UIImageView *bigImageView;
//@property (nonatomic, strong) UIButton *bigImageView;
@property (nonatomic, strong) UILabel *descriptionLabel;
@end
......@@ -14,6 +14,7 @@
if (!_bigImageView) {
_bigImageView = [[UIImageView alloc] init];
_bigImageView.translatesAutoresizingMaskIntoConstraints = NO;
_bigImageView.userInteractionEnabled = YES;
[self.contentView addSubview:_bigImageView];
// 顶端
......@@ -29,17 +30,47 @@
[self.contentView addConstraint:titleRight];
// 高度
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_bigImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:150];
NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_bigImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:170];
[self.contentView addConstraint:titleHeight];
}
return _bigImageView;
}
//- (UIButton *)bigImageView
//{
// if (!_bigImageView) {
// _bigImageView = [[UIButton alloc] init];
// _bigImageView.translatesAutoresizingMaskIntoConstraints = NO;
// [self.contentView addSubview:_bigImageView];
//
// // 顶端
// NSLayoutConstraint *titleTop = [NSLayoutConstraint constraintWithItem:_bigImageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:5];
// [self.contentView addConstraint:titleTop];
//
// // 左边
// NSLayoutConstraint *titleLeft = [NSLayoutConstraint constraintWithItem:_bigImageView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20];
// [self.contentView addConstraint:titleLeft];
//
// // 右边
// NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_bigImageView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-20];
// [self.contentView addConstraint:titleRight];
//
// // 高度
// NSLayoutConstraint *titleHeight = [NSLayoutConstraint constraintWithItem:_bigImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:170];
// [self.contentView addConstraint:titleHeight];
// }
// return _bigImageView;
//}
- (UILabel *)descriptionLabel
{
if (!_descriptionLabel) {
_descriptionLabel = [[UILabel alloc] init];
_descriptionLabel.translatesAutoresizingMaskIntoConstraints = NO;
_descriptionLabel.font = [UIFont systemFontOfSize:15.0];
_descriptionLabel.textColor = kLightBlack;
[self.contentView addSubview:_descriptionLabel];
// 顶端
......
......@@ -14,15 +14,16 @@
self.descriptionText = value;
}
- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
Class cls = self.class;
for (NSString *key in keyedValues.allKeys) {
NSString *varName = [NSString stringWithFormat:@"_%@", key];
const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
Ivar var = class_getInstanceVariable(cls, c_key);
if (var) {
[self setValue:[keyedValues objectForKey:key] forKey:key];
}
}
}
//- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues{
// Class cls = self.class;
// for (NSString *key in keyedValues.allKeys) {
// NSString *varName = [NSString stringWithFormat:@"_%@", key];
// NSLog(@"varName ===== %@", varName);
// const char *c_key = [varName cStringUsingEncoding:NSUTF8StringEncoding];
// Ivar var = class_getInstanceVariable(cls, c_key);
// if (var) {
// [self setValue:[keyedValues objectForKey:key] forKey:key];
// }
// }
//}
@end
......@@ -13,12 +13,15 @@
#import "PictureTextTableCell.h"
#import "PictureCommentTableCell.h"
#import "CheckPicViewController.h"
#import "HttpClient.h"
#import "CommentView.h"
#import <MBProgressHUD.h>
#import "CommentModel.h"
#import <UIImageView+WebCache.h>
#import <UIButton+WebCache.h>
#define kPictureDetailTableCell @"PictureDetailTableViewCell"
#define kPictureTextTableCell @"PictureTextTableViewCell"
......@@ -243,6 +246,14 @@
}];
}
- (void)tapClick:(UIGestureRecognizer *)sender
{
UIImageView *showImageView = (UIImageView *)sender.view;
CheckPicViewController *checkVC = [[CheckPicViewController alloc] init];
checkVC.checkImage = showImageView.image;
[self.navigationController pushViewController:checkVC animated:YES];
}
#pragma mark - UITableView DataSource/Delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
......@@ -305,9 +316,22 @@
}
PicTextModel *picText = _picTextArray[indexPath.row];
NSURL *imageUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", kRedStarURL ,picText.fileUrl]];
UIImageView *imageView = [[UIImageView alloc] init];
[imageView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"default_pic"]];
cell.bigImageView.contentMode = UIViewContentModeScaleAspectFit;
// [cell.bigImageView sd_setImageWithURL:imageUrl forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"default_pic"]];
[cell.bigImageView sd_setImageWithURL:imageUrl placeholderImage:[UIImage imageNamed:@"default_pic"]];
cell.descriptionLabel.text = [NSString stringWithFormat:@"%@", picText.descriptionText];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
[cell.bigImageView addGestureRecognizer:tap];
NSString *str = [NSString stringWithFormat:@"%@", picText.descriptionText];
if (picText.descriptionText == nil || picText.descriptionText == NULL || [picText.descriptionText isEqual:[NSNull null]]) {
cell.descriptionLabel.text = @"";
} else {
cell.descriptionLabel.text = str;
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else {
......@@ -321,6 +345,8 @@
}
}
// 自定义section
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
......
......@@ -15,6 +15,7 @@
@property (nonatomic, strong) UIImageView *titleImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *detailsLabel;
@property (nonatomic, strong) UILabel *adressLabel;
@property (nonatomic, strong) UILabel *dateLabel;
......
......@@ -32,10 +32,11 @@
self.titleLabel.text = [NSString stringWithFormat:@"%@", pictureList.title];
self.detailsLabel.text = [NSString stringWithFormat:@"%@", pictureList.content];
if (pictureList.submitTime == nil || pictureList.submitTime == NULL || [pictureList.submitTime isEqual:[NSNull null]]) {
self.dateLabel.text = [NSString stringWithFormat:@"发布时间: "];
self.dateLabel.text = [NSString stringWithFormat:@""];
} else {
self.dateLabel.text = [NSString stringWithFormat:@"发布时间: %@",pictureList.submitTime];
self.dateLabel.text = [[NSString stringWithFormat:@"%@",pictureList.submitTime] substringToIndex:10];
}
self.adressLabel.text = [NSString stringWithFormat:@"%@", pictureList.storePath];
if (pictureList.hotspot) {
self.hotLabel.hidden = NO;
......@@ -53,6 +54,32 @@
[self.commentBtn setTitle:[NSString stringWithFormat:@"%d", pictureList.commentCount] forState:UIControlStateNormal];
}
//裁剪图片
- (UIImage *)cutImage:(UIImage*)image
{
//压缩图片
CGSize newSize;
CGImageRef imageRef = nil;
if ((image.size.width / image.size.height) < (((kScreenWidth - 20 * 3) / 2) / 90)) {
newSize.width = image.size.width;
newSize.height = image.size.width * 90 / ((kScreenWidth - 20 * 3) / 2);
imageRef = CGImageCreateWithImageInRect([image CGImage], CGRectMake(0, fabs(image.size.height - newSize.height) / 2, newSize.width, newSize.height));
} else {
newSize.height = image.size.height;
newSize.width = image.size.height * ((kScreenWidth - 20 * 3) / 2) / 90;
imageRef = CGImageCreateWithImageInRect([image CGImage], CGRectMake(fabs(image.size.width - newSize.width) / 2, 0, newSize.width, newSize.height));
}
return [UIImage imageWithCGImage:imageRef];
}
#pragma mark - Lazy loading
- (UIImageView *)titleImageView
{
......@@ -149,12 +176,38 @@
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_detailsLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-15];
[self.contentView addConstraint:titleRight];
NSLayoutConstraint *titleImageHeight = [NSLayoutConstraint constraintWithItem:_detailsLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:40];
NSLayoutConstraint *titleImageHeight = [NSLayoutConstraint constraintWithItem:_detailsLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:23];
[self.contentView addConstraint:titleImageHeight];
}
return _detailsLabel;
}
- (UILabel *)adressLabel
{
if (!_adressLabel) {
_adressLabel = [[UILabel alloc] init];
_adressLabel.font = [UIFont systemFontOfSize:14.0];
_adressLabel.translatesAutoresizingMaskIntoConstraints = NO;
_adressLabel.numberOfLines = 0;
_adressLabel.textColor = kLightGray;
[self.contentView addSubview:_adressLabel];
NSLayoutConstraint *titleImageTop = [NSLayoutConstraint constraintWithItem:_adressLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.detailsLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
[self.contentView addConstraint:titleImageTop];
NSLayoutConstraint *titleImageLeft = [NSLayoutConstraint constraintWithItem:_adressLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.titleImageView attribute:NSLayoutAttributeRight multiplier:1.0 constant:10];
[self.contentView addConstraint:titleImageLeft];
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_adressLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-15];
[self.contentView addConstraint:titleRight];
NSLayoutConstraint *titleImageHeight = [NSLayoutConstraint constraintWithItem:_adressLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:23];
[self.contentView addConstraint:titleImageHeight];
}
return _adressLabel;
}
- (UILabel *)dateLabel
{
if (!_dateLabel) {
......@@ -165,16 +218,16 @@
[self.contentView addSubview:_dateLabel];
NSLayoutConstraint *titleImageTop = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:5];
NSLayoutConstraint *titleImageTop = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:7];
[self.contentView addConstraint:titleImageTop];
NSLayoutConstraint *titleImageLeft = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:15];
NSLayoutConstraint *titleImageLeft = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.titleImageView attribute:NSLayoutAttributeRight multiplier:1.0 constant:10];
[self.contentView addConstraint:titleImageLeft];
NSLayoutConstraint *titleRight = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.thumbBtn attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
[self.contentView addConstraint:titleRight];
NSLayoutConstraint *titleImageHeight = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:35];
NSLayoutConstraint *titleImageHeight = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:25];
[self.contentView addConstraint:titleImageHeight];
NSLayoutConstraint *titleImageBottom = [NSLayoutConstraint constraintWithItem:_dateLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-5];
......@@ -194,7 +247,7 @@
_thumbBtn.titleLabel.font = [UIFont systemFontOfSize:16.0];
[self.contentView addSubview:_thumbBtn];
NSLayoutConstraint *titleImageTop = [NSLayoutConstraint constraintWithItem:_thumbBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:12];
NSLayoutConstraint *titleImageTop = [NSLayoutConstraint constraintWithItem:_thumbBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:8];
[self.contentView addConstraint:titleImageTop];
NSLayoutConstraint *titleImageWidth = [NSLayoutConstraint constraintWithItem:_thumbBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.commentBtn attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0];
......@@ -219,7 +272,7 @@
_commentBtn.titleLabel.font = [UIFont systemFontOfSize:16.0];
[self.contentView addSubview:_commentBtn];
NSLayoutConstraint *titleImageTop = [NSLayoutConstraint constraintWithItem:_commentBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:12];
NSLayoutConstraint *titleImageTop = [NSLayoutConstraint constraintWithItem:_commentBtn attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.titleImageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:8];
[self.contentView addConstraint:titleImageTop];
NSLayoutConstraint *titleImageWidth = [NSLayoutConstraint constraintWithItem:_commentBtn attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:70];
......
......@@ -47,7 +47,7 @@
self.scopeTableView = [[ScopeTableView alloc] init];
self.scopeTableView = [[ScopeTableView alloc] initWithTitle:[NSMutableArray arrayWithObjects:@"所有口碑", @"我的口碑", nil]];
GroupItems *scopeItem = [[GroupItems alloc] initWithTitle:@"问题范围" view:_scopeTableView];
self.textView1 = [[UITextView alloc] init];
......
......@@ -9,5 +9,6 @@
#import <UIKit/UIKit.h>
@interface PictureViewController : UIViewController
@property (nonatomic, strong) NSString *come;
@property (nonatomic, strong) NSString *category;
@end
......@@ -67,6 +67,8 @@
[self setupNav];
self.view.backgroundColor = [UIColor whiteColor];
self.menuView.backgroundColor = kInspectSectionBackGroundColor;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
......@@ -76,7 +78,6 @@
self.navigationController.navigationBar.translucent = NO;
}
_page = 0;
}
......@@ -86,7 +87,7 @@
{
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"图说口碑"];
[customLab setText:@"商场风采"];
customLab.font = [UIFont boldSystemFontOfSize:19];
self.navigationItem.titleView = customLab;
......@@ -110,17 +111,22 @@
-(void)doBack:(id)sender
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
if ([self.come isEqualToString:@"首页"]) {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}
- (void)addClick:(UIButton *)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"当前功能正在开发!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"当前功能正在开发!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
// [alert show];
// AddPictureViewController *addPic = [[AddPictureViewController alloc] init];
// [self.navigationController pushViewController:addPic animated:YES];
AddPictureViewController *addPic = [[AddPictureViewController alloc] init];
addPic.category = self.category;
[self.navigationController pushViewController:addPic animated:YES];
}
- (void)requestPicturePraise
......@@ -130,11 +136,14 @@
// 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQueryPicturePraiseURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{
@"scope":@"all",
@"user":user_uuid,
// @"scope":@"all",
@"type":self.category,
@"pageNumber":@(0),
@"pageSize":@(10)
@"pageSize":pageSize
};
// 发起请求
......@@ -178,10 +187,14 @@
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQueryPicturePraiseURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{
@"scope":@"all",
@"user":user_uuid,
@"type":self.category,
@"pageNumber":@(_page),
@"pageSize":@(10)
@"pageSize":pageSize
};
// 发起请求
......@@ -381,12 +394,15 @@
// 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQueryPicturePraiseURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
user_uuid,@"user",
@(0),@"pageNumber",
@(10),@"pageSize", nil];
pageSize,@"pageSize",
self.category,@"type",
@"all",@"scope",
nil];
// 发起请求
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
......@@ -553,11 +569,13 @@
queryOrders = @[@{@"field":@"likeCount",
@"direction":@"asc"}];
}
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{@"user":user_uuid,
@"pageNumber":@(_page),
@"pageSize":@(10),
@"queryOrders":queryOrders
@"pageSize":pageSize,
@"queryOrders":queryOrders,
@"type":self.category,
@"scope":@"all"
};
// 发起请求
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
......
......@@ -47,7 +47,7 @@
self.scopeTableView = [[ScopeTableView alloc] init];
self.scopeTableView = [[ScopeTableView alloc] initWithTitle:[NSMutableArray arrayWithObjects:@"全部问题",@"我的问题", nil]];
GroupItems *scopeItem = [[GroupItems alloc] initWithTitle:@"问题范围" view:_scopeTableView];
self.groupTableView = [[GroupTableView alloc] init];
......
......@@ -16,4 +16,6 @@
@interface ScopeTableView : UITableView
@property (nonatomic, assign) id <ScopeTableViewDelegate>scopeDeleagte;
- (instancetype)initWithTitle:(NSMutableArray *)titleArray;
@end
......@@ -14,6 +14,16 @@
@implementation ScopeTableView
- (instancetype)initWithTitle:(NSMutableArray *)titleArray
{
self = [super init];
if (self) {
_titleArray = titleArray;
[self setup];
}
return self;
}
- (instancetype)init
{
self = [super init];
......@@ -35,7 +45,7 @@
- (void)setup
{
self.titleArray = [NSMutableArray arrayWithObjects:@"全部问题",@"我的问题", nil];
// self.titleArray = [NSMutableArray arrayWithObjects:@"全部问题",@"我的问题", nil];
self.delegate = self;
self.dataSource = self;
......
......@@ -156,12 +156,12 @@
// 请求地址
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
// 请求参数
NSDictionary *parameters = @{@"user":user_uuid,
@"scope":@"all",
@"pageNumber":@(_page),
@"pageSize":@(10)
@"pageSize":pageSize
};
// 发起请求
......@@ -444,11 +444,11 @@
NSString *urlStr = [NSString stringWithFormat:@"%@%@", kRedStarURL, kQuestionListURL];
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
user_uuid,@"user",
@(0),@"pageNumber",
@(10),@"pageSize", nil];
pageSize,@"pageSize", nil];
// 发起请求
HttpClient *httpClient = [[HttpClient alloc] initWithUrl:urlStr];
......
......@@ -11,10 +11,14 @@
#import "GroupItems.h"
#import "SOPTableView.h"
#import "HttpClient.h"
#import "AttachmentTableViewCell.h"
#import "AttachmentModel.h"
#define kAttachmentTableCell @"sopAttachmentCell"
#define SELECTED_VIEW_CONTROLLER_TAG 39998
@interface SOPViewController () <GroupTabBarDelegate, SOPTableViewDelegate>
@interface SOPViewController () <GroupTabBarDelegate, SOPTableViewDelegate, UITableViewDelegate, UITableViewDataSource, UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) GroupTabBar *groupTabBar;
@property (nonatomic, strong) NSArray *titleArray;
......@@ -33,6 +37,10 @@
@property (nonatomic, strong) UIButton *resetBtn;
@property (nonatomic, strong) UIButton *queryBtn;
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *attachmentArray;
@end
......@@ -49,6 +57,8 @@
self.navigationController.navigationBar.translucent = NO;
}
self.attachmentArray = [NSMutableArray array];
self.titleArray = [NSArray arrayWithObjects:@"质量管理",@"价格管理",@"现场服务",@"售后服务",@"环境管理",@"现场管理", @"400呼叫管理",@"单品管理",nil];
......@@ -79,16 +89,140 @@
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kGetAttachmentsURL];
HttpClient *http = [[HttpClient alloc] initWithUrl:url];
NSDictionary *parameters = @{@"type":@"sop",
// @"category1":_titleArray[_groupTabBar.selectNumber],
// @"category2":_detailTitle
@"category1":@"11",
@"category2":@"22"
@"encode":@"123"
};
[http getAttachmentsWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"7.1 口碑标注附件列表 = %@, error = %@", response, error);
NSArray *dataArray = response[@"data"];
for (NSDictionary *attaDict in dataArray) {
AttachmentModel *atta = [[AttachmentModel alloc] init];
[atta setValuesForKeysWithDictionary:attaDict];
[_attachmentArray addObject:atta];
}
CGFloat tableH = _attachmentArray.count * 45;
if (!_bgView) {
_bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeRedView)];
[_bgView addGestureRecognizer:tapGR];
}
CGRect toFrame = CGRectMake(0, 0, kScreenWidth - 50, tableH + 40);
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:toFrame style:UITableViewStyleGrouped];
_tableView.backgroundColor = [UIColor whiteColor];
}
_tableView.delegate = self;
_tableView.dataSource = self;
[self.view addSubview:_bgView];
[self.view insertSubview:_tableView aboveSubview:_bgView];
_bgView.alpha = 0;
_bgView.backgroundColor = [UIColor blackColor];
_tableView.alpha = 0.0;
_tableView.center = CGPointMake( _bgView.center.x, _bgView.center.y - 74);
[UIView animateWithDuration:0.3 animations:^{
_bgView.alpha = 0.6;
_tableView.alpha = 1.0;
}];
}];
}
- (void)closeRedView
{
[UIView animateWithDuration:0.3 animations:^{
_bgView.alpha = .0f;
_tableView.alpha = 0.0;
} completion:^(BOOL finished) {
[_bgView removeFromSuperview];
[_tableView removeFromSuperview];
}];
}
- (void)showFile:(UIButton *)sender
{
NSInteger row = sender.tag - 998473;
AttachmentModel *atta = _attachmentArray[row];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = paths.lastObject;
NSString *url = [NSString stringWithFormat:@"%@/%@", path, atta.fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:url]) {
UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:url]];//为该对象初始化一个加载路径
docController.delegate = self;//设置代理
[docController presentPreviewAnimated:YES];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"文件不存在,请先下载在查看!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
}
}
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
return self;
}
- (void)downloadFile:(UIButton *)sender
{
NSInteger row = sender.tag - 998473;
AttachmentModel *atta = _attachmentArray[row];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = paths.lastObject;
[self downloadFileURL:[NSString stringWithFormat:@"%@%@", kRedStarURL, atta.fileUrl] savePath:path fileName:atta.fileName];
}
- (void)downloadFileURL:(NSString *)aUrl savePath:(NSString *)aSavePath fileName:(NSString *)aFileName
{
NSFileManager *fileManager = [NSFileManager defaultManager];
//检查本地文件是否已存在
NSString *fileName = [NSString stringWithFormat:@"%@/%@", aSavePath, aFileName];
//检查附件是否存在
if ([fileManager fileExistsAtPath:fileName]) {
NSLog(@"存在了");
}else{
NSLog(@"不存在");
//创建附件存储目录
if (![fileManager fileExistsAtPath:aSavePath]) {
[fileManager createDirectoryAtPath:aSavePath withIntermediateDirectories:YES attributes:nil error:nil];
}
//下载附件
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 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"下载成功");
[self.tableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"下载失败");
}];
[operation start];
}
}
- (void)setupNav
{
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
......@@ -177,7 +311,68 @@
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - UITableView Delegate/DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _attachmentArray.count;
}
// cell显示的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AttachmentTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:kAttachmentTableCell];
if (!cell) {
cell = [[AttachmentTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kAttachmentTableCell];
}
AttachmentModel *atta = _attachmentArray[indexPath.row];
NSString *name = atta.fileName;
[cell.nameBtn setTitle:name forState:UIControlStateNormal];
[cell.nameBtn addTarget:self action:@selector(showFile:) forControlEvents:UIControlEventTouchUpInside];
[cell.downloadBtn addTarget:self action:@selector(downloadFile:) forControlEvents:UIControlEventTouchUpInside];
cell.downloadBtn.tag = 998473 + indexPath.row;
cell.nameBtn.tag = 998473 + indexPath.row;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = paths.lastObject;
NSString *url = [NSString stringWithFormat:@"%@/%@", path, atta.fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:url]) {
cell.downloadBtn.selected = YES;
cell.downloadBtn.backgroundColor = [UIColor grayColor];
} else {
cell.downloadBtn.selected = NO;
cell.downloadBtn.backgroundColor = [UIColor colorWithRed:47 / 255.0 green:209/ 255.0 blue:92 / 255.0 alpha:1.0];
}
return cell;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 40)];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, kScreenWidth - 20, 40)];
label.text = @"附件";
label.textColor = kNavigationBarColor;
label.font = [UIFont systemFontOfSize:14.0];
[view addSubview:label];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 40;
}
#pragma mark - SOPTableViewDelegate
- (void)selectRowWithDetailTitle:(NSString *)detailTitle
......
......@@ -116,14 +116,14 @@
- (void)requestMoreList
{
_page++;
NSLog(@"_page = %d", (int)_page);
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{
@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":@[@{@"field":@"lastModifyInfo", @"direction":@"desc"}],
@"pageNumber":@(_page),
@"pageSize":@(10)
@"pageSize":pageSize
};
[httpCilent getInspectListWithParameters:parameters completion:^(id response, NSError *error) {
......@@ -155,11 +155,13 @@
{
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{
@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":@[@{@"field":@"lastModifyInfo", @"direction":@"desc"}],
@"pageNumber":@(0),
@"pageSize":@(10)
@"pageSize":pageSize
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
......@@ -211,11 +213,13 @@
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{
@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":@[@{@"field":@"lastModifyInfo", @"direction":@"desc"}],
@"pageNumber":@(0),
@"pageSize":@(10)
@"pageSize":pageSize
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
......@@ -422,12 +426,12 @@
{
NSString *url = [NSString stringWithFormat:@"%@%@", kRedStarURL, kInspectListURL];
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:url];
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],@"userUuid",
@[],@"queryOrders",
@(0),@"pageNumber",
@(10),@"pageSize", nil];
pageSize,@"pageSize", nil];
if (_screenView.groupTabBar.selectNumber == 0) {
......@@ -607,11 +611,11 @@
queryOrders = @[@{@"field":@"lastModifyInfo",
@"direction":@"asc"}];
}
NSNumber *pageSize = [[NSUserDefaults standardUserDefaults] objectForKey:@"requestNumber"];
NSDictionary *parameters = @{@"userUuid":[[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"],
@"queryOrders":queryOrders,
@"pageNumber":@(0),
@"pageSize":@(10)
@"pageSize":pageSize
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[httpCilent getInspectListWithParameters:parameters completion:^(id response, NSError *error) {
......
......@@ -80,7 +80,7 @@
UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
[customLab setTextColor:[UIColor whiteColor]];
[customLab setText:@"口碑排名"];
[customLab setText:@"口碑报告"];
customLab.font = [UIFont boldSystemFontOfSize:19];
self.navigationItem.titleView = customLab;
......@@ -138,7 +138,7 @@
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
__block RankingListViewController *weakSelf = self;
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"口碑排名response = %@", response);
NSLog(@"口碑报告response = %@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
......@@ -212,7 +212,7 @@
NSLog(@"parrrrrters = %@", parameters);
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[httpCilent getRankingListWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"分区域 口碑排名response = %@ error = %@", response, error);
NSLog(@"分区域 口碑报告response = %@ error = %@", response, error);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
......
......@@ -15,7 +15,7 @@
#import "HttpClient.h"
@interface MineViewController () <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate>
@interface MineViewController () <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate, UIActionSheetDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *titleArray;
......@@ -26,6 +26,9 @@
@property (nonatomic, strong) MineTableFooterView *footView;
@property (nonatomic, copy) NSString *jumpURL;
@property (nonatomic, strong) UIActionSheet *numberActionSheet;
@end
@implementation MineViewController
......@@ -50,7 +53,7 @@
self.view.backgroundColor = kSectionBackGroundColor;
self.titleArray = [NSMutableArray arrayWithObjects:@"配置项目",@"配置",@"帮助与反馈",@"关于",@"检查版本更新", nil];
self.titleArray = [NSMutableArray arrayWithObjects:@"配置",@"关于",@"检查版本更新", nil];
[self setupTableView];
......@@ -189,11 +192,15 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 4) {
if (indexPath.row == 2) {
[self getVersion];
} else if (indexPath.row == 3) {
} else if (indexPath.row == 1) {
AboutMeViewController *about = [[AboutMeViewController alloc] init];
[self.navigationController pushViewController:about animated:YES];
} else {
self.numberActionSheet = [[UIActionSheet alloc] initWithTitle:@"请求数量" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"10",@"20",@"30",@"40", @"50", nil];
[_numberActionSheet showInView:self.view];
}
}
......@@ -209,6 +216,24 @@
return 20;
}
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) {
[[NSUserDefaults standardUserDefaults] setObject:@(10) forKey:@"requestNumber"];
} else if (buttonIndex == 1){
[[NSUserDefaults standardUserDefaults] setObject:@(20) forKey:@"requestNumber"];
} else if (buttonIndex == 2){
[[NSUserDefaults standardUserDefaults] setObject:@(30) forKey:@"requestNumber"];
} else if (buttonIndex == 3){
[[NSUserDefaults standardUserDefaults] setObject:@(40) forKey:@"requestNumber"];
} else if (buttonIndex == 4){
[[NSUserDefaults standardUserDefaults] setObject:@(50) forKey:@"requestNumber"];
}
}
#pragma mark - lazy loading
- (UITableView *)tableView
{
......
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