Commit 5e5aeefd authored by admin's avatar admin

修复上传图片排序错误 返回时刷新所有列表

parent b405c64b
......@@ -2,16 +2,4 @@
<Bucket
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
......@@ -10,13 +10,13 @@
#define Url_h
// url 测试环境
// #define kRedStarURL @"http://218.244.151.129:7580/"
//#define kRedStarURL @"http://218.244.151.129:7580/"
// 正式环境
// #define kRedStarURL @"http://219.235.234.225:7580/"
#define kRedStarURL @"http://219.235.234.225:7580/"
// 最新正式环境
#define kRedStarURL @"http://219.235.234.212:7580/"
// #define kRedStarURL @"http://219.235.234.212:7580/"
// 检查更新
#define kCheckUpdateURL @"redstar-server/rest/ipapk?type=ipa"
......
......@@ -8,6 +8,14 @@
#import <UIKit/UIKit.h>
@protocol AddPictureDelegate <NSObject>
- (void)reloadList;
@end
@interface AddPictureViewController : UIViewController
@property (nonatomic, copy) NSString *category;
@property (nonatomic, assign) id <AddPictureDelegate>delegate;
@end
......@@ -16,6 +16,8 @@
#import "UIImage+Fit.h"
#import "CommonFunc.h"
#import <MBProgressHUD.h>
#define kAddPicTableViewCell @"addPicTableCell"
#define kAddPicTextTableViewCell @"addPicTextTableCell"
#define kAddButtonCell @"addButtonTableViewCell"
......@@ -23,6 +25,8 @@
@interface AddPictureViewController () <UITableViewDelegate, UITableViewDataSource, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate, UIAlertViewDelegate, UITextViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *imageNameArray;
@property (nonatomic, strong) NSMutableArray *textArray;
@property (nonatomic, assign) int rowNumber;
@property (nonatomic, strong) UIView *footView;
......@@ -65,6 +69,7 @@
_rowNumber = 2;
self.imageNameArray = [NSMutableArray array];
self.textArray = [NSMutableArray array];
}
#pragma mark - Private Mothods
......@@ -105,7 +110,6 @@
- (void)addPicText:(UIButton *)sender
{
NSDate *date = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd+hh:mm:ss"];
......@@ -123,6 +127,7 @@
[alert show];
return;
} else {
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
NSString *url = [NSString stringWithFormat:@"%@%@%@&operId=%@&operName=%@", kRedStarURL, kSavePicturePraiseURL,dateString, operId, operName];
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
HttpClient *http1 = [[HttpClient alloc] initWithUrl:url];
......@@ -133,6 +138,11 @@
};
[http1 savePicturePraiseWithParameters:parameters completion:^(id response, NSError *error) {
_praiseUuid = response[@"data"];
if ([response[@"success"] boolValue]) {
NSLog(@"失败");
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}
_rowNumber++;
......@@ -147,6 +157,9 @@
HttpClient *http1 = [[HttpClient alloc] initWithUrl:url];
if ((_imageNameArray.count == _rowNumber - 2) && cell.titleTextView.text.length != 0 ) {
[self.textArray addObject:cell.titleTextView.text];
NSString *imageName = _imageNameArray[_rowNumber - 3];
NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
......@@ -157,10 +170,22 @@
@"fileName":imageName,
@"fileContent":imageBase64
};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[http1 upLoadPraisePictureWithParameters:parameters completion:^(id response, NSError *error) {
NSLog(@"上传单组文字图片 ===== response ------ %@", response);
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
if ([response[@"success"] boolValue]) {
_rowNumber++;
[self.tableView reloadData];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"当前图片上传失败,请重新上传!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
return ;
}
}];
_rowNumber++;
[self.tableView reloadData];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"必须有图片和图片说明!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
......@@ -281,6 +306,7 @@
if (alertView.tag == 334281) {
if (buttonIndex == 1) {
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
NSDate *date = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd+hh:mm:ss"];
......@@ -290,8 +316,8 @@
NSString *operName = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_name"];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:(_rowNumber - 2) inSection:0];
AddPicTextTableViewCell *cell = [_tableView cellForRowAtIndexPath:indexPath]; if (_imageNameArray.count == _rowNumber - 2 || cell.titleTextView.text.length != 0) {
AddPicTextTableViewCell *cell = [_tableView cellForRowAtIndexPath:indexPath];
if (_imageNameArray.count == _rowNumber - 2 || cell.titleTextView.text.length != 0) {
NSString *urlStr = [NSString stringWithFormat:@"%@%@%@/submit_attachment?time=%@&operId=%@&operName=%@", kRedStarURL, kUpLoadPictureURL, _praiseUuid ,dateString, operId, operName];
urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
......@@ -315,8 +341,14 @@
HttpClient *http1 = [[HttpClient alloc] initWithUrl:url];
[http1 submitPicturePraiseWithCompletion:^(id response, NSError *error) {
if ([response[@"success"] boolValue]) {
[self.navigationController popViewControllerAnimated:YES];
UIAlertView *alertt = [[UIAlertView alloc] initWithTitle:@"提示" message:@"新增口碑成功!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
alertt.tag = 893323;
[alertt show];
} else {
UIAlertView *alertt = [[UIAlertView alloc] initWithTitle:@"警告" message:@"新增口碑失败!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alertt show];
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
}];
}
......@@ -328,6 +360,16 @@
[self.navigationController popViewControllerAnimated:YES];
}
}
if (alertView.tag == 893323) {
if (buttonIndex == 0) {
if (_delegate && [_delegate respondsToSelector:@selector(reloadList)]) {
[_delegate reloadList];
}
[self.navigationController popViewControllerAnimated:YES];
}
}
}
......@@ -364,19 +406,37 @@
}
if (_rowNumber - 2 == _imageNameArray.count) {
NSString *imageName = _imageNameArray[indexPath.row - 1];
NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
UIImage *image00 = [UIImage image:image fillSize:CGSizeMake((kScreenWidth - 60) / 2, 90)];
[cell.photoButton setImage:image00 forState:UIControlStateNormal];
[cell.photoButton removeTarget:self action:@selector(createImagePicker:) forControlEvents:UIControlEventTouchUpInside];
[cell.photoButton addTarget:self action:@selector(showBigPic:) forControlEvents:UIControlEventTouchUpInside];
if (indexPath.row == _rowNumber - 2) {
NSString *imageName = _imageNameArray[indexPath.row - 1];
NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
UIImage *image00 = [UIImage image:image fillSize:CGSizeMake((kScreenWidth - 60) / 2, 90)];
[cell.photoButton setImage:image00 forState:UIControlStateNormal];
[cell.photoButton removeTarget:self action:@selector(createImagePicker:) forControlEvents:UIControlEventTouchUpInside];
[cell.photoButton addTarget:self action:@selector(showBigPic:) forControlEvents:UIControlEventTouchUpInside];
cell.titleTextView.userInteractionEnabled = YES;
cell.titleTextView.text = @"";
} else {
NSString *imageName = _imageNameArray[indexPath.row - 1];
NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:fullPath];
UIImage *image00 = [UIImage image:image fillSize:CGSizeMake((kScreenWidth - 60) / 2, 90)];
[cell.photoButton setImage:image00 forState:UIControlStateNormal];
[cell.photoButton removeTarget:self action:@selector(createImagePicker:) forControlEvents:UIControlEventTouchUpInside];
[cell.photoButton addTarget:self action:@selector(showBigPic:) forControlEvents:UIControlEventTouchUpInside];
NSString *textStr = _textArray[indexPath.row - 1];
cell.titleTextView.text = textStr;
}
} else {
if (indexPath.row == _rowNumber - 2) {
[cell.photoButton setImage:[UIImage imageNamed:@"add-photo_icon"] forState:UIControlStateNormal];
[cell.photoButton removeTarget:self action:@selector(showBigPic:) forControlEvents:UIControlEventTouchUpInside];
[cell.photoButton addTarget:self action:@selector(createImagePicker:) forControlEvents:UIControlEventTouchUpInside];
cell.titleTextView.text = @"";
} else {
NSString *imageName = _imageNameArray[indexPath.row - 1];
......@@ -387,6 +447,8 @@
[cell.photoButton removeTarget:self action:@selector(createImagePicker:) forControlEvents:UIControlEventTouchUpInside];
[cell.photoButton addTarget:self action:@selector(showBigPic:) forControlEvents:UIControlEventTouchUpInside];
cell.titleTextView.userInteractionEnabled = NO;
NSString *textStr = _textArray[indexPath.row - 1];
cell.titleTextView.text = textStr;
}
}
return cell;
......
......@@ -8,7 +8,16 @@
#import <UIKit/UIKit.h>
@protocol PictureDetailDelegate <NSObject>
- (void)reloadList;
@end
@interface PictureStoryViewController : UIViewController
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, strong) NSString *titleStr;
@property (nonatomic, assign) id <PictureDetailDelegate>delegate;
@end
......@@ -78,7 +78,7 @@
self.tableView.dataSource = self;
self.imageNameArray = [NSMutableArray array];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
[self requestPicturePraiseDetail];
}
......@@ -90,7 +90,6 @@
NSString *user_uuid = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_uuid"];
NSString *url = [NSString stringWithFormat:@"%@%@%@?userUuid=%@", kRedStarURL, kPicturePraiseDetailURL, self.uuid, user_uuid];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
HttpClient *http = [[HttpClient alloc] initWithUrl:url];
[http getPicturePraiseDetailWithCompletion:^(id response, NSError *error) {
......@@ -146,13 +145,12 @@
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}];
}
[MBProgressHUD hideHUDForView:self.view animated:YES];
[self.tableView reloadData];
}];
}
......@@ -666,6 +664,11 @@
[MBProgressHUD hideHUDForView:self.view animated:YES];
}];
if (_delegate && [_delegate respondsToSelector:@selector(reloadList)]) {
[_delegate reloadList];
}
}
}
}
......
......@@ -27,7 +27,7 @@
#define kPictureTableViewCell @"pictureTabelViewCell"
@interface PictureViewController () <UITableViewDelegate, UITableViewDataSource, TaxisViewDelegate,ScopeTableViewDelegate, TimeTableViewDelegate >
@interface PictureViewController () <UITableViewDelegate, UITableViewDataSource, TaxisViewDelegate,ScopeTableViewDelegate, TimeTableViewDelegate , AddPictureDelegate, PictureDetailDelegate>
@property (nonatomic, strong) MenuView *menuView;
@property (nonatomic, strong) TaxisView *taxisView;
......@@ -53,14 +53,6 @@
@end
@implementation PictureViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self requestPicturePraise];
}
- (void)viewDidLoad
{
[super viewDidLoad];
......@@ -78,6 +70,8 @@
self.navigationController.navigationBar.translucent = NO;
}
[self requestPicturePraise];
_page = 0;
}
......@@ -127,6 +121,7 @@
NSArray *permissions = [[NSUserDefaults standardUserDefaults] objectForKey:@"permissions"];
if ([permissions containsObject:@"500303"]) {
AddPictureViewController *addPic = [[AddPictureViewController alloc] init];
addPic.delegate = self;
addPic.category = self.category;
[self.navigationController pushViewController:addPic animated:YES];
......@@ -527,6 +522,11 @@
return mDate;
}
#pragma mark - AddPictureDelegate
- (void)reloadList
{
[self requestPicturePraise];
}
#pragma mark - MoreScreenDelegate
- (void)scopeTableViewClick:(NSInteger)row
......@@ -647,6 +647,7 @@
{
PictureListModel *picList = _allPraiseListArray[indexPath.row];
PictureStoryViewController *storyVC = [[PictureStoryViewController alloc] init];
storyVC.delegate = self;
storyVC.uuid = picList.uuid;
storyVC.titleStr = self.titleStr;
[self.navigationController pushViewController:storyVC animated:YES];
......
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