This commit is contained in:
lianxiang
2018-09-23 15:52:02 +08:00
parent 3508cab25e
commit 69522b22fc
13 changed files with 476 additions and 36 deletions
@@ -14,8 +14,12 @@
#import "SJPhotoPicker.h"
#import "GiGaNetManager.h"
#import "GiGaAPIResult.h"
#import "GiGaFeedBackKindView.h"
#import "GIGaUserFileHelper.h"
#import "GiGaServerConfig.h"
@interface GiGaFeedBackViewController ()
@property(nonatomic,strong) NSMutableArray *imagesUrl;
@end
@@ -24,7 +28,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self addNavTitile:@"意见反馈"];
_imagesUrl = [NSMutableArray new];
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
@@ -107,6 +111,18 @@
return nil;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
GiGaFeedBackKindView *piker = [GiGaFeedBackKindView showAt:self atRow:0];
piker.selectedItemBlock = ^(NSString *tile) {
GiGaFeedLeiIingViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.kidLabel.text = tile;
};
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section == 0) {
return 40;
@@ -151,10 +167,8 @@
#pragma mark 提交
-(void)tijiaoAction{
GIGaFeedPhontosViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:3]];
NSArray *names =cell.imageNames;
NSLog(@"names:%@",names);
GiGaFeedLeiIingViewCell *kindcell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
if ([kindcell.kidLabel.text isEqualToString:@"选择反馈类型"]) {
@@ -173,24 +187,145 @@
if (qqcell.QTextFiled.text.length == 0) {
qqcell.QTextFiled.text = @"";
}
NSDictionary *dic =nil;
NSString *qqcom = qqcell.QTextFiled.text;
if (!qqcom) {
dic = @{@"type":kindcell.kidLabel.text,@"content":contencell.contentFiled.text};
}else{
dic = @{@"type":kindcell.kidLabel.text,@"content":contencell.contentFiled.text,@"contact":qqcom
};
}
[self.imagesUrl removeAllObjects];
[self uploadImags:dic];
}
//先上传图片获取到 imageurls 再 提交内容信息
-(void)uploadImags:(NSDictionary *)params{
GIGaFeedPhontosViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:3]];
NSArray *names =cell.imageNames;
if (names.count <= 0) {
GIGA_ShowToast(@"请选择图片");
return;
}
NSLog(@"names:%@",names);
[self.view makeToastActivity:CSToastPositionCenter];
//.串行队列同步执行:任务都在当前线程执行(同步),并且顺序执行(串行)
dispatch_queue_t queue = dispatch_queue_create("serialQueue", DISPATCH_QUEUE_SERIAL);
[GiGaNetManager uploadImage:@"sys/sysdict/v1/maskproposaltype" imageNames:names parms:@{} responseBlock:^(NSDictionary *responseDict, NSDictionary *responseHeaderFields, NSError *error) {
for (NSUInteger i= 0; i < names.count; i ++) {
dispatch_sync(queue, ^{
NSLog(@"上船图片%ld **** %@",i,names[i]);
UIImage *image =[GIGaUserFileHelper getUserFeedbackImag:names[i]] ;
if (!image) {
GILog(@"获取图片:************%@ nil",names[i]);
return;
}
NSData*imageData=UIImageJPEGRepresentation(image,1.0f);
[self uploadImage:imageData name:names[i] info:params totalCount:names.count];
});
}
}
// 单张上传
-(void)uploadImage:(NSData *)imageData name:(NSString *)name info:(NSDictionary *)info totalCount:(NSInteger)count{
[self.view makeToastActivity:CSToastPositionCenter];
NSString *url = [NSString stringWithFormat:@"%@%@",[GiGaServerConfig getMainUrl],kUploadFeed];
[GiGaNetManager uploadImage:url imgData:imageData parms:@{@"file":@"file"} responseBlock:^(NSDictionary *responseDict, NSDictionary *responseHeaderFields, NSError *error) {
[self.view hideToastActivity];
GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:responseDict];
if (result.success) {
NSString *url = responseDict[@"url"];
if (url) {
[self.imagesUrl addObject:url];
NSLog(@"上船图片%@成功",name);
NSLog(@"当前获取图片数组:%@",self.imagesUrl);
if (self.imagesUrl.count == count) {
[self uploadFeedinfo:info imgUrlList:self.imagesUrl];
}
}
}else if (result.code == 401){
GIGA_WIndowTost(@"登录超时,请重新登录");
[GiGaBaseAPiRequest userTokenTimeOutGologinFromVC:self];
}else{
GIGA_ShowToast(result.message);
}
}];
}
//body 传参数
-(void)uploadFeedinfo:(NSDictionary*)params imgUrlList:(NSArray *)urlArr{
NSMutableDictionary *finallyparam = [NSMutableDictionary dictionaryWithDictionary:params];
[finallyparam setObject:urlArr forKey:@"imgUrlList"];
NSLog(@"finallyparam%@",finallyparam);
[self.view makeToastActivity:CSToastPositionCenter];
NSString *url = [NSString stringWithFormat:@"%@%@",[GiGaServerConfig getMainUrl],kAPiUpLoadFeeeds];
[GiGaNetManager userbodyRequest:url params:finallyparam completionHandler:^(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error) {
[self.view hideToastActivity];
if (error) {
GILog(@"err:%@",error.localizedDescription);
}else{
GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:responseDict];
GIGA_ShowToast(result.message);
GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:resDic];
if (result.success) {
GIGA_ShowToast(@"🙏感谢提出宝贵意见!🙏");
}else if (result.code == 401){
GIGA_WIndowTost(@"登录超时,请重新登录");
[GiGaBaseAPiRequest userTokenTimeOutGologinFromVC:self];
}else{
GIGA_ShowToast(result.message);
}
}
}];
}
//多张
-(void)mutipuleUpload{
// [GiGaNetManager uploadImage:kUploadFeed imageNames:names parms:@{@"file":@"file"} responseBlock:^(NSDictionary *responseDict, NSDictionary *responseHeaderFields, NSError *error) {
// [self.view hideToastActivity];
// if (error) {
// GILog(@"err:%@",error.localizedDescription);
// GIGA_ShowToast(@"error");
//
// }else{
// GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:responseDict];
// GIGA_ShowToast(result.message);
// if (result.success) {
//
// GIGA_ShowToast(result.message);
// [self uploadFeedinfo:params imgUrlList:@[]];
//
// }else if (result.code == 401){
// GIGA_WIndowTost(@"登录超时,请重新登录");
// [GiGaBaseAPiRequest userTokenTimeOutGologinFromVC:self];
//
// }else{
// GIGA_ShowToast(result.message);
// }
// }
// }];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.