Skip to content

Commit

Permalink
上传头像
Browse files Browse the repository at this point in the history
  • Loading branch information
woaomo committed Sep 3, 2015
1 parent 33c2e0e commit f8bddc5
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 52 deletions.
35 changes: 29 additions & 6 deletions YHB_Prj/YHB_Prj/FourthViewController/ClerkVC/ClerkViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#import "ClerkTableViewCell.h"
#import "ClerkDetailViewController.h"
#import "EmpManage.h"
#import "SVPullToRefresh.h"

@interface ClerkViewController ()<UITableViewDataSource,UITableViewDelegate>
{
UITableView *_clerkTableView;
}

@property(nonatomic, strong) UITableView *clerkTableView;
@property(nonatomic, strong) EmpManage *manage;
@property(nonatomic,strong) NSMutableArray *dataArray;
@end
Expand All @@ -34,10 +34,33 @@ - (void)viewDidLoad {

_dataArray = [NSMutableArray arrayWithCapacity:0];
_manage = [[EmpManage alloc] init];
[_manage getEmpListWithFinishBlock:^(NSArray *resultArr) {
_dataArray = [resultArr mutableCopy];
[_clerkTableView reloadData];
[self addTableViewTrag];
[_clerkTableView triggerPullToRefresh];
}

#pragma mark 增加上拉下拉
- (void)addTableViewTrag
{
__weak ClerkViewController *weakself = self;
[weakself.clerkTableView addPullToRefreshWithActionHandler:^{
[self.manage getEmpListWithFinishBlock:^(NSArray *resultArr) {
if (resultArr && resultArr.count>0)
{
_dataArray = [resultArr mutableCopy];
[_clerkTableView reloadData];
}
else
{
[SVProgressHUD showErrorWithStatus:@"加载失败" cover:YES offsetY:kMainScreenHeight/2.0];
}
[weakself.clerkTableView.pullToRefreshView stopAnimating];
}];
}];


// [weakself.supplierTableView addInfiniteScrollingWithActionHandler:^{
// [weakself.supplierTableView.infiniteScrollingView stopAnimating];
// }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
Expand Down
12 changes: 11 additions & 1 deletion YHB_Prj/YHB_Prj/FourthViewController/FourthViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#import "SDImageCache.h"
#import "LoginManager.h"
#import "SDWebImageManager.h"
#import "NetManager.h"

#define userFace @"userFace"

Expand Down Expand Up @@ -112,14 +113,16 @@ - (void)viewDidLoad {
else
{
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:[NSURL URLWithString:mode.strFaceUrl]
NSString *imgUrl = [NSString stringWithFormat:@"%@%@", mode.strFaceDomain,mode.strFaceUrl];
[manager downloadImageWithURL:[NSURL URLWithString:imgUrl]
options:0
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
[[SDImageCache sharedImageCache] storeImage:image
forKey:userStr
toDisk:YES];
[_userImgBtn setImage:image forState:UIControlStateNormal];
}
}];
}
Expand Down Expand Up @@ -356,6 +359,13 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
[[SDImageCache sharedImageCache] storeImage:image
forKey:userFace
toDisk:YES];
[NetManager uploadImg:image parameters:nil apiName:@"uploadUserFacePic" uploadUrl:nil uploadimgName:nil progressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
MLOG(@"%f", (float)totalBytesExpectedToWrite/totalBytesWritten);
} succ:^(NSDictionary *successDict) {
MLOG(@"1");
} failure:^(NSDictionary *failDict, NSError *error) {
MLOG(@"2");
}];
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImage * oriImage = [info objectForKey:UIImagePickerControllerOriginalImage];
// 保存图片到相册中
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ - (void)viewDidLoad {
[self addTableViewTrag];

_manage = [[SupplierManage alloc] init];
[_manage getSupplierListWithFinishBlock:^(NSArray *resultArr) {
self.dataArray = [resultArr mutableCopy];
[_supplierTableView reloadData];
}];
[_supplierTableView triggerPullToRefresh];
}

#pragma mark 增加上拉下拉
Expand All @@ -49,8 +46,15 @@ - (void)addTableViewTrag
__weak SupplierViewController *weakself = self;
[weakself.supplierTableView addPullToRefreshWithActionHandler:^{
[self.manage getSupplierListWithFinishBlock:^(NSArray *resultArr) {
self.dataArray = [resultArr mutableCopy];
[_supplierTableView reloadData];
if (resultArr && resultArr.count>0)
{
self.dataArray = [resultArr mutableCopy];
[_supplierTableView reloadData];
}
else
{
[SVProgressHUD showErrorWithStatus:@"加载失败" cover:YES offsetY:kMainScreenHeight/2.0];
}
[weakself.supplierTableView.pullToRefreshView stopAnimating];
}];
}];
Expand Down
Loading

0 comments on commit f8bddc5

Please sign in to comment.