Skip to content

Commit

Permalink
商品详情图片 以及 上传图片后的刷新页面
Browse files Browse the repository at this point in the history
  • Loading branch information
woaomo committed Oct 8, 2015
1 parent c56b51b commit 90dd199
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
16 changes: 14 additions & 2 deletions YHB_Prj/YHB_Prj/shangpinguanli/EditSPVC/UploadImgViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ @interface UploadImgViewController ()<UIAlertViewDelegate, UIActionSheetDelegate
@property(nonatomic,strong) void(^ myBlock)(NSArray *);

@property(nonatomic,strong) NSMutableArray *picArray;

@property(nonatomic,strong) NSMutableArray *addPicArray;

@end

@implementation UploadImgViewController
Expand Down Expand Up @@ -82,6 +85,7 @@ - (void)touchOk
__block int chuanOK=0;
for (int i=0; i<count; i++)
{
_addPicArray = [NSMutableArray arrayWithCapacity:0];
[NetManager uploadImgArry:@[_photoArr[i]] parameters:@{@"id":_myId} apiName:@"uploadProductPic" uploadUrl:nil uploadimgName:nil progressBlock:nil succ:^(NSDictionary *successDict) {
NSString *msg = successDict[@"msg"];
MLOG(@"%@", successDict);
Expand All @@ -93,10 +97,18 @@ - (void)touchOk
NSString *domain = temDict[@"picDomain"];
NSString *picName = temDict[@"picName"];
NSString *url = [temDict[@"picUrl"] stringByAppendingString:picName];

SPGLProductPicMode *mode = [[SPGLProductPicMode alloc] init];
mode.strPickDomain = domain;
mode.strPicUrl = url;
mode.strPic = [domain stringByAppendingString:url];
mode.image = _photoArr[i];
[_addPicArray addObject:mode];

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:0];
[dict setObject:url forKey:@"pic_url"];
[dict setObject:domain forKey:@"pic_domain"];
[dict setObject:_myId forKey:@"pid"];
// [dict setObject:_myId forKey:@"pid"];
// [dict setObject:picName forKey:@"picName"];
[_picArray addObject:dict];

Expand All @@ -106,7 +118,7 @@ - (void)touchOk
NSString *msg = successDict[@"msg"];
if ([msg isEqualToString:@"success"])
{
_myBlock(_photoArr);
_myBlock(_addPicArray);
[SVProgressHUD dismiss];
[self.navigationController popViewControllerAnimated:YES];
}
Expand Down
17 changes: 14 additions & 3 deletions YHB_Prj/YHB_Prj/shangpinguanli/SPGLProductDetail.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#import "DJProductCheckViewManager.h"
#import "DJCheckCartItemComponent.h"

@interface SPGLProductDetail ()<DJProductCheckViewDataSoure>
@interface SPGLProductDetail ()<DJProductCheckViewDataSoure,SBPageFlowViewDataSource,SBPageFlowViewDelegate>
{
SBPageFlowView *flowView;
BOOL _isChecked;
Expand Down Expand Up @@ -65,6 +65,9 @@ - (void)viewDidLoad {
[self.scrollerview setContentSize:CGSizeMake(kMainScreenWidth, self.dianmingAndKuncunLabel.bottom+20)];
flowView = [[SBPageFlowView alloc] initWithFrame:CGRectMake(0, 0, self.headImgScrollview.width, self.headImgScrollview.height)];
[self.headImgScrollview addSubview:flowView];
flowView.dataSource = self;
flowView.delegate =self;
[flowView reloadData];
[self reloadView];

[self.xiugaishangpinBT addTarget:self action:@selector(touchXiugai) forControlEvents:UIControlEventTouchUpInside];
Expand Down Expand Up @@ -104,7 +107,9 @@ - (void)touchShangchuan
else
{
UploadImgViewController *vc = [[UploadImgViewController alloc] initWithUploadImgCount:count andId:_productMode.strId andChangeBlock:^(NSArray *aPhotoArr) {
#warning 更新上传图片
[self.productMode.picList addObjectsFromArray:aPhotoArr];
[flowView reloadData];
_changeBlock();
} andPicDict:_productMode.picList];
[self.navigationController pushViewController:vc animated:YES];
}
Expand Down Expand Up @@ -176,6 +181,11 @@ - (void)setInitData:(SPGLManager *)aManager mode:(SPGLProductMode *)aMode change
#pragma mark SBPage datasource
- (void)didReloadData:(UIView *)cell cellForPageAtIndex:(NSInteger)index
{
// [cell removeSubviews];
// SPGLProductPicMode *mode = self.productMode.picList[index];
// UIImageView *imgView = [[UIImageView alloc] initWithFrame:cell.bounds];
// [imgView sd_setImageWithURL:[NSURL URLWithString:mode.strPicUrl]];
// [cell addSubview:imgView];
}

- (NSInteger)numberOfPagesInFlowView:(SBPageFlowView *)flowView
Expand All @@ -195,7 +205,8 @@ - (UIView *)flowView:(SBPageFlowView *)flowView cellForPageAtIndex:(NSInteger)in
{
SPGLProductPicMode *pMode = [self.productMode.picList objectAtIndex:index];
imgview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.headImgScrollview.width/3, self.headImgScrollview.height)];
[imgview sd_setImageWithURL:[NSURL URLWithString:pMode.strPic] placeholderImage:nil];
if (pMode.image) imgview.image = pMode.image;
else [imgview sd_setImageWithURL:[NSURL URLWithString:pMode.strPic] placeholderImage:nil];
}
return imgview;
}
Expand Down
1 change: 1 addition & 0 deletions YHB_Prj/YHB_Prj/shangpinguanli/SPGLProductMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@property (nonatomic, strong) NSString *strPicUrl;
@property (nonatomic, strong) NSString *strPickDomain;
@property (nonatomic, strong) NSString *strPic;
@property (nonatomic, strong) UIImage *image;
@end

@interface SPGLProductMode : NSObject
Expand Down
7 changes: 6 additions & 1 deletion YHB_Prj/YHB_Prj/shangpinguanli/SPGLSearchCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ - (void)awakeFromNib {
- (void)setCellData:(SPGLProductMode *)aMode
{
NSString *picurl = nil;
UIImage *image = [[UIImage alloc] init];
if(aMode.picList && aMode.picList.count>0)
{
SPGLProductPicMode *pic = [aMode.picList objectAtIndex:0];
picurl = pic.strPic;
image = pic.image;
}
[self.headUrl sd_setImageWithURL:[NSURL URLWithString:picurl] placeholderImage:nil];
if (image)
self.headUrl.image = image;
else
[self.headUrl sd_setImageWithURL:[NSURL URLWithString:picurl] placeholderImage:nil];

self.pinming.text = aMode.strProductName;
self.jinjiaLabel.text = aMode.strBuyingPrice;
Expand Down

0 comments on commit 90dd199

Please sign in to comment.