1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//
// ShoppingCell.m
// Lighting
//
// Created by mac on 16/5/23.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "ShoppingCell.h"
#define Width 760
#define Height 90
#define Gap 5
@implementation ShoppingCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.value=1;
self.customGoods=[[CustomTOGoodsEntity alloc]init];
[self bulidLayout];
}
return self;
}
- (void)bulidLayout
{
// 选中
self.selectedButton=[[CustomShopingSeclectButton alloc]initWithFrame:CGRectMake(20, 25, 30, Height-60)];
[self.selectedButton setBackgroundImage:[UIImage imageNamed:@"box-副本"] forState:UIControlStateNormal];
// box-副本
[self.contentView addSubview:self.selectedButton];
// 商品图片
self.goodsImageView=[[UIImageView alloc]initWithFrame:CGRectMake(Width/12, 0, 2*Width/12, Height)];
self.goodsImageView.image=[UIImage imageNamed:@"05产品库-详情_03"];
//05产品库-详情_03
[self.contentView addSubview:self.goodsImageView];
// 商品信息
self.goodsInformationLabe=[[UILabel alloc]initWithFrame:CGRectMake(3*Width/12, 0, 4*Width/12, Height)];
self.goodsInformationLabe.text=@"吊灯jkdsfhkdhfkdsh\n2000133434";
self.goodsInformationLabe.textAlignment=NSTextAlignmentCenter;
self.goodsInformationLabe.numberOfLines=0;
[self.contentView addSubview:self.goodsInformationLabe];
// 吊牌价格
self.tagsPriceLabe=[[UILabel alloc]initWithFrame:CGRectMake(7*Width/12, 0,2*Width/12, Height)];
self.tagsPriceLabe.text=@"¥5500";
self.tagsPriceLabe.textAlignment=NSTextAlignmentCenter;
[self.contentView addSubview:self.tagsPriceLabe];
//// 成交价格
// self.clinchTextfield=[[UITextField alloc]initWithFrame:CGRectMake(8*Width/15, 0, 2*Width/15, Height)];
// self.clinchTextfield.text=@"$5500";
// [self.contentView addSubview:self.clinchTextfield];
// 数量减
self.reduceButton=[[UIButton alloc]initWithFrame:CGRectMake(9*Width/12, 20, Width/12-5, Height-40)];
[self.reduceButton setTitle:@"-" forState:UIControlStateNormal];
self.reduceButton.titleLabel.font=[UIFont systemFontOfSize:18];
self.reduceButton.backgroundColor=RGB(249, 244, 241, 1);
[self.reduceButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
self.reduceButton.titleLabel.font= [UIFont systemFontOfSize: 18.0];
self.reduceButton.tag=100;
[self.reduceButton addTarget:self action:@selector(resetVale:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.reduceButton];
// 商品数量
self.goodsNumbersLabe=[[UILabel alloc]initWithFrame:CGRectMake(10*Width/12, 20, Width/12, Height-40)];
self.goodsNumbersLabe.text=[NSString stringWithFormat:@"%d",self.value];
self.goodsNumbersLabe.layer.masksToBounds = YES;
self.goodsNumbersLabe.layer.cornerRadius=5;
self.goodsNumbersLabe.layer.borderWidth=1;
self.goodsNumbersLabe.layer.borderColor=[UIColor grayColor].CGColor;
self.goodsNumbersLabe.textAlignment=NSTextAlignmentCenter;
[self.contentView addSubview:self.goodsNumbersLabe];
// 数量加
self.addButton=[[UIButton alloc]initWithFrame:CGRectMake(11*Width/12+5, 20, Width/12-5, Height-40)];
[self.addButton setTitle:@"+" forState:UIControlStateNormal];
self.addButton.titleLabel.font=[UIFont systemFontOfSize:18];
self.addButton.backgroundColor=RGB(249, 244, 241, 1);
[self.addButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
self.addButton.titleLabel.font= [UIFont systemFontOfSize: 18.0];
self.addButton.tag=200;
[self.addButton addTarget:self action:@selector(resetVale:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.addButton];
UILabel *lable=[[UILabel alloc]initWithFrame:CGRectMake(15, Height-1, Width-20, 1)];
lable.backgroundColor=[UIColor grayColor];
[self.contentView addSubview:lable];
//// 产品金额
// self.productPriceLabe=[[UILabel alloc]initWithFrame:CGRectMake(13*Width/15, 0, 2*Width/15, Height)];
// self.productPriceLabe.text=@"$5500";
// self.productPriceLabe.textColor=[UIColor redColor];
// [self.contentView addSubview:self.productPriceLabe];
}
-(void)resetVale:(UIButton *)sender
{
switch (sender.tag) {
case 100://减少
{
if (self.value<=1) {
[self ErrorMBProgressView:@"不能小于1"];
return;
}else
{
self.value-=1;
}
}
break;
case 200://增加
{
// //不能大于库存
// [self ErrorMBProgressView:@"超过库存"];
self.value+=1;
}
break;
default:
break;
}
self.goodsNumbersLabe.text=[NSString stringWithFormat:@"%d",self.value];
}
#pragma mark -显示错误的提示框
- (void)ErrorMBProgressView:(NSString *)errorString
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.superview animated:YES];
hud.labelText = errorString;
hud.margin = 10.f;
hud.color = [[UIColor blackColor] colorWithAlphaComponent:0.5];
hud.minSize = CGSizeMake(250, 70);
hud.animationType = MBProgressHUDAnimationZoom;
hud.mode = MBProgressHUDModeText;
hud.removeFromSuperViewOnHide = YES;
[hud hide:YES afterDelay:1.0f];
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end