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

View File

@ -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 = "<group>"; };
8392900D2134FA0A0077D2E8 /* GiGaCommentModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GiGaCommentModel.h; sourceTree = "<group>"; };
8392900E2134FA0A0077D2E8 /* GiGaCommentModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GiGaCommentModel.m; sourceTree = "<group>"; };
83A1DDAD21573D01006DE881 /* GiGaFeedBackKindView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaFeedBackKindView.h; sourceTree = "<group>"; };
83A1DDAE21573D01006DE881 /* GiGaFeedBackKindView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaFeedBackKindView.m; sourceTree = "<group>"; };
83A1DDB021574807006DE881 /* GIGaFeedKind.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GIGaFeedKind.h; sourceTree = "<group>"; };
83A1DDB121574807006DE881 /* GIGaFeedKind.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GIGaFeedKind.m; sourceTree = "<group>"; };
83A2270A212A97ED00B3E75C /* MaskViewBootomWaringView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MaskViewBootomWaringView.h; sourceTree = "<group>"; };
83A2270B212A97ED00B3E75C /* MaskViewBootomWaringView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MaskViewBootomWaringView.m; sourceTree = "<group>"; };
83A22710212A9EA900B3E75C /* UIView+Sizes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Sizes.m"; sourceTree = "<group>"; };
@ -1067,6 +1073,8 @@
8357ADC42123BEBD000816F2 /* GiGaUser.m */,
8342FD842150FD5200D141F4 /* VersionModel.h */,
8342FD852150FD5200D141F4 /* VersionModel.m */,
83A1DDB021574807006DE881 /* GIGaFeedKind.h */,
83A1DDB121574807006DE881 /* GIGaFeedKind.m */,
);
path = Model;
sourceTree = "<group>";
@ -1203,6 +1211,8 @@
8382DFBB21563C2D00BBA5A5 /* GiGaFeedImagsActionCell.h */,
8382DFBC21563C2D00BBA5A5 /* GiGaFeedImagsActionCell.m */,
8382DFBD21563C2D00BBA5A5 /* GiGaFeedImagsActionCell.xib */,
83A1DDAD21573D01006DE881 /* GiGaFeedBackKindView.h */,
83A1DDAE21573D01006DE881 /* GiGaFeedBackKindView.m */,
);
path = FeedViews;
sourceTree = "<group>";
@ -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 */,

View File

@ -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;

View File

@ -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];

View File

@ -199,12 +199,7 @@
[manager POST:fullurl parameters:parms constructingBodyWithBlock:^(id<AFMultipartFormData> _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]];
//

View File

@ -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];
}

View File

@ -66,9 +66,11 @@ const static NSInteger GIGADB_USER_VER = 0;//当前数据库版本号
}
NSLog(@"user dic ***\n%@",result.dic);
}else{
if (errorCodeMsg) {
errorCodeMsg(requst.resultDict);
}
}
}];

View File

@ -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"

View File

@ -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];

View File

@ -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:resDic];
if (result.success) {
GIGA_ShowToast(@"🙏感谢提出宝贵意见!🙏");
}else if (result.code == 401){
GIGA_WIndowTost(@"登录超时,请重新登录");
[GiGaBaseAPiRequest userTokenTimeOutGologinFromVC:self];
}else{
GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:responseDict];
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.

View File

@ -0,0 +1,15 @@
//
// GIGaFeedKind.h
// GIGA
//
// Created by lianxiang on 2018/9/23.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <JSONModel/JSONModel.h>
@interface GIGaFeedKind : JSONModel
@property (nonatomic,copy) NSString *feed_id;
@property (nonatomic,copy) NSString *remarks;
@end

View File

@ -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

View File

@ -0,0 +1,19 @@
//
// GiGaFeedBackKindView.h
// GIGA
//
// Created by lianxiang on 2018/9/23.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <UIKit/UIKit.h>
@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

View File

@ -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 ()<UIPickerViewDelegate,UIPickerViewDataSource>
@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