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
//
// KWMOrderCell.m
// iCemarose
//
// Created by HouWeiBin on 16/8/30.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMOrderCell.h"
#import "KWMImageUtil.h"
#import "UIImageView+WebCache.h"
#import "UIColor+SAMAdditions.h"
#import "KWMStringUtil.h"
@implementation KWMOrderCell{
BOOL isShow;
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
isShow = NO;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickOrder)];
[_vContent addGestureRecognizer:tapGesture];
[_ivImage.layer setMasksToBounds:YES];
_ivImage.layer.cornerRadius = 1; //圆角(圆形)
_ivImage.layer.borderColor = [UIColor sam_colorWithHex:@"545454"].CGColor; //要设置的颜色
_ivImage.layer.borderWidth = 1; //要设置的描边宽
}
- (void)onClickOrder{
if ([self.delegate respondsToSelector:@selector(kwm_onClickProduct:)]) {
NSNumber *productId = _lineItem.productId;
[self.delegate kwm_onClickProduct:productId];
}
}
- (void)setMarkSection:(NSInteger)markSection{
_markSection = markSection;
}
- (void)setLineCount:(NSInteger)lineCount{
_lineCount = lineCount;
[self.btnFooter setTitle:[NSString stringWithFormat:@"共%ld件商品,查看剩余%ld件商品",(long)lineCount,(lineCount - 4)] forState:UIControlStateNormal];
}
- (void)setImageUrl:(NSString *)imageUrl{
NSURL *imageURL = [NSURL URLWithString:imageUrl];
[self.ivImage sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
}
- (void)setOrder:(BUYOrder *)order{
if (order != nil) {
_order = order;
_lbOrderNum.text = [NSString stringWithFormat:@"订单 %@",order.identifier ? order.identifier.stringValue:@""];
_lbTotalPrice.text = [NSString stringWithFormat:@"%@",[KWMStringUtil getEUR2CNYstring:order.totalPrice]];
}
}
- (void)setLineItem:(BUYLineItem *)lineItem{
if (lineItem != nil) {
_lineItem = lineItem;
self.lbPrice.text = [NSString stringWithFormat:@"¥%@",[KWMStringUtil getEUR2CNYstring:lineItem.price]];
self.lbName.text = lineItem.title;
self.lbSize.text = [NSString stringWithFormat:@"x%@/%@",lineItem.quantity,lineItem.variantTitle];
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)updateUI:(NSInteger)position productCount:(NSInteger)productCount showAll:(bool)showAll{
isShow = showAll;//记录是否展开
if(position == 0){
self.vHeader.hidden = NO;
self.headerHeight.constant = 80;
}else{
self.vHeader.hidden = YES;
self.headerHeight.constant = 0;
}
//全部没选中时,显示footView
//选中某个section,但不选中当前的,显示footView
if (productCount > 4) {
self.btnFooter.hidden = NO;
self.footHeight.constant = 40;
}else{
self.btnFooter.hidden = YES;
self.footHeight.constant = 0;
}
//设置展开收起的订单footerView的title
if (!showAll && productCount > 4) {
if (self.lineCount) {
[self.btnFooter setTitle:[NSString stringWithFormat:@"共%ld件商品,查看剩余%ld件商品",(long)self.lineCount,(self.lineCount - 4)] forState:UIControlStateNormal];
[self.btnFooter setImage:nil forState:UIControlStateNormal];
}
}else if(showAll && productCount > 4){
[self.btnFooter setImage:[UIImage imageNamed:@"button_myorder_pull-up"] forState:UIControlStateNormal];
[self.btnFooter setTitle:@"" forState:UIControlStateNormal];
}
}
-(void)onClickShowOther:(id)sender{
if(self.delegate!=nil){
[self.delegate kwm_onClickShowAllWith:_markSection And:isShow];
}
}
-(void)onClickTransport:(id)sender{
if(self.delegate!=nil){
[self.delegate kwm_onClickTrandsport:_order];
}
}
-(void)onClickCancelOrder:(id)sender{
if(self.delegate!=nil){
[self.delegate kwm_onClickCancelOrder:_order];
}
}
@end