Commit 4f6857ed authored by admin's avatar admin

完成图说口碑

parent eb106734
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
{ {
if (!_contentTextView) { if (!_contentTextView) {
_contentTextView = [[UITextView alloc] init]; _contentTextView = [[UITextView alloc] init];
_contentTextView.tag = 1002; _contentTextView.tag = 9992;
_contentTextView.font = [UIFont systemFontOfSize:15.0]; _contentTextView.font = [UIFont systemFontOfSize:15.0];
_contentTextView.translatesAutoresizingMaskIntoConstraints = NO; _contentTextView.translatesAutoresizingMaskIntoConstraints = NO;
[self.backImageView2 addSubview:_contentTextView]; [self.backImageView2 addSubview:_contentTextView];
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
{ {
if (!_titleTextView) { if (!_titleTextView) {
_titleTextView = [[UITextView alloc] init]; _titleTextView = [[UITextView alloc] init];
_titleTextView.tag = 1001; _titleTextView.tag = 9991;
_titleTextView.font = [UIFont systemFontOfSize:15.0]; _titleTextView.font = [UIFont systemFontOfSize:15.0];
_titleTextView.translatesAutoresizingMaskIntoConstraints = NO; _titleTextView.translatesAutoresizingMaskIntoConstraints = NO;
[self.backImageView1 addSubview:_titleTextView]; [self.backImageView1 addSubview:_titleTextView];
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#define kAddPicTextTableViewCell @"addPicTextTableCell" #define kAddPicTextTableViewCell @"addPicTextTableCell"
#define kAddButtonCell @"addButtonTableViewCell" #define kAddButtonCell @"addButtonTableViewCell"
@interface AddPictureViewController () <UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate> @interface AddPictureViewController () <UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate, UIAlertViewDelegate, UITextViewDelegate>
@property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *imageNameArray; @property (nonatomic, strong) NSMutableArray *imageNameArray;
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
@property (nonatomic, strong) UIButton *reportButton; @property (nonatomic, strong) UIButton *reportButton;
@property (nonatomic, strong) UIActionSheet *selectActionSheet; @property (nonatomic, strong) UIActionSheet *selectActionSheet;
@property (nonatomic, copy) NSString *praiseUuid;
@end @end
@implementation AddPictureViewController @implementation AddPictureViewController
...@@ -65,7 +67,16 @@ ...@@ -65,7 +67,16 @@
#pragma mark - Private Mothods #pragma mark - Private Mothods
- (void)uploadInspect:(UIButton *)sender - (void)uploadInspect:(UIButton *)sender
{ {
if (_imageNameArray.count == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"请至少添加一组图片和文字!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
return;
}
// 提示框
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您确定要上报口碑吗?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
alert.tag = 334281;
alert.delegate = self;
[alert show];
} }
- (void)doBack:(id)sender - (void)doBack:(id)sender
...@@ -99,6 +110,8 @@ ...@@ -99,6 +110,8 @@
if (_rowNumber == 2) { if (_rowNumber == 2) {
AddPictureTableCell *cell = [_tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; AddPictureTableCell *cell = [_tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
cell.titleTextView.delegate = self;
cell.contentTextView.delegate = self;
if (cell.titleTextView.text.length == 0 || cell.contentTextView.text.length == 0) { if (cell.titleTextView.text.length == 0 || cell.contentTextView.text.length == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"标题、问题与建议描述不能为空!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"标题、问题与建议描述不能为空!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show]; [alert show];
...@@ -113,9 +126,32 @@ ...@@ -113,9 +126,32 @@
}; };
[http1 savePicturePraiseWithParameters:parameters completion:^(id response, NSError *error) { [http1 savePicturePraiseWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"6.1保存图说口碑 resp = %@, error = %@", response, error); NSLog(@"6.1保存图说口碑 resp = %@, error = %@", response, error);
_praiseUuid = response[@"data"];
}]; }];
} }
} else {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:(_rowNumber - 2) inSection:0];
AddPicTextTableViewCell *cell = [_tableView cellForRowAtIndexPath:indexPath];
NSString *url = [NSString stringWithFormat:@"%@%@%@/submit_attachment?time=%@&operId=%@&operName=%@", kRedStarURL, kUpLoadPictureURL, _praiseUuid ,dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *http1 = [[HttpClient alloc] initWithUrl:url];
NSString *imageName = _imageNameArray[_rowNumber - 3];
NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
NSData *imageData = UIImageJPEGRepresentation(image, 0.5);
NSString *imageBase64 = [imageData base64EncodedStringWithOptions:0];
NSDictionary *parameters = @{
@"description":cell.titleTextView.text,
@"fileName":imageName,
@"fileContent":imageBase64
};
[http1 upLoadPraisePictureWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"6.2上传口碑图片 resp = %@, error = %@", response, error);
}];
} }
_rowNumber++; _rowNumber++;
[self.tableView reloadData]; [self.tableView reloadData];
...@@ -134,6 +170,50 @@ ...@@ -134,6 +170,50 @@
[imageData writeToFile:fullPath atomically:NO]; [imageData writeToFile:fullPath atomically:NO];
} }
#pragma mark - UItextView
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
AddPictureTableCell *cell = [_tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
if (![text isEqualToString:@""]) {
if (textView.tag == 9991) {
cell.placeholderLabel1.hidden = YES;
} else {
cell.placeholderLabel2.hidden = YES;
}
}
if ([text isEqualToString:@""] && range.location == 0 && range.length == 1) {
if (textView.tag == 9991) {
cell.placeholderLabel1.hidden = NO;
} else {
cell.placeholderLabel2.hidden = NO;
}
}
if ([text isEqualToString:@"\n"]) {
[cell.titleTextView resignFirstResponder];
[cell.contentTextView resignFirstResponder];
if (textView.tag == 9991) {
if (textView.text.length != 0) {
cell.placeholderLabel1.hidden = YES;
} else {
cell.placeholderLabel1.hidden = NO;
}
} else {
if (textView.text.length != 0) {
cell.placeholderLabel2.hidden = YES;
} else {
cell.placeholderLabel2.hidden = NO;
}
}
return NO;
}
return YES;
}
#pragma mark - UIImagePickerController 代理方法 #pragma mark - UIImagePickerController 代理方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{ {
...@@ -177,6 +257,33 @@ ...@@ -177,6 +257,33 @@
} }
} }
#pragma mark - UIAlertViewDelegte
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag == 334281) {
if (buttonIndex == 1) {
NSDate *date = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd+hh:mm:ss"];
NSString *dateString = [dateFormatter stringFromDate:date];
NSString *operId = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_code"];
NSString *operName = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_name"];
NSString *url = [NSString stringWithFormat:@"%@%@%@/submit?time=%@&operId=%@&operName=%@", kRedStarURL, kSubmitPicturePraiseURL,_praiseUuid, dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *http1 = [[HttpClient alloc] initWithUrl:url];
[http1 submitPicturePraiseWithCompletion:^(id response, NSError *error) {
NSLog(@"6.3接口上传口碑图片 res = %@, error = %@", response, error);
if (response[@"success"]) {
[self.navigationController popViewControllerAnimated:YES];
}
}];
}
}
}
#pragma mark - UITableView Delegate/DataSource #pragma mark - UITableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
...@@ -191,6 +298,8 @@ ...@@ -191,6 +298,8 @@
if (!cell) { if (!cell) {
cell = [[AddPictureTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kAddPicTableViewCell]; cell = [[AddPictureTableCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kAddPicTableViewCell];
} }
cell.titleTextView.delegate = self;
cell.contentTextView.delegate = self;
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
} else if (indexPath.row == _rowNumber - 1) { } else if (indexPath.row == _rowNumber - 1) {
...@@ -207,18 +316,24 @@ ...@@ -207,18 +316,24 @@
cell = [[AddPicTextTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kAddPicTextTableViewCell]; cell = [[AddPicTextTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kAddPicTextTableViewCell];
} }
if (_rowNumber - 2 == _imageNameArray.count) {
if (_imageNameArray.count != 0) {
NSString *imageName = _imageNameArray[indexPath.row - 1]; NSString *imageName = _imageNameArray[indexPath.row - 1];
NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName]; NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:fullPath]; UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
UIImage *image00 = [self cutImage:image]; UIImage *image00 = [self cutImage:image];
[cell.photoButton setImage:image00 forState:UIControlStateNormal]; [cell.photoButton setImage:image00 forState:UIControlStateNormal];
} else { } else {
[cell.photoButton setImage:[UIImage imageNamed:@"add-photo_icon"] forState:UIControlStateNormal]; if (indexPath.row == _rowNumber - 2) {
[cell.photoButton setImage:[UIImage imageNamed:@"add-photo_icon"] forState:UIControlStateNormal];
} else {
NSString *imageName = _imageNameArray[indexPath.row - 1];
NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
UIImage *image00 = [self cutImage:image];
[cell.photoButton setImage:image00 forState:UIControlStateNormal];
}
} }
cell.titleTextView.delegate = self;
[cell.photoButton addTarget:self action:@selector(createImagePicker:) forControlEvents:UIControlEventTouchUpInside]; [cell.photoButton addTarget:self action:@selector(createImagePicker:) forControlEvents:UIControlEventTouchUpInside];
return cell; return cell;
} }
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"]; NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSDictionary *parameters = @{ NSDictionary *parameters = @{
@"user":user_uuid, @"user":user_uuid,
@"scope":@"all", // @"scope":@"all",
@"pageNumber":@(0), @"pageNumber":@(0),
@"pageSize":@(10) @"pageSize":@(10)
}; };
...@@ -176,7 +176,6 @@ ...@@ -176,7 +176,6 @@
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"]; NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSDictionary *parameters = @{ NSDictionary *parameters = @{
@"user":user_uuid, @"user":user_uuid,
@"scope":@"all",
@"pageNumber":@(_page), @"pageNumber":@(_page),
@"pageSize":@(10) @"pageSize":@(10)
}; };
...@@ -186,9 +185,17 @@ ...@@ -186,9 +185,17 @@
// 请求问题列表 // 请求问题列表
[httpClient queryPicturePraiseWithParameters:parameters completion:^(id response, NSError *error) { [httpClient queryPicturePraiseWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"加载更多的 托说口碑 = %@", response);
NSDictionary *dataDict = response[@"data"];
NSArray *dataArray = dataDict[@"records"];
NSMutableArray *tempArray = [NSMutableArray array]; NSMutableArray *tempArray = [NSMutableArray array];
for (NSDictionary *dict in dataArray) {
PictureListModel *picList = [[PictureListModel alloc] init];
[picList setValuesForKeysWithDictionary:dict];
[tempArray addObject:picList];
}
[_allPraiseListArray addObjectsFromArray:tempArray];
if (tempArray.count < 10) { if (tempArray.count < 10) {
[self.tableView.footer noticeNoMoreData]; [self.tableView.footer noticeNoMoreData];
} else { } else {
......
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