|
@@ -43,11 +43,11 @@
|
|
|
make.width.mas_equalTo(60);
|
|
|
}];
|
|
|
|
|
|
- [self.titleDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.mas_equalTo(self.titleLab.mas_right).offset(4);
|
|
|
- make.centerY.mas_equalTo(self.titleLab);
|
|
|
- make.right.mas_equalTo(-40);
|
|
|
- }];
|
|
|
+// [self.titleDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.left.mas_equalTo(self.titleLab.mas_right).offset(4);
|
|
|
+// make.centerY.mas_equalTo(self.titleLab);
|
|
|
+// make.right.mas_equalTo(-40);
|
|
|
+// }];
|
|
|
|
|
|
[self.rTopBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.centerY.equalTo(self.titleLab);
|
|
@@ -75,23 +75,24 @@
|
|
|
}
|
|
|
|
|
|
- (void)configData:(id)Data isSelect:(BOOL)isSelect{
|
|
|
- GoodsInformationM *model = (GoodsInformationM *)Data;
|
|
|
+
|
|
|
+ NSArray *couponArray = (NSArray *)Data;
|
|
|
|
|
|
self.rTopBtn.selected = isSelect;
|
|
|
|
|
|
if (self.rTopBtn.selected) {//展开
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- NSArray *array = @[@"1", @"2", @"3", @"4", @"5", @"6"];
|
|
|
-
|
|
|
float itemWidth = (KScreenWidth - 50)/2;
|
|
|
float itemX = 10;
|
|
|
float itemY = 10;
|
|
|
- for (int i = 0; i < array.count; i++) {
|
|
|
+ for (int i = 0; i < couponArray.count; i++) {
|
|
|
+
|
|
|
+ ASGoodsCouponModel *couponModel = [couponArray objectAtIndex:i];
|
|
|
+
|
|
|
ASGoodsCouponItemView *itemView = [[ASGoodsCouponItemView alloc] initWithFrame:CGRectMake(itemX, itemY, itemWidth, 100)];
|
|
|
itemView.tag = i;
|
|
|
[self.couponView addSubview:itemView];
|
|
|
+ itemView.couponModel = couponModel;
|
|
|
|
|
|
itemView.userInteractionEnabled = YES;
|
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_clickAction:)];
|
|
@@ -107,7 +108,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (array.count % 2 != 0) {
|
|
|
+ if (couponArray.count % 2 != 0) {
|
|
|
itemY = itemY + 100 + 10;
|
|
|
}
|
|
|
|
|
@@ -186,30 +187,16 @@
|
|
|
|
|
|
@property (nonatomic, strong) UIImageView *bgImaegView;
|
|
|
@property (nonatomic, strong) UILabel *couponCodeLab;
|
|
|
-@property (nonatomic, strong) UILabel *couponPriceLab;
|
|
|
+@property (nonatomic, strong) UILabel *couponTitleLab;
|
|
|
@property (nonatomic, strong) UILabel *couponDescLab;
|
|
|
|
|
|
+@property (nonatomic, strong) UIButton *copyBtn;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
|
|
|
@implementation ASGoodsCouponItemView
|
|
|
|
|
|
-- (UIImageView *)bgImaegView {
|
|
|
- if (!_bgImaegView) {
|
|
|
- _bgImaegView = [[UIImageView alloc] init];
|
|
|
- _bgImaegView.image = [UIImage imageNamed:@"goods_coupon_bg"];
|
|
|
- }
|
|
|
- return _bgImaegView;
|
|
|
-}
|
|
|
-
|
|
|
-- (UILabel *)couponCodeLab {
|
|
|
- if (!_couponCodeLab) {
|
|
|
- _couponCodeLab = [UILabel labelCreateWithText:@"code:1238" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
|
|
|
- _couponCodeLab.textAlignment = NSTextAlignmentCenter;
|
|
|
- }
|
|
|
- return _couponCodeLab;
|
|
|
-}
|
|
|
-
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
if (self = [super initWithFrame:frame]) {
|
|
|
|
|
@@ -217,6 +204,9 @@
|
|
|
[self addSubview:self.bgImaegView];
|
|
|
|
|
|
[self.bgImaegView addSubview:self.couponCodeLab];
|
|
|
+ [self.bgImaegView addSubview:self.couponDescLab];
|
|
|
+ [self.bgImaegView addSubview:self.couponTitleLab];
|
|
|
+ [self.bgImaegView addSubview:self.copyBtn];
|
|
|
|
|
|
|
|
|
[self.bgImaegView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
@@ -228,8 +218,101 @@
|
|
|
make.centerX.equalTo(self.bgImaegView.mas_centerX).offset(-25);
|
|
|
make.width.mas_equalTo((KScreenWidth - 50)/2 - 80);
|
|
|
}];
|
|
|
+
|
|
|
+ [self.couponDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerX.equalTo(self.bgImaegView.mas_centerX).offset(-25);
|
|
|
+ make.width.mas_equalTo((KScreenWidth - 50)/2 - 80);
|
|
|
+ make.centerY.equalTo(self.bgImaegView.mas_centerY).offset(4);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.couponTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerX.equalTo(self.bgImaegView.mas_centerX).offset(-25);
|
|
|
+ make.width.mas_equalTo((KScreenWidth - 50)/2 - 80);
|
|
|
+ make.top.mas_equalTo(16);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.copyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.bottom.top.right.mas_equalTo(0);
|
|
|
+ make.width.mas_equalTo(45);
|
|
|
+ }];
|
|
|
+
|
|
|
}
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
+- (void)setCouponModel:(ASGoodsCouponModel *)couponModel {
|
|
|
+ _couponModel = couponModel;
|
|
|
+
|
|
|
+ self.couponCodeLab.text = [NSString stringWithFormat:@"Code:%@", AS_String_NotNull(couponModel.code)];
|
|
|
+
|
|
|
+ if (AS_String_NotNull(couponModel.gt).length > 1) {
|
|
|
+ self.couponDescLab.text = AS_String_NotNull(couponModel.gt);
|
|
|
+ } else {
|
|
|
+ self.couponDescLab.text = @"";
|
|
|
+ }
|
|
|
+
|
|
|
+ self.couponTitleLab.text = AS_String_NotNull(couponModel.detail);
|
|
|
+}
|
|
|
+
|
|
|
+- (void)_copyClick {
|
|
|
+ UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
|
|
+ pasteboard.string = _couponModel.code;
|
|
|
+
|
|
|
+ UIViewController *topVC = topViewController();
|
|
|
+ [topVC.view makeToast:@"Copy success" duration:2 position:CSToastPositionCenter];
|
|
|
+}
|
|
|
+
|
|
|
+- (UIImageView *)bgImaegView {
|
|
|
+ if (!_bgImaegView) {
|
|
|
+ _bgImaegView = [[UIImageView alloc] init];
|
|
|
+ _bgImaegView.image = [UIImage imageNamed:@"goods_coupon_bg"];
|
|
|
+ _bgImaegView.userInteractionEnabled = YES;
|
|
|
+ }
|
|
|
+ return _bgImaegView;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)couponCodeLab {
|
|
|
+ if (!_couponCodeLab) {
|
|
|
+ _couponCodeLab = [UILabel labelCreateWithText:@"code:1238" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
|
|
|
+ _couponCodeLab.adjustsFontSizeToFitWidth = YES;
|
|
|
+ _couponCodeLab.textAlignment = NSTextAlignmentCenter;
|
|
|
+ }
|
|
|
+ return _couponCodeLab;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)couponDescLab {
|
|
|
+ if (!_couponDescLab) {
|
|
|
+ _couponDescLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_043632];
|
|
|
+ _couponDescLab.adjustsFontSizeToFitWidth = YES;
|
|
|
+ _couponDescLab.textAlignment = NSTextAlignmentCenter;
|
|
|
+ }
|
|
|
+ return _couponDescLab;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)couponTitleLab {
|
|
|
+ if (!_couponTitleLab) {
|
|
|
+ _couponTitleLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_BoldItalic size:18] textColor:_043632];
|
|
|
+ _couponTitleLab.adjustsFontSizeToFitWidth = YES;
|
|
|
+ _couponTitleLab.textAlignment = NSTextAlignmentCenter;
|
|
|
+ }
|
|
|
+ return _couponTitleLab;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIButton *)copyBtn {
|
|
|
+ if (!_copyBtn) {
|
|
|
+ _copyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ _copyBtn.backgroundColor = [UIColor clearColor];
|
|
|
+ [_copyBtn addTarget:self action:@selector(_copyClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ }
|
|
|
+ return _copyBtn;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+
|
|
|
+@implementation ASGoodsCouponModel
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@end
|