// // MyOrderCell.m // model // // Created by JuYi on 2018/7/17. // Copyright © 2018年 Mine. All rights reserved. // 我的订单cell #import "MyOrderCell.h" @implementation MyOrderCell - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // self.selectionStyle = UITableViewCellSelectionStyleNone; [self creatCellSubViews]; } return self; } - (void)creatCellSubViews { // self.iconImageView = [[UIImageView alloc] init]; [self.contentView addSubview:self.iconImageView]; // self.titleLabel = [[UILabel alloc] init]; self.titleLabel.textAlignment = NSTextAlignmentLeft; self.titleLabel.textColor = RGBValueColor(0x333333, 1.0); // 默认 self.titleLabel.font = [UIFont systemFontOfSize:14.0];; // 默认 [self.contentView addSubview:self.titleLabel]; // self.timeLabel = [[UILabel alloc] init]; self.timeLabel.textAlignment = NSTextAlignmentLeft; self.timeLabel.textColor = RGBValueColor(0x999999, 1.0); // 默认 self.timeLabel.font = [UIFont systemFontOfSize:13]; // 默认 [self.contentView addSubview:self.timeLabel]; // self.subTitleLabel = [[UILabel alloc] init]; self.subTitleLabel.textAlignment = NSTextAlignmentRight; self.subTitleLabel.textColor = RGBValueColor(0xfe4086, 1.0);// 默认 self.subTitleLabel.font = [UIFont systemFontOfSize:14];// 默认 [self.contentView addSubview:self.subTitleLabel]; // self.arrowView = [[UIImageView alloc] init]; self.arrowView.image = [UIImage imageNamed:@"youjiantou"]; [self.contentView addSubview:self.arrowView]; // self.lineView = [[UIImageView alloc] init]; self.lineView.image = [UIImage imageNamed:@"fengexian"]; [self.contentView addSubview:self.lineView]; self.onetitleLabel = [[UILabel alloc] init]; self.onetitleLabel.textAlignment = NSTextAlignmentLeft; self.onetitleLabel.textColor = RGBValueColor(0x333333, 1.0); self.onetitleLabel.font = [UIFont systemFontOfSize:16.0]; self.onetitleLabel.hidden = YES; [self.contentView addSubview:self.onetitleLabel]; } - (void)layoutSubviews { [super layoutSubviews]; CGFloat height = self.frame.size.height; self.iconImageView.frame = CGRectMake(20, 12.5, height - 25, height - 25); self.titleLabel.frame = CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + 15, 20, ScreenWidth / 2 - 50, 14); self.timeLabel.frame = CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + 15, CGRectGetMaxY(self.titleLabel.frame) + 15, ScreenWidth - 100, 13); self.subTitleLabel.frame = CGRectMake(ScreenWidth / 2, 0, ScreenWidth / 2 - 20, height); self.arrowView.frame = CGRectMake(ScreenWidth - 28, height / 2 - 7, 8, 14); self.lineView.frame = CGRectMake(0, height - 1, ScreenWidth, 1); self.onetitleLabel.frame = CGRectMake(CGRectGetMaxX(self.iconImageView.frame) + 15, 0, ScreenWidth / 2 - 50, height); } // 可以在赋值里面改变frame - (void)setMyOrderCellValueWithDic:(NSDictionary *)dic titleStr:(NSString *)str { if ([str isEqualToString:@"redEnvelope"]) { self.lineView.hidden = YES; self.arrowView.hidden = YES; [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:[UIImage imageNamed:@"shipintouxiang"]]; self.titleLabel.text = dic[@"modelpk"]; //  这里名字没有 self.subTitleLabel.text = [NSString stringWithFormat:@"%@元", dic[@"coin"]]; NSString *timeStr = dic[@"rdate"]; if ([timeStr containsString:@" "]) { NSArray *timeArr = [timeStr componentsSeparatedByString:@" "]; NSArray *time = [timeArr[0] componentsSeparatedByString:@"-"]; self.timeLabel.text = [NSString stringWithFormat:@"%@.%@.%@", time[0], time[1], time[1]]; } else { self.timeLabel.text = timeStr; } } else if ([str isEqualToString:@"myOrder"]) {//我的订单 self.onetitleLabel.hidden = NO; self.subTitleLabel.hidden = YES; self.titleLabel.hidden = YES; self.timeLabel.hidden = YES; self.iconImageView.image = [UIImage imageNamed:dic[@"iconName"]]; self.onetitleLabel.text = dic[@"title"]; } else if ([str isEqualToString:@"videoOrder"]) { //视频订单 self.onetitleLabel.hidden = YES; self.subTitleLabel.hidden = NO; self.titleLabel.hidden = NO; self.timeLabel.hidden = NO; self.lineView.hidden = YES; self.arrowView.hidden = YES; NSString *urlStr = [NSString stringWithFormat:@"%@/%@", PublicUrl, dic[@"hphoto"]]; [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"shipintouxiang"]]; self.titleLabel.text = dic[@"pet"]; self.timeLabel.text = [NSString stringWithFormat:@"时间:%@",dic[@"begdate"]]; NSString *coinStr = dic[@"coin"]; NSString *durationStr = dic[@"duration"]; NSString *coin = [NSString stringWithFormat:@"%@元/%@分钟", coinStr,durationStr]; if (coin.length > 1) { NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:coin]; [attributedString addAttribute:NSForegroundColorAttributeName value:RGBValueColor(0xfe4086, 1.0) range:NSMakeRange(0,coinStr.length+1)]; [attributedString addAttribute:NSForegroundColorAttributeName value:RGBValueColor(0x333333, 1.0) range:NSMakeRange(coinStr.length+1,durationStr.length+3)]; self.subTitleLabel.attributedText = attributedString; } } } /* { coin = "99.99"; memberpk = 1; modelpk = 1; pk = 93; rdate = "2018-07-09 15:39:42"; rstate = 1; } video { begdate = "2018-06-13 00:00:00"; coin = ""; duration = ""; hphoto = "upload/hphoto/2018-07-13/h1.png"; memberpk = 8; modelpk = 2; pet = "刘德华"; pk = 2; } **/ @end