// // KWMineHomeOrderSubView.m // westkissMob // // Created by iOS on 2022/10/12. // #import "KWMineHomeOrderSubView.h" @interface KWMineHomeOrderSubView () @property (nonatomic, strong) UILabel *titleLB; @property (nonatomic, strong) UILabel *priceLb; @property (nonatomic, strong) UILabel *xLB; @property (nonatomic, strong) UILabel *numLB; @property (nonatomic, strong) UIImageView *imgV; @property (nonatomic, strong) KWMineOrderProInfoModel *m; @end @implementation KWMineHomeOrderSubView - (void)setData:(KWMineOrderProInfoModel *)model { self.m = model; self.titleLB.text = model.product_name; self.priceLb.text = [NSString stringWithFormat:@"%@",model.product_price]; self.numLB.text = model.qty; [self.imgV sd_setImageWithURL:[NSURL URLWithString:model.product_img.urlEncode]]; } -(instancetype)init { self = [super init]; if (self) { [self loadSubV]; } return self; } - (void)loadSubV { self.backgroundColor = UIColor.clearColor; [self addSubview:self.imgV]; [self addSubview:self.titleLB]; [self addSubview:self.priceLb]; [self addSubview:self.xLB]; [self addSubview:self.numLB]; [_imgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self).offset(0); make.left.equalTo(self).offset(0); make.bottom.equalTo(self).offset(0); make.width.height.equalTo(@86); }]; [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.imgV); make.left.equalTo(self.imgV.mas_right).offset(10); make.right.equalTo(self).offset(0); make.height.equalTo(@35); }]; [self.priceLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal]; [self.priceLb mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.imgV); make.left.equalTo(self.titleLB); make.height.equalTo(@17); }]; [self.xLB mas_makeConstraints:^(MASConstraintMaker *make) { make.width.equalTo(@17); make.height.equalTo(@17); make.left.equalTo(self.priceLb.mas_right); make.centerY.equalTo(self.priceLb); }]; [self.numLB mas_makeConstraints:^(MASConstraintMaker *make) { make.width.equalTo(@25); make.height.equalTo(@17); make.left.equalTo(self.xLB.mas_right); make.centerY.equalTo(self.priceLb); }]; } - (UIImageView *)imgV { if (!_imgV) { UIImageView *imgV = [[UIImageView alloc] init]; _imgV = imgV; } return _imgV; } - (UILabel *)titleLB { if (!_titleLB) { UILabel *lb = [[UILabel alloc] init]; lb.font = [UIFont fontWithName:Rob_Regular size:12]; lb.textColor = [UIColor blackColor]; lb.backgroundColor = [UIColor clearColor]; lb.numberOfLines = 2; _titleLB = lb; } return _titleLB; } - (UILabel *)priceLb { if (!_priceLb) { UILabel *lb = [[UILabel alloc] init]; lb.font = [UIFont fontWithName:Rob_Bold size:14]; lb.textColor = _0B0B0B; lb.backgroundColor = [UIColor clearColor]; _priceLb = lb; } return _priceLb; } - (UILabel *)xLB { if (!_xLB) { UILabel *lb = [[UILabel alloc] init]; lb.font = [UIFont fontWithName:Rob_Regular size:14]; lb.textColor = _0B0B0B; lb.backgroundColor = [UIColor clearColor]; lb.textAlignment = NSTextAlignmentCenter; lb.text = @"x"; _xLB = lb; } return _xLB; } - (UILabel *)numLB { if (!_numLB) { UILabel *lb = [[UILabel alloc] init]; lb.font = [UIFont fontWithName:Rob_Regular size:14]; lb.textColor = _0B0B0B; lb.backgroundColor = [UIColor clearColor]; _numLB = lb; } return _numLB; } @end