diff --git a/GIGA.xcodeproj/project.pbxproj b/GIGA.xcodeproj/project.pbxproj index 116e732..28092b6 100644 --- a/GIGA.xcodeproj/project.pbxproj +++ b/GIGA.xcodeproj/project.pbxproj @@ -203,6 +203,8 @@ 839290092134F4C40077D2E8 /* GiGaFlingCommitVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 839290082134F4C40077D2E8 /* GiGaFlingCommitVC.m */; }; 8392900C2134F9F80077D2E8 /* GiGaCommentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8392900A2134F9F80077D2E8 /* GiGaCommentView.m */; }; 8392900F2134FA0A0077D2E8 /* GiGaCommentModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8392900E2134FA0A0077D2E8 /* GiGaCommentModel.m */; }; + 83A1DDAF21573D01006DE881 /* GiGaFeedBackKindView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83A1DDAE21573D01006DE881 /* GiGaFeedBackKindView.m */; }; + 83A1DDB221574807006DE881 /* GIGaFeedKind.m in Sources */ = {isa = PBXBuildFile; fileRef = 83A1DDB121574807006DE881 /* GIGaFeedKind.m */; }; 83A2270C212A97ED00B3E75C /* MaskViewBootomWaringView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83A2270B212A97ED00B3E75C /* MaskViewBootomWaringView.m */; }; 83A22712212A9EA900B3E75C /* UIView+Sizes.m in Sources */ = {isa = PBXBuildFile; fileRef = 83A22710212A9EA900B3E75C /* UIView+Sizes.m */; }; 83A22718212ABDFF00B3E75C /* GiGaBlockButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 83A22717212ABDFF00B3E75C /* GiGaBlockButton.m */; }; @@ -593,6 +595,10 @@ 8392900B2134F9F80077D2E8 /* GiGaCommentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiGaCommentView.h; sourceTree = ""; }; 8392900D2134FA0A0077D2E8 /* GiGaCommentModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiGaCommentModel.h; sourceTree = ""; }; 8392900E2134FA0A0077D2E8 /* GiGaCommentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiGaCommentModel.m; sourceTree = ""; }; + 83A1DDAD21573D01006DE881 /* GiGaFeedBackKindView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaFeedBackKindView.h; sourceTree = ""; }; + 83A1DDAE21573D01006DE881 /* GiGaFeedBackKindView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaFeedBackKindView.m; sourceTree = ""; }; + 83A1DDB021574807006DE881 /* GIGaFeedKind.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GIGaFeedKind.h; sourceTree = ""; }; + 83A1DDB121574807006DE881 /* GIGaFeedKind.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GIGaFeedKind.m; sourceTree = ""; }; 83A2270A212A97ED00B3E75C /* MaskViewBootomWaringView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MaskViewBootomWaringView.h; sourceTree = ""; }; 83A2270B212A97ED00B3E75C /* MaskViewBootomWaringView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MaskViewBootomWaringView.m; sourceTree = ""; }; 83A22710212A9EA900B3E75C /* UIView+Sizes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Sizes.m"; sourceTree = ""; }; @@ -1067,6 +1073,8 @@ 8357ADC42123BEBD000816F2 /* GiGaUser.m */, 8342FD842150FD5200D141F4 /* VersionModel.h */, 8342FD852150FD5200D141F4 /* VersionModel.m */, + 83A1DDB021574807006DE881 /* GIGaFeedKind.h */, + 83A1DDB121574807006DE881 /* GIGaFeedKind.m */, ); path = Model; sourceTree = ""; @@ -1203,6 +1211,8 @@ 8382DFBB21563C2D00BBA5A5 /* GiGaFeedImagsActionCell.h */, 8382DFBC21563C2D00BBA5A5 /* GiGaFeedImagsActionCell.m */, 8382DFBD21563C2D00BBA5A5 /* GiGaFeedImagsActionCell.xib */, + 83A1DDAD21573D01006DE881 /* GiGaFeedBackKindView.h */, + 83A1DDAE21573D01006DE881 /* GiGaFeedBackKindView.m */, ); path = FeedViews; sourceTree = ""; @@ -1920,6 +1930,7 @@ 83901176214E20B2004CA790 /* LYSDatePickerTypeDayDelegate.m in Sources */, 8384643E214A484400F12B33 /* MaskTestResult.m in Sources */, 83346AD4212BFF6E0054D597 /* UserGuardViewController.m in Sources */, + 83A1DDAF21573D01006DE881 /* GiGaFeedBackKindView.m in Sources */, 83BC8A8A2148D28300820437 /* QustionAnswer.m in Sources */, 8342FD7D2150F94600D141F4 /* AppVerionDescriptionVC.m in Sources */, 8357ADC92123BFCA000816F2 /* GiGaUserManager.m in Sources */, @@ -1956,6 +1967,7 @@ 8382DFE921564A1F00BBA5A5 /* SJAlbumModel.m in Sources */, 83773FC221479FED0014EE4C /* UIColor+HexColor.m in Sources */, 8382DFEE21564A1F00BBA5A5 /* SJPhotoPickerManager.m in Sources */, + 83A1DDB221574807006DE881 /* GIGaFeedKind.m in Sources */, 83901172214E20B2004CA790 /* LYSDatePickerTypeDayAndTimeDelegate.m in Sources */, 835060A9212D38EE007E6220 /* GiGaStartAdView.m in Sources */, 83928FFA2134D8F60077D2E8 /* GiGaFlyingCommitInputView.m in Sources */, diff --git a/GIGA/AppDelegate.m b/GIGA/AppDelegate.m index dc68b0f..d0212e2 100644 --- a/GIGA/AppDelegate.m +++ b/GIGA/AppDelegate.m @@ -12,6 +12,7 @@ #import "GiGaUserDefault.h" #import "JPUSHService.h" #import "GiGaLocalNotificationManager.h" +#import "GiGaBaseAPiRequest.h" @interface AppDelegate () //保持后台长时间运行 @@ -41,7 +42,12 @@ BOOL islogin = [GiGaUserDefault isUserLogin]; if (islogin) { - [[GiGaUserManager shareUser] synsisUserInfo:nil userErrorMsgBlock:nil]; + [[GiGaUserManager shareUser] synsisUserInfo:nil userErrorMsgBlock:^(NSDictionary *errorCodemsg) { + if ([errorCodemsg[@"code"] integerValue] == 401) { + //token失效 + [GiGaBaseAPiRequest userTokenTimeOutGologinFromVC:self.window.rootViewController]; + } + }]; } return YES; diff --git a/GIGA/Common/GiGaNetTool/GiGaBaseAPiRequest.m b/GIGA/Common/GiGaNetTool/GiGaBaseAPiRequest.m index 7d8c89e..f2d73cf 100644 --- a/GIGA/Common/GiGaNetTool/GiGaBaseAPiRequest.m +++ b/GIGA/Common/GiGaNetTool/GiGaBaseAPiRequest.m @@ -90,7 +90,6 @@ } NSLog(@" %@", _fullUrl); // NSMutableDictionary *postDict = [self buildRequestDict]; - [GiGaNetManager requestMethod:self.requestMethod Url:self.fullUrl params:self.params responseBlock:^(NSDictionary *responseDict, NSDictionary *responseHeaderFields, NSError *error) { [self analyseResponseInfo:responseDict headerFileds:responseHeaderFields error:error]; diff --git a/GIGA/Common/GiGaNetTool/GiGaNetManager.m b/GIGA/Common/GiGaNetTool/GiGaNetManager.m index 1eb029b..ac555f8 100644 --- a/GIGA/Common/GiGaNetTool/GiGaNetManager.m +++ b/GIGA/Common/GiGaNetTool/GiGaNetManager.m @@ -199,12 +199,7 @@ [manager POST:fullurl parameters:parms constructingBodyWithBlock:^(id _Nonnull formData) { for (NSUInteger i= 0; i < imageNames.count; i ++) { - //上传时使用当前的系统事件作为文件名 -// NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; -// -// formatter.dateFormat = @"yyyyMMddHHmmss"; -// -// NSString *str = [formatter stringFromDate:[NSDate date]]; + NSString *fileName = [NSString stringWithFormat:@"%@.png", imageNames[i]]; //服务器上传文件的字段和类型 diff --git a/GIGA/Common/GiGaUserDB/GIGaUserFileHelper.m b/GIGA/Common/GiGaUserDB/GIGaUserFileHelper.m index 9244b02..457f243 100644 --- a/GIGA/Common/GiGaUserDB/GIGaUserFileHelper.m +++ b/GIGA/Common/GiGaUserDB/GIGaUserFileHelper.m @@ -150,22 +150,38 @@ NSData*imageData=UIImagePNGRepresentation(image); - NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:[NSString stringWithFormat:@"gigafeed/%@.png",imagename]]; - NSLog(@"fullPath%@",fullPath); - [imageData writeToFile:fullPath atomically:YES]; + NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; + + NSString *savePath = nil; + savePath = [NSString stringWithFormat:@"%@/gigafee/%@",rootPath,imagename]; + + NSFileManager *manager = [NSFileManager defaultManager]; + if(![manager fileExistsAtPath:savePath]){ + [manager createDirectoryAtPath:savePath withIntermediateDirectories:YES attributes:nil error:nil]; + } + [imageData writeToFile:[NSString stringWithFormat:@"%@/%@.png",savePath,imagename] atomically:YES]; + } +(UIImage *)getUserFeedbackImag:(NSString *)imageName{ - NSString*fullpath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:[NSString stringWithFormat:@"gigafeed/%@.png",imageName]]; - UIImage*saveImage=[[UIImage alloc]initWithContentsOfFile:fullpath]; + NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; + + NSString *filePath = nil; + filePath = [NSString stringWithFormat:@"%@/gigafee/%@/%@.png",rootPath,imageName,imageName]; + NSLog(@"获取Path:%@",filePath); + UIImage *Img = [UIImage imageWithContentsOfFile:filePath]; + + return Img; - return saveImage; } +(void)delectAllfeedimages{ - NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:[NSString stringWithFormat:@"gigafeed/"]]; - NSFileManager *fileManager = [NSFileManager defaultManager];[fileManager removeItemAtPath:fullPath error:nil]; + NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; + + NSString *filePath = nil; + filePath = [NSString stringWithFormat:@"%@/gigafee/",rootPath]; + NSFileManager *fileManager = [NSFileManager defaultManager];[fileManager removeItemAtPath:filePath error:nil]; } diff --git a/GIGA/Common/GiGaUserDB/GiGaUserManager.m b/GIGA/Common/GiGaUserDB/GiGaUserManager.m index 6ce50f1..325a20e 100644 --- a/GIGA/Common/GiGaUserDB/GiGaUserManager.m +++ b/GIGA/Common/GiGaUserDB/GiGaUserManager.m @@ -66,9 +66,11 @@ const static NSInteger GIGADB_USER_VER = 0;//当前数据库版本号 } NSLog(@"user dic ***\n%@",result.dic); }else{ + if (errorCodeMsg) { errorCodeMsg(requst.resultDict); } + } }]; diff --git a/GIGA/Config/ApiRequestConfig.h b/GIGA/Config/ApiRequestConfig.h index 3b72786..8c26d80 100644 --- a/GIGA/Config/ApiRequestConfig.h +++ b/GIGA/Config/ApiRequestConfig.h @@ -17,8 +17,10 @@ #define kApiOccuption @"sys/sysdict/v1/maskoccupation" //修改用户信息 #define kFixUserInfo @"user/v1/editinfo" -//头像上传 +//头像上传 上传多张反馈 #define kUploadAvator @"sys/oss/v1/upload" +#define kUploadFeed @"sys/oss/v1/upload" + //版本说明 #define kAPiAPPVersion @"sys/maskversionarticle/v1/list" //修改密码 @@ -33,6 +35,10 @@ #define kApiChangePassSendCode @"msg/sms/v1/retrievesendcode" //异步验证手机验证码 #define kApiVersifyPhoneCode @"v1/user/v1/validateSmsCode" +//获取意见反馈类型 (设置意见反馈) +#define kApiGetFeedList @"sys/sysdict/v1/maskproposaltype" +//意见建议 +#define kAPiUpLoadFeeeds @"sys/proposal/v1/save" diff --git a/GIGA/Modules/Mask/Exercises/Controller/GiGaQuestionVC.m b/GIGA/Modules/Mask/Exercises/Controller/GiGaQuestionVC.m index 5c399ab..2e9a6ab 100644 --- a/GIGA/Modules/Mask/Exercises/Controller/GiGaQuestionVC.m +++ b/GIGA/Modules/Mask/Exercises/Controller/GiGaQuestionVC.m @@ -366,25 +366,32 @@ [GiGaNetManager userbodyRequest:url params:params completionHandler:^(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error) { [self.view hideToastActivity]; GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:resDic]; + if (result.success) { + MaskTestResult* mode = [[MaskTestResult alloc] initWithDictionary:resDic error:nil]; + [self userTestEnd:mode]; + }else{ + GIGA_ShowToast(result.message); + } GILog(@"**测试结果***\n code:%ld\n message:%@\n *******\n dic:%@",result.code,result.message,result.dic); - [self userTestEnd]; + + }]; } --(void)userTestEnd{ +-(void)userTestEnd:(MaskTestResult*)model{ BOOL isUserLogin = [GiGaUserDefault isUserLogin]; if (isUserLogin) { //展示结果 - NSDictionary *dic = @{ - @"dryness":@"0.41", - @"drynessPercent":@"41%", - @"mask":@"", - @"minute":@"19", - @"oiliness":@"0.59", - @"oilinessPercent":@"59%" - }; - MaskTestResult *model =[[MaskTestResult alloc] initWithDictionary:dic error:nil]; +// NSDictionary *dic = @{ +// @"dryness":@"0.41", +// @"drynessPercent":@"41%", +// @"mask":@"", +// @"minute":@"19", +// @"oiliness":@"0.59", +// @"oilinessPercent":@"59%" +// }; +// MaskTestResult *model =[[MaskTestResult alloc] initWithDictionary:dic error:nil]; MaskTestResultVC *resultVC = [[MaskTestResultVC alloc] init]; resultVC.model = model; [self.navigationController pushViewController:resultVC animated:YES]; diff --git a/GIGA/Modules/Me/Controller/GiGaFeedBackViewController.m b/GIGA/Modules/Me/Controller/GiGaFeedBackViewController.m index 6dd1c1d..430f89d 100644 --- a/GIGA/Modules/Me/Controller/GiGaFeedBackViewController.m +++ b/GIGA/Modules/Me/Controller/GiGaFeedBackViewController.m @@ -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. diff --git a/GIGA/Modules/Me/Model/GIGaFeedKind.h b/GIGA/Modules/Me/Model/GIGaFeedKind.h new file mode 100644 index 0000000..fb3f250 --- /dev/null +++ b/GIGA/Modules/Me/Model/GIGaFeedKind.h @@ -0,0 +1,15 @@ +// +// GIGaFeedKind.h +// GIGA +// +// Created by lianxiang on 2018/9/23. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import + +@interface GIGaFeedKind : JSONModel +@property (nonatomic,copy) NSString *feed_id; +@property (nonatomic,copy) NSString *remarks; + +@end diff --git a/GIGA/Modules/Me/Model/GIGaFeedKind.m b/GIGA/Modules/Me/Model/GIGaFeedKind.m new file mode 100644 index 0000000..cea6d27 --- /dev/null +++ b/GIGA/Modules/Me/Model/GIGaFeedKind.m @@ -0,0 +1,21 @@ +// +// GIGaFeedKind.m +// GIGA +// +// Created by lianxiang on 2018/9/23. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import "GIGaFeedKind.h" + +@implementation GIGaFeedKind ++(JSONKeyMapper *)keyMapper{ + return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{@"feed_id":@"id"}]; +} + ++ (BOOL)propertyIsOptional:(NSString *)propertyName{ + + return YES; +} + +@end diff --git a/GIGA/Modules/Me/View/FeedViews/GiGaFeedBackKindView.h b/GIGA/Modules/Me/View/FeedViews/GiGaFeedBackKindView.h new file mode 100644 index 0000000..9212737 --- /dev/null +++ b/GIGA/Modules/Me/View/FeedViews/GiGaFeedBackKindView.h @@ -0,0 +1,19 @@ +// +// GiGaFeedBackKindView.h +// GIGA +// +// Created by lianxiang on 2018/9/23. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import + +@interface GiGaFeedBackKindView : UIViewController +typedef void (^SelectedItemBlock)(NSString *tile); + ++(GiGaFeedBackKindView *)showAt:(UIViewController *)vc atRow:(NSInteger)row; +@property(nonatomic,copy)NSString *showStr; +@property(nonatomic) NSInteger defultRow; +@property (nonatomic, copy) SelectedItemBlock selectedItemBlock; + +@end diff --git a/GIGA/Modules/Me/View/FeedViews/GiGaFeedBackKindView.m b/GIGA/Modules/Me/View/FeedViews/GiGaFeedBackKindView.m new file mode 100644 index 0000000..2348f9d --- /dev/null +++ b/GIGA/Modules/Me/View/FeedViews/GiGaFeedBackKindView.m @@ -0,0 +1,207 @@ +// +// GiGaFeedBackKindView.m +// GIGA +// +// Created by lianxiang on 2018/9/23. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import "GiGaFeedBackKindView.h" +#define PickerHeight 180 +#define PickerToolBarHeight 44 +#import "GiGaBaseAPiRequest.h" +#import "GIGaFeedKind.h" + +@interface GiGaFeedBackKindView () + +@property (nonatomic, strong) UIView *pickerContainerView; +@property (nonatomic, strong) UIPickerView *pickerView; +//picker控件数据源 +@property(nonatomic,strong)NSMutableArray *pickerDataArr; + +@end + +@implementation GiGaFeedBackKindView + +- (void)viewDidLoad { + [super viewDidLoad]; + self.view.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.4]; + self.pickerDataArr = [NSMutableArray new]; + [self initUI]; + // Do any additional setup after loading the view. + +} + +-(void)requstData{ + GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:kApiGetFeedList method:RequestPostMethod parms:@{}]; + [api requstDataWithResult:^(GiGaAPIResult *result) { + if (result.success) { + GILog(@"反馈类型%@",result.dic); + NSArray *list =result.dic[@"list"]; + if (!list) { + list= [NSArray new]; + } + for (NSDictionary *feedDic in list) { + GIGaFeedKind *mode = [[GIGaFeedKind alloc] initWithDictionary:feedDic error:nil];; + [self.pickerDataArr addObject:mode]; + } + + [self.pickerView reloadAllComponents]; + [self.pickerView selectRow:self.defultRow inComponent:0 animated:YES]; + GIGaFeedKind *mode = self.pickerDataArr[self.defultRow]; + if (mode) { + self.showStr =mode.remarks; + } + + }else{ + + GIGA_ShowToast(result.message); + } + }]; +} + +-(void)initUI{ + + self.pickerContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height - (PickerHeight + PickerToolBarHeight), [UIScreen mainScreen].bounds.size.width, PickerHeight + PickerToolBarHeight)]; + + UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, PickerToolBarHeight)]; + toolBar.barTintColor = [UIColor whiteColor]; + + UIBarButtonItem *noSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; + noSpace.width=10; + + UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(done:)];; + doneBtn.tintColor = GIGARGB(131, 10, 10, 1); + + UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancel:)]; + cancelBtn.tintColor = GIGARGB(131, 10, 10, 1); + + UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; + [toolBar setItems:[NSArray arrayWithObjects:noSpace,cancelBtn,flexSpace,doneBtn,noSpace, nil]]; + UILabel *titleLabel = [UILabel new]; + titleLabel.frame = CGRectMake(0, 0, 200, PickerToolBarHeight); + titleLabel.center = toolBar.center; + titleLabel.textAlignment = NSTextAlignmentCenter; + titleLabel.textColor = GIGARGB(62, 62, 62, 1); + titleLabel.text = @"反馈类型"; + titleLabel.font = GIGA_TEXTFONTBOLD(14); + [toolBar addSubview:titleLabel]; + + self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, PickerToolBarHeight, [UIScreen mainScreen].bounds.size.width, PickerHeight)]; + self.pickerView.dataSource = self; + self.pickerView.delegate = self; + self.pickerView.backgroundColor = [UIColor whiteColor]; + + [self.pickerContainerView addSubview:toolBar]; + [self.pickerContainerView addSubview:self.pickerView]; + [self.view addSubview:self.pickerContainerView]; + +} + + +#pragma mark-- UIPickerViewDataSource +//列数 +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView +{ + return 1; +} + +//每列个数 +- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component +{ + return [self.pickerDataArr count]; +} + + +#pragma mark-- UIPickerViewDelegate +-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view +{ + UILabel *label = (id)view; + if (!label) + { + label= [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [pickerView rowSizeForComponent:component].width, [pickerView rowSizeForComponent:component].height)]; + label.textAlignment = NSTextAlignmentCenter; + label.textColor = [UIColor blackColor]; + GIGaFeedKind *mode = self.pickerDataArr[row]; + label.text = mode.remarks; + } + return label; +} + +//点击选择 +-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component +{ + if (self.selectedItemBlock) { + + if (self.pickerDataArr.count > 0 ) { + GIGaFeedKind *mode = self.pickerDataArr[row]; + self.showStr = mode.remarks; + self.selectedItemBlock(self.showStr); + } + } + +} + +-(void)done:(UIButton *)btn{ + + if (self.selectedItemBlock) { + if ([self.showStr isEqualToString:@"未知"]) { + [self hide]; + return; + } + self.selectedItemBlock(self.showStr); + + } + + [self hide]; + +} + +-(void)cancel:(UIButton*)btn{ + + [self hide]; + +} + +-(void)hide{ + + [self dismissViewControllerAnimated:NO completion:^{ + + }]; +} + ++(GiGaFeedBackKindView *)showAt:(UIViewController *)vc atRow:(NSInteger)row +{ + + GiGaFeedBackKindView *piker = [[GiGaFeedBackKindView alloc] init]; + if (!row) { + row = 0; + } + piker.defultRow = row; + [vc presentViewController:piker animated:YES completion:^{ + + }]; + + return piker; +} + +-(instancetype)init{ + + if (self = [super init]) { + self.modalPresentationStyle = UIModalPresentationOverCurrentContext; + self.showStr = @"未知"; + + [self requstData]; + + } + return self; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + + +@end