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
//
// ShoppingTableViewCell.m
// Lighting
//
// Created by 曹云霄 on 16/4/29.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "ShoppingTableViewCell.h"
@implementation ShoppingTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
#pragma mark -赋值
- (void)setModel:(ShopcarModel *)model
{
_model = model;
self.selectedButton.selected = _model.isSelected;
[self.goodsImageView sd_setImageWithURL:[NSURL URLWithString:_model.goods.pictures] placeholderImage:ReplaceImage];
self.goodsInformationLabe.text = _model.goods.name;
self.tagsPriceLabe.text = [_model.goods.tagPrice stringValue];
self.clinchTextfield.text = [_model.goods.costPrice stringValue];
self.goodsNumbersLabe.text = [NSString stringWithFormat:@"%d",_model.goodsNum];
self.productPriceLabe.text = [_model.goods.costPrice stringValue];
}
#pragma mark -增加或者减少商品
- (IBAction)reduceAndaddButtonClick:(UIButton *)sender {
//sender.tag == 100 减少
//sender.tag == 101 增加
NSLog(@"%ld",sender.tag);
NSInteger goodsNumber = [self.goodsNumbersLabe.text integerValue];
switch (sender.tag) {
case 100://减少
{
if (goodsNumber <= 1) {
//不能小于1
return;
}
goodsNumber --;
self.goodsNumbersLabe.text = [NSString stringWithFormat:@"%ld",goodsNumber];
}
break;
case 101://增加
{
if (goodsNumber >= [_model.goods.number integerValue]) {
//不能大于库存
return;
}
goodsNumber ++;
self.goodsNumbersLabe.text = [NSString stringWithFormat:@"%ld",goodsNumber];
}
break;
default:
break;
}
}
#pragma mark -商品选中
- (IBAction)selectedButtonClick:(UIButton *)sender {
if (self.returnCellblock) {
self.returnCellblock(_cellindex);
}
sender.selected = YES;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end