123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- //
- // LDChildCommissionCell.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/18.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDChildCommissionCell.h"
- #import "CCCopyLabel.h"
- @interface LDChildCommissionCell ()
- @property (nonatomic, strong) UIImageView *iconView;
- @property (nonatomic, strong) CCCopyLabel *titleLabel;
- @property (nonatomic, strong) UILabel *makeDate;
- @property (nonatomic, strong) UILabel *endDate;
- @property (nonatomic, strong) UILabel *buyPrice;
- @property (nonatomic, strong) UILabel *endPrice;
- @property(nonatomic,strong)UIButton *bottomBtn;
- @property(nonatomic,strong)UIImageView *redimgV;
- @property(nonatomic,strong)UILabel *redpriceLabel;
- @end
- @implementation LDChildCommissionCell
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString *cellID = nil;
- cellID = NSStringFromClass([self class]);
- LDChildCommissionCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
- if (!cell) {
- cell = [[LDChildCommissionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
- }
- return cell;
-
- }
- - (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
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- [self.contentView addSubview:self.iconView];
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.makeDate];
- [self.contentView addSubview:self.endDate];
- [self.contentView addSubview:self.buyPrice];
- [self.contentView addSubview:self.endPrice];
- [self.contentView addSubview:self.bottomBtn];
- [self.bottomBtn addSubview:self.redimgV];
- [self.bottomBtn addSubview:self.redpriceLabel];
-
- [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.mas_equalTo(10);
- make.width.height.mas_equalTo(90);
- }];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.iconView.mas_right).mas_offset(10);
- make.top.mas_equalTo(self.iconView);
- make.right.mas_equalTo(-10);
- }];
-
- [self.makeDate mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.titleLabel);
- make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(10);
- make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
- }];
-
- [self.endDate mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-10);
- make.top.mas_equalTo(self.makeDate);
- make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
- }];
-
- [self.buyPrice mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(self.titleLabel);
- make.bottom.mas_equalTo(self.iconView.mas_bottom);
- make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
- }];
-
- [self.endPrice mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-10);
- make.bottom.mas_equalTo(self.buyPrice);
- make.width.mas_equalTo((SCREEN_WIDTH-130)/2);
- }];
- [self.bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.endPrice.mas_bottom).offset(10);
- make.width.mas_equalTo(SCREEN_WIDTH);
- make.height.mas_equalTo(30);
- }];
- [self.redpriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(self.mas_right).offset(-15);
- make.height.mas_equalTo(16);
- make.top.mas_equalTo(4);
- }];
- [self.redimgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(self.redpriceLabel.mas_left).offset(-5);
- make.width.mas_equalTo(17);
- make.height.mas_equalTo(19);
- make.top.mas_equalTo(2);
- }];
- }
- - (UIImageView *)iconView {
- if (!_iconView) {
- _iconView = [[UIImageView alloc] init];
- _iconView.contentMode = UIViewContentModeScaleAspectFill;
- _iconView.backgroundColor = [UIColor yhGrayColor];
- }
- return _iconView;
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [[CCCopyLabel alloc] init];
- _titleLabel.numberOfLines = 2;
- _titleLabel.font = [UIFont systemFontOfSize:15];
- _titleLabel.textColor = [UIColor YHColorWithHex:0x333333];
- _titleLabel.text = @"未知商品";
- }
- return _titleLabel;
- }
- - (UILabel *)makeDate {
- if (!_makeDate) {
- _makeDate = [[UILabel alloc] init];
- _makeDate.textColor = [UIColor YHColorWithHex:0x999999];
- _makeDate.font = [UIFont systemFontOfSize:12];
- _makeDate.text = @"创建日:无";
- }
- return _makeDate;
- }
- - (UILabel *)endDate {
- if (!_endDate) {
- _endDate = [[UILabel alloc] init];
- _endDate.textColor = [UIColor YHColorWithHex:0x999999];
- _endDate.font = [UIFont systemFontOfSize:12];
- _endDate.text = @"";
- }
- return _endDate;
- }
- - (UILabel *)buyPrice {
- if (!_buyPrice) {
- _buyPrice = [[UILabel alloc] init];
- _buyPrice.textColor = [UIColor YHColorWithHex:0x666666];
- _buyPrice.font = [UIFont systemFontOfSize:12];
- }
- return _buyPrice;
- }
- -(UIButton *)bottomBtn
- {
- if (!_bottomBtn) {
- _bottomBtn =[[UIButton alloc]init];
- _bottomBtn.hidden=YES;
- _bottomBtn.backgroundColor=[UIColor clearColor];
- [_bottomBtn addTarget:self action:@selector(clickRedModel) forControlEvents:UIControlEventTouchUpInside];
- }
- return _bottomBtn;
- }
- -(UIImageView *)redimgV
- {
- if (!_redimgV) {
- _redimgV =[[UIImageView alloc]init];
- _redimgV.image=[UIImage imageNamed:@"red_detail"];
-
- }
- return _redimgV;
- }
- -(UILabel *)redpriceLabel
- {
- if (!_redpriceLabel) {
- _redpriceLabel =[[UILabel alloc]init];
- _redpriceLabel.textColor=[UIColor YHColorWithHex:0xF22E26];
- _redpriceLabel.font=[UIFont systemFontOfSize:FITSIZE(11)];
- _redpriceLabel.text=@"获得xx元红包,点击查看 >";
- }
- return _redpriceLabel;
-
- }
- - (UILabel *)endPrice {
- if (!_endPrice) {
- _endPrice = [[UILabel alloc] init];
- _endPrice.font = [UIFont systemFontOfSize:16];
- NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"待结算佣金 ¥0.00"];
- [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 6)];
- [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(6,AttributedStr.length-6)];
- [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(0, 6)];
- [AttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(6,AttributedStr.length-6)];
- _endPrice.attributedText = AttributedStr;
- }
- return _endPrice;
- }
- -(void)setModel:(LDChildCommissionModel *)model{
- _model=model;
-
- self.titleLabel.text=model.name;
- self.makeDate.text=[NSString stringWithFormat:@"创建日:%@",model.order_create_at];
- /*
- 待结算-显示已付款 :用户下单成功后红包直接给到用户,此时为待结算状态
- 已结算-显示结算日:下个月25号,如果该订单有效,则变为已结算状态,红包金额进入账户余额,用户可随时提现
- 已失效-显示已失效:如果整个过程中,用户发生退货、退款等行为被淘宝判定为失效订单,则红包变为已失效
- 0已失效 1已付款 2已结算
- */
- NSString *moneyTypeStr=@"";
- switch ([model.type integerValue]) {//判断是否是红包
- case 7:
- {
- moneyTypeStr=@"红包奖励金";
- }
- break;
-
- default:
- moneyTypeStr=@"佣金";
- break;
- }
-
- NSMutableAttributedString *AttributedStr2;
- switch ([model.status integerValue]) {//0已失效 1已付款 2已结算 status
- case 0:
- {
- NSString *legalStr=@"";
- switch ([model.maintain_power integerValue]) {//0不维权 1维权申请 2维权失败 3维权成功
- case 1:
- {
- legalStr=@"维权申请";
- }
- break;
- case 2:
- {
- legalStr=@"维权失败";
- }
- break;
- case 3:
- {
- legalStr=@"已失效";
- }
- break;
- default:
- break;
- }
- self.endDate.text=legalStr;
-
- AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已失效%@¥ %@",moneyTypeStr,model.rebate]];
- [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF1E00] range:NSMakeRange(0, AttributedStr2.length)];
- [AttributedStr2 addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, AttributedStr2.length)];
- }
- break;
- case 1:
- {
- self.endDate.text=@"已付款";
- AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"待结算%@¥ %@",moneyTypeStr,model.rebate]];
- [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0x3E97FF] range:NSMakeRange(0, AttributedStr2.length)];
- }
- break;
- case 2:
- {
- self.endDate.text= [NSString stringWithFormat:@"结算日:%@",model.order_balance_at];
- AttributedStr2 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已结算%@¥ %@",moneyTypeStr,model.rebate]];
- [AttributedStr2 addAttribute:NSForegroundColorAttributeName value:[UIColor YHColorWithHex:0xFF1E00] range:NSMakeRange(0, AttributedStr2.length)];
- }
- break;
- default:
- break;
- }
- if (AttributedStr2) {
- [AttributedStr2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(0, 7)];
- [AttributedStr2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.0f] range:NSMakeRange(7,AttributedStr2.length-7)];
- self.endPrice.attributedText = AttributedStr2;
- }
- self.buyPrice.text=[NSString stringWithFormat:@"付款金额 ¥%@",model.money];
- [self.iconView sd_setImageWithURL:[NSURL URLWithString:model.img]];
- if (model.order_status.integerValue == 1) {
- self.bottomBtn.hidden=NO;
- self.redpriceLabel.text=[NSString stringWithFormat:@"获得%@元红包,点击查看 >",model.red_money];
- }else{
- self.bottomBtn.hidden=YES;
- }
- }
- -(void)clickRedModel
- {
- if ([self.delegatre respondsToSelector:@selector(ClickModel:)] ) {
- [self.delegatre ClickModel:_model];
-
- }
- }
- @end
|