86 lines
3.0 KiB
Mathematica
86 lines
3.0 KiB
Mathematica
|
|
//
|
||
|
|
// BottlePhotoCollectionCell.m
|
||
|
|
// TreeHole
|
||
|
|
//
|
||
|
|
// Created by mambaxie on 2022/7/16.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "BottlePhotoCollectionCell.h"
|
||
|
|
|
||
|
|
NSString *BottlePhotoCollectionCellReuseID = @"BottlePhotoCollectionCellReuseID";
|
||
|
|
|
||
|
|
CGFloat BottlePhotoCollectionCellWidth = 76;
|
||
|
|
CGFloat BottlePhotoCollectionCellHeight = 95;
|
||
|
|
|
||
|
|
@interface BottlePhotoCollectionCell ()
|
||
|
|
|
||
|
|
|
||
|
|
@end
|
||
|
|
|
||
|
|
@implementation BottlePhotoCollectionCell
|
||
|
|
|
||
|
|
|
||
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
||
|
|
if (self = [super initWithFrame:frame]) {
|
||
|
|
[self setupUI];
|
||
|
|
}
|
||
|
|
|
||
|
|
return self;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)setupUI {
|
||
|
|
self.backgroundColor = [UIColor clearColor];
|
||
|
|
self.contentView.backgroundColor = [UIColor clearColor];
|
||
|
|
self.contentView.layer.cornerRadius = FIX_SIZE(18);
|
||
|
|
self.contentView.layer.borderColor = COLOR_WITH_RGB(0xEAF0F3).CGColor;
|
||
|
|
self.contentView.layer.borderWidth = 1;
|
||
|
|
self.contentView.clipsToBounds = YES;
|
||
|
|
self.contentView.width = FIX_SIZE(BottlePhotoCollectionCellWidth);
|
||
|
|
self.contentView.height = FIX_SIZE(BottlePhotoCollectionCellHeight);
|
||
|
|
|
||
|
|
self.photoImageView = [[PYImageView alloc] init];
|
||
|
|
self.photoImageView.backgroundColor = [UIColor clearColor];
|
||
|
|
self.photoImageView.frame = self.contentView.bounds;
|
||
|
|
[self.contentView addSubview:self.photoImageView];
|
||
|
|
|
||
|
|
if ([UserService currentUser].is_manager) {
|
||
|
|
self.deleBtn = [[UIButton alloc]initWithFrame:CGRectMake(
|
||
|
|
self.photoImageView.width - 23, 5, 18, 18)];
|
||
|
|
[self.deleBtn addTarget:self action:@selector(deleBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
|
self.deleBtn.layer.cornerRadius = 9;
|
||
|
|
self.deleBtn.layer.masksToBounds = YES;
|
||
|
|
self.deleBtn.backgroundColor = [UIColor redColor];
|
||
|
|
UIImageView* deleImgV = [[UIImageView alloc]initWithFrame:CGRectMake((self.deleBtn.width - 10)/2.0, (self.deleBtn.height - 10)/2.0, 10, 10)];
|
||
|
|
deleImgV.image = [UIImage imageNamed:@"TH_bottleManagerDele"];
|
||
|
|
[self.deleBtn addSubview:deleImgV];
|
||
|
|
[self.contentView addSubview:_deleBtn];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
- (void)setPhoto:(UIImage *)photo {
|
||
|
|
_photo = photo;
|
||
|
|
self.photoImageView.image = photo;
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)deleBtnClick:(UIButton*)sender{
|
||
|
|
[MTAlertView showWithSetupBlcok:^(MTAlertViewConfig *config) {
|
||
|
|
config.title = @"确定删除?";
|
||
|
|
config.cancelTitle = @"否";
|
||
|
|
config.otherTitle = @"是";
|
||
|
|
config.otherHandler = ^(MTAlertButton *button) {
|
||
|
|
NSDictionary* paraDict = @{
|
||
|
|
@"bottle_id" : [NSNumber numberWithInt:self.bottle_id],
|
||
|
|
@"image_url" : self.photoImageView.imageUrl,
|
||
|
|
};
|
||
|
|
[PYHTTPManager postWithPath:@"delbottleimage" params:paraDict callback:^(id _Nullable rsp, NSError * _Nullable error) {
|
||
|
|
if (!error) {
|
||
|
|
!self.deleClickBlock?:self.deleClickBlock(self.photoImageView.imageUrl);
|
||
|
|
[SVProgressHUD showSuccessWithStatus:@"删除成功"];
|
||
|
|
}
|
||
|
|
}];
|
||
|
|
};
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|